Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4435


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
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs

    r3904 r4435  
    182182        try {
    183183          i++;
     184          SetEnabledStateOfContentViews(item, false);
    184185          XmlGenerator.Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl", 9);
    185186          OnItemSaved(item, progressBar.Maximum / listView.Items.Count);
     
    192193      if (item != null) {
    193194        if (InvokeRequired)
    194           Invoke(new Action<T, int>(OnItemLoaded), item, progress);
    195         else
     195          Invoke(new Action<T, int>(OnItemSaved), item, progress);
     196        else {
    196197          progressBar.Value += progress;
     198          SetEnabledStateOfContentViews(item, true);
     199        }
    197200      }
    198201    }
     
    203206        Enabled = true;
    204207        infoPanel.Visible = false;
     208      }
     209    }
     210
     211    private void SetEnabledStateOfContentViews(IItem item, bool enabled) {
     212      if (InvokeRequired)
     213        Invoke((Action<IItem, bool>)SetEnabledStateOfContentViews, item, enabled);
     214      else {
     215        var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == item).ToList();
     216        views.ForEach(v => v.Enabled = enabled);
    205217      }
    206218    }
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.Designer.cs

    r3281 r4435  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.valuePanel = new System.Windows.Forms.Panel();
    4847      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    49       this.valuePanel.SuspendLayout();
    5048      this.SuspendLayout();
    51       //
    52       // valuePanel
    53       //
    54       this.valuePanel.AllowDrop = true;
    55       this.valuePanel.Controls.Add(this.viewHost);
    56       this.valuePanel.Dock = System.Windows.Forms.DockStyle.Fill;
    57       this.valuePanel.Location = new System.Drawing.Point(0, 0);
    58       this.valuePanel.Name = "valuePanel";
    59       this.valuePanel.Size = new System.Drawing.Size(359, 274);
    60       this.valuePanel.TabIndex = 0;
    61       this.valuePanel.DragOver += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver);
    62       this.valuePanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragDrop);
    63       this.valuePanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.valuePanel_DragEnterOver);
    6449      //
    6550      // viewHost
    6651      //
     52      this.viewHost.Caption = "View";
    6753      this.viewHost.Content = null;
    6854      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    6955      this.viewHost.Location = new System.Drawing.Point(0, 0);
    7056      this.viewHost.Name = "viewHost";
     57      this.viewHost.ReadOnly = false;
    7158      this.viewHost.Size = new System.Drawing.Size(359, 274);
    7259      this.viewHost.TabIndex = 0;
     
    7764      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    7865      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    79       this.Controls.Add(this.valuePanel);
     66      this.Controls.Add(this.viewHost);
    8067      this.Name = "VariableValueView";
    8168      this.Size = new System.Drawing.Size(359, 274);
    82       this.valuePanel.ResumeLayout(false);
    8369      this.ResumeLayout(false);
    8470
     
    8773    #endregion
    8874
    89     protected HeuristicLab.MainForm.WindowsForms.ViewHost viewHost;
    90     protected System.Windows.Forms.Panel valuePanel;
     75    protected MainForm.WindowsForms.ViewHost viewHost;
     76
    9177  }
    9278}
  • trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.cs

    r4068 r4435  
    7777    }
    7878
    79     protected override void SetEnabledStateOfControls() {
    80       base.SetEnabledStateOfControls();
    81       valuePanel.Enabled = Content != null;
    82     }
    83 
    8479    protected virtual void Content_ValueChanged(object sender, EventArgs e) {
    8580      if (InvokeRequired)
  • 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
  • trunk/sources/HeuristicLab.MainForm/3.3/Interfaces/IView.cs

    r4068 r4435  
    2727    string Caption { get; set; }
    2828    bool ReadOnly { get; set; }
     29    bool Enabled { get; set; }
     30
     31    event EventHandler CaptionChanged;
    2932    event EventHandler ReadOnlyChanged;
    30     event EventHandler CaptionChanged;
     33    event EventHandler EnabledChanged;
    3134    event EventHandler Changed;
    3235
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphView.cs

    r4068 r4435  
    8686        screenshotButton.Enabled = true;
    8787        detailsViewHost.Enabled = true;
    88         connectButton.Enabled = !ReadOnly && !Locked;
     88        connectButton.Enabled = !ReadOnly;
    8989      }
    9090    }
     
    168168        this.initialToolStripMenuItem.Enabled = !ReadOnly && !Locked;
    169169        this.breakPointToolStripMenuItem.Checked = op.Breakpoint;
    170         this.breakPointToolStripMenuItem.Enabled = !Locked;
     170        this.breakPointToolStripMenuItem.Enabled = !ReadOnly && !Locked;
    171171      }
    172172    }
  • trunk/sources/HeuristicLab.Operators.Views/3.3/MultiOperatorView.cs

    r4068 r4435  
    7777    protected override void SetEnabledStateOfControls() {
    7878      base.SetEnabledStateOfControls();
    79       breakpointCheckBox.Enabled = Content != null && !Locked;
     79      breakpointCheckBox.Enabled = Content != null && !ReadOnly;
    8080      operatorListView.Enabled = Content != null;
    8181      parameterCollectionView.Enabled = Content != null;
  • trunk/sources/HeuristicLab.Operators.Views/3.3/OperatorView.cs

    r4068 r4435  
    7474    protected override void SetEnabledStateOfControls() {
    7575      base.SetEnabledStateOfControls();
    76       breakpointCheckBox.Enabled = Content != null && !Locked;
     76      breakpointCheckBox.Enabled = Content != null && !ReadOnly;
    7777    }
    7878
  • trunk/sources/HeuristicLab.Operators.Views/3.3/ValuesCollectorView.cs

    r4068 r4435  
    7777    protected override void SetEnabledStateOfControls() {
    7878      base.SetEnabledStateOfControls();
    79       breakpointCheckBox.Enabled = Content != null && !Locked;
     79      breakpointCheckBox.Enabled = Content != null && !ReadOnly;
    8080      collectedValuesView.Enabled = Content != null;
    8181      parameterCollectionView.Enabled = Content != null;
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultView.cs

    r3904 r4435  
    4545
    4646    public override bool ReadOnly {
    47       get { return base.ReadOnly; }
     47      get { return true; }
    4848      set { /*not needed because results are always readonly */}
    4949    }
     
    5454    public ResultView() {
    5555      InitializeComponent();
    56       base.ReadOnly = true;
    5756    }
    5857
     
    9190      dataTypeTextBox.Enabled = Content != null;
    9291      viewHost.Enabled = Content != null;
     92      viewHost.ReadOnly = this.ReadOnly;
    9393    }
    9494
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionComparisonConstraintView.cs

    r4068 r4435  
    8686    protected override void SetEnabledStateOfControls() {
    8787      base.SetEnabledStateOfControls();
    88       txtConstraintData.ReadOnly = Content == null || this.ReadOnly;
     88      txtConstraintData.Enabled = Content != null;
     89      txtConstraintData.ReadOnly = ReadOnly;
    8990    }
    9091
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintView.cs

    r4152 r4435  
    8383    protected override void SetEnabledStateOfControls() {
    8484      base.SetEnabledStateOfControls();
    85       cmbConstraintColumn.Enabled = !this.ReadOnly && !this.Locked && Content != null;
    86       cmbConstraintOperation.Enabled = !this.ReadOnly && !this.Locked && Content != null;
     85      cmbConstraintColumn.Enabled = !this.ReadOnly && Content != null;
     86      cmbConstraintOperation.Enabled = !this.ReadOnly && Content != null;
    8787      chbActive.Enabled = !this.Locked && Content != null;
    8888    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionEqualityConstraintView.cs

    r4152 r4435  
    4545    protected override void SetEnabledStateOfControls() {
    4646      base.SetEnabledStateOfControls();
    47       txtConstraintData.ReadOnly = Content == null || this.ReadOnly;
     47      txtConstraintData.Enabled = Content != null;
     48      txtConstraintData.ReadOnly = ReadOnly;
    4849    }
    4950
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs

    r4200 r4435  
    3535    public RunCollectionTabularView() {
    3636      InitializeComponent();
    37       base.ReadOnly = true;
    3837    }
    3938
    4039    public override bool ReadOnly {
    41       get { return base.ReadOnly; }
     40      get { return true; }
    4241      set { /*not needed because results are always readonly */}
    4342    }
  • trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs

    r4245 r4435  
    9393        else {
    9494          ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
    95           var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    96           views.ForEach(v => v.ReadOnly = true);
    97           views.ForEach(v => v.Locked = true);
     95          SetEnabledStateOfContentViews(content, false);
    9896          ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted);
    9997        }
     
    120118        if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    121119          ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor();
    122           var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    123           views.ForEach(v => v.ReadOnly = true);
    124           views.ForEach(v => v.Locked = true);
     120          SetEnabledStateOfContentViews(content, false);
    125121          if (saveFileDialog.FilterIndex == 1) {
    126122            ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted);
     
    133129    private static void SavingCompleted(IStorableContent content, Exception error) {
    134130      try {
    135         var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
    136         views.ForEach(v => v.ReadOnly = false);
    137         views.ForEach(v => v.Locked = false);
     131        SetEnabledStateOfContentViews(content, true);
    138132        if (error != null) throw error;
    139133        MainFormManager.GetMainForm<OptimizerMainForm>().UpdateTitle();
     
    146140      }
    147141    }
     142
     143    private static void SetEnabledStateOfContentViews(IStorableContent content, bool enabled) {
     144      OptimizerMainForm mainForm = MainFormManager.GetMainForm<OptimizerMainForm>();
     145      if (mainForm.InvokeRequired)
     146        mainForm.Invoke((Action<IStorableContent, bool>)SetEnabledStateOfContentViews, content, enabled);
     147      else {
     148        var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList();
     149        views.ForEach(v => v.Enabled = enabled);
     150      }
     151    }
    148152  }
    149153}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/ConstantView.cs

    r4068 r4435  
    5858      base.SetEnabledStateOfControls();
    5959      minValueTextBox.Enabled = Content != null;
     60      minValueTextBox.ReadOnly = ReadOnly;
    6061      maxValueTextBox.Enabled = Content != null;
     62      maxValueTextBox.ReadOnly = ReadOnly;
    6163      valueChangeNuTextBox.Enabled = Content != null;
     64      valueChangeNuTextBox.ReadOnly = ReadOnly;
    6265      valueChangeSigmaTextBox.Enabled = Content != null;
     66      valueChangeSigmaTextBox.ReadOnly = ReadOnly;
    6367    }
    6468
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/LaggedVariableView.cs

    r4068 r4435  
    5757      base.SetEnabledStateOfControls();
    5858      minTimeOffsetTextBox.Enabled = Content != null;
     59      minTimeOffsetTextBox.ReadOnly = ReadOnly;
    5960      maxTimeOffsetTextBox.Enabled = Content != null;
     61      maxTimeOffsetTextBox.ReadOnly = ReadOnly;
    6062    }
    6163
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/VariableView.cs

    r4068 r4435  
    5858      base.SetEnabledStateOfControls();
    5959      weightNuTextBox.Enabled = Content != null;
     60      weightNuTextBox.ReadOnly = ReadOnly;
    6061      weightSigmaTextBox.Enabled = Content != null;
     62      weightSigmaTextBox.ReadOnly = ReadOnly;
    6163      weightChangeNuTextBox.Enabled = Content != null;
     64      weightChangeNuTextBox.ReadOnly = ReadOnly;
    6265      weightChangeSigmaTextBox.Enabled = Content != null;
     66      weightChangeSigmaTextBox.ReadOnly = ReadOnly;
    6367    }
    6468
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/PathTSPTourView.cs

    r4373 r4435  
    7171        tourViewHost.Content = Content.Permutation;
    7272      }
    73     }
    74 
    75     protected override void OnReadOnlyChanged() {
    76       base.OnReadOnlyChanged();
    77       SetEnabledStateOfControls();
    7873    }
    7974
Note: See TracChangeset for help on using the changeset viewer.