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); }
private void ActionChangeToolStripButton(ToolStripButton button, object sender, bool checkDefaults) { ActionChangeToolStripItem(button, sender, checkDefaults); if (sender is TCustomAction) { TCustomAction action = (TCustomAction)sender; if (!checkDefaults || !button.Checked) { button.Checked = action.Checked; } } }
private void ActionChangeButton(ButtonBase btn, object sender, bool checkDefaults) { ActionChangeControl(btn, sender, checkDefaults); if (sender is TCustomAction) { TCustomAction action = (TCustomAction)sender; if (!checkDefaults || (btn.Image == null && this.ImageList != null && action.ImageIndex >= 0 && action.ImageIndex < this.ImageList.Images.Count)) { btn.ImageList = this.ImageList; btn.ImageIndex = action.ImageIndex; } } }
protected virtual bool DoShowHint(ref string strHint) { if (Action is TCustomAction) { TCustomAction custAction = (TCustomAction)Action; if (custAction.OnDoHint(ref strHint) && /*Application.HintShortCuts &&*/ //TODO: how to replace this in .Net? (custAction.ShortCut != Keys.None)) { if (!string.IsNullOrEmpty(strHint)) { strHint = string.Format("{0} ({0})", strHint, ShortCutToText(custAction.ShortCut)); } } } return(true); }
private void ActionChangeToolStripMenuItem(ToolStripMenuItem item, object sender, bool checkDefaults) { ActionChangeToolStripItem(item, sender, checkDefaults); if (sender is TCustomAction) { TCustomAction action = (TCustomAction)sender; if (!checkDefaults || !item.CheckOnClick) { item.CheckOnClick = action.AutoCheck; } if (!checkDefaults || !item.Checked) { item.Checked = action.Checked; } if (!checkDefaults || item.ShortcutKeys == Keys.None) { item.ShortcutKeys = action.ShortCut; } } }
private void SetState(TActionListState value) { if (state == value) { return; } state = value; if (state == TActionListState.asSuspended) { return; } for (int i = 0; i < actions.Count; i++) { TCustomAction Action = actions[i] as TAction; if (Action is TCustomAction) { switch (value) { case TActionListState.asNormal: { if (state == TActionListState.asSuspendedEnabled) { Action.Enabled = Action.SavedEnabledState; } Action.OnUpdate(EventArgs.Empty); } break; case TActionListState.asSuspendedEnabled: if (value == TActionListState.asSuspendedEnabled) { Action.SavedEnabledState = Action.Enabled; Action.Enabled = true; } break; } } } }
private void ActionChangeToolStripItem(ToolStripItem item, object sender, bool checkDefaults) { if (sender is TCustomAction) { TCustomAction action = (TCustomAction)sender; if (!checkDefaults || string.IsNullOrEmpty(item.Text) || item.Text == item.Name) { item.Text = action.Caption; } if (!checkDefaults || item.Enabled) { item.Enabled = action.Enabled; } if (!checkDefaults || string.IsNullOrEmpty(item.ToolTipText)) { item.ToolTipText = action.Hint; } if (!checkDefaults || item.Visible) { item.Visible = action.Visible; } if (!checkDefaults || item.ImageIndex == -1) { item.ImageIndex = action.ImageIndex; } if (!checkDefaults || item.GetClickEvent() == null) { item.Click += action.ExecuteDelegate; //TBasicActionLink link = compToActionLinks[item]; //item.Click += (s, e) => link.OnExecute(item, e); } DelphiHelpProvider helpext = HelpExtender as DelphiHelpProvider; if (helpext != null) { string helpkey = helpext.GetHelpKeyword(item); int helpcontext = helpext.GetHelpContext(item); HelpNavigator helpnav = helpext.GetHelpNavigator(item); int helpkeyctxt; if (helpcontext != -1 && int.TryParse(helpkey, out helpkeyctxt) && helpkeyctxt == helpcontext) { helpkey = null; } if (!checkDefaults || helpcontext == -1) { helpext.SetHelpContext(item, action.HelpContext); } if (!checkDefaults || helpkey == null) { helpext.SetHelpKeyword(item, action.HelpKeyword); } if (!checkDefaults || helpnav == HelpNavigator.AssociateIndex) { helpext.SetHelpNavigator(item, action.HelpType); } } } }
private void ActionChangeControl(Control ctl, object sender, bool checkDefaults) { if (sender is TCustomAction) { TCustomAction action = (TCustomAction)sender; if (!checkDefaults || string.IsNullOrEmpty(ctl.Text) || ctl.Text == ctl.Name) { ctl.Text = action.Caption; } if (!checkDefaults || ctl.Enabled) { ctl.SetShadowProperty(() => ctl.Enabled, action.Enabled); } if (ToolTipExtender != null) { if (!checkDefaults || string.IsNullOrEmpty(ToolTipExtender.GetToolTip(ctl))) { ToolTipExtender.SetToolTip(ctl, action.Hint); } } if (!checkDefaults || ctl.Visible) { ctl.Visible = action.Visible; } if (!checkDefaults || ctl.GetClickEvent() == null) { ctl.Click += action.ExecuteDelegate; //TBasicActionLink link = compToActionLinks[ctl]; //ctl.Click += (s, e) => link.OnExecute(ctl, e); } if (HelpExtender != null) { DelphiHelpProvider helpext = HelpExtender as DelphiHelpProvider; string helpkey = HelpExtender.GetHelpKeyword(ctl); int helpcontext = helpext == null ? -1 : helpext.GetHelpContext(ctl); HelpNavigator helpnav = HelpExtender.GetHelpNavigator(ctl); int helpkeyctxt; if (helpcontext != -1 && int.TryParse(helpkey, out helpkeyctxt) && helpkeyctxt == helpcontext) { helpkey = null; } if (!checkDefaults || helpcontext == -1) { if (helpext != null) { helpext.SetHelpContext(ctl, action.HelpContext); } else { HelpExtender.SetHelpKeyword(ctl, action.HelpContext.ToString()); } } if (!checkDefaults || helpkey == null) { HelpExtender.SetHelpKeyword(ctl, action.HelpKeyword); } if (!checkDefaults || helpnav == HelpNavigator.AssociateIndex) { HelpExtender.SetHelpNavigator(ctl, action.HelpType); } } } }