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); } } } }