Changeset 15081 for stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation
- Timestamp:
- 06/28/17 22:10:45 (7 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13501,13503,13511,13513,13534-13535,13540,13550,13552,13593,13666
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.Designer.cs
r14186 r15081 49 49 this.refreshButton = new System.Windows.Forms.Button(); 50 50 this.cloneProblemButton = new System.Windows.Forms.Button(); 51 this.tabControl = new System.Windows.Forms.TabControl(); 52 this.parametersTabPage = new System.Windows.Forms.TabPage(); 51 53 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 54 this.flaAnalysisTabPage = new System.Windows.Forms.TabPage(); 55 this.calculateButton = new System.Windows.Forms.Button(); 56 this.flaSplitContainer = new System.Windows.Forms.SplitContainer(); 57 this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView(); 58 this.uploadCharacteristicsButton = new System.Windows.Forms.Button(); 59 this.downloadCharacteristicsButton = new System.Windows.Forms.Button(); 52 60 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 61 this.tabControl.SuspendLayout(); 62 this.parametersTabPage.SuspendLayout(); 63 this.flaAnalysisTabPage.SuspendLayout(); 64 ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).BeginInit(); 65 this.flaSplitContainer.Panel1.SuspendLayout(); 66 this.flaSplitContainer.Panel2.SuspendLayout(); 67 this.flaSplitContainer.SuspendLayout(); 53 68 this.SuspendLayout(); 54 69 // … … 58 73 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 59 74 this.nameTextBox.Location = new System.Drawing.Point(72, 27); 60 this.nameTextBox.Size = new System.Drawing.Size(6 04, 20);75 this.nameTextBox.Size = new System.Drawing.Size(640, 20); 61 76 this.nameTextBox.TabIndex = 5; 62 77 // … … 68 83 // infoLabel 69 84 // 70 this.infoLabel.Location = new System.Drawing.Point( 687, 30);85 this.infoLabel.Location = new System.Drawing.Point(723, 30); 71 86 this.infoLabel.TabIndex = 6; 72 87 // 73 88 // problemComboBox 74 89 // 75 this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 76 90 this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 91 | System.Windows.Forms.AnchorStyles.Right))); 77 92 this.problemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 78 93 this.problemComboBox.FormattingEnabled = true; 79 94 this.problemComboBox.Location = new System.Drawing.Point(72, 0); 80 95 this.problemComboBox.Name = "problemComboBox"; 81 this.problemComboBox.Size = new System.Drawing.Size( 574, 21);96 this.problemComboBox.Size = new System.Drawing.Size(610, 21); 82 97 this.problemComboBox.TabIndex = 1; 83 98 this.problemComboBox.SelectedValueChanged += new System.EventHandler(this.problemComboBox_SelectedValueChanged); … … 95 110 // 96 111 this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 97 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 98 this.refreshButton.Location = new System.Drawing.Point(682, -1); 112 this.refreshButton.Location = new System.Drawing.Point(718, -1); 99 113 this.refreshButton.Name = "refreshButton"; 100 114 this.refreshButton.Size = new System.Drawing.Size(24, 24); … … 107 121 // 108 122 this.cloneProblemButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 109 this.cloneProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Clone; 110 this.cloneProblemButton.Location = new System.Drawing.Point(652, -1); 123 this.cloneProblemButton.Location = new System.Drawing.Point(688, -1); 111 124 this.cloneProblemButton.Name = "cloneProblemButton"; 112 125 this.cloneProblemButton.Size = new System.Drawing.Size(24, 24); … … 116 129 this.cloneProblemButton.Click += new System.EventHandler(this.cloneProblemButton_Click); 117 130 // 131 // tabControl 132 // 133 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 134 | System.Windows.Forms.AnchorStyles.Left) 135 | System.Windows.Forms.AnchorStyles.Right))); 136 this.tabControl.Controls.Add(this.parametersTabPage); 137 this.tabControl.Controls.Add(this.flaAnalysisTabPage); 138 this.tabControl.Location = new System.Drawing.Point(6, 53); 139 this.tabControl.Name = "tabControl"; 140 this.tabControl.SelectedIndex = 0; 141 this.tabControl.Size = new System.Drawing.Size(736, 473); 142 this.tabControl.TabIndex = 8; 143 // 144 // parametersTabPage 145 // 146 this.parametersTabPage.Controls.Add(this.parameterCollectionView); 147 this.parametersTabPage.Location = new System.Drawing.Point(4, 22); 148 this.parametersTabPage.Name = "parametersTabPage"; 149 this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3); 150 this.parametersTabPage.Size = new System.Drawing.Size(692, 314); 151 this.parametersTabPage.TabIndex = 0; 152 this.parametersTabPage.Text = "Parameters"; 153 this.parametersTabPage.UseVisualStyleBackColor = true; 154 // 118 155 // parameterCollectionView 119 156 // 120 157 this.parameterCollectionView.AllowEditingOfHiddenParameters = false; 121 this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)122 | System.Windows.Forms.AnchorStyles.Left)123 | System.Windows.Forms.AnchorStyles.Right)));124 158 this.parameterCollectionView.Caption = "ParameterCollection View"; 125 159 this.parameterCollectionView.Content = null; 126 this.parameterCollectionView.Location = new System.Drawing.Point(0, 53); 160 this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill; 161 this.parameterCollectionView.Location = new System.Drawing.Point(3, 3); 127 162 this.parameterCollectionView.Name = "parameterCollectionView"; 128 this.parameterCollectionView.ReadOnly = false; 129 this.parameterCollectionView.Size = new System.Drawing.Size(706, 340); 130 this.parameterCollectionView.TabIndex = 7; 163 this.parameterCollectionView.ReadOnly = true; 164 this.parameterCollectionView.ShowDetails = true; 165 this.parameterCollectionView.Size = new System.Drawing.Size(686, 308); 166 this.parameterCollectionView.TabIndex = 8; 167 // 168 // flaAnalysisTabPage 169 // 170 this.flaAnalysisTabPage.Controls.Add(this.flaSplitContainer); 171 this.flaAnalysisTabPage.Location = new System.Drawing.Point(4, 22); 172 this.flaAnalysisTabPage.Name = "flaAnalysisTabPage"; 173 this.flaAnalysisTabPage.Padding = new System.Windows.Forms.Padding(3); 174 this.flaAnalysisTabPage.Size = new System.Drawing.Size(728, 447); 175 this.flaAnalysisTabPage.TabIndex = 2; 176 this.flaAnalysisTabPage.Text = "Fitness Landscape Analysis"; 177 this.flaAnalysisTabPage.UseVisualStyleBackColor = true; 178 // 179 // calculateButton 180 // 181 this.calculateButton.Location = new System.Drawing.Point(3, 3); 182 this.calculateButton.Name = "calculateButton"; 183 this.calculateButton.Size = new System.Drawing.Size(26, 23); 184 this.calculateButton.TabIndex = 8; 185 this.calculateButton.Text = "Calculate"; 186 this.calculateButton.UseVisualStyleBackColor = true; 187 this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click); 188 // 189 // flaSplitContainer 190 // 191 this.flaSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 192 this.flaSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; 193 this.flaSplitContainer.Location = new System.Drawing.Point(3, 3); 194 this.flaSplitContainer.Name = "flaSplitContainer"; 195 // 196 // flaSplitContainer.Panel1 197 // 198 this.flaSplitContainer.Panel1.Controls.Add(this.calculateButton); 199 // 200 // flaSplitContainer.Panel2 201 // 202 this.flaSplitContainer.Panel2.Controls.Add(this.characteristicsMatrixView); 203 this.flaSplitContainer.Panel2.Controls.Add(this.uploadCharacteristicsButton); 204 this.flaSplitContainer.Panel2.Controls.Add(this.downloadCharacteristicsButton); 205 this.flaSplitContainer.Size = new System.Drawing.Size(722, 441); 206 this.flaSplitContainer.SplitterDistance = 363; 207 this.flaSplitContainer.TabIndex = 7; 208 // 209 // characteristicsMatrixView 210 // 211 this.characteristicsMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 212 | System.Windows.Forms.AnchorStyles.Left) 213 | System.Windows.Forms.AnchorStyles.Right))); 214 this.characteristicsMatrixView.Caption = "StringConvertibleMatrix View"; 215 this.characteristicsMatrixView.Content = null; 216 this.characteristicsMatrixView.Location = new System.Drawing.Point(3, 32); 217 this.characteristicsMatrixView.Name = "characteristicsMatrixView"; 218 this.characteristicsMatrixView.ReadOnly = false; 219 this.characteristicsMatrixView.ShowRowsAndColumnsTextBox = false; 220 this.characteristicsMatrixView.ShowStatisticalInformation = false; 221 this.characteristicsMatrixView.Size = new System.Drawing.Size(349, 406); 222 this.characteristicsMatrixView.TabIndex = 4; 223 // 224 // uploadCharacteristicsButton 225 // 226 this.uploadCharacteristicsButton.Location = new System.Drawing.Point(35, 3); 227 this.uploadCharacteristicsButton.Name = "uploadCharacteristicsButton"; 228 this.uploadCharacteristicsButton.Size = new System.Drawing.Size(26, 23); 229 this.uploadCharacteristicsButton.TabIndex = 5; 230 this.uploadCharacteristicsButton.Text = "Upload"; 231 this.uploadCharacteristicsButton.UseVisualStyleBackColor = true; 232 this.uploadCharacteristicsButton.Click += new System.EventHandler(this.uploadCharacteristicsButton_Click); 233 // 234 // downloadCharacteristicsButton 235 // 236 this.downloadCharacteristicsButton.Location = new System.Drawing.Point(3, 3); 237 this.downloadCharacteristicsButton.Name = "downloadCharacteristicsButton"; 238 this.downloadCharacteristicsButton.Size = new System.Drawing.Size(26, 23); 239 this.downloadCharacteristicsButton.TabIndex = 6; 240 this.downloadCharacteristicsButton.Text = "Download"; 241 this.downloadCharacteristicsButton.UseVisualStyleBackColor = true; 242 this.downloadCharacteristicsButton.Click += new System.EventHandler(this.downloadCharacteristicsButton_Click); 131 243 // 132 244 // OKBProblemView … … 134 246 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 135 247 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 248 this.Controls.Add(this.tabControl); 136 249 this.Controls.Add(this.problemComboBox); 137 this.Controls.Add(this.parameterCollectionView);138 250 this.Controls.Add(this.problemLabel); 139 251 this.Controls.Add(this.cloneProblemButton); 140 252 this.Controls.Add(this.refreshButton); 141 253 this.Name = "OKBProblemView"; 142 this.Size = new System.Drawing.Size(7 06, 393);254 this.Size = new System.Drawing.Size(742, 526); 143 255 this.Controls.SetChildIndex(this.refreshButton, 0); 144 256 this.Controls.SetChildIndex(this.cloneProblemButton, 0); 145 257 this.Controls.SetChildIndex(this.problemLabel, 0); 146 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 258 this.Controls.SetChildIndex(this.problemComboBox, 0); 259 this.Controls.SetChildIndex(this.tabControl, 0); 147 260 this.Controls.SetChildIndex(this.nameTextBox, 0); 148 261 this.Controls.SetChildIndex(this.nameLabel, 0); 149 262 this.Controls.SetChildIndex(this.infoLabel, 0); 150 this.Controls.SetChildIndex(this.problemComboBox, 0);151 263 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 264 this.tabControl.ResumeLayout(false); 265 this.parametersTabPage.ResumeLayout(false); 266 this.flaAnalysisTabPage.ResumeLayout(false); 267 this.flaSplitContainer.Panel1.ResumeLayout(false); 268 this.flaSplitContainer.Panel2.ResumeLayout(false); 269 ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).EndInit(); 270 this.flaSplitContainer.ResumeLayout(false); 152 271 this.ResumeLayout(false); 153 272 this.PerformLayout(); … … 161 280 private System.Windows.Forms.Button refreshButton; 162 281 private System.Windows.Forms.Button cloneProblemButton; 163 private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView; 282 private System.Windows.Forms.TabControl tabControl; 283 private System.Windows.Forms.TabPage parametersTabPage; 284 private Core.Views.ParameterCollectionView parameterCollectionView; 285 private System.Windows.Forms.TabPage flaAnalysisTabPage; 286 private System.Windows.Forms.Button calculateButton; 287 private System.Windows.Forms.SplitContainer flaSplitContainer; 288 private Data.Views.StringConvertibleMatrixView characteristicsMatrixView; 289 private System.Windows.Forms.Button uploadCharacteristicsButton; 290 private System.Windows.Forms.Button downloadCharacteristicsButton; 164 291 165 292 -
stable/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs
r14186 r15081 20 20 #endregion 21 21 22 using HeuristicLab.Common.Resources; 23 using HeuristicLab.Core; 24 using HeuristicLab.Core.Views; 25 using HeuristicLab.Data; 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Optimization; 28 using HeuristicLab.PluginInfrastructure; 22 29 using System; 30 using System.Collections.Generic; 31 using System.Drawing; 23 32 using System.Linq; 24 33 using System.Windows.Forms; 25 using HeuristicLab.Core.Views;26 using HeuristicLab.MainForm;27 34 28 35 namespace HeuristicLab.Clients.OKB.RunCreation { … … 31 38 [Content(typeof(MultiObjectiveOKBProblem), true)] 32 39 public sealed partial class OKBProblemView : NamedItemView { 40 private readonly CheckedItemList<ICharacteristicCalculator> calculatorList; 41 33 42 public new OKBProblem Content { 34 43 get { return (OKBProblem)base.Content; } … … 38 47 public OKBProblemView() { 39 48 InitializeComponent(); 49 var calculatorListView = new CheckedItemListView<ICharacteristicCalculator>() { 50 Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top, 51 Location = new Point(flaSplitContainer.Padding.Left, calculateButton.Location.Y + calculateButton.Height + calculateButton.Padding.Bottom + 3), 52 }; 53 calculatorListView.Size = new Size(flaSplitContainer.Panel1.Size.Width - flaSplitContainer.Panel1.Padding.Horizontal, 54 flaSplitContainer.Panel1.Height - calculatorListView.Location.Y - flaSplitContainer.Panel1.Padding.Bottom); 55 calculatorList = new CheckedItemList<ICharacteristicCalculator>(); 56 calculatorList.ItemsAdded += CalculatorListOnChanged; 57 calculatorList.ItemsRemoved += CalculatorListOnChanged; 58 calculatorList.ItemsReplaced += CalculatorListOnChanged; 59 calculatorList.CollectionReset += CalculatorListOnChanged; 60 calculatorList.CheckedItemsChanged += CalculatorListOnChanged; 61 62 calculatorListView.Content = calculatorList.AsReadOnly(); 63 64 flaSplitContainer.Panel1.Controls.Add(calculatorListView); 65 calculateButton.Text = string.Empty; 66 calculateButton.Image = VSImageLibrary.Play; 67 refreshButton.Text = string.Empty; 68 refreshButton.Image = VSImageLibrary.Refresh; 69 cloneProblemButton.Text = string.Empty; 70 cloneProblemButton.Image = VSImageLibrary.Clone; 71 downloadCharacteristicsButton.Text = string.Empty; 72 downloadCharacteristicsButton.Image = VSImageLibrary.Refresh; 73 uploadCharacteristicsButton.Text = string.Empty; 74 uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb; 75 } 76 77 private void CalculatorListOnChanged(object sender, EventArgs e) { 78 SetEnabledStateOfControls(); 40 79 } 41 80 … … 65 104 parameterCollectionView.Content = Content.Parameters; 66 105 } 106 UpdateCharacteristicCalculators(); 67 107 } 68 108 … … 73 113 refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked; 74 114 parameterCollectionView.Enabled = Content != null; 115 characteristicsMatrixView.Enabled = Content != null; 116 downloadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked; 117 uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly 118 && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0; 119 calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorList.CheckedItems.Any(); 75 120 } 76 121 … … 79 124 RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed); 80 125 base.OnClosed(e); 126 } 127 128 private void UpdateCharacteristicCalculators() { 129 calculatorList.Clear(); 130 if (Content == null || Content.ProblemId == -1) return; 131 var problem = Content.CloneProblem(); 132 var calculators = ApplicationManager.Manager.GetInstances<ICharacteristicCalculator>().ToList(); 133 foreach (var calc in calculators) { 134 calc.Problem = problem; 135 if (!calc.CanCalculate()) continue; 136 calculatorList.Add(calc, true); 137 } 81 138 } 82 139 … … 103 160 if (InvokeRequired) 104 161 Invoke(new EventHandler(Content_ProblemChanged), sender, e); 105 else 162 else { 106 163 OnContentChanged(); 164 SetEnabledStateOfControls(); 165 } 107 166 } 108 167 #endregion … … 123 182 } 124 183 } 184 private void downloadCharacteristicsButton_Click(object sender, EventArgs e) { 185 var values = RunCreationClient.GetCharacteristicValues(Content.ProblemId).ToList(); 186 var content = new StringMatrix(values.Count, 3); 187 for (var i = 0; i < values.Count; i++) { 188 content[i, 0] = values[i].Name; 189 content[i, 1] = values[i].GetValue(); 190 content[i, 2] = values[i].GetType().Name; 191 } 192 characteristicsMatrixView.Content = content; 193 SetEnabledStateOfControls(); 194 } 195 private void uploadCharacteristicsButton_Click(object sender, EventArgs e) { 196 var matrix = characteristicsMatrixView.Content as StringMatrix; 197 if (matrix == null) return; 198 var values = new List<Value>(matrix.Rows); 199 for (var i = 0; i < matrix.Rows; i++) { 200 var name = matrix[i, 0]; 201 var strValue = matrix[i, 1]; 202 var type = matrix[i, 2]; 203 values.Add(Value.Create(name, strValue, type)); 204 } 205 try { 206 RunCreationClient.SetCharacteristicValues(Content.ProblemId, values); 207 } catch (Exception ex) { ErrorHandling.ShowErrorDialog(ex); } 208 } 209 private void calculateButton_Click(object sender, EventArgs e) { 210 var calculators = calculatorList.CheckedItems.Select(x => x.Value).Where(x => x.CanCalculate()).ToList(); 211 if (calculators.Count == 0) return; 212 213 var results = new Dictionary<string, Value>(); 214 foreach (var calc in calculators) { 215 foreach (var result in calc.Calculate()) 216 results[result.Name] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Name); 217 } 218 var matrix = (characteristicsMatrixView.Content as StringMatrix) ?? (new StringMatrix(results.Count, 3)); 219 for (var i = 0; i < matrix.Rows; i++) { 220 Value r; 221 if (results.TryGetValue(matrix[i, 0], out r)) { 222 matrix[i, 1] = r.GetValue(); 223 matrix[i, 2] = r.GetType().Name; 224 results.Remove(matrix[i, 0]); 225 } 226 } 227 if (results.Count == 0) return; 228 var resultsList = results.ToList(); 229 var counter = resultsList.Count - 1; 230 for (var i = 0; i < matrix.Rows; i++) { 231 if (string.IsNullOrEmpty(matrix[i, 0])) { 232 matrix[i, 0] = resultsList[counter].Key; 233 matrix[i, 1] = resultsList[counter].Value.GetValue(); 234 matrix[i, 2] = resultsList[counter].Value.GetType().Name; 235 resultsList.RemoveAt(counter); 236 counter--; 237 if (counter < 0) return; 238 } 239 } 240 if (counter >= 0) { 241 ((IStringConvertibleMatrix)matrix).Rows += counter + 1; 242 for (var i = matrix.Rows - 1; counter >= 0; i--) { 243 matrix[i, 0] = resultsList[0].Key; 244 matrix[i, 1] = resultsList[0].Value.GetValue(); 245 matrix[i, 2] = resultsList[0].Value.GetType().Name; 246 resultsList.RemoveAt(0); 247 counter--; 248 } 249 } 250 characteristicsMatrixView.Content = matrix; 251 SetEnabledStateOfControls(); 252 } 125 253 #endregion 126 254 … … 132 260 } 133 261 #endregion 262 134 263 } 135 264 }
Note: See TracChangeset
for help on using the changeset viewer.