Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 16:09:16 (14 years ago)
Author:
mkommend
Message:

added possibility to clear the cached views in the ViewHost (ticket #972)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ViewHost.cs

    r4083 r4084  
    7777      }
    7878    }
    79 
    8079    private Control ActiveViewControl {
    8180      get { return ActiveView as Control; }
     
    103102        this.viewsLabel.Enabled = value;
    104103        this.ResumeRepaint(true);
     104      }
     105    }
     106
     107    public void ClearCache() {
     108      foreach (var cachedView in cachedViews) {
     109        if (cachedView.Value != activeView) {
     110          Control c = cachedView.Value as Control;
     111          if (c != null) {
     112            this.Controls.Remove(c);
     113            c.Dispose();
     114          }
     115          cachedViews.Remove(cachedView.Key);
     116        }
    105117      }
    106118    }
     
    185197    }
    186198
     199    private void RegisterActiveViewEvents() {
     200      activeView.Changed += new EventHandler(activeView_Changed);
     201      activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged);
     202    }
     203    private void DeregisterActiveViewEvents() {
     204      activeView.Changed -= new EventHandler(activeView_Changed);
     205      activeView.CaptionChanged -= new EventHandler(activeView_CaptionChanged);
     206    }
     207    private void activeView_CaptionChanged(object sender, EventArgs e) {
     208      this.ActiveViewChanged();
     209    }
     210    private void activeView_Changed(object sender, EventArgs e) {
     211      this.ActiveViewChanged();
     212    }
     213    private void ActiveViewChanged() {
     214      if (ActiveView != null) {
     215        this.Caption = this.ActiveView.Caption;
     216        this.Locked = this.ActiveView.Locked;
     217      }
     218    }
     219
    187220    protected override void OnSizeChanged(EventArgs e) {
    188221      //mkommend: solution to resizing issues. taken from http://support.microsoft.com/kb/953934
     
    194227      base.OnSizeChanged(e);
    195228      this.viewsLabel.Location = new System.Drawing.Point(this.Width - this.viewsLabel.Margin.Right - this.viewsLabel.Width, this.viewsLabel.Margin.Top);
    196     }
    197 
    198     private void RegisterActiveViewEvents() {
    199       activeView.Changed += new EventHandler(activeView_Changed);
    200       activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged);
    201     }
    202     private void DeregisterActiveViewEvents() {
    203       activeView.Changed -= new EventHandler(activeView_Changed);
    204       activeView.CaptionChanged -= new EventHandler(activeView_CaptionChanged);
    205     }
    206     private void activeView_CaptionChanged(object sender, EventArgs e) {
    207       this.ActiveViewChanged();
    208     }
    209     private void activeView_Changed(object sender, EventArgs e) {
    210       this.ActiveViewChanged();
    211     }
    212     private void ActiveViewChanged() {
    213       if (ActiveView != null) {
    214         this.Caption = this.ActiveView.Caption;
    215         this.Locked = this.ActiveView.Locked;
    216       }
    217229    }
    218230
Note: See TracChangeset for help on using the changeset viewer.