Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2963


Ignore:
Timestamp:
03/08/10 11:23:54 (15 years ago)
Author:
mkommend
Message:

corrected behaviour of the ActiveViewChangedEvent (ticket #897)

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

Legend:

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

    r2790 r2963  
    6969    private void dockPanel_ActiveContentChanged(object sender, EventArgs e) {
    7070      DockForm content = this.dockPanel.ActiveContent as DockForm;
    71       this.ActiveView = content == null ? null : content.View;
     71      if (content != null)
     72        this.ActiveView = content.View;
    7273    }
    7374  }
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.2/MainForm.cs

    r2793 r2963  
    8686      get { return this.activeView; }
    8787      protected set {
    88         if (this.activeView != value && (value != null || this.views.Keys.All(v => !v.IsShown))) {
     88        if (this.activeView != value) {
    8989          if (InvokeRequired) {
    9090            Action<IView> action = delegate(IView activeView) { this.ActiveView = activeView; };
     
    159159    }
    160160
    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 
    174161    private void FormActivated(object sender, EventArgs e) {
    175162      this.ActiveView = GetView((Form)sender);
     
    179166    #region create, get, show, hide, close views
    180167    protected virtual Form CreateForm(IView view) {
    181       throw new NotImplementedException("CreateForm must be implemented in subclasses of MainFormBase.");
     168      throw new NotImplementedException("CreateForm must be implemented in subclasses of MainForm.");
    182169    }
    183170
     
    197184        if (firstTimeShown) {
    198185          Form form = CreateForm(view);
     186          view.Changed += new EventHandler(ViewChanged);
    199187          this.views[view] = form;
    200188          form.Activated += new EventHandler(FormActivated);
    201189          form.FormClosed += new FormClosedEventHandler(ChildFormClosed);
     190         
    202191        }
    203192        this.Show(view, firstTimeShown);
    204193        this.OnViewShown(view, firstTimeShown);
    205194      }
     195    }
     196
     197    private void ViewChanged(object sender, EventArgs e) {
     198      IView view = (IView)sender;
     199      if (view == this.ActiveView)
     200        this.OnActiveViewChanged();
    206201    }
    207202
     
    214209        if (this.views.ContainsKey(view)) {
    215210          this.Hide(view);
    216           if (this.activeView == view && views.All(v => !view.IsShown))
     211          if (this.activeView == view)
    217212            this.ActiveView = null;
    218213          this.OnViewHidden(view);
     
    222217
    223218    protected virtual void Hide(IView view) {
     219    }
     220
     221    private void ChildFormClosed(object sender, FormClosedEventArgs e) {
     222      Form form = (Form)sender;
     223      IView view = GetView(form);
     224
     225      view.Changed -= new EventHandler(ViewChanged);
     226      form.Activated -= new EventHandler(FormActivated);
     227      form.FormClosed -= new FormClosedEventHandler(ChildFormClosed);
     228
     229      views.Remove(view);
     230      this.OnViewClosed(view);
     231      if (ActiveView == view)
     232        ActiveView = null;
    224233    }
    225234
     
    238247      else {
    239248        if (this.views.ContainsKey(view)) {
    240           ((View)view).closeReason = closeReason;
     249          ((View)view).CloseReason = closeReason;
    241250          this.CloseView(view);
    242251        }
Note: See TracChangeset for help on using the changeset viewer.