Changeset 2249
- Timestamp:
- 08/06/09 13:57:51 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 13 added
- 1 deleted
- 9 edited
- 3 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.Test/3.2/HeuristicLab.MainForm.Test-3.2.csproj
r2247 r2249 82 82 </ItemGroup> 83 83 <ItemGroup> 84 <Compile Include="OpenMenuItem.cs" /> 85 <Compile Include="SaveMenuItem.cs" /> 84 <Compile Include="Actions\NewEditorAction.cs" /> 85 <Compile Include="ButtonItems\NewEditorToolStripButtonItem.cs" /> 86 <Compile Include="ButtonItems\NewFormToolStripButtonItem.cs" /> 87 <Compile Include="ButtonItems\SaveToolStripButtonItem.cs" /> 88 <Compile Include="ButtonItems\OpenToolStripButtonItem.cs" /> 89 <Compile Include="MenuItems\NewFormToolStripMenuItem.cs" /> 90 <Compile Include="MenuItems\NewEditorToolStripMenuItem.cs" /> 91 <Compile Include="MenuItems\FileToolStripMenuItem.cs" /> 92 <Compile Include="MenuItems\NewToolStripMenuItem.cs" /> 93 <Compile Include="Actions\NewFormAction.cs" /> 94 <Compile Include="Actions\OpenAction.cs" /> 95 <Compile Include="MenuItems\OpenToolStripMenuItem.cs" /> 96 <Compile Include="Actions\SaveAction.cs" /> 97 <Compile Include="MenuItems\SaveToolStripMenuItem.cs" /> 86 98 <Compile Include="HeuristicLabMainFormTestApplication.cs" /> 87 99 <Compile Include="HeuristicLabMainFormTestPlugin.cs" /> 88 100 <Compile Include="ITestUserInterfaceItemProvider.cs" /> 89 101 <Compile Include="Properties\AssemblyInfo.cs" /> 90 <Compile Include="ViewsMenuItem.cs"> 91 <SubType>Code</SubType> 92 </Compile> 102 <Compile Include="ButtonItems\NewToolStripButtonItem.cs" /> 93 103 </ItemGroup> 94 104 <ItemGroup> -
trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/NewEditorToolStripMenuItem.cs
r2247 r2249 9 9 10 10 namespace HeuristicLab.MainForm.Test { 11 public class SaveMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider {11 public class NewEditorToolStripMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider { 12 12 public override string Name { 13 get { return " Save"; }13 get { return "Editor"; } 14 14 } 15 15 16 public override string MenuStructure {17 get { return "File "; }16 public override string Structure { 17 get { return "File/New"; } 18 18 } 19 19 20 20 public override int Position { 21 get { return 1200; } 22 } 23 24 public override Keys ShortCutKeys { 25 get { return Keys.Control | Keys.S; } 26 } 27 28 public override System.Drawing.Image Image { 29 get { return Resources.SaveIcon; } 21 get { return 1120; } 30 22 } 31 23 32 24 public override void Execute(IMainForm mainform) { 33 MessageBox.Show("Save Execute called");25 new NewEditorAction().Execute(mainform); 34 26 } 35 27 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/NewFormToolStripMenuItem.cs
r2247 r2249 9 9 10 10 namespace HeuristicLab.MainForm.Test { 11 public class SaveMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider {11 public class NewFormToolStripMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider { 12 12 public override string Name { 13 get { return " Save"; }13 get { return "Form"; } 14 14 } 15 15 16 public override string MenuStructure {17 get { return "File "; }16 public override string Structure { 17 get { return "File/New"; } 18 18 } 19 19 20 20 public override int Position { 21 get { return 1200; } 22 } 23 24 public override Keys ShortCutKeys { 25 get { return Keys.Control | Keys.S; } 26 } 27 28 public override System.Drawing.Image Image { 29 get { return Resources.SaveIcon; } 21 get { return 1110; } 30 22 } 31 23 32 24 public override void Execute(IMainForm mainform) { 33 MessageBox.Show("Save Execute called");25 new NewFormAction().Execute(mainform); 34 26 } 35 27 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/NewToolStripMenuItem.cs
r2247 r2249 9 9 10 10 namespace HeuristicLab.MainForm.Test { 11 public class SaveMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider {11 public class NewToolStripMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider { 12 12 public override string Name { 13 get { return " Save"; }13 get { return "New"; } 14 14 } 15 15 16 public override string MenuStructure {16 public override string Structure { 17 17 get { return "File"; } 18 18 } 19 19 20 20 public override int Position { 21 get { return 1200; } 22 } 23 24 public override Keys ShortCutKeys { 25 get { return Keys.Control | Keys.S; } 21 get { return 1100; } 26 22 } 27 23 28 24 public override System.Drawing.Image Image { 29 get { return Resources. SaveIcon; }25 get { return Resources.NewIcon; } 30 26 } 31 27 32 28 public override void Execute(IMainForm mainform) { 33 MessageBox.Show("Save Execute called");34 29 } 35 30 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/OpenToolStripMenuItem.cs
r2247 r2249 8 8 9 9 namespace HeuristicLab.MainForm.Test { 10 public class Open MenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider {10 public class OpenToolStripMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider { 11 11 public override string Name { 12 12 get { return "Open"; } 13 13 } 14 14 15 public override string MenuStructure {15 public override string Structure { 16 16 get { return "File"; } 17 17 } 18 18 19 19 public override int Position { 20 get { return 1 100; }20 get { return 1200; } 21 21 } 22 22 … … 30 30 31 31 public override void Execute(IMainForm mainform) { 32 MessageBox.Show("Open Execute called");32 new OpenAction().Execute(mainform); 33 33 } 34 34 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/SaveToolStripMenuItem.cs
r2247 r2249 9 9 10 10 namespace HeuristicLab.MainForm.Test { 11 public class Save MenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider {11 public class SaveToolStripMenuItem : ToolStripMenuItemBase, ITestUserInterfaceItemProvider { 12 12 public override string Name { 13 13 get { return "Save"; } 14 14 } 15 15 16 public override string MenuStructure {16 public override string Structure { 17 17 get { return "File"; } 18 18 } 19 19 20 20 public override int Position { 21 get { return 1 200; }21 get { return 1300; } 22 22 } 23 23 … … 31 31 32 32 public override void Execute(IMainForm mainform) { 33 MessageBox.Show("Save Execute called");33 new SaveAction().Execute(mainform); 34 34 } 35 35 } -
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.