Changeset 4435
- Timestamp:
- 09/19/10 19:43:05 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r3904 r4435 182 182 try { 183 183 i++; 184 SetEnabledStateOfContentViews(item, false); 184 185 XmlGenerator.Serialize(item, ItemsPath + Path.DirectorySeparatorChar + i.ToString("00000000") + ".hl", 9); 185 186 OnItemSaved(item, progressBar.Maximum / listView.Items.Count); … … 192 193 if (item != null) { 193 194 if (InvokeRequired) 194 Invoke(new Action<T, int>(OnItem Loaded), item, progress);195 else 195 Invoke(new Action<T, int>(OnItemSaved), item, progress); 196 else { 196 197 progressBar.Value += progress; 198 SetEnabledStateOfContentViews(item, true); 199 } 197 200 } 198 201 } … … 203 206 Enabled = true; 204 207 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); 205 217 } 206 218 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.Designer.cs
r3281 r4435 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.valuePanel = new System.Windows.Forms.Panel();48 47 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 49 this.valuePanel.SuspendLayout();50 48 this.SuspendLayout(); 51 //52 // valuePanel53 //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);64 49 // 65 50 // viewHost 66 51 // 52 this.viewHost.Caption = "View"; 67 53 this.viewHost.Content = null; 68 54 this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill; 69 55 this.viewHost.Location = new System.Drawing.Point(0, 0); 70 56 this.viewHost.Name = "viewHost"; 57 this.viewHost.ReadOnly = false; 71 58 this.viewHost.Size = new System.Drawing.Size(359, 274); 72 59 this.viewHost.TabIndex = 0; … … 77 64 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 78 65 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 79 this.Controls.Add(this.v aluePanel);66 this.Controls.Add(this.viewHost); 80 67 this.Name = "VariableValueView"; 81 68 this.Size = new System.Drawing.Size(359, 274); 82 this.valuePanel.ResumeLayout(false);83 69 this.ResumeLayout(false); 84 70 … … 87 73 #endregion 88 74 89 protected HeuristicLab.MainForm.WindowsForms.ViewHost viewHost;90 protected System.Windows.Forms.Panel valuePanel; 75 protected MainForm.WindowsForms.ViewHost viewHost; 76 91 77 } 92 78 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.cs
r4068 r4435 77 77 } 78 78 79 protected override void SetEnabledStateOfControls() {80 base.SetEnabledStateOfControls();81 valuePanel.Enabled = Content != null;82 }83 84 79 protected virtual void Content_ValueChanged(object sender, EventArgs e) { 85 80 if (InvokeRequired) -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ContentView.cs
r4068 r4435 67 67 } else { 68 68 if (value != locked) { 69 this.SuspendRepaint();70 69 locked = value; 71 70 OnLockedChanged(); 72 this.SetEnabledStateOfControls();71 SetEnabledStateOfControls(); 73 72 PropertyInfo prop = typeof(IContentView).GetProperty("Locked"); 74 73 PropagateStateChanges(this, typeof(IContentView), prop); 75 74 OnChanged(); 76 this.ResumeRepaint(true);77 75 } 78 76 } … … 111 109 /// </summary> 112 110 protected override void SetEnabledStateOfControls() { 111 base.SetEnabledStateOfControls(); 112 Enabled = Content != null; 113 113 } 114 114 } -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/View.cs
r4083 r4435 65 65 } else { 66 66 if (value != readOnly) { 67 this.SuspendRepaint();68 67 this.readOnly = value; 69 this.OnReadOnlyChanged();70 this.SetEnabledStateOfControls();68 OnReadOnlyChanged(); 69 SetEnabledStateOfControls(); 71 70 PropertyInfo prop = typeof(IView).GetProperty("ReadOnly"); 72 71 PropagateStateChanges(this, typeof(IView), prop); 73 this.ResumeRepaint(true);72 OnChanged(); 74 73 } 75 74 } 76 75 } 77 76 } 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 78 95 /// <summary> 79 96 /// This method is called if the ReadyOnly property of the View changes to update the controls of the view. … … 160 177 var thisValue = propertyInfo.GetValue(this, null); 161 178 controlPropertyInfo.SetValue(c, thisValue, null); 162 } else 163 PropagateStateChanges(c, type, propertyInfo); 179 } else PropagateStateChanges(c, type, propertyInfo); 164 180 } 165 181 } … … 226 242 } 227 243 228 public new bool Enabled {229 get { return base.Enabled; }230 set {231 SuspendRepaint();232 base.Enabled = value;233 ResumeRepaint(true);234 }235 }236 244 237 245 public void SuspendRepaint() { -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ViewHost.cs
r4418 r4435 61 61 View view = activeView as View; 62 62 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); 63 65 view.OnShown(new ViewShownEventArgs(view, false)); 64 66 Controls.Add(view); 65 67 } 66 68 } else viewType = null; 67 OnActiveViewChanged();68 69 } 69 70 } … … 84 85 OnViewTypeChanged(); 85 86 } 86 }87 }88 89 public new bool Enabled {90 get { return base.Enabled; }91 set {92 base.Enabled = value;93 this.viewsLabel.Enabled = value;94 87 } 95 88 } … … 136 129 IContentView view; 137 130 view = MainFormManager.CreateView(viewType); 131 view.Locked = this.Locked; 138 132 view.ReadOnly = this.ReadOnly; 139 view.Locked = this.Locked;140 133 ActiveView = view; //necessary to allow the views to change the status of the viewhost 141 134 view.Content = Content; … … 145 138 } 146 139 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 158 140 private void RegisterActiveViewEvents() { 159 activeView.Changed += new EventHandler(activeView_Changed);160 141 activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged); 142 activeView.LockedChanged += new EventHandler(activeView_LockedChanged); 161 143 } 162 144 private void DeregisterActiveViewEvents() { 163 activeView.C hanged -= 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); 165 147 } 166 148 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; 178 153 } 179 154 -
trunk/sources/HeuristicLab.MainForm/3.3/Interfaces/IView.cs
r4068 r4435 27 27 string Caption { get; set; } 28 28 bool ReadOnly { get; set; } 29 bool Enabled { get; set; } 30 31 event EventHandler CaptionChanged; 29 32 event EventHandler ReadOnlyChanged; 30 event EventHandler CaptionChanged;33 event EventHandler EnabledChanged; 31 34 event EventHandler Changed; 32 35 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphView.cs
r4068 r4435 86 86 screenshotButton.Enabled = true; 87 87 detailsViewHost.Enabled = true; 88 connectButton.Enabled = !ReadOnly && !Locked;88 connectButton.Enabled = !ReadOnly; 89 89 } 90 90 } … … 168 168 this.initialToolStripMenuItem.Enabled = !ReadOnly && !Locked; 169 169 this.breakPointToolStripMenuItem.Checked = op.Breakpoint; 170 this.breakPointToolStripMenuItem.Enabled = ! Locked;170 this.breakPointToolStripMenuItem.Enabled = !ReadOnly && !Locked; 171 171 } 172 172 } -
trunk/sources/HeuristicLab.Operators.Views/3.3/MultiOperatorView.cs
r4068 r4435 77 77 protected override void SetEnabledStateOfControls() { 78 78 base.SetEnabledStateOfControls(); 79 breakpointCheckBox.Enabled = Content != null && ! Locked;79 breakpointCheckBox.Enabled = Content != null && !ReadOnly; 80 80 operatorListView.Enabled = Content != null; 81 81 parameterCollectionView.Enabled = Content != null; -
trunk/sources/HeuristicLab.Operators.Views/3.3/OperatorView.cs
r4068 r4435 74 74 protected override void SetEnabledStateOfControls() { 75 75 base.SetEnabledStateOfControls(); 76 breakpointCheckBox.Enabled = Content != null && ! Locked;76 breakpointCheckBox.Enabled = Content != null && !ReadOnly; 77 77 } 78 78 -
trunk/sources/HeuristicLab.Operators.Views/3.3/ValuesCollectorView.cs
r4068 r4435 77 77 protected override void SetEnabledStateOfControls() { 78 78 base.SetEnabledStateOfControls(); 79 breakpointCheckBox.Enabled = Content != null && ! Locked;79 breakpointCheckBox.Enabled = Content != null && !ReadOnly; 80 80 collectedValuesView.Enabled = Content != null; 81 81 parameterCollectionView.Enabled = Content != null; -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultView.cs
r3904 r4435 45 45 46 46 public override bool ReadOnly { 47 get { return base.ReadOnly; }47 get { return true; } 48 48 set { /*not needed because results are always readonly */} 49 49 } … … 54 54 public ResultView() { 55 55 InitializeComponent(); 56 base.ReadOnly = true;57 56 } 58 57 … … 91 90 dataTypeTextBox.Enabled = Content != null; 92 91 viewHost.Enabled = Content != null; 92 viewHost.ReadOnly = this.ReadOnly; 93 93 } 94 94 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionComparisonConstraintView.cs
r4068 r4435 86 86 protected override void SetEnabledStateOfControls() { 87 87 base.SetEnabledStateOfControls(); 88 txtConstraintData.ReadOnly = Content == null || this.ReadOnly; 88 txtConstraintData.Enabled = Content != null; 89 txtConstraintData.ReadOnly = ReadOnly; 89 90 } 90 91 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintView.cs
r4152 r4435 83 83 protected override void SetEnabledStateOfControls() { 84 84 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; 87 87 chbActive.Enabled = !this.Locked && Content != null; 88 88 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionEqualityConstraintView.cs
r4152 r4435 45 45 protected override void SetEnabledStateOfControls() { 46 46 base.SetEnabledStateOfControls(); 47 txtConstraintData.ReadOnly = Content == null || this.ReadOnly; 47 txtConstraintData.Enabled = Content != null; 48 txtConstraintData.ReadOnly = ReadOnly; 48 49 } 49 50 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs
r4200 r4435 35 35 public RunCollectionTabularView() { 36 36 InitializeComponent(); 37 base.ReadOnly = true;38 37 } 39 38 40 39 public override bool ReadOnly { 41 get { return base.ReadOnly; }40 get { return true; } 42 41 set { /*not needed because results are always readonly */} 43 42 } -
trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs
r4245 r4435 93 93 else { 94 94 ((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); 98 96 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted); 99 97 } … … 120 118 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 121 119 ((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); 125 121 if (saveFileDialog.FilterIndex == 1) { 126 122 ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted); … … 133 129 private static void SavingCompleted(IStorableContent content, Exception error) { 134 130 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); 138 132 if (error != null) throw error; 139 133 MainFormManager.GetMainForm<OptimizerMainForm>().UpdateTitle(); … … 146 140 } 147 141 } 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 } 148 152 } 149 153 } -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/ConstantView.cs
r4068 r4435 58 58 base.SetEnabledStateOfControls(); 59 59 minValueTextBox.Enabled = Content != null; 60 minValueTextBox.ReadOnly = ReadOnly; 60 61 maxValueTextBox.Enabled = Content != null; 62 maxValueTextBox.ReadOnly = ReadOnly; 61 63 valueChangeNuTextBox.Enabled = Content != null; 64 valueChangeNuTextBox.ReadOnly = ReadOnly; 62 65 valueChangeSigmaTextBox.Enabled = Content != null; 66 valueChangeSigmaTextBox.ReadOnly = ReadOnly; 63 67 } 64 68 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/LaggedVariableView.cs
r4068 r4435 57 57 base.SetEnabledStateOfControls(); 58 58 minTimeOffsetTextBox.Enabled = Content != null; 59 minTimeOffsetTextBox.ReadOnly = ReadOnly; 59 60 maxTimeOffsetTextBox.Enabled = Content != null; 61 maxTimeOffsetTextBox.ReadOnly = ReadOnly; 60 62 } 61 63 -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/Symbolic/Symbols/VariableView.cs
r4068 r4435 58 58 base.SetEnabledStateOfControls(); 59 59 weightNuTextBox.Enabled = Content != null; 60 weightNuTextBox.ReadOnly = ReadOnly; 60 61 weightSigmaTextBox.Enabled = Content != null; 62 weightSigmaTextBox.ReadOnly = ReadOnly; 61 63 weightChangeNuTextBox.Enabled = Content != null; 64 weightChangeNuTextBox.ReadOnly = ReadOnly; 62 65 weightChangeSigmaTextBox.Enabled = Content != null; 66 weightChangeSigmaTextBox.ReadOnly = ReadOnly; 63 67 } 64 68 -
trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/PathTSPTourView.cs
r4373 r4435 71 71 tourViewHost.Content = Content.Permutation; 72 72 } 73 }74 75 protected override void OnReadOnlyChanged() {76 base.OnReadOnlyChanged();77 SetEnabledStateOfControls();78 73 } 79 74
Note: See TracChangeset
for help on using the changeset viewer.