Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2243


Ignore:
Timestamp:
08/05/09 19:24:49 (15 years ago)
Author:
mkommend
Message:

added HeuristicLab!.MainForm.Test project and demo implementation
adapted MainForm to new design (ticket #716)

Location:
trunk/sources
Files:
20 added
7 edited
4 copied
2 moved

Legend:

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

    r2229 r2243  
    2525using System.Windows.Forms;
    2626using HeuristicLab.PluginInfrastructure;
     27using HeuristicLab.MainForm;
    2728
    28 namespace HeuristicLab.Grid {
    29   [ClassInfo(Name = "Grid Client", Description="Client application for the distributed engine grid.", AutoRestart = true)]
     29namespace HeuristicLab.MainForm.Test {
     30  [ClassInfo(Name = "MainForm Test", Description="Test application for new mainform development.")]
    3031  class GridClientApplication : ApplicationBase {
    3132    public override void Run() {
    32       Form mainForm = new ClientForm();
     33      DockingMainForm mainForm = new DockingMainForm(typeof(ITestUserInterfaceItemProvider));
     34      mainForm.Title = "Test new MAINFORM concept";
    3335      Application.Run(mainForm);
    3436    }
  • trunk/sources/HeuristicLab.MainForm.Test/3.2/HeuristicLabMainFormTestPlugin.cs

    r2233 r2243  
    2626
    2727namespace HeuristicLab.Modeling.Database {
    28   [ClassInfo(Name = "HeuristicLab.MainForm-3.2")]
    29   [PluginFile(Filename = "HeuristicLab.MainForm-3.2.dll", Filetype = PluginFileType.Assembly)]
    30   [PluginFile(Filename = "HeuristicLab.MainForm.Docking-3.2.dll", Filetype = PluginFileType.Assembly)]
    31   [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    32   public class HeuristicLabMainFormPlugin : PluginBase {
     28  [ClassInfo(Name = "HeuristicLab.MainForm.Test-3.2")]
     29  [PluginFile(Filename = "HeuristicLab.MainForm.Test-3.2.dll", Filetype = PluginFileType.Assembly)] 
     30  [Dependency(Dependency = "HeuristicLab.MainForm-3.2")]
     31  public class HeuristicLabMainFormTestPlugin : PluginBase {
    3332  }
    3433}
  • trunk/sources/HeuristicLab.MainForm/3.2/HeuristicLab.MainForm.csproj

    r2233 r2243  
    8282  </ItemGroup>
    8383  <ItemGroup>
     84    <Compile Include="Interfaces\IUserInterfaceItem.cs" />
     85    <Compile Include="ToolStripMenuItemBase.cs" />
     86    <Compile Include="ToolStripButtonItemBase.cs" />
     87    <Compile Include="ToolStripItemBase.cs" />
    8488    <Compile Include="DockingMainForm.cs">
    8589      <SubType>Form</SubType>
     
    97101    <Compile Include="Interfaces\IAction.cs" />
    98102    <Compile Include="Interfaces\IMainForm.cs" />
    99     <Compile Include="Interfaces\IMenuItem.cs" />
     103    <Compile Include="Interfaces\IToolStripMenuItem.cs" />
    100104    <Compile Include="Interfaces\IModel.cs" />
     105    <Compile Include="Interfaces\IToolStripButtonItem.cs" />
    101106    <Compile Include="Interfaces\IToolStripItem.cs" />
    102     <Compile Include="Interfaces\IUserInterfaceItem.cs" />
    103107    <Compile Include="Interfaces\IView.cs" />
    104108    <Compile Include="Properties\AssemblyInfo.cs" />
     109    <Compile Include="UserInterfaceItemBase.cs" />
    105110    <Compile Include="ViewBase.cs">
    106111      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.MainForm/3.2/HeuristicLabMainFormPlugin.cs

    r2233 r2243  
    2828  [ClassInfo(Name = "HeuristicLab.MainForm-3.2")]
    2929  [PluginFile(Filename = "HeuristicLab.MainForm-3.2.dll", Filetype = PluginFileType.Assembly)]
    30   [PluginFile(Filename = "HeuristicLab.MainForm.Docking-3.2.dll", Filetype = PluginFileType.Assembly)]
    3130  [Dependency(Dependency = "HeuristicLab.Core-3.2")]
    3231  public class HeuristicLabMainFormPlugin : PluginBase {
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IAction.cs

    r2233 r2243  
    2828  public interface IAction {
    2929    void Execute(IMainForm mainform);
    30     bool Enabled(IMainForm mainform);
    3130  }
    3231}
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IMainForm.cs

    r2233 r2243  
    3232    Icon Icon { get; set; }
    3333
    34     IModel Model { get; }
    3534    IView ActiveView { get; }
    3635    IEnumerable<IView> OpenViews { get; }
    3736
    3837    Type UserInterfaceItemType { get; }
    39 
    4038    void ShowView(IView view);
    4139  }
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripButtonItem.cs

    r2233 r2243  
    2626
    2727namespace HeuristicLab.MainForm {
    28   public interface IToolStripItem {
     28  public interface IToolStripButtonItem : IToolStripItem {
    2929  }
    3030}
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripItem.cs

    r2233 r2243  
    2525using System.Text;
    2626using System.Drawing;
     27using System.Windows.Forms;
    2728
    28 namespace HeuristicLab.MainForm.Interfaces {
    29   public interface IUserInterfaceItem : IAction {
    30     string Name { get; }
     29namespace HeuristicLab.MainForm {
     30  public interface IToolStripItem : IUserInterfaceItem {
    3131    Image Image { get; }
    32     string ImagePath { get; }
     32    ToolStripItemDisplayStyle DisplayStyle { get; }
     33    ToolStripItem ToolStripItem { get; set; }
    3334  }
    3435}
  • trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripMenuItem.cs

    r2233 r2243  
    2424using System.Linq;
    2525using System.Text;
     26using System.Windows.Forms;
    2627
    2728namespace HeuristicLab.MainForm {
    28   public interface IMenuItem {
     29  public interface IToolStripMenuItem : IToolStripItem {
     30    string MenuStructure { get; }
     31    char MenuStructureSeparator { get; }
     32    Keys ShortCutKeys { get; }
    2933  }
    3034}
  • trunk/sources/HeuristicLab.MainForm/3.2/MainFormBase.cs

    r2233 r2243  
    2929using System.Windows.Forms;
    3030
     31using HeuristicLab.PluginInfrastructure;
     32
    3133namespace HeuristicLab.MainForm {
    32   public partial class MainFormBase : Form, IMainForm {
    33     public MainFormBase()
     34  public abstract partial class MainFormBase : Form, IMainForm {
     35    protected MainFormBase(Type userInterfaceItemType)
    3436      : base() {
    3537      InitializeComponent();
    3638      openViews = new List<IView>();
    37     }
    38 
    39     public MainFormBase(Type userInterfaceItemType)
    40       : this() {
    4139      this.userInterfaceItemType = userInterfaceItemType;
     40      CreateGUI();
    4241    }
    4342
    4443    #region IMainForm Members
    4544    public string Title {
    46       get { return this.Title; }
    47       set { this.Title = value; }
     45      get { return this.Text; }
     46      set { this.Text = value; }
    4847    }
    4948
     
    5655    public Type UserInterfaceItemType {
    5756      get { return this.userInterfaceItemType; }
    58     }
    59 
    60     protected IModel model;
    61     public IModel Model {
    62       get { return this.model; }
    63       set { this.model = value; }
    6457    }
    6558
     
    7972      openViews.Add(view);
    8073    }
     74    #endregion
    8175
     76    #region create menu and toolbar
     77    private void CreateGUI() {
     78      DiscoveryService ds = new DiscoveryService();
     79      Type[] userInterfaceTypes = ds.GetTypes(userInterfaceItemType);
     80
     81      foreach (Type t in userInterfaceTypes.Where(t=> typeof(IToolStripMenuItem).IsAssignableFrom(t))) {
     82        if (!t.IsAbstract && !t.IsInterface && !t.HasElementType) {
     83          IToolStripMenuItem item = (IToolStripMenuItem) Activator.CreateInstance(t);
     84          AddToolStripMenuItem(item);
     85        }
     86      }
     87
     88      foreach (Type t in userInterfaceTypes.Where(t => typeof(IToolStripButtonItem).IsAssignableFrom(t))) {
     89        if (!t.IsAbstract && !t.IsInterface && !t.HasElementType) {
     90          IToolStripButtonItem item = (IToolStripButtonItem)Activator.CreateInstance(t);
     91          AddToolStripButtonItem(item);
     92        }
     93      }
     94    }
     95
     96    private void AddToolStripMenuItem(IToolStripMenuItem menuItem) {
     97      ToolStripMenuItem item = new ToolStripMenuItem();
     98      SetToolStripItemProperties(item, menuItem);   
     99      item.ShortcutKeys = menuItem.ShortCutKeys;
     100
     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
     116      if (parent == null)
     117        menuStrip.Items.Add(item);
     118      else
     119        parent.DropDownItems.Add(item);
     120    }
     121
     122    private void AddToolStripButtonItem(IToolStripButtonItem buttonItem) {
     123      ToolStripButton item = new ToolStripButton();
     124      SetToolStripItemProperties(item, buttonItem);
     125      toolStrip.Items.Add(item);
     126    }
     127
     128    private void SetToolStripItemProperties(ToolStripItem toolStripItem, IToolStripItem iToolStripItem) {
     129      toolStripItem.Text = iToolStripItem.Name;
     130      toolStripItem.Name = iToolStripItem.Name;
     131      toolStripItem.Tag = iToolStripItem;
     132      toolStripItem.Image = iToolStripItem.Image;
     133      toolStripItem.DisplayStyle = iToolStripItem.DisplayStyle;
     134      toolStripItem.Click += new EventHandler(ToolStripItemClicked);
     135      iToolStripItem.ToolStripItem = toolStripItem;
     136    }
     137
     138    private void ToolStripItemClicked(object sender, EventArgs e) {
     139      System.Windows.Forms.ToolStripItem item = (System.Windows.Forms.ToolStripItem)sender;
     140      ((IAction)item.Tag).Execute(this);
     141    }
    82142    #endregion
    83143  }
  • trunk/sources/HeuristicLab.sln

    r2240 r2243  
    243243EndProject
    244244Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MainForm", "HeuristicLab.MainForm\3.2\HeuristicLab.MainForm.csproj", "{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}"
     245EndProject
     246Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MainForm.Test-3.2", "HeuristicLab.MainForm.Test\3.2\HeuristicLab.MainForm.Test-3.2.csproj", "{569E430B-B4CE-4B94-A44E-6246B6E4E3BC}"
    245247EndProject
    246248Global
     
    39063908    {3BD61258-31DA-4B09-89C0-4F71FEF5F05A}.Visualization Debug|x64.ActiveCfg = Debug|Any CPU
    39073909    {3BD61258-31DA-4B09-89C0-4F71FEF5F05A}.Visualization Debug|x86.ActiveCfg = Debug|Any CPU
     3910    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.CEDMA Debug|Any CPU.ActiveCfg = Debug|Any CPU
     3911    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.CEDMA Debug|Any CPU.Build.0 = Debug|Any CPU
     3912    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.CEDMA Debug|x64.ActiveCfg = Debug|Any CPU
     3913    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.CEDMA Debug|x86.ActiveCfg = Debug|Any CPU
     3914    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     3915    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
     3916    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Debug|x64.ActiveCfg = Debug|Any CPU
     3917    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Debug|x86.ActiveCfg = Debug|x86
     3918    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Debug|x86.Build.0 = Debug|x86
     3919    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Modeling Debug|Any CPU.ActiveCfg = Debug|Any CPU
     3920    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Modeling Debug|Any CPU.Build.0 = Debug|Any CPU
     3921    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Modeling Debug|x64.ActiveCfg = Debug|Any CPU
     3922    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Modeling Debug|x86.ActiveCfg = Debug|Any CPU
     3923    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
     3924    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Release|Any CPU.Build.0 = Release|Any CPU
     3925    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Release|x64.ActiveCfg = Release|Any CPU
     3926    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Release|x86.ActiveCfg = Release|x86
     3927    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Release|x86.Build.0 = Release|x86
     3928    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.v3.2 Debug|Any CPU.ActiveCfg = Debug|Any CPU
     3929    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.v3.2 Debug|Any CPU.Build.0 = Debug|Any CPU
     3930    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.v3.2 Debug|x64.ActiveCfg = Debug|Any CPU
     3931    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.v3.2 Debug|x86.ActiveCfg = Debug|Any CPU
     3932    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Visualization Debug|Any CPU.ActiveCfg = Debug|Any CPU
     3933    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Visualization Debug|Any CPU.Build.0 = Debug|Any CPU
     3934    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Visualization Debug|x64.ActiveCfg = Debug|Any CPU
     3935    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC}.Visualization Debug|x86.ActiveCfg = Debug|Any CPU
    39083936  EndGlobalSection
    39093937  GlobalSection(SolutionProperties) = preSolution
     
    39964024    {45D11FBD-A71B-48D3-8A94-8EB0DFE8E06A} = {410732DB-725A-4824-896B-C298978343C0}
    39974025    {3BD61258-31DA-4B09-89C0-4F71FEF5F05A} = {410732DB-725A-4824-896B-C298978343C0}
     4026    {569E430B-B4CE-4B94-A44E-6246B6E4E3BC} = {410732DB-725A-4824-896B-C298978343C0}
    39984027    {A9E282EA-180F-4233-B809-AEDF0787545C} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B}
    39994028    {BF7D9494-A586-457B-8DF9-ED599F9E6A71} = {78982D7C-D63D-4A3D-AE1F-F58AC007603B}
  • trunk/sources/HeuristicLab/CopyAssemblies.cmd

    r2240 r2243  
    7171copy "%SolutionDir%\HeuristicLab.Logging\3.2\%Outdir%\HeuristicLab.Logging-3.2.dll" .\plugins
    7272copy "%SolutionDir%\HeuristicLab.Logging\3.3\%Outdir%\HeuristicLab.Logging-3.3.dll" .\plugins
     73copy "%SolutionDir%\HeuristicLab.MainForm\3.2\%Outdir%\HeuristicLab.MainForm-3.2.dll" .\plugins
     74copy "%SolutionDir%\HeuristicLab.MainForm.Test\3.2\%Outdir%\HeuristicLab.MainForm.Test-3.2.dll" .\plugins
    7375copy "%SolutionDir%\HeuristicLab.Modeling\3.2\%Outdir%\HeuristicLab.Modeling-3.2.dll" .\plugins
    7476copy "%SolutionDir%\HeuristicLab.Modeling\3.3\%Outdir%\HeuristicLab.Modeling-3.3.dll" .\plugins
Note: See TracChangeset for help on using the changeset viewer.