Exemplo n.º 1
0
        void attachToSingleControl(Control control, IStandardEventListener listener, bool isAttach)
        {
            Button button = control as Button;

            if (null != button)
            {
                if (isAttach)
                {
                    button.Click += listener.OnButtonClick;
                }
                else
                {
                    button.Click -= listener.OnButtonClick;
                }
                return;
            }

            CheckBox checkBox = control as CheckBox;

            if (null != checkBox)
            {
                if (isAttach)
                {
                    checkBox.CheckedChanged += listener.OnCheckedChanged;
                }
                else
                {
                    checkBox.CheckedChanged -= listener.OnCheckedChanged;
                }
                return;
            }
        }
Exemplo n.º 2
0
    public void ReplaceStandardEventListener(IStandardEventListener newValue)
    {
        var index     = TestComponentsLookup.StandardEventListener;
        var component = CreateComponent <StandardEventListenerComponent>(index);

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Exemplo n.º 3
0
    public void AddStandardEventListener(IStandardEventListener value)
    {
        var listeners = hasStandardEventListener
            ? standardEventListener.value
            : new System.Collections.Generic.List <IStandardEventListener>();

        listeners.Add(value);
        ReplaceStandardEventListener(listeners);
    }
Exemplo n.º 4
0
    public void RemoveStandardEventListener(IStandardEventListener value)
    {
        var listeners = standardEventListener.value;

        listeners.Remove(value);
        if (listeners.Count == 0)
        {
            RemoveStandardEventListener();
        }
        else
        {
            ReplaceStandardEventListener(listeners);
        }
    }
Exemplo n.º 5
0
        void attachToSingleControl(ToolStripItem control, IStandardEventListener listener, bool isAttach)
        {
            ToolStripButton button = control as ToolStripButton;

            if (null != button)
            {
                if (isAttach)
                {
                    button.Click += listener.OnButtonClick;
                }
                else
                {
                    button.Click -= listener.OnButtonClick;
                }
                return;
            }
        }
Exemplo n.º 6
0
        void doAttachEvents(Control control, IStandardEventListener listener, bool isAttach)
        {
            attachToSingleControl(control, listener, isAttach);

            var strip = control as ToolStrip;

            if (strip != null)
            {
                foreach (ToolStripItem child in strip.Items)
                {
                    attachToSingleControl(child, listener, isAttach);
                }
            }
            else
            {
                foreach (Control child in control.Controls)
                {
                    doAttachEvents(child, listener, isAttach);
                }
            }
        }
Exemplo n.º 7
0
 public void DetachEvents(Control control, IStandardEventListener listener)
 {
     doAttachEvents(control, listener, false);
 }
Exemplo n.º 8
0
 public void AttachEvents(Control control, IStandardEventListener listener)
 {
     doAttachEvents(control, listener, true);
 }