/// <summary> /// Initializes a new instance of the <see cref="Tool"/> class. /// </summary> /// <param name="toolManager">The <see cref="ToolManager"/>.</param> /// <param name="settings">The <see cref="ToolSettings"/> to use to create this <see cref="Tool"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="toolManager"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception> protected Tool(ToolManager toolManager, ToolSettings settings) { if (toolManager == null) { throw new ArgumentNullException("toolManager"); } if (settings == null) { throw new ArgumentNullException("settings"); } settings.Lock(); // Set the properties _toolManager = toolManager; _settings = settings; _toolBarControl = ToolBar.CreateToolControl(this, ToolSettings.ToolBarControlType); if (ToolBarControl != null) { // Set the default image ToolBarControl.ControlSettings.Image = ToolSettings.DisabledImage ?? ToolSettings.DefaultImage; // If an image is set, then default to showing only the image if (ToolBarControl.ControlSettings.Image != null) { ToolBarControl.ControlSettings.DisplayStyle = ToolStripItemDisplayStyle.Image; } } }
/// <summary> /// Initializes a new instance of the <see cref="Tool"/> class. /// </summary> /// <param name="toolManager">The <see cref="ToolManager"/>.</param> /// <param name="settings">The <see cref="ToolSettings"/> to use to create this <see cref="Tool"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="toolManager"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception> protected Tool(ToolManager toolManager, ToolSettings settings) { if (toolManager == null) throw new ArgumentNullException("toolManager"); if (settings == null) throw new ArgumentNullException("settings"); settings.Lock(); // Set the properties _toolManager = toolManager; _settings = settings; _toolBarControl = ToolBar.CreateToolControl(this, ToolSettings.ToolBarControlType); if (ToolBarControl != null) { // Set the default image ToolBarControl.ControlSettings.Image = ToolSettings.DisabledImage ?? ToolSettings.DefaultImage; // If an image is set, then default to showing only the image if (ToolBarControl.ControlSettings.Image != null) ToolBarControl.ControlSettings.DisplayStyle = ToolStripItemDisplayStyle.Image; // Bind help if (!string.IsNullOrEmpty(settings.HelpName) && !string.IsNullOrEmpty(settings.HelpWikiPage)) { EditorHelpManager.Instance.Add((ToolStripItem)ToolBarControl, settings.HelpName, settings.HelpWikiPage); } } }
/// <summary> /// Gets the <see cref="IToolBarControl"/>s on the <see cref="ToolBar"/>. /// </summary> /// <returns>The <see cref="IToolBarControl"/>s on the <see cref="ToolBar"/>, ordered by the same order that they appear. /// Separators and other non-<see cref="IToolBarControl"/> items are denoted with a null value.</returns> public IEnumerable <IToolBarControl> GetItems() { var ret = new IToolBarControl[Items.Count]; for (var i = 0; i < ret.Length; i++) { var item = Items[i]; ret[i] = item as IToolBarControl; } return(ret); }
/// <summary> /// Initializes a new instance of the <see cref="Tool"/> class. /// </summary> /// <param name="toolManager">The <see cref="ToolManager"/>.</param> /// <param name="settings">The <see cref="ToolSettings"/> to use to create this <see cref="Tool"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="toolManager"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception> protected Tool(ToolManager toolManager, ToolSettings settings) { if (toolManager == null) { throw new ArgumentNullException("toolManager"); } if (settings == null) { throw new ArgumentNullException("settings"); } settings.Lock(); // Set the properties _toolManager = toolManager; _settings = settings; _toolBarControl = ToolBar.CreateToolControl(this, ToolSettings.ToolBarControlType); if (ToolBarControl != null) { // Set the default image ToolBarControl.ControlSettings.Image = ToolSettings.DisabledImage ?? ToolSettings.DefaultImage; // If an image is set, then default to showing only the image if (ToolBarControl.ControlSettings.Image != null) { ToolBarControl.ControlSettings.DisplayStyle = ToolStripItemDisplayStyle.Image; } // Bind help if (!string.IsNullOrEmpty(settings.HelpName) && !string.IsNullOrEmpty(settings.HelpWikiPage)) { EditorHelpManager.Instance.Add((ToolStripItem)ToolBarControl, settings.HelpName, settings.HelpWikiPage); } } }
/// <summary> /// Initializes a new instance of the <see cref="Tool"/> class. /// </summary> /// <param name="toolManager">The <see cref="ToolManager"/>.</param> /// <param name="settings">The <see cref="ToolSettings"/> to use to create this <see cref="Tool"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="toolManager"/> is null.</exception> /// <exception cref="ArgumentNullException"><paramref name="settings"/> is null.</exception> protected Tool(ToolManager toolManager, ToolSettings settings) { if (toolManager == null) throw new ArgumentNullException("toolManager"); if (settings == null) throw new ArgumentNullException("settings"); settings.Lock(); // Set the properties _toolManager = toolManager; _settings = settings; _toolBarControl = ToolBar.CreateToolControl(this, ToolSettings.ToolBarControlType); if (ToolBarControl != null) { // Set the default image ToolBarControl.ControlSettings.Image = ToolSettings.DisabledImage ?? ToolSettings.DefaultImage; // If an image is set, then default to showing only the image if (ToolBarControl.ControlSettings.Image != null) ToolBarControl.ControlSettings.DisplayStyle = ToolStripItemDisplayStyle.Image; } }
/// <summary> /// Gets the <see cref="IToolBarControl"/>s on the <see cref="ToolBar"/>. /// </summary> /// <returns>The <see cref="IToolBarControl"/>s on the <see cref="ToolBar"/>, ordered by the same order that they appear. /// Separators and other non-<see cref="IToolBarControl"/> items are denoted with a null value.</returns> public IEnumerable<IToolBarControl> GetItems() { var ret = new IToolBarControl[Items.Count]; for (var i = 0; i < ret.Length; i++) { var item = Items[i]; ret[i] = item as IToolBarControl; } return ret; }