- Timestamp:
- 10/13/09 10:58:31 (15 years ago)
- Location:
- branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms
- Files:
-
- 8 added
- 21 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/DockForm.Designer.cs
r2420 r2426 20 20 #endregion 21 21 22 namespace HeuristicLab.MainForm {22 namespace HeuristicLab.MainForm.WindowsForms { 23 23 partial class DockForm { 24 24 /// <summary> -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/DockForm.cs
r2420 r2426 29 29 using WeifenLuo.WinFormsUI.Docking; 30 30 31 namespace HeuristicLab.MainForm {31 namespace HeuristicLab.MainForm.WindowsForms { 32 32 /// <summary> 33 33 /// Displays the used view. -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/DockingMainForm.Designer.cs
r2420 r2426 1 namespace HeuristicLab.MainForm {1 namespace HeuristicLab.MainForm.WindowsForms { 2 2 partial class DockingMainForm { 3 3 /// <summary> -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/DockingMainForm.cs
r2420 r2426 30 30 using WeifenLuo.WinFormsUI.Docking; 31 31 32 namespace HeuristicLab.MainForm {32 namespace HeuristicLab.MainForm.WindowsForms { 33 33 public partial class DockingMainForm : MainFormBase { 34 34 public DockingMainForm() … … 53 53 DockContent dockForm = new DockForm(view); 54 54 dockForm.Activated += new EventHandler(DockFormActivated); 55 dockForm.FormClosing += new FormClosingEventHandler(view.FormClosing); 55 dockForm.FormClosing += new FormClosingEventHandler(view.OnClosing); 56 dockForm.FormClosed += new FormClosedEventHandler(view.OnClosed); 56 57 dockForm.FormClosed += new FormClosedEventHandler(DockFormClosed); 57 foreach (I ToolStripItem item in ToolStripItems)58 view. StateChanged += new EventHandler(item.ViewChanged);58 foreach (IUserInterfaceItem item in UserInterfaceItems) 59 view.Changed += new EventHandler(item.ViewChanged); 59 60 dockForm.Show(dockPanel); 60 61 } … … 75 76 ViewClosed(dockForm.View); 76 77 dockForm.Activated -= new EventHandler(DockFormActivated); 77 dockForm.FormClosing -= new FormClosingEventHandler(dockForm.View.FormClosing); 78 dockForm.FormClosing -= new FormClosingEventHandler(dockForm.View.OnClosing); 79 dockForm.FormClosed -= new FormClosedEventHandler(dockForm.View.OnClosed); 78 80 dockForm.FormClosed -= new FormClosedEventHandler(DockFormClosed); 79 foreach (I ToolStripItem item in ToolStripItems)80 dockForm.View. StateChanged -= new EventHandler(item.ViewChanged);81 foreach (IUserInterfaceItem item in UserInterfaceItems) 82 dockForm.View.Changed -= new EventHandler(item.ViewChanged); 81 83 } 82 84 -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/DocumentForm.Designer.cs
r2420 r2426 20 20 #endregion 21 21 22 namespace HeuristicLab.MainForm {22 namespace HeuristicLab.MainForm.WindowsForms { 23 23 partial class DocumentForm { 24 24 /// <summary> -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/DocumentForm.cs
r2420 r2426 28 28 using System.Windows.Forms; 29 29 30 namespace HeuristicLab.MainForm {30 namespace HeuristicLab.MainForm.WindowsForms { 31 31 public partial class DocumentForm : Form { 32 32 private IView myView; -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/HeuristicLabMainFormWindowsFormsPlugin.cs
r2420 r2426 25 25 using HeuristicLab.PluginInfrastructure; 26 26 27 namespace HeuristicLab.M odeling.Database{28 [ClassInfo(Name = "HeuristicLab.MainForm. Test-3.2")]29 [PluginFile(Filename = "HeuristicLab.MainForm. Test-3.2.dll", Filetype = PluginFileType.Assembly)]27 namespace HeuristicLab.MainForm.WindowsForms { 28 [ClassInfo(Name = "HeuristicLab.MainForm.WindowsForms-3.2")] 29 [PluginFile(Filename = "HeuristicLab.MainForm.WindowsForms-3.2.dll", Filetype = PluginFileType.Assembly)] 30 30 [Dependency(Dependency = "HeuristicLab.MainForm-3.2")] 31 [Dependency(Dependency = "HeuristicLab.Common.Resources-3.2")]32 31 public class HeuristicLabMainFormTestPlugin : PluginBase { 33 32 } -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.Designer.cs
r2420 r2426 1 namespace HeuristicLab.MainForm {1 namespace HeuristicLab.MainForm.WindowsForms { 2 2 partial class MainFormBase { 3 3 /// <summary> … … 28 28 this.toolStrip = new System.Windows.Forms.ToolStrip(); 29 29 this.statusStrip = new System.Windows.Forms.StatusStrip(); 30 this.toolStripProgressBar = new System.Windows.Forms.ToolStripProgressBar();31 this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel();32 30 this.statusStrip.SuspendLayout(); 33 31 this.SuspendLayout(); … … 50 48 // statusStrip 51 49 // 52 this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {53 this.toolStripProgressBar,54 this.toolStripStatusLabel});55 50 this.statusStrip.Location = new System.Drawing.Point(0, 390); 56 51 this.statusStrip.Name = "statusStrip"; … … 58 53 this.statusStrip.TabIndex = 2; 59 54 this.statusStrip.Text = "statusStrip"; 60 //61 // toolStripProgressBar62 //63 this.toolStripProgressBar.Name = "toolStripProgressBar";64 this.toolStripProgressBar.Size = new System.Drawing.Size(100, 16);65 this.toolStripProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Marquee;66 this.toolStripProgressBar.Visible = false;67 //68 // toolStripStatusLabel69 //70 this.toolStripStatusLabel.Name = "toolStripStatusLabel";71 this.toolStripStatusLabel.Size = new System.Drawing.Size(112, 17);72 this.toolStripStatusLabel.Text = "toolStripStatusLabel";73 55 // 74 56 // MainFormBase … … 92 74 #endregion 93 75 94 pr ivateSystem.Windows.Forms.ToolStrip toolStrip;95 pr ivateSystem.Windows.Forms.StatusStrip statusStrip;76 protected System.Windows.Forms.ToolStrip toolStrip; 77 protected System.Windows.Forms.StatusStrip statusStrip; 96 78 protected System.Windows.Forms.MenuStrip menuStrip; 97 private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar;98 private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel;99 79 } 100 80 } -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs
r2420 r2426 31 31 using HeuristicLab.PluginInfrastructure; 32 32 33 namespace HeuristicLab.MainForm {33 namespace HeuristicLab.MainForm.WindowsForms { 34 34 public partial class MainFormBase : Form, IMainForm { 35 35 protected MainFormBase() 36 36 : base() { 37 37 InitializeComponent(); 38 views = new List<IView>();39 t oolStripItems = new List<IToolStripItem>();40 this.StatusStripText = "";38 this.views = new List<IView>(); 39 this.userInterfaceItems = new List<IUserInterfaceItem>(); 40 MainFormManager.RegisterMainForm(this); 41 41 } 42 42 … … 58 58 } else 59 59 this.Text = value; 60 }61 }62 63 public string StatusStripText {64 get { return this.toolStripStatusLabel.Text; }65 set {66 if (InvokeRequired) {67 Action<string> action = delegate(string s) { this.StatusStripText = s; };68 Invoke(action, value);69 } else70 this.toolStripStatusLabel.Text = value;71 }72 }73 74 public bool StatusStripProgressBarVisible {75 get { return this.toolStripProgressBar.Visible; }76 set {77 if (InvokeRequired) {78 Action<bool> action = delegate(bool b) { this.StatusStripProgressBarVisible = b; };79 Invoke(action, value);80 } else81 this.toolStripProgressBar.Visible = value;82 60 } 83 61 } … … 121 99 } 122 100 123 private List<I ToolStripItem> toolStripItems;124 protected IEnumerable<I ToolStripItem> ToolStripItems {125 get { return this. toolStripItems; }101 private List<IUserInterfaceItem> userInterfaceItems; 102 protected IEnumerable<IUserInterfaceItem> UserInterfaceItems { 103 get { return this.userInterfaceItems; } 126 104 } 127 105 … … 134 112 } 135 113 136 public event EventHandler MainFormChanged;114 public event EventHandler Changed; 137 115 public void FireMainFormChanged() { 138 116 OnMainFormChanged(); … … 141 119 if (InvokeRequired) 142 120 Invoke((MethodInvoker)FireMainFormChanged); 143 else if ( MainFormChanged != null)144 MainFormChanged(this, new EventArgs());121 else if (Changed != null) 122 Changed(this, new EventArgs()); 145 123 } 146 124 147 125 public virtual void ShowView(IView view) { 148 126 if (!views.Contains(view)) { 149 view.MainForm = this;150 127 views.Add(view); 151 ActiveView = view;152 }128 } 129 this.ActiveView = view; 153 130 } 154 131 … … 173 150 174 151 object[] items = ds.GetInstances(userInterfaceItemType); 175 IEnumerable< IToolStripMenuItem> toolStripMenuItems =152 IEnumerable<MenuItemBase> toolStripMenuItems = 176 153 from mi in items 177 where mi is IToolStripMenuItem178 orderby (( IToolStripMenuItem)mi).Position179 select ( IToolStripMenuItem)mi;180 foreach ( IToolStripMenuItemmenuItem in toolStripMenuItems)154 where mi is MenuItemBase 155 orderby ((MenuItemBase)mi).Position 156 select (MenuItemBase)mi; 157 foreach (MenuItemBase menuItem in toolStripMenuItems) 181 158 AddToolStripMenuItem(menuItem); 182 159 183 160 items = ds.GetInstances(userInterfaceItemType); 184 IEnumerable< IToolStripButtonItem> toolStripButtonItems =161 IEnumerable<ToolBarItemBase> toolStripButtonItems = 185 162 from bi in items 186 where bi is IToolStripButtonItem187 orderby (( IToolStripButtonItem)bi).Position188 select ( IToolStripButtonItem)bi;189 foreach ( IToolStripButtonItemtoolStripButtonItem in toolStripButtonItems)163 where bi is ToolBarItemBase 164 orderby ((ToolBarItemBase)bi).Position 165 select (ToolBarItemBase)bi; 166 foreach (ToolBarItemBase toolStripButtonItem in toolStripButtonItems) 190 167 AddToolStripButtonItem(toolStripButtonItem); 191 168 } 192 169 193 private void AddToolStripMenuItem( IToolStripMenuItemmenuItem) {170 private void AddToolStripMenuItem(MenuItemBase menuItem) { 194 171 ToolStripMenuItem item = new ToolStripMenuItem(); 195 172 SetToolStripItemProperties(item, menuItem); 173 menuItem.ToolStripItem = item; 196 174 item.ShortcutKeys = menuItem.ShortCutKeys; 197 198 ToolStripDropDownItem parent = FindParent(menuItem, menuStrip.Items); 199 if (parent == null) 200 menuStrip.Items.Add(item); 201 else 202 parent.DropDownItems.Add(item); 203 } 204 205 private void AddToolStripButtonItem(IToolStripButtonItem buttonItem) { 175 item.DisplayStyle = menuItem.ToolStripItemDisplayStyle; 176 this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items); 177 } 178 179 private void AddToolStripButtonItem(ToolBarItemBase buttonItem) { 206 180 ToolStripItem item; 207 181 if (buttonItem.IsDropDownButton) … … 211 185 212 186 SetToolStripItemProperties(item, buttonItem); 213 ToolStripDropDownItem parent = FindParent(buttonItem, toolStrip.Items); 214 if (parent == null) 215 toolStrip.Items.Add(item); 216 else 217 parent.DropDownItems.Add(item); 218 } 219 220 private ToolStripDropDownItem FindParent(IToolStripItem item, ToolStripItemCollection parentItems) { 221 if (String.IsNullOrEmpty(item.Structure)) 222 return null; 223 187 item.DisplayStyle = buttonItem.ToolStripItemDisplayStyle; 188 buttonItem.ToolStripItem = item; 189 this.InsertItem(buttonItem.Structure, typeof(ToolStripDropDownButton), item, toolStrip.Items); 190 } 191 192 private void InsertItem(IEnumerable<string> structure, Type t,ToolStripItem item, ToolStripItemCollection parentItems) { 224 193 ToolStripDropDownItem parent = null; 225 foreach (string structure in item.Structure.Split(item.StructureSeparator)) { 226 if (parentItems.ContainsKey(structure)) 227 parent = (ToolStripDropDownItem)parentItems[structure]; 228 else 229 throw new ArgumentException("Structure string for item " + item.Name + 230 " is invalid. Could not find " + structure + " in toolstrip!"); 194 foreach (string s in structure) { 195 if (parentItems.ContainsKey(s)) 196 parent = (ToolStripDropDownItem)parentItems[s]; 197 else { 198 parent = (ToolStripDropDownItem)Activator.CreateInstance(t, s,null,null,s); ; 199 parentItems.Add(parent); 200 } 231 201 parentItems = parent.DropDownItems; 232 202 } 233 return parent;234 } 235 236 private void SetToolStripItemProperties(ToolStripItem toolStripItem, I ToolStripItem iToolStripItem) {237 toolStripItem. Text = iToolStripItem.Name;238 toolStripItem. Name = iToolStripItem.Name;239 toolStripItem.T ag = iToolStripItem;240 toolStripItem. Image = iToolStripItem.Image;241 toolStripItem. DisplayStyle = iToolStripItem.DisplayStyle;242 this.ActiveViewChanged += new EventHandler( iToolStripItem.ActiveViewChanged);243 this. MainFormChanged += new EventHandler(iToolStripItem.MainFormChanged);203 parentItems.Add(item); 204 } 205 206 private void SetToolStripItemProperties(ToolStripItem toolStripItem, IUserInterfaceItem userInterfaceItem) { 207 toolStripItem.Name = userInterfaceItem.Name; 208 toolStripItem.Text = userInterfaceItem.Name; 209 toolStripItem.ToolTipText = userInterfaceItem.ToolTipText; 210 toolStripItem.Tag = userInterfaceItem; 211 toolStripItem.Image = userInterfaceItem.Image; 212 this.ActiveViewChanged += new EventHandler(userInterfaceItem.ActiveViewChanged); 213 this.Changed += new EventHandler(userInterfaceItem.MainFormChanged); 244 214 toolStripItem.Click += new EventHandler(ToolStripItemClicked); 245 this.toolStripItems.Add(iToolStripItem); 246 iToolStripItem.ToolStripItem = toolStripItem; 215 this.userInterfaceItems.Add(userInterfaceItem); 247 216 } 248 217 249 218 private void ToolStripItemClicked(object sender, EventArgs e) { 250 219 System.Windows.Forms.ToolStripItem item = (System.Windows.Forms.ToolStripItem)sender; 251 ((I Action)item.Tag).Execute(this);220 ((IUserInterfaceItem)item.Tag).Execute(); 252 221 } 253 222 #endregion -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MultipleDocumentMainForm.Designer.cs
r2420 r2426 1 namespace HeuristicLab.MainForm {1 namespace HeuristicLab.MainForm.WindowsForms { 2 2 partial class MultipleDocumentMainForm { 3 3 /// <summary> … … 36 36 this.ResumeLayout(false); 37 37 this.PerformLayout(); 38 39 38 } 40 41 39 #endregion 42 40 } -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/MultipleDocumentMainForm.cs
r2420 r2426 29 29 using System.Windows.Forms; 30 30 31 namespace HeuristicLab.MainForm {31 namespace HeuristicLab.MainForm.WindowsForms { 32 32 public partial class MultipleDocumentMainForm : MainFormBase { 33 33 public MultipleDocumentMainForm() … … 59 59 DocumentForm form = new DocumentForm(view); 60 60 form.Activated += new EventHandler(MultipleDocumentFormActivated); 61 form.FormClosing += new FormClosingEventHandler(view.FormClosing); 61 form.FormClosing += new FormClosingEventHandler(view.OnClosing); 62 form.FormClosed += new FormClosedEventHandler(view.OnClosed); 62 63 form.FormClosed += new FormClosedEventHandler(MultipleDocumentFormClosed); 63 64 form.MdiParent = this; 64 foreach (I ToolStripItem item in ToolStripItems)65 view. StateChanged += new EventHandler(item.ViewChanged);65 foreach (IUserInterfaceItem item in UserInterfaceItems) 66 view.Changed += new EventHandler(item.ViewChanged); 66 67 form.Show(); 67 68 } … … 86 87 ViewClosed(form.View); 87 88 form.Activated -= new EventHandler(MultipleDocumentFormActivated); 88 form.FormClosing -= new FormClosingEventHandler(form.View.FormClosing); 89 form.FormClosing -= new FormClosingEventHandler(form.View.OnClosing); 90 form.FormClosed -= new FormClosedEventHandler(form.View.OnClosed); 89 91 form.FormClosed -= new FormClosedEventHandler(MultipleDocumentFormClosed); 90 foreach (I ToolStripItem item in ToolStripItems)91 form.View. StateChanged -= new EventHandler(item.ViewChanged);92 foreach (IUserInterfaceItem item in UserInterfaceItems) 93 form.View.Changed -= new EventHandler(item.ViewChanged); 92 94 } 93 95 -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/SingleDocumentMainForm.Designer.cs
r2420 r2426 1 namespace HeuristicLab.MainForm {1 namespace HeuristicLab.MainForm.WindowsForms { 2 2 partial class SingleDocumentMainForm { 3 3 /// <summary> -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/SingleDocumentMainForm.cs
r2420 r2426 30 30 using WeifenLuo.WinFormsUI.Docking; 31 31 32 namespace HeuristicLab.MainForm {32 namespace HeuristicLab.MainForm.WindowsForms { 33 33 public partial class SingleDocumentMainForm : MainFormBase { 34 34 public SingleDocumentMainForm() … … 54 54 form.ShowInTaskbar = true; 55 55 form.Activated += new EventHandler(DocumentFormActivated); 56 form.FormClosing += new FormClosingEventHandler(view.FormClosing); 56 form.FormClosing += new FormClosingEventHandler(view.OnClosing); 57 form.FormClosed += new FormClosedEventHandler(view.OnClosed); 57 58 form.FormClosed += new FormClosedEventHandler(DocumentFormClosed); 58 foreach (I ToolStripItem item in ToolStripItems)59 view. StateChanged += new EventHandler(item.ViewChanged);59 foreach (IUserInterfaceItem item in UserInterfaceItems) 60 view.Changed += new EventHandler(item.ViewChanged); 60 61 form.Show(this); 61 62 } … … 76 77 ViewClosed(form.View); 77 78 form.Activated -= new EventHandler(DocumentFormActivated); 78 form.FormClosing -= new FormClosingEventHandler(form.View.FormClosing); 79 form.FormClosing -= new FormClosingEventHandler(form.View.OnClosing); 80 form.FormClosed -= new FormClosedEventHandler(form.View.OnClosed); 79 81 form.FormClosed -= new FormClosedEventHandler(DocumentFormClosed); 80 foreach (I ToolStripItem item in ToolStripItems)81 form.View. StateChanged -= new EventHandler(item.ViewChanged);82 foreach (IUserInterfaceItem item in UserInterfaceItems) 83 form.View.Changed -= new EventHandler(item.ViewChanged); 82 84 } 83 85 -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/ViewBase.Designer.cs
r2420 r2426 22 22 using System; 23 23 24 namespace HeuristicLab.MainForm {24 namespace HeuristicLab.MainForm.WindowsForms { 25 25 partial class ViewBase { 26 26 /// <summary> -
branches/Mainform refactoring/HeuristicLab.MainForm.WindowsForms/3.2/ViewBase.cs
r2420 r2426 29 29 using System.Windows.Forms; 30 30 31 namespace HeuristicLab.MainForm {31 namespace HeuristicLab.MainForm.WindowsForms { 32 32 public partial class ViewBase : UserControl,IView { 33 33 public ViewBase() { 34 34 InitializeComponent(); 35 }36 37 public ViewBase(IMainForm mainForm)38 : this() {39 this.mainForm = mainForm;40 35 } 41 36 … … 57 52 } 58 53 59 public event EventHandler StateChanged;60 protected virtual void On StateChanged() {61 if ( StateChanged != null)62 StateChanged(this, new EventArgs());54 public event EventHandler Changed; 55 protected virtual void OnChanged() { 56 if (Changed != null) 57 Changed(this, new EventArgs()); 63 58 } 64 59 65 private IMainForm mainForm; 66 public IMainForm MainForm { 67 get { return this.mainForm; } 68 set { this.mainForm = value; } 60 public virtual void OnClosing(object sender, CancelEventArgs e) { 69 61 } 70 62 71 public virtual void FormClosing(object sender, FormClosingEventArgs e) {63 public virtual void OnClosed(object sender, EventArgs e) { 72 64 } 73 65 }
Note: See TracChangeset
for help on using the changeset viewer.