示例#1
0
            protected override void OnClick(EventArgs e)
            {
                TToolButtonActionLink actionlink   = (TToolButtonActionLink)TActionList.GetActionLink(this);
                TBasicAction          action       = actionlink != null ? actionlink.Action : null;
                EventHandler          clickhandler = this.GetClickEvent();

                // Following code based on D4's TControl.Click
                // Call OnClick if assigned and not equal to associated action's OnExecute.
                // If associated action's OnExecute assigned then call it, otherwise, call
                // OnClick.
                if (DesignMode || actionlink == null ||
                    action == null || !Extensions.AreIntersectingOrBothEmpty(clickhandler, action.ExecuteDelegate))
                {
                    base.OnClick(e);
                }
                else
                {
                    // Following code based on D6's TMenuItem.Click
                    if (CheckOnClick && (actionlink == null || !actionlink.IsAutoCheckLinked))
                    {
                        Checked = !Checked;
                    }
                    actionlink.OnExecute(this, EventArgs.Empty);
                }
            }
示例#2
0
        private bool DispatchAction(ref Message m)
        {
            bool result = false;
            Form form   = Form.ActiveForm;

            if (form is TCustomForm && ((TCustomForm)form).Perform(m.Msg, IntPtr.Zero, m.LParam) == (IntPtr)1)
            {
                result = true;
            }
            else if (MainForm != form && MainForm is TCustomForm && ((TCustomForm)MainForm).Perform(m.Msg, IntPtr.Zero, m.LParam) == (IntPtr)1)
            {
                result = true;
            }

            TBasicAction  action     = (TBasicAction)GCHandle.FromIntPtr(m.LParam).Target;
            TCustomAction custAction = action as TCustomAction;

            if (!result && custAction != null &&
                custAction.Enabled && custAction.DisableIfNoHandler)
            {
                custAction.Enabled = action.ExecuteDelegate != null;
            }

            return(result);
        }
示例#3
0
        public virtual bool UpdateAction(TBasicAction action)
        {
            ActionEventAgs args = new ActionEventAgs(action, false);

            if (ActionUpdate != null)
            {
                ActionUpdate(this, args);
            }
            return(args.Result);
        }
 protected virtual void SetAction(TBasicAction value)
 {
     if (action != value)
     {
         if (action != null)
         {
             action.UnRegisterChanges(this);
         }
         action = value;
         if (value != null)
         {
             value.RegisterChanges(this);
         }
     }
 }
示例#5
0
        private bool DoUpdateAction(TBasicAction action)
        {
            if (DesignMode || !Visible) //use Showing instead of Visible, but it doesn't exist in .net
            {
                return(false);
            }

            if (ProcessUpdate(ActiveControl, action) ||
                ProcessUpdate(this, action) ||
                TraverseClients(this, action))
            {
                return(true);
            }

            return(false);
        }
示例#6
0
 private bool TraverseClients(Control container, TBasicAction action)
 {
     if (container.Visible) //use Showing instead of Visible, but it doesn't exist in .net
     {
         var controls = container.Controls;
         for (int i = 0; i < controls.Count; i++)
         {
             Control childControl = controls[i]; //TODO: include also components
             if (ComponentAllowed(childControl) && ProcessUpdate(childControl, action) ||
                 childControl is Control && TraverseClients(childControl, action))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#7
0
        private bool DoExecuteAction(TBasicAction action)
        {
            if (DesignMode || !Visible)
            {
                return(false);
            }

            if (ActiveControl != null && ActiveControl.ExecuteAction(action))
            {
                return(true);
            }

            if (this.ExecuteAction(action))
            {
                return(true);
            }

            return(false);
        }
示例#8
0
        private bool DoExecuteActionInChildControls(Control parentControl, TBasicAction action)
        {
            var controls = parentControl.Controls;

            for (int i = 0; i < controls.Count; i++)
            {
                Control childControl = controls[i]; //TODO: include components
                if (childControl.Visible)
                {
                    if (controls[i].ExecuteAction(action))
                    {
                        return(true);
                    }
                    if (DoExecuteActionInChildControls(childControl, action))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#9
0
        public void SetAction(Component self, TBasicAction value)
        {
            TBasicActionLink actionLink = GetActionLink(self);

            if (actionLink != null && actionLink.Action == value)
            {
                return;
            }

            if (value == null)
            {
                actionLink.Dispose();
                lock (compToActionLinks) compToActionLinks.Remove(self);
            }
            else
            {
                if (actionLink == null)
                {
                    actionLink = CreateActionLink(self);
                    lock (compToActionLinks) compToActionLinks.Add(self, actionLink);
                    actionLink.Change += (sender, e) => DoActionChange(self, sender, e);
                }
                actionLink.Action = value;

                bool  isloading = false;
                ISite site      = value.Site ?? self.Site;
                if (site != null)
                {
                    IDesignerHost designHost = site.GetService(typeof(IDesignerHost)) as IDesignerHost;
                    if (designHost != null)
                    {
                        isloading = designHost.Loading;
                    }
                }
                ActionChange(self, value, isloading);
            }
        }
示例#10
0
 private bool ProcessUpdate(Component component, TBasicAction action)
 {
     return(component != null && component.UpdateAction(action));
 }
示例#11
0
 internal void SetActionInternal(TBasicAction value)
 {
     this.action = value;
 }
示例#12
0
 public ActionEventAgs(TBasicAction action, bool result)
 {
     Action = action;
     Result = result;
 }