Changeset 2254
- Timestamp:
- 08/07/09 11:27:34 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.Test/3.2/ButtonItems/SaveToolStripButtonItem.cs
r2249 r2254 21 21 new SaveAction().Execute(mainform); 22 22 } 23 24 public override bool ListenActiveViewChanged { 25 get { return true; } 26 } 27 28 public override void ActiveViewChanged(object sender, EventArgs e) { 29 IMainForm mainform = (IMainForm)sender; 30 if (mainform.ActiveView == null) 31 this.ToolStripItem.Enabled = false; 32 else 33 this.ToolStripItem.Enabled = !(mainform.ActiveView is FormView); 34 } 35 36 public override bool ListenViewStateChanged { 37 get { return true; } 38 } 39 40 public override void ViewStateChanged(object sender, EventArgs e) { 41 this.ToolStripItem.Enabled = !this.ToolStripItem.Enabled; 42 } 23 43 } 24 44 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/EditorView.Designer.cs
r2250 r2254 25 25 private void InitializeComponent() { 26 26 this.label1 = new System.Windows.Forms.Label(); 27 this.ChangeStateButton = new System.Windows.Forms.Button(); 27 28 this.SuspendLayout(); 28 29 // … … 37 38 this.label1.Text = "EditorForm"; 38 39 // 40 // ChangeStateButton 41 // 42 this.ChangeStateButton.Location = new System.Drawing.Point(34, 100); 43 this.ChangeStateButton.Name = "ChangeStateButton"; 44 this.ChangeStateButton.Size = new System.Drawing.Size(75, 23); 45 this.ChangeStateButton.TabIndex = 1; 46 this.ChangeStateButton.Text = "ChangeState"; 47 this.ChangeStateButton.UseVisualStyleBackColor = true; 48 this.ChangeStateButton.Click += new System.EventHandler(this.ChangeStateButton_Click); 49 // 39 50 // EditorView 40 51 // 41 52 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 42 53 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 54 this.Controls.Add(this.ChangeStateButton); 43 55 this.Controls.Add(this.label1); 44 56 this.ForeColor = System.Drawing.SystemColors.ControlText; … … 52 64 53 65 private System.Windows.Forms.Label label1; 66 private System.Windows.Forms.Button ChangeStateButton; 54 67 } 55 68 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/EditorView.cs
r2250 r2254 17 17 : base(mainform) { 18 18 } 19 20 private void ChangeStateButton_Click(object sender, EventArgs e) { 21 this.OnStateChanged(); 22 } 19 23 } 20 24 } -
trunk/sources/HeuristicLab.MainForm.Test/3.2/MenuItems/ExitToolStripMenuItem.cs
r2250 r2254 23 23 24 24 public override void Execute(IMainForm mainform) { 25 mainform.Close ();25 mainform.CloseForm(); 26 26 } 27 27 } -
trunk/sources/HeuristicLab.MainForm/3.2/DockingMainForm.cs
r2253 r2254 44 44 private DockPanel dockPanel; 45 45 46 public override void ShowView(IView view) { 47 46 public override void ShowView(IView view) { 48 47 if (InvokeRequired) Invoke((Action<IView>)ShowView, view); 49 48 else { … … 52 51 content.Activated += new EventHandler(DockFormActivated); 53 52 content.FormClosing += new FormClosingEventHandler(DockFormClosing); 53 foreach (IToolStripItem item in viewStateChangeToolStripItems) 54 view.StateChanged += new EventHandler(item.ViewStateChanged); 54 55 content.Show(dockPanel); 55 56 } … … 60 61 openViews.Remove(dockForm.View); 61 62 if (openViews.Count == 0) 62 activeView = null;63 ActiveView = null; 63 64 dockForm.Activated -= new EventHandler(DockFormActivated); 64 65 dockForm.FormClosing -= new FormClosingEventHandler(DockFormClosing); 66 foreach (IToolStripItem item in viewStateChangeToolStripItems) 67 dockForm.View.StateChanged -= new EventHandler(item.ViewStateChanged); 65 68 } 66 69 67 70 private void DockFormActivated(object sender, EventArgs e) { 68 base. activeView = ((DockForm)sender).View;71 base.ActiveView = ((DockForm)sender).View; 69 72 base.StatusStripText = ((DockForm)sender).View.Caption; 70 73 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IMainForm.cs
r2250 r2254 33 33 34 34 IView ActiveView { get; } 35 event EventHandler ActiveViewChanged; 35 36 IEnumerable<IView> OpenViews { get; } 36 37 37 38 Type UserInterfaceItemType { get; } 38 39 void ShowView(IView view); 39 40 void Close(); 40 void CloseForm(); 41 41 } 42 42 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IToolStripItem.cs
r2249 r2254 37 37 38 38 ToolStripItem ToolStripItem { get; set; } 39 40 bool ListenActiveViewChanged { get; } 41 bool ListenViewStateChanged { get; } 42 void ActiveViewChanged(object sender, EventArgs e); 43 void ViewStateChanged(object sender, EventArgs e); 39 44 } 40 45 } -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IView.cs
r2233 r2254 28 28 string Caption { get; set; } 29 29 event EventHandler CaptionChanged; 30 event EventHandler StateChanged; 30 31 IMainForm MainForm { get; set; } 31 32 } -
trunk/sources/HeuristicLab.MainForm/3.2/MainFormBase.cs
r2250 r2254 37 37 InitializeComponent(); 38 38 openViews = new List<IView>(); 39 viewStateChangeToolStripItems = new List<IToolStripItem>(); 39 40 this.userInterfaceItemType = userInterfaceItemType; 40 41 CreateGUI(); 42 OnActiveViewChanged(); 41 43 } 42 44 … … 57 59 } 58 60 59 pr otectedIView activeView;61 private IView activeView; 60 62 public IView ActiveView { 61 63 get { return this.activeView; } 64 protected set { 65 if (this.activeView != value) { 66 this.activeView = value; 67 OnActiveViewChanged(); 68 } 69 } 70 } 71 72 protected List<IToolStripItem> viewStateChangeToolStripItems; 73 74 public event EventHandler ActiveViewChanged; 75 protected virtual void OnActiveViewChanged() { 76 if(ActiveViewChanged != null) 77 ActiveViewChanged(this,new EventArgs()); 62 78 } 63 79 … … 68 84 69 85 public virtual void ShowView(IView view) { 70 view.MainForm = this; 71 activeView = view; 86 view.MainForm = this; 72 87 openViews.Add(view); 88 ActiveView = view; 73 89 } 74 90 75 public void Close () {76 ((Form)this).Close();91 public void CloseForm() { 92 this.Close(); 77 93 } 78 94 #endregion … … 94 110 foreach (IToolStripButtonItem toolStripButtonItem in toolStripItems) { 95 111 AddToolStripButtonItem(toolStripButtonItem); 96 } 112 } 97 113 } 98 114 … … 117 133 118 134 SetToolStripItemProperties(item, buttonItem); 119 ToolStripDropDownItem parent = FindParent(buttonItem, toolStrip.Items);135 ToolStripDropDownItem parent = FindParent(buttonItem, toolStrip.Items); 120 136 if (parent == null) 121 137 toolStrip.Items.Add(item); … … 142 158 toolStripItem.Image = iToolStripItem.Image; 143 159 toolStripItem.DisplayStyle = iToolStripItem.DisplayStyle; 160 if (iToolStripItem.ListenActiveViewChanged) 161 this.ActiveViewChanged += new EventHandler(iToolStripItem.ActiveViewChanged); 162 if (iToolStripItem.ListenViewStateChanged) 163 this.viewStateChangeToolStripItems.Add(iToolStripItem); 144 164 toolStripItem.Click += new EventHandler(ToolStripItemClicked); 145 165 iToolStripItem.ToolStripItem = toolStripItem; -
trunk/sources/HeuristicLab.MainForm/3.2/MultipleDocumentMainForm.Designer.cs
r2253 r2254 34 34 this.Name = "MultipleDocumentMainForm"; 35 35 this.ResumeLayout(false); 36 37 36 } 38 37 -
trunk/sources/HeuristicLab.MainForm/3.2/MultipleDocumentMainForm.cs
r2253 r2254 29 29 30 30 private void MultipleDocumentFormActivated(object sender, EventArgs e) { 31 base. activeView = ((MultipleDocumentForm)sender).View;31 base.ActiveView = ((MultipleDocumentForm)sender).View; 32 32 base.StatusStripText = ((MultipleDocumentForm)sender).View.Caption; 33 33 } … … 37 37 openViews.Remove(form.View); 38 38 if (openViews.Count == 0) 39 activeView = null;39 ActiveView = null; 40 40 form.Activated -= new EventHandler(MultipleDocumentFormActivated); 41 41 form.FormClosing -= new FormClosingEventHandler(MultipleDocumentFormClosing); -
trunk/sources/HeuristicLab.MainForm/3.2/ToolStripItemBase.cs
r2249 r2254 55 55 get { return ToolStripMenuItemBase.structureSeparator; } 56 56 } 57 58 public virtual bool ListenActiveViewChanged { 59 get { return false; } 60 } 61 public virtual bool ListenViewStateChanged { 62 get { return false; } 63 } 64 65 public virtual void ActiveViewChanged(object sender, EventArgs e) { 66 } 67 68 public virtual void ViewStateChanged(object sender, EventArgs e) { 69 } 57 70 #endregion 58 71 } -
trunk/sources/HeuristicLab.MainForm/3.2/ViewBase.cs
r2250 r2254 57 57 } 58 58 59 public event EventHandler StateChanged; 60 protected virtual void OnStateChanged() { 61 if (StateChanged != null) 62 StateChanged(this, new EventArgs()); 63 } 64 59 65 private IMainForm mainForm; 60 66 public IMainForm MainForm { … … 62 68 set { this.mainForm = value; } 63 69 } 64 65 70 } 66 71 }
Note: See TracChangeset
for help on using the changeset viewer.