/// <summary> /// <para>Add a menu item to the user interface.</para> /// </summary> /// <param name="configurationMenuItem"> /// <para>The <see cref="ConfigurationMenuItem"/> to add.</para> /// </param> protected void AddMenuItem(ConfigurationMenuItem configurationMenuItem) { ArgumentValidation.CheckForNullReference(configurationMenuItem, "configurationMenuItem"); Debug.Assert(currentContainerService != null, "The currentContainerService should not be null"); currentContainerService.MenuItems.Add(configurationMenuItem); }
/// <summary> /// <para>Adds a a <see cref="ValidateNodeCommand"/> and <see cref="RemoveNodeCommand"/> if the parent node is not readonly.</para> /// </summary> protected override void OnAddMenuItems() { if (!Parent.GetType().Equals(typeof(ReadOnlyConfigurationSectionNode))) { AddMenuItem(ConfigurationMenuItem.CreateRemoveNodeCommand(Site, this)); } AddMenuItem(ConfigurationMenuItem.CreateValidateNodeCommand(Site, this)); }
/// <summary> /// <para>Adds the close and validate menu items to the user interface menu system.</para> /// </summary> protected override void OnAddMenuItems() { AddMenuItem(ConfigurationMenuItem.CreateValidateNodeCommand(Site, this)); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.CloseApplicationMenuItemText, new CloseApplicationConfigurationCommand(Site), this, Shortcut.None, SR.CloseApplicationStatusText, InsertionPoint.Action); AddMenuItem(item); Hierarchy.Load(); }
private static void CreateCommands(IServiceProvider serviceProvider) { IUIHierarchy currentHierarchy = ServiceHelper.GetCurrentHierarchy(serviceProvider); ConfigurationNode rootNode = ServiceHelper.GetCurrentRootNode(serviceProvider); bool containsNode = currentHierarchy.ContainsNodeType(rootNode, typeof(ConfigurationSectionCollectionNode)); IMenuContainerService menuService = ServiceHelper.GetMenuContainerService(serviceProvider); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.ConfigurationSectionCollectionMenuItemText, new AddChildNodeCommand(serviceProvider, typeof(ConfigurationSectionCollectionNode)), rootNode, Shortcut.None, SR.ConfigurationSectionCollectionStatusText, InsertionPoint.New); item.Enabled = !containsNode; menuService.MenuItems.Add(item); }
/// <summary> /// <para>Create a menu item for the <see cref="AddChildNodeCommand"/> for the <paramref name="node"/>.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="node"> /// <para>The <see cref="ConfigurationNode"/> to associate with the menu.</para> /// </param> /// <param name="t"> /// <para>The type of node to create.</para> /// </param> /// <param name="menuText"> /// <para>The text to display in the menu item.</para> /// </param> /// <param name="allowMultiple"> /// <para>Allow multiple of the same node typ for the parent <paramref name="node"/>.</para> /// </param> /// <returns> /// <para>An instance of the <see cref="AddChildNodeCommand"/> class.</para> /// </returns> public static ConfigurationMenuItem CreateAddChildNodeMenuItem(IServiceProvider serviceProvider, ConfigurationNode node, Type t, string menuText, bool allowMultiple) { ConfigurationMenuItem item = new ConfigurationMenuItem(menuText, new AddChildNodeCommand(serviceProvider, t), node, Shortcut.None, SR.GenericCreateStatusText(menuText), InsertionPoint.New); if (!allowMultiple) { if (node.Hierarchy.ContainsNodeType(node, t)) { item.Enabled = false; } } return(item); }
/// <summary> /// <para>Adds a <see cref="ValidateNodeCommand"/>, a command for creating <see cref="XmlIncludeTypeNode"/> objects and if the parent node is not readonly, a <see cref="RemoveNodeCommand"/> to the menus for the user interface.</para> /// </summary> protected override void OnAddMenuItems() { if (!Parent.GetType().Equals(typeof(ReadOnlyConfigurationSectionNode))) { AddMenuItem(ConfigurationMenuItem.CreateRemoveNodeCommand(Site, this)); } AddMenuItem(ConfigurationMenuItem.CreateValidateNodeCommand(Site, this)); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.XmlIncludeTypeMenuItem, new AddChildNodeCommand(Site, typeof(XmlIncludeTypeNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.XmlIncludeTypeMenuItem), InsertionPoint.New); AddMenuItem(item); }
/// <summary> /// <para>Create menu items based on the nodes registered with the <see cref="INodeCreationService"/> for the spefied type.</para> /// </summary> /// <param name="nodeType"> /// <para>The type to create menu items.</para> /// </param> protected void CreateDynamicMenuItems(Type nodeType) { INodeCreationService service = ServiceHelper.GetNodeCreationService(Site); StringCollection names = service.GetDisplayNames(nodeType); ConfigurationMenuItem item = null; foreach (string name in names) { NodeCreationEntry entry = service.GetNodeCreationEntry(name); item = new ConfigurationMenuItem(name, entry.ConfigurationNodeCommand, this, Shortcut.None, SR.GenericCreateStatusText(name), InsertionPoint.New); if (!entry.AllowMultiple) { if (Hierarchy.ContainsNodeType(this, nodeType /*entry.BaseTypeToCompare*/)) { item.Enabled = false; } } AddMenuItem(item); } }
protected override void OnAddMenuItems() { base.OnAddMenuItems (); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.ClientSettings, new AddConfigurationSectionCommand(Site, typeof(ClientSettingsNode), LoggingSettings.SectionName), this, Shortcut.None, SR.GenericCreateStatusText(SR.LogSettingsCmd), InsertionPoint.New); bool containsNode = Hierarchy.ContainsNodeType(typeof(ClientSettingsNode)); item.Enabled = !containsNode; AddMenuItem(item); item = new ConfigurationMenuItem(SR.DistributorSettings, new AddConfigurationSectionCommand(Site, typeof(DistributorSettingsNode), DistributorSettings.SectionName), this, Shortcut.None, SR.GenericCreateStatusText(SR.DistributorSettings), InsertionPoint.New); containsNode = Hierarchy.ContainsNodeType(typeof(DistributorSettingsNode)); item.Enabled = !containsNode; AddMenuItem(item); }
private void AddMenuItem(Type type, string text) { ConfigurationMenuItem item = new ConfigurationMenuItem(text, new AddChildNodeCommand(Site, type), this, Shortcut.None, SR.GenericCreateStatusText(text), InsertionPoint.New); bool contains = Hierarchy.ContainsNodeType(this, type); item.Enabled = !contains; AddMenuItem(item); }
/// <summary> /// <para>Adds the default nodes for the connection string.</para> /// </summary> protected override void OnAddMenuItems() { AddMenuItem(ConfigurationMenuItem.CreateValidateNodeCommand(Site, this)); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.InstanceNodeMenuText, new AddChildNodeCommand(Site, typeof(InstanceNode)), this, Shortcut.None, SR.InstanceNodeStatusText, InsertionPoint.New); AddMenuItem(item); }
/// <summary> /// <para>Adds the base menu items and a menu item to create <see cref="AuthorizationRuleNode"/> objects.</para> /// </summary> protected override void OnAddMenuItems() { base.OnAddMenuItems(); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.AuthorizationRuleCommandName, new AuthorizationRuleNodeCommandInterceptor(Site, typeof(AuthorizationRuleNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.AuthorizationRuleCommandName), InsertionPoint.New); AddMenuItem(item); }
protected override void OnAddMenuItems() { base.OnAddMenuItems (); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.ExceptionPolicyNodeMenuText, new AddChildNodeCommand(Site, typeof(ExceptionPolicyNode)), this, Shortcut.None, SR.ExceptionPolicyNodeStatusText, InsertionPoint.New); AddMenuItem(item); }
/// <summary> /// <para>Adds the base menu items and a menu item for creating <see cref="OraclePackageNode"/> objects.</para> /// </summary> protected override void OnAddMenuItems() { base.OnAddMenuItems (); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.DefaultOraclePackageNodeName, new AddChildNodeCommand(Site, typeof(OraclePackageNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.DefaultOraclePackageNodeName), InsertionPoint.New); AddMenuItem(item); }
protected override void OnAddMenuItems() { base.OnAddMenuItems (); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.Category, new AddChildNodeCommand(Site, typeof(CategoryNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.Category), InsertionPoint.New); AddMenuItem(item); }
/// <summary> /// <para>Create menu items based on the nodes registered with the <see cref="INodeCreationService"/> for the spefied type.</para> /// </summary> /// <param name="nodeType"> /// <para>The type to create menu items.</para> /// </param> protected void CreateDynamicMenuItems(Type nodeType) { INodeCreationService service = ServiceHelper.GetNodeCreationService(Site); StringCollection names = service.GetDisplayNames(nodeType); ConfigurationMenuItem item = null; foreach (string name in names) { NodeCreationEntry entry = service.GetNodeCreationEntry(name); item = new ConfigurationMenuItem(name, entry.ConfigurationNodeCommand, this, Shortcut.None, SR.GenericCreateStatusText(name), InsertionPoint.New); if (!entry.AllowMultiple) { if (Hierarchy.ContainsNodeType(this, nodeType/*entry.BaseTypeToCompare*/)) { item.Enabled = false; } } AddMenuItem(item); } }
/// <summary> /// <para>Allows nodes that override to add menu items for the user interface.</para> /// </summary> /// <remarks> /// <para>Call <seealso cref="AddMenuItem"/> for every menu item that needs to be added to the user interface.</para> /// <para>By default, the base class adds the <see cref="ValidateNodeCommand"/> and <see cref="RemoveNodeCommand"/></para> /// </remarks> protected virtual void OnAddMenuItems() { currentContainerService.MenuItems.Add(ConfigurationMenuItem.CreateValidateNodeCommand(Site, this)); currentContainerService.MenuItems.Add(ConfigurationMenuItem.CreateRemoveNodeCommand(Site, this)); }
private static void CreateCommands(IServiceProvider serviceProvider) { IUIHierarchyService hierarchyService = ServiceHelper.GetUIHierarchyService(serviceProvider); IUIHierarchy currentHierarchy = hierarchyService.SelectedHierarchy; bool containsNode = currentHierarchy.ContainsNodeType(typeof(CacheManagerSettingsNode)); IMenuContainerService menuService = ServiceHelper.GetMenuContainerService(serviceProvider); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.CacheSettingsMenuText, new AddConfigurationSectionCommand(serviceProvider, typeof(CacheManagerSettingsNode), CacheManagerSettings.SectionName), ServiceHelper.GetCurrentRootNode(serviceProvider), Shortcut.None, SR.CacheSettingsStatusText, InsertionPoint.New); item.Enabled = !containsNode; menuService.MenuItems.Add(item); }
private void CreateMoveUpMenuItem() { if (this.PreviousSibling == null) return; ConfigurationMenuItem moveUpMenuItem = new ConfigurationMenuItem(SR.MoveUpMenuItemText, new MoveNodeBeforeCommand(Site, this, this.PreviousSibling), this.Parent, Shortcut.None, SR.MoveUpStatusText, InsertionPoint.Action); AddMenuItem(moveUpMenuItem); }
/// <summary> /// <para>Create a menu item for the <see cref="AddChildNodeCommand"/> for the <paramref name="node"/>.</para> /// </summary> /// <param name="serviceProvider"> /// <para>The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</para> /// </param> /// <param name="node"> /// <para>The <see cref="ConfigurationNode"/> to associate with the menu.</para> /// </param> /// <param name="t"> /// <para>The type of node to create.</para> /// </param> /// <param name="menuText"> /// <para>The text to display in the menu item.</para> /// </param> /// <param name="allowMultiple"> /// <para>Allow multiple of the same node typ for the parent <paramref name="node"/>.</para> /// </param> /// <returns> /// <para>An instance of the <see cref="AddChildNodeCommand"/> class.</para> /// </returns> public static ConfigurationMenuItem CreateAddChildNodeMenuItem(IServiceProvider serviceProvider, ConfigurationNode node, Type t, string menuText, bool allowMultiple) { ConfigurationMenuItem item = new ConfigurationMenuItem(menuText, new AddChildNodeCommand(serviceProvider, t), node, Shortcut.None, SR.GenericCreateStatusText(menuText), InsertionPoint.New); if (!allowMultiple) { if (node.Hierarchy.ContainsNodeType(node, t)) { item.Enabled = false; } } return item; }
private static void CreateCommands(IServiceProvider provider) { IUIHierarchyService hierarchyService = provider.GetService(typeof(IUIHierarchyService)) as IUIHierarchyService; Debug.Assert(hierarchyService != null, "Could not get the IUIHierarchyService"); IUIHierarchy currentHierarchy = hierarchyService.SelectedHierarchy; bool containsNode = currentHierarchy.ContainsNodeType(typeof(LoggingSettingsNode)); IMenuContainerService menuService = provider.GetService(typeof(IMenuContainerService)) as IMenuContainerService; Debug.Assert(menuService != null, "Could not get the IMenuContainerService"); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.LogSettingsCmd, new AddChildNodeCommand(provider, typeof(LoggingSettingsNode)), ServiceHelper.GetCurrentRootNode(provider), Shortcut.None, SR.GenericCreateStatusText(SR.LogSettingsCmd), InsertionPoint.New); item.Enabled = !containsNode; menuService.MenuItems.Add(item); }
/// <summary> /// <para>Creates a copy of the current <see cref="ConfigurationMenuItem"/>.</para> /// </summary> /// <returns> /// <para>A <see cref="ConfigurationMenuItem"/> that represents the duplicated menu item.</para> /// </returns> public override MenuItem CloneMenu() { ConfigurationMenuItem item = new ConfigurationMenuItem(); item.CloneMenu(this); item.StatusBarText = this.statusBarText; item.InsertionPoint = this.insertionPoint; item.Node = this.node; item.Command = this.command; return item; }
/// <summary> /// <para>Adds the default menu items.</para> /// </summary> protected override void OnAddMenuItems() { base.OnAddMenuItems(); AddMenuItem(ConfigurationMenuItem.CreateAddChildNodeMenuItem(Site, this, typeof(CustomSymmetricCryptoProviderNode), SR.CustomSymmetricCryptoProviderNodeName, true)); ConfigurationMenuItem item = new ConfigurationMenuItem(SR.SymmetricAlgorithmProviderNodeName, new AddSymmetricAlgorithmProviderNodeCommand(Site, typeof(SymmetricAlgorithmProviderNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.SymmetricAlgorithmProviderNodeName), InsertionPoint.New); AddMenuItem(item); item = new ConfigurationMenuItem(SR.DpapiSymmetricCryptoProviderNodeName, new AddDpapiSymmetricProviderNodeCommand(Site, typeof(DpapiSymmetricCryptoProviderNode)), this, Shortcut.None, SR.GenericCreateStatusText(SR.DpapiSymmetricCryptoProviderNodeName), InsertionPoint.New); AddMenuItem(item); }
private void AddNodeMenu(Type type, string menuText, string statusText) { ConfigurationMenuItem item = new ConfigurationMenuItem(menuText, new AddChildNodeCommand(Site, type), this, Shortcut.None, statusText, InsertionPoint.New); item.Enabled = !DoesChildNodeExist(typeof(ConnectionStringCollectionNode)); AddMenuItem(item); }