- Timestamp:
- 11/27/14 11:23:37 (10 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunView.cs
r11591 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.ComponentModel; 25 using System.Linq; 23 26 using System.Windows.Forms; 27 using HeuristicLab.Collections; 24 28 using HeuristicLab.Common; 25 29 using HeuristicLab.Core; … … 34 38 [Content(typeof(IRun), true)] 35 39 public sealed partial class RunView : NamedItemView { 40 private readonly Dictionary<string, ListViewItem> parametersItemToListViewItem; 41 private readonly Dictionary<string, ListViewItem> resultsItemToListViewItem; 36 42 /// <summary> 37 43 /// Gets or sets the variable to represent visually. … … 49 55 public RunView() { 50 56 InitializeComponent(); 57 parametersItemToListViewItem = new Dictionary<string, ListViewItem>(); 58 resultsItemToListViewItem = new Dictionary<string, ListViewItem>(); 51 59 } 52 60 53 61 protected override void RegisterContentEvents() { 54 62 base.RegisterContentEvents(); 55 Content.Changed += new EventHandler(Content_Changed); 63 Content.PropertyChanged += Content_PropertyChanged; 64 RegisterContentParametersEvents(); 65 RegisterContentResultsEents(); 66 } 67 private void RegisterContentParametersEvents() { 68 Content.Parameters.ItemsAdded += ParametersOnItemsChanged; 69 Content.Parameters.ItemsRemoved += ParametersOnItemsRemoved; 70 Content.Parameters.ItemsReplaced += ParametersOnItemsChanged; 71 Content.Parameters.CollectionReset += ParametersOnItemsChanged; 72 } 73 private void RegisterContentResultsEents() { 74 Content.Results.ItemsAdded += ResultsOnItemsChanged; 75 Content.Results.ItemsRemoved += ResultsOnItemsRemoved; 76 Content.Results.ItemsReplaced += ResultsOnItemsChanged; 77 Content.Results.CollectionReset += ResultsOnItemsChanged; 56 78 } 57 79 protected override void DeregisterContentEvents() { 58 80 base.DeregisterContentEvents(); 59 Content.Changed -= new EventHandler(Content_Changed); 60 } 61 private void Content_Changed(object sender, EventArgs e) { 62 if (InvokeRequired) 63 this.Invoke(new EventHandler(Content_Changed), sender, e); 64 else 65 UpdateColor(); 81 Content.PropertyChanged -= Content_PropertyChanged; 82 DeregisterContentParametersEvents(); 83 DeregisterContentResultsEvents(); 84 } 85 private void DeregisterContentParametersEvents() { 86 Content.Parameters.ItemsAdded -= ParametersOnItemsChanged; 87 Content.Parameters.ItemsRemoved -= ParametersOnItemsRemoved; 88 Content.Parameters.ItemsReplaced -= ParametersOnItemsChanged; 89 Content.Parameters.CollectionReset -= ParametersOnItemsChanged; 90 } 91 private void DeregisterContentResultsEvents() { 92 Content.Results.ItemsAdded -= ResultsOnItemsChanged; 93 Content.Results.ItemsRemoved -= ResultsOnItemsRemoved; 94 Content.Results.ItemsReplaced -= ResultsOnItemsChanged; 95 Content.Results.CollectionReset -= ResultsOnItemsChanged; 96 } 97 98 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 99 if (e.PropertyName == "Color") { 100 if (InvokeRequired) this.Invoke((Action)UpdateColor, null); 101 else UpdateColor(); 102 } else if (e.PropertyName == "Parameters") { 103 if (InvokeRequired) this.Invoke((Action<bool>)FillParametersListView, true); 104 else FillParametersListView(); 105 RegisterContentParametersEvents(); 106 } else if (e.PropertyName == "Results") { 107 if (InvokeRequired) this.Invoke((Action<bool>)FillResultsListView, true); 108 else FillResultsListView(); 109 RegisterContentResultsEents(); 110 } 111 } 112 113 private void ParametersOnItemsChanged(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 114 foreach (var item in e.OldItems) { 115 listView.Items.Remove(parametersItemToListViewItem[item.Key]); 116 parametersItemToListViewItem.Remove(item.Key); 117 } 118 foreach (var item in e.Items) { 119 var listViewItem = CreateListViewItem(item.Key, Content.Parameters[item.Key], listView.Groups["parametersGroup"]); 120 listView.Items.Add(listViewItem); 121 parametersItemToListViewItem[item.Key] = listViewItem; 122 } 123 } 124 125 private void ParametersOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 126 foreach (var item in e.Items) { 127 listView.Items.Remove(parametersItemToListViewItem[item.Key]); 128 parametersItemToListViewItem.Remove(item.Key); 129 } 130 } 131 132 private void ResultsOnItemsChanged(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 133 foreach (var item in e.OldItems) { 134 listView.Items.Remove(resultsItemToListViewItem[item.Key]); 135 resultsItemToListViewItem.Remove(item.Key); 136 } 137 foreach (var item in e.Items) { 138 var listViewItem = CreateListViewItem(item.Key, Content.Results[item.Key], listView.Groups["resultsGroup"]); 139 listView.Items.Add(listViewItem); 140 resultsItemToListViewItem[item.Key] = listViewItem; 141 } 142 } 143 144 private void ResultsOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) { 145 foreach (var item in e.Items) { 146 listView.Items.Remove(resultsItemToListViewItem[item.Key]); 147 resultsItemToListViewItem.Remove(item.Key); 148 } 66 149 } 67 150 … … 101 184 if (listView.SelectedItems.Count == 1) selectedName = listView.SelectedItems[0].SubItems[0].Text; 102 185 103 listView.Items.Clear(); 104 listView.SmallImageList.Images.Clear(); 186 FillParametersListView(false); 187 FillResultsListView(false); 188 if (listView.Items.Count > 0) { 189 for (int i = 0; i < listView.Columns.Count; i++) 190 listView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 191 selectedName = null; 192 } 193 } 194 195 private void FillParametersListView(bool resize = true) { 196 listView.BeginUpdate(); 197 foreach (var item in listView.Groups["parametersGroup"].Items.OfType<ListViewItem>().OrderByDescending(x => x.ImageIndex).ToList()) { 198 listView.SmallImageList.Images.RemoveAt(item.ImageIndex); 199 listView.Items.Remove(item); 200 } 201 parametersItemToListViewItem.Clear(); 202 203 var counter = 0; 204 foreach (var item in listView.Items.OfType<ListViewItem>().OrderBy(x => x.ImageIndex).ToList()) 205 item.ImageIndex = counter++; 206 listView.EndUpdate(); 207 105 208 if (Content != null) { 106 foreach (string key in Content.Parameters.Keys) 107 CreateListViewItem(key, Content.Parameters[key], listView.Groups["parametersGroup"], selectedName); 108 foreach (string key in Content.Results.Keys) 109 CreateListViewItem(key, Content.Results[key], listView.Groups["resultsGroup"], selectedName); 110 if (listView.Items.Count > 0) { 209 foreach (string key in Content.Parameters.Keys) { 210 var listViewItem = CreateListViewItem(key, Content.Parameters[key], listView.Groups["parametersGroup"]); 211 listView.Items.Add(listViewItem); 212 if ((selectedName != null) && key.Equals(selectedName)) listViewItem.Selected = true; 213 parametersItemToListViewItem[key] = listViewItem; 214 } 215 if (resize && listView.Items.Count > 0) { 111 216 for (int i = 0; i < listView.Columns.Count; i++) 112 217 listView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 113 selectedName = null; 114 } 115 } 116 } 117 118 private void CreateListViewItem(string name, IItem value, ListViewGroup group, string selectedName) { 119 ListViewItem item = new ListViewItem(new string[] { name, value != null ? value.ToString() : "-" }); 218 } 219 } 220 } 221 222 private void FillResultsListView(bool resize = true) { 223 listView.BeginUpdate(); 224 foreach (var item in listView.Groups["resultsGroup"].Items.OfType<ListViewItem>().OrderByDescending(x => x.ImageIndex).ToList()) { 225 listView.SmallImageList.Images.RemoveAt(item.ImageIndex); 226 listView.Items.Remove(item); 227 } 228 resultsItemToListViewItem.Clear(); 229 230 var counter = 0; 231 foreach (var item in listView.Items.OfType<ListViewItem>().OrderBy(x => x.ImageIndex).ToList()) 232 item.ImageIndex = counter++; 233 listView.EndUpdate(); 234 235 if (Content != null) { 236 foreach (string key in Content.Results.Keys) { 237 var listViewItem = CreateListViewItem(key, Content.Results[key], listView.Groups["resultsGroup"]); 238 listView.Items.Add(listViewItem); 239 if ((selectedName != null) && key.Equals(selectedName)) listViewItem.Selected = true; 240 resultsItemToListViewItem[key] = listViewItem; 241 } 242 if (resize && listView.Items.Count > 0) { 243 for (int i = 0; i < listView.Columns.Count; i++) 244 listView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 245 } 246 } 247 } 248 249 private ListViewItem CreateListViewItem(string name, IItem value, ListViewGroup group) { 250 var item = new ListViewItem(new string[] { name, value != null ? value.ToString() : "-" }); 120 251 item.Tag = value; 121 252 item.Group = group; 122 253 listView.SmallImageList.Images.Add(value == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : value.ItemImage); 123 254 item.ImageIndex = listView.SmallImageList.Images.Count - 1; 124 listView.Items.Add(item); 125 if ((selectedName != null) && name.Equals(selectedName)) item.Selected = true; 255 return item; 126 256 } 127 257
Note: See TracChangeset
for help on using the changeset viewer.