Changeset 6693
- Timestamp:
- 09/01/11 15:51:30 (13 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r6673 r6693 128 128 <DependentUpon>BatchRunView.cs</DependentUpon> 129 129 </Compile> 130 <Compile Include="RunCollectionModifierListView.cs"> 131 <SubType>UserControl</SubType> 132 </Compile> 133 <Compile Include="RunCollectionModifierListView.Designer.cs"> 134 <DependentUpon>RunCollectionModifierListView.cs</DependentUpon> 135 </Compile> 130 136 <Compile Include="RunCollectionContentConstraintView.cs"> 131 137 <SubType>UserControl</SubType> -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs
r5744 r6693 65 65 this.constraintPage = new System.Windows.Forms.TabPage(); 66 66 this.runCollectionConstraintCollectionView = new HeuristicLab.Optimization.Views.RunCollectionConstraintCollectionView(); 67 this.modifiersPage = new System.Windows.Forms.TabPage(); 68 this.runCollectionModifiersListView = new HeuristicLab.Optimization.Views.RunCollectionModifiersListView(); 67 69 this.splitContainer.Panel1.SuspendLayout(); 68 70 this.splitContainer.Panel2.SuspendLayout(); … … 74 76 this.runPage.SuspendLayout(); 75 77 this.constraintPage.SuspendLayout(); 78 this.modifiersPage.SuspendLayout(); 76 79 this.SuspendLayout(); 77 80 // … … 235 238 this.tabControl.Controls.Add(this.runPage); 236 239 this.tabControl.Controls.Add(this.constraintPage); 240 this.tabControl.Controls.Add(this.modifiersPage); 237 241 this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill; 238 242 this.tabControl.Location = new System.Drawing.Point(0, 0); … … 274 278 this.runCollectionConstraintCollectionView.Size = new System.Drawing.Size(518, 351); 275 279 this.runCollectionConstraintCollectionView.TabIndex = 0; 280 // 281 // modifiersPage 282 // 283 this.modifiersPage.Controls.Add(this.runCollectionModifiersListView); 284 this.modifiersPage.Location = new System.Drawing.Point(4, 22); 285 this.modifiersPage.Name = "modifiersPage"; 286 this.modifiersPage.Padding = new System.Windows.Forms.Padding(3); 287 this.modifiersPage.Size = new System.Drawing.Size(524, 357); 288 this.modifiersPage.TabIndex = 2; 289 this.modifiersPage.Text = "Modification"; 290 this.modifiersPage.UseVisualStyleBackColor = true; 291 // 292 // runCollectionModifiersListView 293 // 294 this.runCollectionModifiersListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 295 | System.Windows.Forms.AnchorStyles.Left) 296 | System.Windows.Forms.AnchorStyles.Right))); 297 this.runCollectionModifiersListView.Caption = "Modifier View"; 298 this.runCollectionModifiersListView.Content = null; 299 this.runCollectionModifiersListView.Location = new System.Drawing.Point(3, 6); 300 this.runCollectionModifiersListView.Name = "runCollectionModifiersListView"; 301 this.runCollectionModifiersListView.ReadOnly = false; 302 this.runCollectionModifiersListView.Size = new System.Drawing.Size(515, 345); 303 this.runCollectionModifiersListView.TabIndex = 0; 276 304 // 277 305 // RunCollectionView … … 291 319 this.runPage.ResumeLayout(false); 292 320 this.constraintPage.ResumeLayout(false); 321 this.modifiersPage.ResumeLayout(false); 293 322 this.ResumeLayout(false); 294 323 … … 314 343 private Button clearButton; 315 344 private CheckBox showDetailsCheckBox; 345 private TabPage modifiersPage; 346 private RunCollectionModifiersListView runCollectionModifiersListView; 316 347 } 317 348 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r6664 r6693 58 58 itemsGroupBox.Text = "Runs"; 59 59 itemListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>(); 60 runCollectionModifiersListView.Evaluator = EvaluateModifications; 60 61 } 61 62 … … 98 99 } 99 100 } 100 var modifierMenuItem = new ToolStripMenuItem();101 modifierMenuItem.Text = "Modify RunCollection";102 modifierMenuItem.Click += ModifierMenuItem_OnClick;103 analyzeRunsToolStripDropDownButton.DropDownItems.Add(modifierMenuItem);104 101 } 105 102 … … 122 119 runCollectionConstraintCollectionView.Content = RunCollection.Constraints; 123 120 runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0; 121 if (!tabControl.TabPages.Contains(modifiersPage)) 122 tabControl.TabPages.Add(modifiersPage); 123 runCollectionModifiersListView.Content = RunCollection.Modifiers; 124 124 } 125 125 foreach (IRun item in Content) { … … 134 134 if (tabControl.TabPages.Contains(constraintPage)) 135 135 tabControl.TabPages.Remove(constraintPage); 136 if (tabControl.TabPages.Contains(modifiersPage)) 137 tabControl.TabPages.Remove(modifiersPage); 136 138 } 137 139 } … … 340 342 } 341 343 } 342 private void ModifierMenuItem_OnClick(object sender, EventArgs args) {343 var modifier = new RunCollectionModificationEvaluator();344 modifier.RunCollection.AddRange(Content.Select(r => (IRun)r.Clone()));345 MainFormManager.MainForm.ShowContent(modifier);346 }347 344 private void removeButton_Click(object sender, EventArgs e) { 348 345 if (itemsListView.SelectedItems.Count > 0) { … … 357 354 #endregion 358 355 359 #region C heckBoxEvents356 #region Control Events 360 357 private void showDetailsCheckBox_CheckedChanged(object sender, EventArgs e) { 361 358 if (showDetailsCheckBox.Checked) { … … 368 365 } 369 366 } 367 private void EvaluateModifications() { 368 if (RunCollection == null) 369 return; 370 ReadOnly = true; 371 try { 372 RunCollection.Modify(); 373 } finally { 374 ReadOnly = false; 375 } 376 } 370 377 #endregion 371 378 -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs
r5445 r6693 51 51 52 52 constraints = new RunCollectionConstraintCollection(original.constraints.Select(x => cloner.Clone(x))); 53 modifiers = new CheckedItemList<IRunCollectionModifier>(original.modifiers.Select(cloner.Clone)); 53 54 foreach (IRunCollectionConstraint constraint in constraints) 54 55 constraint.ConstrainedValue = this; … … 67 68 dataTypes = new Dictionary<string, HashSet<Type>>(); 68 69 constraints = new RunCollectionConstraintCollection(); 70 modifiers = new CheckedItemList<IRunCollectionModifier>(); 69 71 RegisterConstraintsEvents(); 70 72 } … … 83 85 get { return constraints; } 84 86 } 87 88 [Storable] 89 private CheckedItemList<IRunCollectionModifier> modifiers; 90 public CheckedItemList<IRunCollectionModifier> Modifiers { 91 get { return modifiers; } 92 } 93 85 94 86 95 private bool updateOfRunsInProgress; … … 98 107 private void AfterDeserialization() { 99 108 if (constraints == null) constraints = new RunCollectionConstraintCollection(); 109 if (modifiers == null) modifiers = new CheckedItemList<IRunCollectionModifier>(); 100 110 RegisterConstraintsEvents(); 101 111 RegisterConstraintEvents(constraints); … … 393 403 } 394 404 #endregion 405 406 #region Modification 407 public void Modify() { 408 UpdateOfRunsInProgress = true; 409 var runs = this.ToList(); 410 var selectedRuns = runs.Where(r => r.Visible).ToList(); 411 int nSelected = selectedRuns.Count; 412 if (nSelected > 0) { 413 foreach (var modifier in Modifiers.CheckedItems) 414 modifier.Value.Modify(selectedRuns); 415 if (nSelected != selectedRuns.Count || HaveDifferentOrder(selectedRuns, runs.Where(r => r.Visible))) { 416 Clear(); 417 AddRange(ReplaceVisibleRuns(runs, selectedRuns)); 418 } else if (runs.Count > 0) { 419 OnCollectionReset(this, runs); 420 } 421 } 422 UpdateOfRunsInProgress = false; 423 } 424 425 private static IEnumerable<IRun> ReplaceVisibleRuns(IEnumerable<IRun> runs, IEnumerable<IRun> visibleRuns) { 426 var newRuns = new List<IRun>(); 427 var runIt = runs.GetEnumerator(); 428 var visibleRunIt = visibleRuns.GetEnumerator(); 429 while (runIt.MoveNext()) { 430 if (runIt.Current != null && !runIt.Current.Visible) 431 newRuns.Add(runIt.Current); 432 else if (visibleRunIt.MoveNext()) 433 newRuns.Add(visibleRunIt.Current); 434 } 435 while (visibleRunIt.MoveNext()) 436 newRuns.Add(visibleRunIt.Current); 437 return newRuns; 438 } 439 440 private static bool HaveDifferentOrder(IEnumerable<IRun> l1, IEnumerable<IRun> l2) { 441 return l1.Zip(l2, (r1, r2) => r1 != r2).Any(); 442 } 443 #endregion 395 444 } 396 445 } -
trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionModificationEvaluator.cs
r6677 r6693 48 48 #endregion 49 49 50 [StorableHook(HookType.AfterDeserialization)] 51 private void AfterDeserialization() { 52 if (RunCollection != null && RunCollection.Modifiers != null) { 53 RunCollection.Modifiers.AddRange(Modifiers); 54 foreach (var modifier in RunCollection.Modifiers) { 55 RunCollection.Modifiers.SetItemCheckedState(modifier, Modifiers.ItemChecked(modifier)); 56 } 57 Modifiers.Clear(); 58 } 59 } 60 50 61 public void Evaluate() { 51 62 RunCollection.UpdateOfRunsInProgress = true; 52 var runs = RunCollection.Select((r, i) => new { Run = r, r.Visible, Index = i}).ToList();63 var runs = RunCollection.Select((r, i) => new { Run = r, r.Visible, Index = i }).ToList(); 53 64 var visibleRuns = runs.Where(r => r.Visible).Select(r => r.Run).ToList(); 54 65 int n = visibleRuns.Count; … … 73 84 RunCollection.AddRange(newRuns); 74 85 } else if (runs.Count > 0) { // force update 75 var run = (IRun) 86 var run = (IRun)runs[0].Run.Clone(); 76 87 RunCollection.Add(run); 77 88 RunCollection.Remove(run);
Note: See TracChangeset
for help on using the changeset viewer.