Changeset 2696 for trunk/sources/HeuristicLab.MainForm.WindowsForms
- Timestamp:
- 01/28/10 16:15:21 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2
- Files:
-
- 2 added
- 7 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/DockForm.cs
r2458 r2696 33 33 /// Displays the used view. 34 34 /// </summary> 35 publicpartial class DockForm : DockContent {35 internal partial class DockForm : DockContent { 36 36 public DockForm(IView view) { 37 37 InitializeComponent(); -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/DockingMainForm.cs
r2636 r2696 31 31 32 32 namespace HeuristicLab.MainForm.WindowsForms { 33 public partial class DockingMainForm : MainForm Base{33 public partial class DockingMainForm : MainForm { 34 34 public DockingMainForm() 35 35 : base() { -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/DocumentForm.cs
r2458 r2696 29 29 30 30 namespace HeuristicLab.MainForm.WindowsForms { 31 publicpartial class DocumentForm : Form {31 internal partial class DocumentForm : Form { 32 32 private IView myView; 33 33 public IView View { -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/HeuristicLab.MainForm.WindowsForms-3.2.csproj
r2649 r2696 82 82 </ItemGroup> 83 83 <ItemGroup> 84 <Compile Include="ContentView.cs"> 85 <SubType>UserControl</SubType> 86 </Compile> 87 <Compile Include="ContentView.Designer.cs"> 88 <DependentUpon>ContentView.cs</DependentUpon> 89 </Compile> 84 90 <Compile Include="DockForm.cs"> 85 91 <SubType>Form</SubType> … … 101 107 </Compile> 102 108 <Compile Include="HeuristicLabMainFormWindowsFormsPlugin.cs" /> 103 <Compile Include="MainForm Base.cs">104 <SubType>Form</SubType> 105 </Compile> 106 <Compile Include="MainForm Base.Designer.cs">107 <DependentUpon>MainForm Base.cs</DependentUpon>108 </Compile> 109 <Compile Include="MenuItem Base.cs" />109 <Compile Include="MainForm.cs"> 110 <SubType>Form</SubType> 111 </Compile> 112 <Compile Include="MainForm.Designer.cs"> 113 <DependentUpon>MainForm.cs</DependentUpon> 114 </Compile> 115 <Compile Include="MenuItem.cs" /> 110 116 <Compile Include="MultipleDocumentMainForm.cs"> 111 117 <SubType>Form</SubType> … … 121 127 <DependentUpon>SingleDocumentMainForm.cs</DependentUpon> 122 128 </Compile> 123 <Compile Include="ToolBarItem Base.cs" />124 <Compile Include="View Base.cs">129 <Compile Include="ToolBarItem.cs" /> 130 <Compile Include="View.cs"> 125 131 <SubType>UserControl</SubType> 126 132 </Compile> 127 <Compile Include="View Base.Designer.cs">128 <DependentUpon>View Base.cs</DependentUpon>133 <Compile Include="View.Designer.cs"> 134 <DependentUpon>View.cs</DependentUpon> 129 135 </Compile> 130 136 <Compile Include="ViewContextMenuStrip.cs"> … … 165 171 <SubType>Designer</SubType> 166 172 </EmbeddedResource> 167 <EmbeddedResource Include="MainForm Base.resx">168 <DependentUpon>MainForm Base.cs</DependentUpon>173 <EmbeddedResource Include="MainForm.resx"> 174 <DependentUpon>MainForm.cs</DependentUpon> 169 175 </EmbeddedResource> 170 176 <EmbeddedResource Include="MultipleDocumentMainForm.resx"> -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainForm.Designer.cs
r2689 r2696 20 20 #endregion 21 21 namespace HeuristicLab.MainForm.WindowsForms { 22 partial class MainForm Base{22 partial class MainForm { 23 23 /// <summary> 24 24 /// Required designer variable. … … 44 44 /// </summary> 45 45 private void InitializeComponent() { 46 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm Base));46 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); 47 47 this.menuStrip = new System.Windows.Forms.MenuStrip(); 48 48 this.toolStrip = new System.Windows.Forms.ToolStrip(); -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainForm.cs
r2689 r2696 30 30 31 31 using HeuristicLab.PluginInfrastructure; 32 using System.Collections; 32 33 33 34 namespace HeuristicLab.MainForm.WindowsForms { 34 public partial class MainFormBase : Form, IMainForm { 35 35 public partial class MainForm : Form, IMainForm { 36 36 private bool initialized; 37 protected MainFormBase() 37 38 protected MainForm() 38 39 : base() { 39 40 InitializeComponent(); … … 43 44 } 44 45 45 protected MainForm Base(Type userInterfaceItemType)46 protected MainForm(Type userInterfaceItemType) 46 47 : this() { 47 48 this.userInterfaceItemType = userInterfaceItemType; 48 CreateGUI(); 49 } 50 51 private void MainFormBase_Load(object sender, EventArgs e) { 52 if (!DesignMode) { 53 MainFormManager.RegisterMainForm(this); 54 if (!this.initialized) { 55 this.initialized = true; 56 if (this.Initialized != null) 57 this.Initialized(this, new EventArgs()); 58 } 59 } 60 } 61 62 public event EventHandler Initialized; 63 64 #region IMainForm Members 49 } 50 51 #region properties 65 52 public string Title { 66 53 get { return this.Text; } … … 93 80 public IEnumerable<IView> Views { 94 81 get { return views.Keys; } 95 }96 97 public Form GetForm(IView view) {98 if (views.ContainsKey(view))99 return views[view];100 return null;101 82 } 102 83 … … 121 102 get { return this.userInterfaceItems; } 122 103 } 123 104 #endregion 105 106 #region events 124 107 public event EventHandler ActiveViewChanged; 125 108 protected virtual void OnActiveViewChanged() { … … 155 138 156 139 public event EventHandler Changed; 157 public void FireMainFormChanged() { 158 OnMainFormChanged(); 159 } 160 protected virtual void OnMainFormChanged() { 140 protected void FireMainFormChanged() { 161 141 if (InvokeRequired) 162 Invoke((MethodInvoker) OnMainFormChanged);142 Invoke((MethodInvoker)FireMainFormChanged); 163 143 else if (Changed != null) 164 144 Changed(this, new EventArgs()); 165 145 } 166 146 147 private void MainFormBase_Load(object sender, EventArgs e) { 148 if (!DesignMode) { 149 MainFormManager.RegisterMainForm(this); 150 if (!this.initialized) { 151 this.initialized = true; 152 this.OnInitialized(new EventArgs()); 153 } 154 this.CreateGUI(); 155 } 156 } 157 158 protected virtual void OnInitialized(EventArgs e) { 159 } 160 161 private void ChildFormClosed(object sender, FormClosedEventArgs e) { 162 Form form = (Form)sender; 163 IView view = GetView(form); 164 165 form.Activated -= new EventHandler(FormActivated); 166 form.FormClosed -= new FormClosedEventHandler(ChildFormClosed); 167 168 views.Remove(view); 169 this.OnViewClosed(view); 170 if (ActiveView == view) 171 ActiveView = null; 172 } 173 174 private void FormActivated(object sender, EventArgs e) { 175 this.ActiveView = GetView((Form)sender); 176 } 177 #endregion 178 179 #region create, get, show, hide, close views 167 180 protected virtual Form CreateForm(IView view) { 168 181 throw new NotImplementedException("CreateForm must be implemented in subclasses of MainFormBase."); 169 182 } 170 183 171 public void ShowView(IView view) { 172 if (InvokeRequired) Invoke((Action<IView>)ShowView, view); 184 internal Form GetForm(IView view) { 185 if (views.ContainsKey(view)) 186 return views[view]; 187 return null; 188 } 189 190 internal IView GetView(Form form) { 191 return views.Where(x => x.Value == form).Single().Key; 192 } 193 194 internal void ShowView(IView view,bool firstTimeShown) { 195 if (InvokeRequired) Invoke((Action<IView, bool>)ShowView, view,firstTimeShown); 173 196 else { 174 if ( !views.Keys.Contains(view)) {197 if (firstTimeShown) { 175 198 Form form = CreateForm(view); 176 views[view] = form;199 this.views[view] = form; 177 200 form.Activated += new EventHandler(FormActivated); 178 form.FormClosing += new FormClosingEventHandler(view.OnClosing);179 form.FormClosing += new FormClosingEventHandler(((ViewBase)view).OnClosingHelper);180 form.FormClosed += new FormClosedEventHandler(view.OnClosed);181 201 form.FormClosed += new FormClosedEventHandler(ChildFormClosed); 182 foreach (IUserInterfaceItem item in UserInterfaceItems) 183 view.Changed += new EventHandler(item.ViewChanged); 184 this.Show(view, true); 185 this.OnViewShown(view, true); 186 } else { 187 this.Show(view, false); 188 this.OnViewShown(view, false); 189 } 202 } 203 this.Show(view, firstTimeShown); 204 this.OnViewShown(view, firstTimeShown); 190 205 } 191 206 } … … 194 209 } 195 210 196 publicvoid HideView(IView view) {211 internal void HideView(IView view) { 197 212 if (InvokeRequired) Invoke((Action<IView>)HideView, view); 198 213 else { … … 207 222 } 208 223 209 publicvoid CloseView(IView view) {224 internal void CloseView(IView view) { 210 225 if (InvokeRequired) Invoke((Action<IView>)CloseView, view); 211 226 else { … … 217 232 } 218 233 219 publicvoid CloseView(IView view, CloseReason closeReason) {234 internal void CloseView(IView view, CloseReason closeReason) { 220 235 if (InvokeRequired) Invoke((Action<IView>)CloseView, view); 221 236 else { 222 237 if (this.views.ContainsKey(view)) { 223 ((View Base)view).closeReason = closeReason;238 ((View)view).closeReason = closeReason; 224 239 this.CloseView(view); 225 240 } … … 227 242 } 228 243 229 public v irtual void CloseAllViews() {244 public void CloseAllViews() { 230 245 foreach (IView view in views.Keys.ToArray()) 231 246 CloseView(view); 232 247 } 233 248 234 public v irtual void CloseAllViews(CloseReason closeReason) {249 public void CloseAllViews(CloseReason closeReason) { 235 250 foreach (IView view in views.Keys.ToArray()) 236 251 CloseView(view, closeReason); … … 238 253 #endregion 239 254 240 #region events241 private void ChildFormClosed(object sender, FormClosedEventArgs e) {242 Form form = (Form)sender;243 IView view = GetViewForForm(form);244 245 form.Activated -= new EventHandler(FormActivated);246 form.FormClosing -= new FormClosingEventHandler(view.OnClosing);247 form.FormClosing -= new FormClosingEventHandler(((ViewBase)view).OnClosingHelper);248 form.FormClosed -= new FormClosedEventHandler(view.OnClosed);249 form.FormClosed -= new FormClosedEventHandler(ChildFormClosed);250 foreach (IUserInterfaceItem item in UserInterfaceItems)251 view.Changed -= new EventHandler(item.ViewChanged);252 253 views.Remove(view);254 this.OnViewClosed(view);255 if (ActiveView == view)256 ActiveView = null;257 }258 259 private void FormActivated(object sender, EventArgs e) {260 this.ActiveView = GetViewForForm((Form)sender);261 }262 263 private IView GetViewForForm(Form form) {264 return views.Where(x => x.Value == form).Single().Key;265 }266 #endregion267 268 255 #region create menu and toolbar 269 protected virtual void CreateGUI() { 270 IEnumerable<IMenuItem> toolStripMenuItems = 271 from mi in ApplicationManager.Manager.GetInstances(userInterfaceItemType) 272 where mi is IMenuItem 273 orderby ((IMenuItem)mi).Position 274 select (IMenuItem)mi; 275 foreach (IMenuItem menuItem in toolStripMenuItems) 276 AddToolStripMenuItem(menuItem); 277 278 IEnumerable<IToolBarItem> toolStripButtonItems = 279 from bi in ApplicationManager.Manager.GetInstances(userInterfaceItemType) 280 where bi is IToolBarItem 281 orderby ((IToolBarItem)bi).Position 282 select (IToolBarItem)bi; 283 foreach (IToolBarItem toolStripButtonItem in toolStripButtonItems) 284 AddToolStripButtonItem(toolStripButtonItem); 256 private void CreateGUI() { 257 IEnumerable<object> allUserInterfaceItems = ApplicationManager.Manager.GetInstances(userInterfaceItemType); 258 259 IEnumerable<IPositionableUserInterfaceItem> toolStripMenuItems = 260 from mi in allUserInterfaceItems 261 where (mi is IPositionableUserInterfaceItem) && 262 (mi is IMenuItem || mi is IMenuSeparatorItem) 263 orderby ((IPositionableUserInterfaceItem)mi).Position 264 select (IPositionableUserInterfaceItem)mi; 265 266 foreach (IPositionableUserInterfaceItem menuItem in toolStripMenuItems) { 267 if (menuItem is IMenuItem) 268 AddToolStripMenuItem((IMenuItem)menuItem); 269 else if (menuItem is IMenuSeparatorItem) 270 AddToolStripMenuItem((IMenuSeparatorItem)menuItem); 271 } 272 273 IEnumerable<IPositionableUserInterfaceItem> toolStripButtonItems = 274 from bi in allUserInterfaceItems 275 where (bi is IPositionableUserInterfaceItem) && 276 (bi is IToolBarItem || bi is IToolBarSeparatorItem) 277 orderby ((IPositionableUserInterfaceItem)bi).Position 278 select (IPositionableUserInterfaceItem)bi; 279 280 foreach (IPositionableUserInterfaceItem toolStripButtonItem in toolStripButtonItems) { 281 if (toolStripButtonItem is IToolBarItem) 282 AddToolStripButtonItem((IToolBarItem)toolStripButtonItem); 283 else if (toolStripButtonItem is IToolBarSeparatorItem) 284 AddToolStripButtonItem((IToolBarSeparatorItem)toolStripButtonItem); 285 } 286 287 this.AdditionalCreationOfGUIElements(); 288 } 289 290 protected virtual void AdditionalCreationOfGUIElements() { 285 291 } 286 292 287 293 private void AddToolStripMenuItem(IMenuItem menuItem) { 288 if (menuItem is MenuItemBase) { 289 ToolStripMenuItem item = new ToolStripMenuItem(); 290 SetToolStripItemProperties(item, menuItem); 291 ((MenuItemBase)menuItem).ToolStripItem = item; 292 item.ShortcutKeys = ((MenuItemBase)menuItem).ShortCutKeys; 293 item.DisplayStyle = ((MenuItemBase)menuItem).ToolStripItemDisplayStyle; 294 this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items); 295 } else if (menuItem is MenuSeparatorItemBase) { 296 this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), new ToolStripSeparator(), menuStrip.Items); 297 } 294 ToolStripMenuItem item = new ToolStripMenuItem(); 295 this.SetToolStripItemProperties(item, menuItem); 296 if (menuItem is MenuItem) { 297 MenuItem menuItemBase = (MenuItem)menuItem; 298 menuItemBase.ToolStripItem = item; 299 item.ShortcutKeys = menuItemBase.ShortCutKeys; 300 item.DisplayStyle = menuItemBase.ToolStripItemDisplayStyle; 301 } 302 this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), item, menuStrip.Items); 303 } 304 305 private void AddToolStripMenuItem(IMenuSeparatorItem menuItem) { 306 this.InsertItem(menuItem.Structure, typeof(ToolStripMenuItem), new ToolStripSeparator(), menuStrip.Items); 298 307 } 299 308 300 309 private void AddToolStripButtonItem(IToolBarItem buttonItem) { 301 ToolStripItem item = n ull;302 303 if (buttonItem is ToolBarItemBase) {304 if ( ((ToolBarItemBase)buttonItem).IsDropDownButton)310 ToolStripItem item = new ToolStripButton(); 311 if (buttonItem is ToolBarItem) { 312 ToolBarItem buttonItemBase = (ToolBarItem)buttonItem; 313 if (buttonItemBase.IsDropDownButton) 305 314 item = new ToolStripDropDownButton(); 306 else 307 item = new ToolStripButton(); 308 309 SetToolStripItemProperties(item, buttonItem); 310 item.DisplayStyle = ((ToolBarItemBase)buttonItem).ToolStripItemDisplayStyle; 311 ((ToolBarItemBase)buttonItem).ToolStripItem = item; 312 } else if (buttonItem is IToolBarSeparatorItem) 313 item = new ToolStripSeparator(); 314 315 316 item.DisplayStyle = buttonItemBase.ToolStripItemDisplayStyle; 317 buttonItemBase.ToolStripItem = item; 318 } 319 320 this.SetToolStripItemProperties(item, buttonItem); 315 321 this.InsertItem(buttonItem.Structure, typeof(ToolStripDropDownButton), item, toolStrip.Items); 322 } 323 324 private void AddToolStripButtonItem(IToolBarSeparatorItem buttonItem) { 325 this.InsertItem(buttonItem.Structure, typeof(ToolStripDropDownButton), new ToolStripSeparator(), toolStrip.Items); 316 326 } 317 327 … … 330 340 } 331 341 332 private void SetToolStripItemProperties(ToolStripItem toolStripItem, I UserInterfaceItem userInterfaceItem) {342 private void SetToolStripItemProperties(ToolStripItem toolStripItem, IActionUserInterfaceItem userInterfaceItem) { 333 343 toolStripItem.Name = userInterfaceItem.Name; 334 344 toolStripItem.Text = userInterfaceItem.Name; … … 336 346 toolStripItem.Tag = userInterfaceItem; 337 347 toolStripItem.Image = userInterfaceItem.Image; 338 this.ActiveViewChanged += new EventHandler(userInterfaceItem.ActiveViewChanged);339 this.Changed += new EventHandler(userInterfaceItem.MainFormChanged);340 this.Initialized += new EventHandler(userInterfaceItem.MainFormInitialized);341 348 toolStripItem.Click += new EventHandler(ToolStripItemClicked); 342 349 this.userInterfaceItems.Add(userInterfaceItem); … … 345 352 private void ToolStripItemClicked(object sender, EventArgs e) { 346 353 System.Windows.Forms.ToolStripItem item = (System.Windows.Forms.ToolStripItem)sender; 347 ((I UserInterfaceItem)item.Tag).Execute();354 ((IActionUserInterfaceItem)item.Tag).Execute(); 348 355 } 349 356 #endregion -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MenuItem.cs
r2689 r2696 26 26 27 27 namespace HeuristicLab.MainForm.WindowsForms { 28 public abstract class MenuItem Base : HeuristicLab.MainForm.MenuItemBase{28 public abstract class MenuItem : HeuristicLab.MainForm.MenuItem{ 29 29 public virtual Keys ShortCutKeys { 30 30 get { return Keys.None; } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MultipleDocumentMainForm.cs
r2548 r2696 30 30 31 31 namespace HeuristicLab.MainForm.WindowsForms { 32 public partial class MultipleDocumentMainForm : MainForm Base{32 public partial class MultipleDocumentMainForm : MainForm { 33 33 public MultipleDocumentMainForm() 34 34 : base() { … … 41 41 } 42 42 43 protected override void CreateGUI() {44 base. CreateGUI();43 protected override void AdditionalCreationOfGUIElements() { 44 base.AdditionalCreationOfGUIElements(); 45 45 ToolStripMenuItem window = new ToolStripMenuItem("Windows"); 46 base.menuStrip.MdiWindowListItem = window;47 base.menuStrip.Items.Add(window);46 this.menuStrip.MdiWindowListItem = window; 47 this.menuStrip.Items.Add(window); 48 48 } 49 49 … … 53 53 base.Show(view, firstTimeShown); 54 54 if (firstTimeShown) 55 GetForm(view).Show(this);55 this.GetForm(view).Show(); 56 56 else { 57 GetForm(view).Visible = true;58 GetForm(view).Activate();57 this.GetForm(view).Visible = true; 58 this.GetForm(view).Activate(); 59 59 } 60 60 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/SingleDocumentMainForm.cs
r2548 r2696 31 31 32 32 namespace HeuristicLab.MainForm.WindowsForms { 33 public partial class SingleDocumentMainForm : MainForm Base{33 public partial class SingleDocumentMainForm : MainForm { 34 34 public SingleDocumentMainForm() 35 35 : base() { … … 47 47 base.Show(view, firstTimeShown); 48 48 if (firstTimeShown) 49 GetForm(view).Show(this);49 this.GetForm(view).Show(this); 50 50 else { 51 GetForm(view).Visible = true;52 GetForm(view).Activate();51 this.GetForm(view).Visible = true; 52 this.GetForm(view).Activate(); 53 53 } 54 54 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ToolBarItem.cs
r2689 r2696 19 19 */ 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; … … 26 27 27 28 namespace HeuristicLab.MainForm.WindowsForms { 28 public abstract class ToolBarItem Base : HeuristicLab.MainForm.ToolBarItemBase{29 public abstract class ToolBarItem : HeuristicLab.MainForm.ToolBarItem { 29 30 private ToolStripItem toolStripItem; 30 31 public virtual ToolStripItem ToolStripItem { -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/View.Designer.cs
r2689 r2696 21 21 22 22 namespace HeuristicLab.MainForm.WindowsForms { 23 partial class View Base{23 partial class View { 24 24 /// <summary> 25 25 /// Required designer variable. -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/View.cs
r2689 r2696 30 30 31 31 namespace HeuristicLab.MainForm.WindowsForms { 32 public partial class View Base: UserControl, IView {32 public partial class View : UserControl, IView { 33 33 private bool initialized; 34 public View Base() {34 public View() { 35 35 InitializeComponent(); 36 36 this.initialized = false; … … 54 54 } 55 55 56 public void Show() { 57 MainForm mainform = MainFormManager.GetMainForm<MainForm>(); 58 bool firstTimeShown = mainform.GetForm(this) == null; 59 60 MainFormManager.GetMainForm<MainForm>().ShowView(this,firstTimeShown); 61 if (firstTimeShown) { 62 Form form = mainform.GetForm(this); 63 form.FormClosed += new FormClosedEventHandler(OnClosedHelper); 64 form.FormClosing += new FormClosingEventHandler(OnClosingHelper); 65 } 66 this.OnShown(new ViewShownEventArgs(this,firstTimeShown)); 67 } 68 69 public void Close() { 70 MainForm mainform = MainFormManager.GetMainForm<MainForm>(); 71 Form form = mainform.GetForm(this); 72 if (form != null) 73 mainform.CloseView(this); 74 } 75 76 public void Close(CloseReason closeReason) { 77 MainForm mainform = MainFormManager.GetMainForm<MainForm>(); 78 Form form = mainform.GetForm(this); 79 if (form != null) 80 mainform.CloseView(this,closeReason); 81 } 82 83 public void Hide() { 84 MainFormManager.GetMainForm<MainForm>().HideView(this); 85 this.OnHidden(new EventArgs()); 86 } 87 56 88 public event EventHandler CaptionChanged; 57 89 protected virtual void OnCaptionChanged() { … … 68 100 } 69 101 70 public virtual void OnClosing(object sender, CancelEventArgs e) { 102 protected virtual void OnShown(ViewShownEventArgs e) { 103 } 104 105 protected virtual void OnHidden(EventArgs e) { 71 106 } 72 107 … … 74 109 internal void OnClosingHelper(object sender, FormClosingEventArgs e) { 75 110 if (this.closeReason != CloseReason.None) 76 this.OnClosing( sender,new FormClosingEventArgs(this.closeReason, e.Cancel));111 this.OnClosing(new FormClosingEventArgs(this.closeReason, e.Cancel)); 77 112 else 78 this.OnClosing( sender,e);113 this.OnClosing(e); 79 114 80 115 this.closeReason = CloseReason.None; 81 116 } 82 117 83 p ublic virtual void OnClosing(object sender,FormClosingEventArgs e) {118 protected virtual void OnClosing(FormClosingEventArgs e) { 84 119 } 85 120 86 public virtual void OnClosed(object sender, EventArgs e) { 121 internal void OnClosedHelper(object sender, FormClosedEventArgs e) { 122 if (this.closeReason != CloseReason.None) 123 this.OnClosed(new FormClosedEventArgs(this.closeReason)); 124 else 125 this.OnClosed(e); 126 127 Form form = (Form)sender; 128 form.FormClosed -= new FormClosedEventHandler(OnClosedHelper); 129 form.FormClosing -= new FormClosingEventHandler(OnClosingHelper); 130 this.closeReason = CloseReason.None; 87 131 } 88 132 89 public event EventHandler Initialized; 133 protected virtual void OnClosed(FormClosedEventArgs e) { 134 } 90 135 91 136 private void ViewBase_Load(object sender, EventArgs e) { 92 137 if (!this.initialized && !this.DesignMode) { 93 if (this.Initialized != null) 94 this.Initialized(this, new EventArgs()); 138 this.OnInitialized(e); 95 139 this.initialized = true; 96 140 } 97 141 } 142 143 protected virtual void OnInitialized(EventArgs e) { 144 } 98 145 } 99 146 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewContextMenuStrip.cs
r2545 r2696 34 34 Type viewType = e.ClickedItem.Tag as Type; 35 35 IView view = MainFormManager.CreateView(viewType, this.item); 36 MainFormManager.MainForm.ShowView(view);36 view.Show(); 37 37 } 38 38 }
Note: See TracChangeset
for help on using the changeset viewer.