Changeset 2548
- Timestamp:
- 12/10/09 10:11:28 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/DockingMainForm.cs
r2458 r2548 42 42 } 43 43 44 p ublic override bool ShowView(IView view) {45 if (InvokeRequired) return (bool)Invoke((Func<IView, bool>)ShowView, view);44 protected override void Show(IView view, bool firstTimeShown) { 45 if (InvokeRequired) Invoke((Action<IView, bool>)Show, view, firstTimeShown); 46 46 else { 47 b ool ret = base.ShowView(view);48 if ( ret)47 base.Show(view, firstTimeShown); 48 if (firstTimeShown) 49 49 ((DockForm)GetForm(view)).Show(dockPanel); 50 50 else 51 51 ((DockForm)GetForm(view)).Activate(); 52 return ret;53 52 } 54 53 } 55 public override void HideView(IView view) { 54 55 protected override void Hide(IView view) { 56 56 if (InvokeRequired) Invoke((Action<IView>)HideView, view); 57 57 else { 58 58 Form form = base.GetForm(view); 59 if (form != null) 59 if (form != null) { 60 60 ((DockForm)form).Hide(); 61 } 61 62 } 62 63 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs
r2544 r2548 130 130 } 131 131 132 public event EventHandler<ViewEventArgs> ViewClosed; 133 protected virtual void OnViewClosed(IView view) { 134 if (InvokeRequired) Invoke((Action<IView>)OnViewClosed, view); 135 else if (this.ViewClosed != null) { 136 this.ViewClosed(this, new ViewEventArgs(view)); 137 } 138 } 139 140 public event EventHandler<ViewShownEventArgs> ViewShown; 141 protected virtual void OnViewShown(IView view, bool firstTimeShown) { 142 if (InvokeRequired) Invoke((Action<IView, bool>)OnViewShown, view, firstTimeShown); 143 else if (this.ViewShown != null) { 144 this.ViewShown(this, new ViewShownEventArgs(view, firstTimeShown)); 145 } 146 } 147 148 public event EventHandler<ViewEventArgs> ViewHidden; 149 protected virtual void OnViewHidden(IView view) { 150 if (InvokeRequired) Invoke((Action<IView>)OnViewHidden, view); 151 else if (this.ViewHidden != null) { 152 this.ViewHidden(this, new ViewEventArgs(view)); 153 } 154 } 155 132 156 public event EventHandler Changed; 133 157 public void FireMainFormChanged() { … … 145 169 } 146 170 147 public v irtual boolShowView(IView view) {148 if (InvokeRequired) return (bool)Invoke((Func<IView, bool>)ShowView, view);171 public void ShowView(IView view) { 172 if (InvokeRequired) Invoke((Action<IView>)ShowView, view); 149 173 else { 150 174 if (!views.Keys.Contains(view)) { … … 159 183 foreach (IUserInterfaceItem item in UserInterfaceItems) 160 184 view.Changed += new EventHandler(item.ViewChanged); 161 return true; 162 } else 163 return false; 164 } 165 } 166 167 public virtual void HideView(IView view) { 185 this.Show(view, true); 186 this.OnViewShown(view, true); 187 } else { 188 this.Show(view, false); 189 this.OnViewShown(view, false); 190 } 191 } 192 } 193 194 protected virtual void Show(IView view, bool firstTimeShown) { 195 } 196 197 public void HideView(IView view) { 168 198 if (InvokeRequired) Invoke((Action<IView>)HideView, view); 169 199 else { 170 if (views.ContainsKey(view)) 171 views[view].Hide(); 172 } 200 if (this.views.ContainsKey(view)) { 201 this.Hide(view); 202 this.OnViewHidden(view); 203 } 204 } 205 } 206 207 protected virtual void Hide(IView view) { 173 208 } 174 209 … … 176 211 if (InvokeRequired) Invoke((Action<IView>)CloseView, view); 177 212 else { 178 if (views.ContainsKey(view)) 179 views[view].Close(); 213 if (this.views.ContainsKey(view)) { 214 this.views[view].Close(); 215 this.OnViewClosed(view); 216 } 180 217 } 181 218 } … … 184 221 if (InvokeRequired) Invoke((Action<IView>)CloseView, view); 185 222 else { 186 if ( views.ContainsKey(view)) {223 if (this.views.ContainsKey(view)) { 187 224 ((ViewBase)view).closeReason = closeReason; 188 views[view].Close();225 this.CloseView(view); 189 226 } 190 227 } … … 198 235 public virtual void CloseAllViews(CloseReason closeReason) { 199 236 foreach (IView view in views.Keys.ToArray()) 200 CloseView(view, closeReason);237 CloseView(view, closeReason); 201 238 } 202 239 #endregion … … 217 254 218 255 views.Remove(view); 256 this.OnViewClosed(view); 219 257 if (ActiveView == view) 220 258 ActiveView = null; -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MultipleDocumentMainForm.cs
r2458 r2548 48 48 } 49 49 50 p ublic override bool ShowView(IView view) {51 if (InvokeRequired) return (bool)Invoke((Func<IView, bool>)ShowView, view);50 protected override void Show(IView view, bool firstTimeShown) { 51 if (InvokeRequired) Invoke((Action<IView, bool>)Show, view, firstTimeShown); 52 52 else { 53 b ool ret = base.ShowView(view);54 if ( ret)55 GetForm(view).Show( );53 base.Show(view, firstTimeShown); 54 if (firstTimeShown) 55 GetForm(view).Show(this); 56 56 else { 57 57 GetForm(view).Visible = true; 58 58 GetForm(view).Activate(); 59 59 } 60 return ret; 60 } 61 } 62 63 protected override void Hide(IView view) { 64 if (InvokeRequired) Invoke((Action<IView>)Hide, view); 65 else { 66 base.Hide(view); 67 this.GetForm(view).Hide(); 61 68 } 62 69 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/SingleDocumentMainForm.cs
r2458 r2548 42 42 } 43 43 44 p ublic override bool ShowView(IView view) {45 if (InvokeRequired) return (bool)Invoke((Func<IView, bool>)ShowView, view);44 protected override void Show(IView view, bool firstTimeShown) { 45 if (InvokeRequired) Invoke((Action<IView, bool>)Show, view, firstTimeShown); 46 46 else { 47 b ool ret = base.ShowView(view);48 if ( ret)47 base.Show(view, firstTimeShown); 48 if (firstTimeShown) 49 49 GetForm(view).Show(this); 50 50 else { … … 52 52 GetForm(view).Activate(); 53 53 } 54 return ret; 54 } 55 } 56 57 protected override void Hide(IView view) { 58 if (InvokeRequired) Invoke((Action<IView>)Hide, view); 59 else { 60 base.Hide(view); 61 this.GetForm(view).Hide(); 55 62 } 56 63 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewBase.cs
r2543 r2548 42 42 get { return myCaption; } 43 43 set { 44 if (value != myCaption) { 45 myCaption = value; 46 OnCaptionChanged(); 44 if (InvokeRequired) { 45 Action<string> action = delegate(string s) { this.Caption = s; }; 46 Invoke(action, value); 47 } else { 48 if (value != myCaption) { 49 myCaption = value; 50 OnCaptionChanged(); 51 } 47 52 } 48 53 } … … 57 62 public event EventHandler Changed; 58 63 protected virtual void OnChanged() { 59 if (Changed != null) 64 if (InvokeRequired) 65 Invoke((MethodInvoker)OnChanged); 66 else if (Changed != null) 60 67 Changed(this, new EventArgs()); 61 68 } 62 69 63 public virtual void OnClosing(object sender, CancelEventArgs e) { 70 public virtual void OnClosing(object sender, CancelEventArgs e) { 64 71 } 65 72 … … 67 74 internal void OnClosingHelper(object sender, FormClosingEventArgs e) { 68 75 if (this.closeReason != CloseReason.None) 69 this.OnClosing(sender, new FormClosingEventArgs(this.closeReason, e.Cancel));76 this.OnClosing(sender, new FormClosingEventArgs(this.closeReason, e.Cancel)); 70 77 else 71 78 this.OnClosing(sender, e); 72 79 73 80 this.closeReason = CloseReason.None; 74 81 } 75 82 76 public virtual void OnClosing(object sender, FormClosingEventArgs e) { 83 public virtual void OnClosing(object sender, FormClosingEventArgs e) { 77 84 } 78 85 -
trunk/sources/HeuristicLab.MainForm/3.2/HeuristicLab.MainForm-3.2.csproj
r2514 r2548 81 81 </ItemGroup> 82 82 <ItemGroup> 83 <Compile Include="ViewShownEventArgs.cs" /> 84 <Compile Include="ViewEventArgs.cs" /> 83 85 <Compile Include="ToolBarSeparatorItemBase.cs" /> 84 86 <Compile Include="Interfaces\IToolBarSeparatorItem.cs" /> -
trunk/sources/HeuristicLab.MainForm/3.2/Interfaces/IMainForm.cs
r2458 r2548 31 31 32 32 IView ActiveView { get; } 33 IEnumerable<IView> Views { get; } 34 33 35 event EventHandler ActiveViewChanged; 34 36 event EventHandler Changed; 35 IEnumerable<IView> Views { get; } 37 38 event EventHandler<ViewEventArgs> ViewClosed; 39 event EventHandler<ViewShownEventArgs> ViewShown; 40 event EventHandler<ViewEventArgs> ViewHidden; 36 41 37 42 Type UserInterfaceItemType { get; } 38 bool ShowView(IView view); //return value indicates if a new form for the view is created43 void ShowView(IView view); 39 44 void HideView(IView view); 40 45 void CloseView(IView view);
Note: See TracChangeset
for help on using the changeset viewer.