Index: branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs
===================================================================
--- branches/Mainform refactoring/HeuristicLab.MainForm/3.2/MainFormBase.cs	(revision 2420)
+++ branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs	(revision 2426)
@@ -31,12 +31,12 @@
 using HeuristicLab.PluginInfrastructure;
 
-namespace HeuristicLab.MainForm {
+namespace HeuristicLab.MainForm.WindowsForms {
   public partial class MainFormBase : Form, IMainForm {
     protected MainFormBase()
       : base() {
       InitializeComponent();
-      views = new List<IView>();
-      toolStripItems = new List<IToolStripItem>();
-      this.StatusStripText = "";
+      this.views = new List<IView>();
+      this.userInterfaceItems = new List<IUserInterfaceItem>();
+      MainFormManager.RegisterMainForm(this);
     }
 
@@ -58,26 +58,4 @@
         } else
           this.Text = value;
-      }
-    }
-
-    public string StatusStripText {
-      get { return this.toolStripStatusLabel.Text; }
-      set {
-        if (InvokeRequired) {
-          Action<string> action = delegate(string s) { this.StatusStripText = s; };
-          Invoke(action, value);
-        } else
-          this.toolStripStatusLabel.Text = value;
-      }
-    }
-
-    public bool StatusStripProgressBarVisible {
-      get { return this.toolStripProgressBar.Visible; }
-      set {
-        if (InvokeRequired) {
-          Action<bool> action = delegate(bool b) { this.StatusStripProgressBarVisible = b; };
-          Invoke(action, value);
-        } else
-          this.toolStripProgressBar.Visible = value;
       }
     }
@@ -121,7 +99,7 @@
     }
 
-    private List<IToolStripItem> toolStripItems;
-    protected IEnumerable<IToolStripItem> ToolStripItems {
-      get { return this.toolStripItems; }
+    private List<IUserInterfaceItem> userInterfaceItems;
+    protected IEnumerable<IUserInterfaceItem> UserInterfaceItems {
+      get { return this.userInterfaceItems; }
     }
 
@@ -134,5 +112,5 @@
     }
 
-    public event EventHandler MainFormChanged;
+    public event EventHandler Changed;
     public void FireMainFormChanged() {
       OnMainFormChanged();
@@ -141,14 +119,13 @@
       if (InvokeRequired)
         Invoke((MethodInvoker)FireMainFormChanged);
-      else if (MainFormChanged != null)
-        MainFormChanged(this, new EventArgs());
+      else if (Changed != null)
+        Changed(this, new EventArgs());
     }
 
     public virtual void ShowView(IView view) {
       if (!views.Contains(view)) {
-        view.MainForm = this;
         views.Add(view);
-        ActiveView = view;
-      }
+      }
+      this.ActiveView = view;
     }
 
@@ -173,35 +150,32 @@
 
       object[] items = ds.GetInstances(userInterfaceItemType);
-      IEnumerable<IToolStripMenuItem> toolStripMenuItems =
+      IEnumerable<MenuItemBase> toolStripMenuItems =
         from mi in items
-        where mi is IToolStripMenuItem
-        orderby ((IToolStripMenuItem)mi).Position
-        select (IToolStripMenuItem)mi;
-      foreach (IToolStripMenuItem menuItem in toolStripMenuItems)
+        where mi is MenuItemBase
+        orderby ((MenuItemBase)mi).Position
+        select (MenuItemBase)mi;
+      foreach (MenuItemBase menuItem in toolStripMenuItems)
         AddToolStripMenuItem(menuItem);
 
       items = ds.GetInstances(userInterfaceItemType);
-      IEnumerable<IToolStripButtonItem> toolStripButtonItems =
+      IEnumerable<ToolBarItemBase> toolStripButtonItems =
         from bi in items
-        where bi is IToolStripButtonItem
-        orderby ((IToolStripButtonItem)bi).Position
-        select (IToolStripButtonItem)bi;
-      foreach (IToolStripButtonItem toolStripButtonItem in toolStripButtonItems)
+        where bi is ToolBarItemBase
+        orderby ((ToolBarItemBase)bi).Position
+        select (ToolBarItemBase)bi;
+      foreach (ToolBarItemBase toolStripButtonItem in toolStripButtonItems)
         AddToolStripButtonItem(toolStripButtonItem);
     }
 
-    private void AddToolStripMenuItem(IToolStripMenuItem menuItem) {
+    private void AddToolStripMenuItem(MenuItemBase menuItem) {
       ToolStripMenuItem item = new ToolStripMenuItem();
       SetToolStripItemProperties(item, menuItem);
+      menuItem.ToolStripItem = item;
       item.ShortcutKeys = menuItem.ShortCutKeys;
-
-      ToolStripDropDownItem parent = FindParent(menuItem, menuStrip.Items);
-      if (parent == null)
-        menuStrip.Items.Add(item);
-      else
-        parent.DropDownItems.Add(item);
-    }
-
-    private void AddToolStripButtonItem(IToolStripButtonItem buttonItem) {
+      item.DisplayStyle = menuItem.ToolStripItemDisplayStyle;
+      this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items);
+    }
+
+    private void AddToolStripButtonItem(ToolBarItemBase buttonItem) {
       ToolStripItem item;
       if (buttonItem.IsDropDownButton)
@@ -211,43 +185,38 @@
 
       SetToolStripItemProperties(item, buttonItem);
-      ToolStripDropDownItem parent = FindParent(buttonItem, toolStrip.Items);
-      if (parent == null)
-        toolStrip.Items.Add(item);
-      else
-        parent.DropDownItems.Add(item);
-    }
-
-    private ToolStripDropDownItem FindParent(IToolStripItem item, ToolStripItemCollection parentItems) {
-      if (String.IsNullOrEmpty(item.Structure))
-        return null;
-
+      item.DisplayStyle = buttonItem.ToolStripItemDisplayStyle;
+      buttonItem.ToolStripItem = item;
+      this.InsertItem(buttonItem.Structure, typeof(ToolStripDropDownButton), item, toolStrip.Items);
+    }
+
+    private void InsertItem(IEnumerable<string> structure, Type t,ToolStripItem item, ToolStripItemCollection parentItems) {
       ToolStripDropDownItem parent = null;
-      foreach (string structure in item.Structure.Split(item.StructureSeparator)) {
-        if (parentItems.ContainsKey(structure))
-          parent = (ToolStripDropDownItem)parentItems[structure];
-        else
-          throw new ArgumentException("Structure string for item " + item.Name +
-            " is invalid. Could not find " + structure + " in toolstrip!");
+      foreach (string s in structure) {
+        if (parentItems.ContainsKey(s))
+          parent = (ToolStripDropDownItem)parentItems[s];
+        else {
+          parent = (ToolStripDropDownItem)Activator.CreateInstance(t, s,null,null,s); ;
+          parentItems.Add(parent);
+        }
         parentItems = parent.DropDownItems;
       }
-      return parent;
-    }
-
-    private void SetToolStripItemProperties(ToolStripItem toolStripItem, IToolStripItem iToolStripItem) {
-      toolStripItem.Text = iToolStripItem.Name;
-      toolStripItem.Name = iToolStripItem.Name;
-      toolStripItem.Tag = iToolStripItem;
-      toolStripItem.Image = iToolStripItem.Image;
-      toolStripItem.DisplayStyle = iToolStripItem.DisplayStyle;
-      this.ActiveViewChanged += new EventHandler(iToolStripItem.ActiveViewChanged);
-      this.MainFormChanged += new EventHandler(iToolStripItem.MainFormChanged);
+      parentItems.Add(item);
+    }
+
+    private void SetToolStripItemProperties(ToolStripItem toolStripItem, IUserInterfaceItem userInterfaceItem) {
+      toolStripItem.Name = userInterfaceItem.Name;
+      toolStripItem.Text = userInterfaceItem.Name;
+      toolStripItem.ToolTipText = userInterfaceItem.ToolTipText;
+      toolStripItem.Tag = userInterfaceItem;
+      toolStripItem.Image = userInterfaceItem.Image;
+      this.ActiveViewChanged += new EventHandler(userInterfaceItem.ActiveViewChanged);
+      this.Changed += new EventHandler(userInterfaceItem.MainFormChanged);
       toolStripItem.Click += new EventHandler(ToolStripItemClicked);
-      this.toolStripItems.Add(iToolStripItem);
-      iToolStripItem.ToolStripItem = toolStripItem;
+      this.userInterfaceItems.Add(userInterfaceItem);
     }
 
     private void ToolStripItemClicked(object sender, EventArgs e) {
       System.Windows.Forms.ToolStripItem item = (System.Windows.Forms.ToolStripItem)sender;
-      ((IAction)item.Tag).Execute(this);
+      ((IUserInterfaceItem)item.Tag).Execute();
     }
     #endregion
