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/ContentView.cs

    r3389 r3416  
    2828using System.Text;
    2929using System.Windows.Forms;
     30using HeuristicLab.Common;
     31using System.Reflection;
    3032
    3133namespace HeuristicLab.MainForm.WindowsForms {
    3234  public partial class ContentView : View, IContentView {
    33     private object content;
    34     public object Content {
     35    private IContent content;
     36    public IContent Content {
    3537      get { return content; }
    3638      set {
     
    3840          throw new ArgumentException(string.Format("View \"{0}\" cannot view object \"{1}\".", this.GetType().Name, value.GetType().Name));
    3941        if (InvokeRequired) {
    40           Invoke(new Action<object>(delegate(object o) { this.Content = o; }), value);
     42          Invoke(new Action<IContent>(delegate(IContent o) { this.Content = o; }), value);
    4143        } else {
    4244          if (this.content != value) {
     
    4951      }
    5052    }
    51     private bool saveEnabled;
    52     public bool SaveEnabled {
    53       get { return saveEnabled; }
    54       protected set {
    55         if (value != saveEnabled) {
    56           saveEnabled = value;
    57           OnChanged();
    58         }
    59       }
    60     }
    6153
    6254    public ContentView()
    6355      : base() {
    6456      InitializeComponent();
    65       saveEnabled = true;
     57      this.locked = false;
    6658    }
    67     public ContentView(object content)
     59    public ContentView(IContent content)
    6860      : this() {
    6961      this.content = content;
     62    }
     63
     64    private bool locked;
     65    public virtual bool Locked {
     66      get { return this.locked; }
     67      set {
     68        if (InvokeRequired) {
     69          Action<bool> action = delegate(bool b) { this.Locked = b; };
     70          Invoke(action, value);
     71        } else {
     72          if (value != locked) {
     73            locked = value;
     74            PropertyInfo prop = typeof(IContentView).GetProperty("Locked");
     75            PropagateStateChanges(this, typeof(IContentView), prop);
     76            OnLockedChanged();
     77            OnChanged();
     78          }
     79        }
     80      }
     81    }
     82    public event EventHandler LockedChanged;
     83    protected virtual void OnLockedChanged() {
     84      if (InvokeRequired)
     85        Invoke((MethodInvoker)OnLockedChanged);
     86      else {
     87        EventHandler handler = LockedChanged;
     88        if (handler != null)
     89          handler(this, EventArgs.Empty);
     90      }
    7091    }
    7192
Note: See TracChangeset for help on using the changeset viewer.