Changeset 13691 for trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs
- Timestamp:
- 03/11/16 15:29:05 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs
r13684 r13691 73 73 uploadCharacteristicsButton.Text = string.Empty; 74 74 uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb; 75 refreshSolutionsButton.Text = string.Empty; 76 refreshSolutionsButton.Image = VSImageLibrary.Refresh; 77 uploadSolutionsButton.Text = string.Empty; 78 uploadSolutionsButton.Image = VSImageLibrary.PublishToWeb; 75 79 } 76 80 … … 93 97 base.RegisterContentEvents(); 94 98 Content.ProblemChanged += new EventHandler(Content_ProblemChanged); 99 Content.Solutions.ItemsAdded += SolutionsOnChanged; 100 Content.Solutions.ItemsReplaced += SolutionsOnChanged; 101 Content.Solutions.ItemsRemoved += SolutionsOnChanged; 102 Content.Solutions.CollectionReset += SolutionsOnChanged; 103 } 104 105 private void SolutionsOnChanged(object sender, EventArgs e) { 106 SetEnabledStateOfControls(); 95 107 } 96 108 … … 100 112 problemComboBox.SelectedIndex = -1; 101 113 parameterCollectionView.Content = null; 114 solutionsViewHost.Content = null; 102 115 } else { 103 116 problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId); 104 117 parameterCollectionView.Content = Content.Parameters; 118 solutionsViewHost.Content = Content.Solutions; 105 119 } 106 120 UpdateCharacteristicCalculators(); … … 118 132 && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0; 119 133 calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorList.CheckedItems.Any(); 134 refreshSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1; 135 uploadSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1 && Content.Solutions.Any(x => x.SolutionId == -1); 120 136 } 121 137 … … 217 233 } 218 234 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]); 235 try { 236 for (var i = 0; i < matrix.Rows; i++) { 237 Value r; 238 if (results.TryGetValue(matrix[i, 0], out r)) { 239 matrix[i, 1] = r.GetValue(); 240 matrix[i, 2] = r.GetType().Name; 241 results.Remove(matrix[i, 0]); 242 } 225 243 } 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;244 if (results.Count == 0) return; 245 var resultsList = results.ToList(); 246 var counter = resultsList.Count - 1; 247 for (var i = 0; i < matrix.Rows; i++) { 248 if (string.IsNullOrEmpty(matrix[i, 0])) { 249 matrix[i, 0] = resultsList[counter].Key; 250 matrix[i, 1] = resultsList[counter].Value.GetValue(); 251 matrix[i, 2] = resultsList[counter].Value.GetType().Name; 252 resultsList.RemoveAt(counter); 253 counter--; 254 if (counter < 0) return; 255 } 238 256 } 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--;257 if (counter >= 0) { 258 ((IStringConvertibleMatrix)matrix).Rows += counter + 1; 259 for (var i = matrix.Rows - 1; counter >= 0; i--) { 260 matrix[i, 0] = resultsList[0].Key; 261 matrix[i, 1] = resultsList[0].Value.GetValue(); 262 matrix[i, 2] = resultsList[0].Value.GetType().Name; 263 resultsList.RemoveAt(0); 264 counter--; 265 } 248 266 } 249 } 250 characteristicsMatrixView.Content = matrix; 251 SetEnabledStateOfControls(); 267 } finally { 268 characteristicsMatrixView.Content = matrix; 269 SetEnabledStateOfControls(); 270 } 252 271 } 253 272 #endregion … … 261 280 #endregion 262 281 282 private void refreshSolutionsButton_Click(object sender, EventArgs e) { 283 Content.RefreshSolutions(); 284 } 285 286 private void uploadSolutionsButton_Click(object sender, EventArgs e) { 287 foreach (var solution in Content.Solutions.Where(x => x.SolutionId == -1)) 288 solution.Upload(); 289 } 290 263 291 } 264 292 }
Note: See TracChangeset
for help on using the changeset viewer.