using System.Windows.Forms.Design;

namespace Hawkeye.VisionBuilder.Features.ImagesStrip;

[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)]
public class ToolStripNumberControl : ToolStripControlHost
{
    public ToolStripNumberControl()
        : base(new NumericUpDown())
    {
        (Control as NumericUpDown).Maximum = 10000;
        (Control as NumericUpDown).Minimum = 0;
    }

    protected override void OnSubscribeControlEvents(Control control)
    {
        base.OnSubscribeControlEvents(control);
        ((NumericUpDown)control).ValueChanged += new EventHandler(OnValueChanged);
    }

    protected override void OnUnsubscribeControlEvents(Control control)
    {
        base.OnUnsubscribeControlEvents(control);
        ((NumericUpDown)control).ValueChanged -= new EventHandler(OnValueChanged);
    }

    public event EventHandler ValueChanged;

    public Control NumericUpDownControl
    {
        get { return Control as NumericUpDown; }
    }

    public void OnValueChanged(object sender, EventArgs e)
    {
        if (ValueChanged != null)
        {
            ValueChanged(this, e);
        }
    }
}