Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/19/10 21:00:30 (14 years ago)
Author:
mkommend
Message:

implemented ContentViews and propagation of view state changes (ticket #982)

File:
1 edited

Legend:

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

    r3403 r3416  
    2525using System.Windows.Forms;
    2626using HeuristicLab.MainForm;
     27using HeuristicLab.Common;
    2728
    2829namespace HeuristicLab.MainForm.WindowsForms {
     
    3839      activeView = null;
    3940    }
    40     public ViewHost(object content)
     41    public ViewHost(IContent content)
    4142      : this() {
    4243      this.Content = content;
     
    7576            View view = activeView as View;
    7677            if (view != null)
    77               view.OnShown(new ViewShownEventArgs(view,false));
     78              view.OnShown(new ViewShownEventArgs(view, false));
    7879          }
    7980          ActiveViewChanged();
     
    9596      }
    9697    }
    97     public new object Content {
     98    public new IContent Content {
    9899      get { return base.Content; }
    99100      set {
     
    116117    }
    117118
    118     protected override void OnReadOnlyChanged() {
    119       base.OnReadOnlyChanged();
    120       foreach (IContentView view in cachedViews.Values)
    121         view.ReadOnly = this.ReadOnly;
    122     }
     119
    123120
    124121    protected override void OnContentChanged() {
     
    162159        view = cachedViews[ViewType];
    163160      else {
    164         view = MainFormManager.CreateView(viewType, Content, ReadOnly);
     161        view = MainFormManager.CreateView(viewType, Content);
     162        view.ReadOnly = this.ReadOnly;
     163        view.Locked = this.Locked;
    165164        cachedViews.Add(viewType, view);
    166165      }
     
    192191      if (ActiveView != null) {
    193192        this.Caption = this.ActiveView.Caption;
    194         this.SaveEnabled = this.ActiveView.SaveEnabled;
     193        this.Locked = this.ActiveView.Locked;
    195194      }
    196195    }
    197196
    198197    #region forwarding of view events
     198    protected override void OnReadOnlyChanged() {
     199      base.OnReadOnlyChanged();
     200      foreach (IContentView view in cachedViews.Values)
     201        view.ReadOnly = this.ReadOnly;
     202    }
     203    protected override void OnLockedChanged() {
     204      base.OnLockedChanged();
     205      foreach (IContentView view in cachedViews.Values)
     206        view.Locked = this.Locked;
     207    }
    199208    internal protected override void OnShown(ViewShownEventArgs e) {
    200209      base.OnShown(e);
     
    203212        view.OnShown(e);
    204213    }
    205 
    206214    internal protected override void OnHidden(EventArgs e) {
    207215      base.OnHidden(e);
     
    210218        view.OnHidden(e);
    211219    }
    212 
    213220    internal protected override void OnClosing(FormClosingEventArgs e) {
    214221      base.OnClosing(e);
     
    216223        view.OnClosing(e);
    217224    }
    218 
    219225    internal protected override void OnClosed(FormClosedEventArgs e) {
    220226      base.OnClosed(e);
     
    246252
    247253    private void viewsLabel_DoubleClick(object sender, EventArgs e) {
    248       MainFormManager.CreateView(viewType, Content, ReadOnly).Show();
     254      IContentView view = MainFormManager.CreateView(viewType, Content);
     255      view.ReadOnly = this.ReadOnly;
     256      view.Locked = this.Locked;
     257      view.Show();
    249258    }
    250259    private void viewContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
     
    255264    private bool startDragAndDrop;
    256265    private void viewsLabel_MouseDown(object sender, MouseEventArgs e) {
    257       startDragAndDrop = true;
    258       viewsLabel.Capture = false;
     266      if (!Locked) {
     267        startDragAndDrop = true;
     268        viewsLabel.Capture = false;
     269      }
    259270    }
    260271    private void viewsLabel_MouseLeave(object sender, EventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.