Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2514 for trunk


Ignore:
Timestamp:
11/19/09 18:13:55 (15 years ago)
Author:
mkommend
Message:

added ability to generate separators in between menu- and toolbaritems (ticket #771)

Location:
trunk/sources
Files:
4 added
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.Test/3.2/ButtonItems/OpenToolStripButtonItem.cs

    r2458 r2514  
    66
    77namespace HeuristicLab.MainForm.Test {
    8   public class OpenToolStripButtonItem : ToolBarItemBase, ITestUserInterfaceItemProvider {
     8  public class OpenToolStripButtonItem : HeuristicLab.MainForm.WindowsForms.ToolBarItemBase, ITestUserInterfaceItemProvider {
    99    public override int Position {
    1010      get { return 20; }
  • trunk/sources/HeuristicLab.MainForm.Test/3.2/ButtonItems/SeparatorToolStripButtonItem.cs

    r2504 r2514  
    66
    77namespace HeuristicLab.MainForm.Test {
    8   public class NewToolStripButtonItem : HeuristicLab.MainForm.WindowsForms.ToolBarItemBase, ITestUserInterfaceItemProvider {
     8  public class SeparatorToolStripButtonItem : ToolBarSeparatorItemBase, ITestUserInterfaceItemProvider {
    99    public override int Position {
    10       get { return 10; }
    11     }
    12 
    13     public override string Name {
    14       get { return "New"; }
    15     }
    16 
    17     public override bool IsDropDownButton {
    18       get { return true; }
    19     }
    20 
    21     public override System.Drawing.Image Image {
    22       get { return HeuristicLab.Common.Resources.Resources.NewIcon; }
    23     }
    24 
    25     public override void Execute() {
     10      get { return 15; }
    2611    }
    2712  }
  • trunk/sources/HeuristicLab.MainForm.Test/3.2/HeuristicLab.MainForm.Test-3.2.csproj

    r2499 r2514  
    8383  <ItemGroup>
    8484    <Compile Include="Actions\NewEditorAction.cs" />
     85    <Compile Include="ButtonItems\SeparatorToolStripButtonItem.cs" />
    8586    <Compile Include="ButtonItems\NewEditorToolStripButtonItem.cs" />
    8687    <Compile Include="ButtonItems\NewFormToolStripButtonItem.cs" />
     
    107108      <DependentUpon>FormView.cs</DependentUpon>
    108109    </Compile>
     110    <Compile Include="MenuItems\SeparatorMenuItem.cs" />
    109111    <Compile Include="MenuItems\ExitToolStripMenuItem.cs" />
    110112    <Compile Include="MenuItems\NewFormToolStripMenuItem.cs" />
  • trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/SeparatorMenuItem.cs

    r2504 r2514  
    99
    1010namespace HeuristicLab.MainForm.Test {
    11   public class NewFormToolStripMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItemBase, ITestUserInterfaceItemProvider {
    12     public override string Name {
    13       get { return "Form"; }
    14     }
    15 
     11  public class SeparatorMenuItem : MenuSeparatorItemBase, ITestUserInterfaceItemProvider {
    1612    public override IEnumerable<string> Structure {
    17       get { return "File/New".Split('/'); }
     13      get { return new string[] { "File" }; }
    1814    }
    1915
    2016    public override int Position {
    21       get { return 1110; }
    22    
    23     }
     17      get { return 1120; }
    2418
    25     public override void Execute() {
    26       new NewFormAction().Execute(MainFormManager.MainForm);
    2719    }
    2820  }
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs

    r2469 r2514  
    207207
    208208      object[] items = ds.GetInstances(userInterfaceItemType);
    209       IEnumerable<MenuItemBase> toolStripMenuItems =
     209      IEnumerable<IMenuItem> toolStripMenuItems =
    210210        from mi in items
    211         where mi is MenuItemBase
    212         orderby ((MenuItemBase)mi).Position
    213         select (MenuItemBase)mi;
    214       foreach (MenuItemBase menuItem in toolStripMenuItems)
     211        where mi is IMenuItem
     212        orderby ((IMenuItem)mi).Position
     213        select (IMenuItem)mi;
     214      foreach (IMenuItem menuItem in toolStripMenuItems)
    215215        AddToolStripMenuItem(menuItem);
    216216
    217217      items = ds.GetInstances(userInterfaceItemType);
    218       IEnumerable<ToolBarItemBase> toolStripButtonItems =
     218      IEnumerable<IToolBarItem> toolStripButtonItems =
    219219        from bi in items
    220         where bi is ToolBarItemBase
    221         orderby ((ToolBarItemBase)bi).Position
    222         select (ToolBarItemBase)bi;
    223       foreach (ToolBarItemBase toolStripButtonItem in toolStripButtonItems)
     220        where bi is IToolBarItem
     221        orderby ((IToolBarItem)bi).Position
     222        select (IToolBarItem)bi;
     223      foreach (IToolBarItem toolStripButtonItem in toolStripButtonItems)
    224224        AddToolStripButtonItem(toolStripButtonItem);
    225225    }
    226226
    227     private void AddToolStripMenuItem(MenuItemBase menuItem) {
    228       ToolStripMenuItem item = new ToolStripMenuItem();
    229       SetToolStripItemProperties(item, menuItem);
    230       menuItem.ToolStripItem = item;
    231       item.ShortcutKeys = menuItem.ShortCutKeys;
    232       item.DisplayStyle = menuItem.ToolStripItemDisplayStyle;
    233       this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items);
    234     }
    235 
    236     private void AddToolStripButtonItem(ToolBarItemBase buttonItem) {
    237       ToolStripItem item;
    238       if (buttonItem.IsDropDownButton)
    239         item = new ToolStripDropDownButton();
    240       else
    241         item = new ToolStripButton();
    242 
    243       SetToolStripItemProperties(item, buttonItem);
    244       item.DisplayStyle = buttonItem.ToolStripItemDisplayStyle;
    245       buttonItem.ToolStripItem = item;
     227    private void AddToolStripMenuItem(IMenuItem menuItem) {
     228      if (menuItem is MenuItemBase) {
     229        ToolStripMenuItem item = new ToolStripMenuItem();
     230        SetToolStripItemProperties(item, menuItem);
     231        ((MenuItemBase)menuItem).ToolStripItem = item;
     232        item.ShortcutKeys = ((MenuItemBase)menuItem).ShortCutKeys;
     233        item.DisplayStyle = ((MenuItemBase)menuItem).ToolStripItemDisplayStyle;
     234        this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items);
     235      } else if (menuItem is MenuSeparatorItemBase) {
     236        this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), new ToolStripSeparator(), menuStrip.Items);
     237      }
     238     }
     239
     240    private void AddToolStripButtonItem(IToolBarItem buttonItem) {
     241      ToolStripItem item = null;
     242
     243      if (buttonItem is ToolBarItemBase) {
     244        if (((ToolBarItemBase)buttonItem).IsDropDownButton)
     245          item = new ToolStripDropDownButton();
     246        else
     247          item = new ToolStripButton();
     248
     249        SetToolStripItemProperties(item, buttonItem);
     250        item.DisplayStyle = ((ToolBarItemBase)buttonItem).ToolStripItemDisplayStyle;
     251        ((ToolBarItemBase)buttonItem).ToolStripItem = item;
     252      } else if (buttonItem is IToolBarSeparatorItem)
     253        item = new ToolStripSeparator();
     254     
    246255      this.InsertItem(buttonItem.Structure, typeof(ToolStripDropDownButton), item, toolStrip.Items);
    247256    }
  • trunk/sources/HeuristicLab.MainForm/3.2/HeuristicLab.MainForm-3.2.csproj

    r2466 r2514  
    8181  </ItemGroup>
    8282  <ItemGroup>
     83    <Compile Include="ToolBarSeparatorItemBase.cs" />
     84    <Compile Include="Interfaces\IToolBarSeparatorItem.cs" />
    8385    <Compile Include="Interfaces\IMenuItem.cs" />
     86    <Compile Include="Interfaces\IMenuSeparatorItem.cs" />
    8487    <Compile Include="Interfaces\IToolBarItem.cs" />
    8588    <Compile Include="MainFormManager.cs" />
    8689    <Compile Include="MenuItemBase.cs" />
     90    <Compile Include="MenuSeparatorItemBase.cs" />
    8791    <Compile Include="ToolBarItemBase.cs" />
    8892    <Compile Include="HeuristicLabMainFormPlugin.cs" />
Note: See TracChangeset for help on using the changeset viewer.