Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4083 for trunk


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

fixed bug concerning invisible views in viewhost (ticket #972)

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

Legend:

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

    r4068 r4083  
    146146      }
    147147    }
    148     protected void PropagateStateChanges(Control control, Type type, PropertyInfo propertyInfo) {
     148    protected virtual void PropagateStateChanges(Control control, Type type, PropertyInfo propertyInfo) {
    149149      if (!type.GetProperties().Contains(propertyInfo))
    150150        throw new ArgumentException("The specified type " + type + "implement the property " + propertyInfo.Name + ".");
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ViewHost.cs

    r4068 r4083  
    2525using System.Windows.Forms;
    2626using HeuristicLab.Common;
     27using System.Reflection;
    2728
    2829namespace HeuristicLab.MainForm.WindowsForms {
     
    175176      if (activeView != null) {
    176177        UpdateActiveMenuItem();
     178        this.ActiveView.ReadOnly = this.ReadOnly;
     179        this.ActiveView.Locked = this.Locked;
    177180        this.ActiveViewControl.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
    178181        this.ActiveViewControl.Size = new System.Drawing.Size(this.Width - this.viewsLabel.Width - this.viewsLabel.Margin.Left - this.viewsLabel.Margin.Right, this.Height);
     
    215218
    216219    #region forwarding of view events
    217     protected override void OnReadOnlyChanged() {
    218       this.SuspendRepaint();
    219       base.OnReadOnlyChanged();
    220       foreach (IContentView view in cachedViews.Values)
    221         view.ReadOnly = this.ReadOnly;
    222       this.ResumeRepaint(true);
    223     }
    224     protected override void OnLockedChanged() {
    225       this.SuspendRepaint();
    226       base.OnLockedChanged();
    227       foreach (IContentView view in cachedViews.Values)
    228         view.Locked = this.Locked;
    229       this.ResumeRepaint(true);
    230     }
     220    protected override void PropagateStateChanges(Control control, Type type, System.Reflection.PropertyInfo propertyInfo) {
     221      if (!type.GetProperties().Contains(propertyInfo))
     222        throw new ArgumentException("The specified type " + type + "implement the property " + propertyInfo.Name + ".");
     223      if (!type.IsAssignableFrom(this.GetType()))
     224        throw new ArgumentException("The specified type " + type + "must be the same or a base class / interface of this object.");
     225      if (!propertyInfo.CanWrite)
     226        throw new ArgumentException("The specified property " + propertyInfo.Name + " must have a setter.");
     227
     228      if (activeView != null) {
     229        Type controlType = activeView.GetType();
     230        PropertyInfo controlPropertyInfo = controlType.GetProperty(propertyInfo.Name, propertyInfo.PropertyType);
     231        if (type.IsAssignableFrom(controlType) && controlPropertyInfo != null) {
     232          var thisValue = propertyInfo.GetValue(this, null);
     233          controlPropertyInfo.SetValue(activeView, thisValue, null);
     234        }
     235      }
     236    }
     237
    231238    internal protected override void OnShown(ViewShownEventArgs e) {
    232239      base.OnShown(e);
Note: See TracChangeset for help on using the changeset viewer.