Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2543


Ignore:
Timestamp:
12/04/09 15:09:43 (15 years ago)
Author:
mkommend
Message:

changed CloseReason to FormOwnerClosing if IView.Close method is used (ticket #771)

Location:
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainFormBase.cs

    r2541 r2543  
    5555          this.initialized = true;
    5656          if (this.Initialized != null)
    57             this.Initialized(this,new EventArgs());
     57            this.Initialized(this, new EventArgs());
    5858        }
    5959      }
     
    154154          form.GotFocus += new EventHandler(FormActivated);
    155155          form.FormClosing += new FormClosingEventHandler(view.OnClosing);
    156           form.FormClosing += new FormClosingEventHandler(((ViewBase)view).OnClosing);
     156          form.FormClosing += new FormClosingEventHandler(((ViewBase)view).OnClosingHelper);
    157157          form.FormClosed += new FormClosedEventHandler(view.OnClosed);
    158158          form.FormClosed += new FormClosedEventHandler(ChildFormClosed);
     
    176176      if (InvokeRequired) Invoke((Action<IView>)CloseView, view);
    177177      else {
    178         if (views.ContainsKey(view))
     178        if (views.ContainsKey(view)) {
     179          ((ViewBase)view).closeReason = CloseReason.FormOwnerClosing;
    179180          views[view].Close();
     181        }
    180182      }
    181183    }
     
    195197      form.GotFocus -= new EventHandler(FormActivated);
    196198      form.FormClosing -= new FormClosingEventHandler(view.OnClosing);
    197       form.FormClosing -= new FormClosingEventHandler(((ViewBase)view).OnClosing);
     199      form.FormClosing -= new FormClosingEventHandler(((ViewBase)view).OnClosingHelper);
    198200      form.FormClosed -= new FormClosedEventHandler(view.OnClosed);
    199201      form.FormClosed -= new FormClosedEventHandler(ChildFormClosed);
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/ViewBase.cs

    r2541 r2543  
    3535      InitializeComponent();
    3636      this.initialized = false;
     37      this.closeReason = CloseReason.None;
    3738    }
    3839
     
    6364    }
    6465
    65     public virtual void OnClosing(object sender, FormClosingEventArgs e) {
     66    internal CloseReason closeReason;
     67    internal void OnClosingHelper(object sender, FormClosingEventArgs e) {
     68      if (this.closeReason != CloseReason.None)
     69        this.OnClosing(sender, new FormClosingEventArgs(this.closeReason,e.Cancel));
     70      else
     71        this.OnClosing(sender, e);
     72     
     73      this.closeReason = CloseReason.None;
     74    }
     75
     76    public virtual void OnClosing(object sender, FormClosingEventArgs e) {     
    6677    }
    6778
Note: See TracChangeset for help on using the changeset viewer.