Changeset 2249 for trunk/sources/HeuristicLab.MainForm
- Timestamp:
- 08/06/09 13:57:51 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm/3.2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripButtonItem.cs
r2243 r2249 27 27 namespace HeuristicLab.MainForm { 28 28 public interface IToolStripButtonItem : IToolStripItem { 29 bool IsDropDownButton { get; } 29 30 } 30 31 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripItem.cs
r2247 r2249 32 32 Image Image { get; } 33 33 ToolStripItemDisplayStyle DisplayStyle { get; } 34 35 string Structure { get; } 36 char StructureSeparator { get; } 37 34 38 ToolStripItem ToolStripItem { get; set; } 35 39 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripMenuItem.cs
r2243 r2249 28 28 namespace HeuristicLab.MainForm { 29 29 public interface IToolStripMenuItem : IToolStripItem { 30 string MenuStructure { get; }31 char MenuStructureSeparator { get; }32 30 Keys ShortCutKeys { get; } 33 31 } -
trunk/sources/HeuristicLab.MainForm/3.2/MainFormBase.cs
r2247 r2249 77 77 private void CreateGUI() { 78 78 DiscoveryService ds = new DiscoveryService(); 79 Type[] userInterfaceTypes = ds.GetTypes(userInterfaceItemType);80 79 81 80 object[] items = ds.GetInstances(userInterfaceItemType); … … 96 95 private void AddToolStripMenuItem(IToolStripMenuItem menuItem) { 97 96 ToolStripMenuItem item = new ToolStripMenuItem(); 98 SetToolStripItemProperties(item, menuItem); 97 SetToolStripItemProperties(item, menuItem); 99 98 item.ShortcutKeys = menuItem.ShortCutKeys; 100 99 101 ToolStripMenuItem parent = null; 102 if (!String.IsNullOrEmpty(menuItem.MenuStructure)) { 103 ToolStripItemCollection parentItems = menuStrip.Items; 104 foreach (string structure in menuItem.MenuStructure.Split(menuItem.MenuStructureSeparator)) { 105 if (parentItems.ContainsKey(structure)) 106 parent = (ToolStripMenuItem)parentItems[structure]; 107 else { 108 parent = new ToolStripMenuItem(structure); 109 parent.Name = structure; 110 parentItems.Add(parent); 111 } 112 parentItems = parent.DropDownItems; 113 } 114 } 115 100 ToolStripDropDownItem parent = FindParent(menuItem, menuStrip.Items); 116 101 if (parent == null) 117 102 menuStrip.Items.Add(item); … … 121 106 122 107 private void AddToolStripButtonItem(IToolStripButtonItem buttonItem) { 123 ToolStripButton item = new ToolStripButton(); 108 ToolStripItem item; 109 if (buttonItem.IsDropDownButton) 110 item = new ToolStripDropDownButton(); 111 else 112 item = new ToolStripButton(); 113 124 114 SetToolStripItemProperties(item, buttonItem); 125 toolStrip.Items.Add(item); 115 ToolStripDropDownItem parent = FindParent(buttonItem,toolStrip.Items); 116 if (parent == null) 117 toolStrip.Items.Add(item); 118 else 119 parent.DropDownItems.Add(item); 120 } 121 122 private ToolStripDropDownItem FindParent(IToolStripItem item, ToolStripItemCollection parentItems) { 123 ToolStripDropDownItem parent = null; 124 foreach (string structure in item.Structure.Split(item.StructureSeparator)) { 125 if (parentItems.ContainsKey(structure)) 126 parent = (ToolStripDropDownItem)parentItems[structure]; 127 else 128 break; 129 parentItems = parent.DropDownItems; 130 } 131 return parent; 126 132 } 127 133 -
trunk/sources/HeuristicLab.MainForm/3.2/ToolStripButtonItemBase.cs
r2243 r2249 27 27 28 28 namespace HeuristicLab.MainForm { 29 public abstract class ToolStripButtonItemBase : ToolStripItemBase, IToolStrip Item {29 public abstract class ToolStripButtonItemBase : ToolStripItemBase, IToolStripButtonItem { 30 30 public override ToolStripItemDisplayStyle DisplayStyle { 31 31 get { … … 36 36 } 37 37 } 38 39 public virtual bool IsDropDownButton { 40 get { return false; } 41 } 38 42 } 39 43 } -
trunk/sources/HeuristicLab.MainForm/3.2/ToolStripItemBase.cs
r2247 r2249 46 46 set { this.toolStripItem = value; } 47 47 } 48 49 public virtual string Structure { 50 get { return string.Empty; } 51 } 52 53 public static readonly char structureSeparator = '/'; 54 public char StructureSeparator { 55 get { return ToolStripMenuItemBase.structureSeparator; } 56 } 48 57 #endregion 49 58 } -
trunk/sources/HeuristicLab.MainForm/3.2/ToolStripMenuItemBase.cs
r2247 r2249 31 31 get { return Keys.None; } 32 32 } 33 public virtual string MenuStructure {34 get { return string.Empty; }35 }36 33 37 34 public override ToolStripItemDisplayStyle DisplayStyle { 38 35 get { return ToolStripItemDisplayStyle.ImageAndText; } 39 36 } 40 41 public static readonly char StructureSeparator = '/';42 public char MenuStructureSeparator {43 get { return ToolStripMenuItemBase.StructureSeparator; }44 }45 37 } 46 38 } -
trunk/sources/HeuristicLab.MainForm/3.2/UserInterfaceItemBase.cs
r2243 r2249 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq;
Note: See TracChangeset
for help on using the changeset viewer.