Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/19/10 19:43:05 (14 years ago)
Author:
mkommend
Message:

Adjusted the SetEnabledStateOfControls method in all views, added the Enabled property into the IView interface and adapted the ViewHost, View and ContentView class (ticket #1155).

Location:
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3
Files:
3 edited

Legend:

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

    r4068 r4435  
    6767        } else {
    6868          if (value != locked) {
    69             this.SuspendRepaint();
    7069            locked = value;
    7170            OnLockedChanged();
    72             this.SetEnabledStateOfControls();
     71            SetEnabledStateOfControls();
    7372            PropertyInfo prop = typeof(IContentView).GetProperty("Locked");
    7473            PropagateStateChanges(this, typeof(IContentView), prop);
    7574            OnChanged();
    76             this.ResumeRepaint(true);
    7775          }
    7876        }
     
    111109    /// </summary>
    112110    protected override void SetEnabledStateOfControls() {
     111      base.SetEnabledStateOfControls();
     112      Enabled = Content != null;
    113113    }
    114114  }
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/View.cs

    r4083 r4435  
    6565        } else {
    6666          if (value != readOnly) {
    67             this.SuspendRepaint();
    6867            this.readOnly = value;
    69             this.OnReadOnlyChanged();
    70             this.SetEnabledStateOfControls();
     68            OnReadOnlyChanged();
     69            SetEnabledStateOfControls();
    7170            PropertyInfo prop = typeof(IView).GetProperty("ReadOnly");
    7271            PropagateStateChanges(this, typeof(IView), prop);
    73             this.ResumeRepaint(true);
     72            OnChanged();
    7473          }
    7574        }
    7675      }
    7776    }
     77
     78    bool IView.Enabled {
     79      get { return base.Enabled; }
     80      set {
     81        if (base.Enabled != value) {
     82          this.SuspendRepaint();
     83          base.Enabled = value;
     84          bool isTopLevelView = MainFormManager.MainForm.Views.Contains(this);
     85          this.ResumeRepaint(isTopLevelView);
     86        }
     87      }
     88    }
     89
     90    protected override void OnEnabledChanged(EventArgs e) {
     91      base.OnEnabledChanged(e);
     92      if (Enabled) SetEnabledStateOfControls();
     93    }
     94
    7895    /// <summary>
    7996    /// This method is called if the ReadyOnly property of the View changes to update the controls of the view.
     
    160177          var thisValue = propertyInfo.GetValue(this, null);
    161178          controlPropertyInfo.SetValue(c, thisValue, null);
    162         } else
    163           PropagateStateChanges(c, type, propertyInfo);
     179        } else PropagateStateChanges(c, type, propertyInfo);
    164180      }
    165181    }
     
    226242    }
    227243
    228     public new bool Enabled {
    229       get { return base.Enabled; }
    230       set {
    231         SuspendRepaint();
    232         base.Enabled = value;
    233         ResumeRepaint(true);
    234       }
    235     }
    236244
    237245    public void SuspendRepaint() {
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ViewHost.cs

    r4418 r4435  
    6161            View view = activeView as View;
    6262            if (view != null) {
     63              view.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
     64              view.Size = new System.Drawing.Size(this.Width - this.viewsLabel.Width - this.viewsLabel.Margin.Left - this.viewsLabel.Margin.Right, this.Height);
    6365              view.OnShown(new ViewShownEventArgs(view, false));
    6466              Controls.Add(view);
    6567            }
    6668          } else viewType = null;
    67           OnActiveViewChanged();
    6869        }
    6970      }
     
    8485          OnViewTypeChanged();
    8586        }
    86       }
    87     }
    88 
    89     public new bool Enabled {
    90       get { return base.Enabled; }
    91       set {
    92         base.Enabled = value;
    93         this.viewsLabel.Enabled = value;
    9487      }
    9588    }
     
    136129        IContentView view;
    137130        view = MainFormManager.CreateView(viewType);
     131        view.Locked = this.Locked;
    138132        view.ReadOnly = this.ReadOnly;
    139         view.Locked = this.Locked;
    140133        ActiveView = view; //necessary to allow the views to change the status of the viewhost
    141134        view.Content = Content;
     
    145138    }
    146139
    147     private void OnActiveViewChanged() {
    148       this.SuspendRepaint();
    149       if (activeView != null) {
    150         this.ActiveView.ReadOnly = this.ReadOnly;
    151         this.ActiveView.Locked = this.Locked;
    152         this.ActiveViewControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
    153         this.ActiveViewControl.Size = new System.Drawing.Size(this.Width - this.viewsLabel.Width - this.viewsLabel.Margin.Left - this.viewsLabel.Margin.Right, this.Height);
    154       }
    155       this.ResumeRepaint(true);
    156     }
    157 
    158140    private void RegisterActiveViewEvents() {
    159       activeView.Changed += new EventHandler(activeView_Changed);
    160141      activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged);
     142      activeView.LockedChanged += new EventHandler(activeView_LockedChanged);
    161143    }
    162144    private void DeregisterActiveViewEvents() {
    163       activeView.Changed -= new EventHandler(activeView_Changed);
    164       activeView.CaptionChanged -= new EventHandler(activeView_CaptionChanged);
     145      activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged);
     146      activeView.LockedChanged += new EventHandler(activeView_LockedChanged);
    165147    }
    166148    private void activeView_CaptionChanged(object sender, EventArgs e) {
    167       this.ActiveViewChanged();
    168     }
    169     private void activeView_Changed(object sender, EventArgs e) {
    170       this.ActiveViewChanged();
    171     }
    172     private void ActiveViewChanged() {
    173       if (ActiveView != null) {
    174         this.Caption = this.ActiveView.Caption;
    175         this.ReadOnly = this.ActiveView.ReadOnly;
    176         this.Locked = this.ActiveView.Locked;
    177       }
     149      this.Caption = activeView.Caption;
     150    }
     151    private void activeView_LockedChanged(object sender, EventArgs e) {
     152      this.Locked = activeView.Locked;
    178153    }
    179154
Note: See TracChangeset for help on using the changeset viewer.