- Timestamp:
- 01/08/11 01:47:47 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.Designer.cs
r3764 r5237 20 20 #endregion 21 21 22 using System;23 using System.Windows.Forms;24 22 25 23 namespace HeuristicLab.Core.Views { … … 29 27 /// </summary> 30 28 private System.ComponentModel.IContainer components = null; 31 32 /// <summary>33 /// Clean up any resources being used.34 /// </summary>35 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>36 protected override void Dispose(bool disposing) {37 if (disposing) {38 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();39 foreach (ListViewItem item in listView.Items) {40 ((T)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);41 ((T)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);42 }43 if (components != null) components.Dispose();44 }45 base.Dispose(disposing);46 }47 29 48 30 #region Component Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r4500 r5237 34 34 public sealed partial class Clipboard<T> : HeuristicLab.MainForm.WindowsForms.Sidebar where T : class, IItem { 35 35 private TypeSelectorDialog typeSelectorDialog; 36 private Dictionary<T, ListViewItem> itemListViewItem Table;36 private Dictionary<T, ListViewItem> itemListViewItemMapping; 37 37 38 38 private string itemsPath; … … 62 62 ItemsPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + 63 63 Path.DirectorySeparatorChar + "HeuristicLab" + Path.DirectorySeparatorChar + "Clipboard"; 64 itemListViewItem Table= new Dictionary<T, ListViewItem>();64 itemListViewItemMapping = new Dictionary<T, ListViewItem>(); 65 65 } 66 66 public Clipboard(string itemsPath) { 67 67 InitializeComponent(); 68 68 ItemsPath = itemsPath; 69 itemListViewItemTable = new Dictionary<T, ListViewItem>(); 69 itemListViewItemMapping = new Dictionary<T, ListViewItem>(); 70 } 71 72 protected override void Dispose(bool disposing) { 73 if (disposing) { 74 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 75 foreach (T item in itemListViewItemMapping.Keys) { 76 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 77 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 78 } 79 if (components != null) components.Dispose(); 80 } 81 base.Dispose(disposing); 70 82 } 71 83 … … 91 103 Invoke(new Action<T>(AddItem), item); 92 104 else { 93 if (!itemListViewItemTable.ContainsKey(item)) { 105 if (item == null) throw new ArgumentNullException("item", "Cannot add null item to clipboard."); 106 if (!itemListViewItemMapping.ContainsKey(item)) { 94 107 ListViewItem listViewItem = new ListViewItem(item.ToString()); 95 108 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; … … 98 111 listViewItem.Tag = item; 99 112 listView.Items.Add(listViewItem); 100 itemListViewItem Table.Add(item, listViewItem);113 itemListViewItemMapping.Add(item, listViewItem); 101 114 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 102 115 item.ToStringChanged += new EventHandler(Item_ToStringChanged); … … 111 124 Invoke(new Action<T>(RemoveItem), item); 112 125 else { 113 if (itemListViewItem Table.ContainsKey(item)) {126 if (itemListViewItemMapping.ContainsKey(item)) { 114 127 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 115 128 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 116 ListViewItem listViewItem = itemListViewItem Table[item];129 ListViewItem listViewItem = itemListViewItemMapping[item]; 117 130 listViewItem.Remove(); 118 foreach (ListViewItem other in listView.Items) 119 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 120 listView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 121 itemListViewItemTable.Remove(item); 131 itemListViewItemMapping.Remove(item); 122 132 sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1; 123 133 } … … 178 188 179 189 int i = 0; 180 T[] items = GetStorableItems(itemListViewItem Table.Keys);190 T[] items = GetStorableItems(itemListViewItemMapping.Keys); 181 191 182 192 foreach (T item in items) { … … 243 253 foreach (ListViewItem item in listView.SelectedItems) 244 254 RemoveItem((T)item.Tag); 255 RebuildImageList(); 245 256 } 246 257 } … … 271 282 } else { 272 283 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 273 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 284 if ((result & DragDropEffects.Move) == DragDropEffects.Move) { 274 285 RemoveItem(item); 286 RebuildImageList(); 287 } 275 288 } 276 289 } … … 281 294 if (!ReadOnly && (type != null) && (item != null)) { 282 295 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 283 else if (((e.KeyState & 4) == 4) && !itemListViewItem Table.ContainsKey(item)) e.Effect = DragDropEffects.Move; // SHIFT key296 else if (((e.KeyState & 4) == 4) && !itemListViewItemMapping.ContainsKey(item)) e.Effect = DragDropEffects.Move; // SHIFT key 284 297 else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy; 285 else if (((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) && !itemListViewItem Table.ContainsKey(item)) e.Effect = DragDropEffects.Move;286 else if (((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) && !itemListViewItem Table.ContainsKey(item)) e.Effect = DragDropEffects.Link;298 else if (((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) && !itemListViewItemMapping.ContainsKey(item)) e.Effect = DragDropEffects.Move; 299 else if (((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) && !itemListViewItemMapping.ContainsKey(item)) e.Effect = DragDropEffects.Link; 287 300 } 288 301 } … … 291 304 T item = e.Data.GetData("Value") as T; 292 305 if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (T)item.Clone(); 293 AddItem(item); 306 try { 307 AddItem(item); 308 } 309 catch (Exception ex) { 310 ErrorHandling.ShowErrorDialog(this, ex); 311 } 294 312 } 295 313 } … … 326 344 foreach (ListViewItem item in listView.SelectedItems) 327 345 RemoveItem((T)item.Tag); 346 RebuildImageList(); 328 347 } 329 348 } 330 349 private void saveButton_Click(object sender, EventArgs e) { 331 IEnumerable<T> items = itemListViewItem Table.Keys.Except(GetStorableItems(itemListViewItemTable.Keys));350 IEnumerable<T> items = itemListViewItemMapping.Keys.Except(GetStorableItems(itemListViewItemMapping.Keys)); 332 351 if (items.Any()) { 333 352 string itemNames = string.Join(Environment.NewLine, items.Select(item => item.ToString()).ToArray()); … … 345 364 else { 346 365 T item = (T)sender; 347 ListViewItem listViewItem = itemListViewItem Table[item];366 ListViewItem listViewItem = itemListViewItemMapping[item]; 348 367 int i = listViewItem.ImageIndex; 349 368 listViewItem.ImageList.Images[i] = item.ItemImage; … … 357 376 else { 358 377 T item = (T)sender; 359 itemListViewItem Table[item].Text = item.ToString();378 itemListViewItemMapping[item].Text = item.ToString(); 360 379 listView.Sort(); 361 380 AdjustListViewColumnSizes(); … … 371 390 } 372 391 } 392 private void RebuildImageList() { 393 listView.SmallImageList.Images.Clear(); 394 foreach (ListViewItem item in listView.Items) { 395 listView.SmallImageList.Images.Add(((T)item.Tag).ItemImage); 396 item.ImageIndex = listView.SmallImageList.Images.Count - 1; 397 } 398 } 373 399 #endregion 374 400 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs
r4096 r5237 29 29 /// </summary> 30 30 private System.ComponentModel.IContainer components = null; 31 32 /// <summary>33 /// Clean up any resources being used.34 /// </summary>35 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>36 protected override void Dispose(bool disposing) {37 if (disposing) {38 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();39 foreach (ListViewItem listViewItem in itemsListView.Items) {40 T item = listViewItem.Tag as T;41 if (item != null) item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);42 if (item != null) item.ToStringChanged -= new EventHandler(Item_ToStringChanged);43 }44 if (components != null) components.Dispose();45 }46 base.Dispose(disposing);47 }48 31 49 32 #region Windows Form Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs
r5070 r5237 30 30 31 31 namespace HeuristicLab.Core.Views { 32 /// <summary>33 /// The visual representation of all variables in a specified scope.34 /// </summary>35 32 [View("ItemArray View")] 36 33 [Content(typeof(ItemArray<>), true)] 37 34 [Content(typeof(IItemArray<>), false)] 38 35 public partial class ItemArrayView<T> : ItemView where T : class, IItem { 36 protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping; 39 37 protected TypeSelectorDialog typeSelectorDialog; 40 38 41 /// <summary>42 /// Gets or sets the scope whose variables to represent visually.43 /// </summary>44 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.45 /// No won data storage present.</remarks>46 39 public new IItemArray<T> Content { 47 40 get { return (IItemArray<T>)base.Content; } … … 53 46 } 54 47 55 /// <summary>56 /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".57 /// </summary>58 48 public ItemArrayView() { 59 49 InitializeComponent(); 60 } 61 62 /// <summary> 63 /// Removes the eventhandlers from the underlying <see cref="IScope"/>. 64 /// </summary> 65 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 50 itemListViewItemMapping = new Dictionary<T, List<ListViewItem>>(); 51 } 52 53 protected override void Dispose(bool disposing) { 54 if (disposing) { 55 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 56 if (components != null) components.Dispose(); 57 } 58 base.Dispose(disposing); 59 } 60 66 61 protected override void DeregisterContentEvents() { 67 62 Content.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsReplaced); 68 63 Content.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsMoved); 69 64 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset); 70 foreach (T item in Content) { 71 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 72 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 65 foreach (T item in itemListViewItemMapping.Keys) { 66 DeregisterItemEvents(item); 73 67 } 74 68 base.DeregisterContentEvents(); 75 69 } 76 77 /// <summary>78 /// Adds eventhandlers to the underlying <see cref="IScope"/>.79 /// </summary>80 /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>81 70 protected override void RegisterContentEvents() { 82 71 base.RegisterContentEvents(); … … 85 74 Content.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset); 86 75 } 76 protected virtual void DeregisterItemEvents(T item) { 77 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 78 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 79 } 80 protected virtual void RegisterItemEvents(T item) { 81 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 82 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 83 } 87 84 88 85 protected override void OnContentChanged() { … … 92 89 if (itemsListView.SelectedItems.Count == 1) selectedIndex = itemsListView.SelectedIndices[0]; 93 90 94 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 91 itemsListView.Items.Clear(); 92 itemListViewItemMapping.Clear(); 93 RebuildImageList(); 95 94 viewHost.Content = null; 96 95 if (Content != null) { … … 140 139 try { 141 140 return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 142 } catch (Exception ex) { 141 } 142 catch (Exception ex) { 143 143 ErrorHandling.ShowErrorDialog(this, ex); 144 144 } … … 148 148 protected virtual ListViewItem CreateListViewItem(T item) { 149 149 ListViewItem listViewItem = new ListViewItem(); 150 listViewItem.Text = item == null ? "null" : item.ToString(); 151 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 152 itemsListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage); 153 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 154 listViewItem.Tag = item; 150 if (item == null) { 151 listViewItem.Text = "null"; 152 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing); 153 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 154 } else { 155 listViewItem.Text = item.ToString(); 156 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 157 itemsListView.SmallImageList.Images.Add(item.ItemImage); 158 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 159 listViewItem.Tag = item; 160 } 155 161 return listViewItem; 156 162 } 157 163 protected virtual void AddListViewItem(ListViewItem listViewItem) { 164 T item = (listViewItem.Tag as T); 158 165 itemsListView.Items.Add(listViewItem); 159 if (listViewItem.Tag != null) { 160 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 161 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 166 if (item != null) { 167 if (!itemListViewItemMapping.ContainsKey(item)) { 168 RegisterItemEvents(item); 169 itemListViewItemMapping.Add(item, new List<ListViewItem>()); 170 } 171 itemListViewItemMapping[item].Add(listViewItem); 162 172 } 163 173 } 164 174 protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) { 175 T item = (listViewItem.Tag as T); 165 176 itemsListView.Items.Insert(index, listViewItem); 166 if (listViewItem.Tag != null) { 167 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 168 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 177 if (item != null) { 178 if (!itemListViewItemMapping.ContainsKey(item)) { 179 RegisterItemEvents(item); 180 itemListViewItemMapping.Add(item, new List<ListViewItem>()); 181 } 182 itemListViewItemMapping[item].Add(listViewItem); 169 183 } 170 184 } 171 185 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { 172 if (listViewItem.Tag != null) { 173 ((T)listViewItem.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 174 ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged); 186 T item = (listViewItem.Tag as T); 187 if (item != null) { 188 itemListViewItemMapping[item].Remove(listViewItem); 189 if (itemListViewItemMapping[item].Count == 0) { 190 itemListViewItemMapping.Remove(item); 191 DeregisterItemEvents(item); 192 } 175 193 } 176 194 listViewItem.Remove(); 177 foreach (ListViewItem other in itemsListView.Items)178 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--;179 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex);180 195 } 181 196 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { … … 190 205 listViewItem.Text = item == null ? "null" : item.ToString(); 191 206 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 207 } 208 protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(T item) { 209 return itemListViewItemMapping[item]; 192 210 } 193 211 … … 347 365 foreach (ListViewItem listViewItem in listViewItems) 348 366 RemoveListViewItem(listViewItem); 367 RebuildImageList(); 349 368 350 369 foreach (IndexedItem<T> item in e.Items) … … 377 396 foreach (ListViewItem listViewItem in listViewItems) 378 397 RemoveListViewItem(listViewItem); 398 RebuildImageList(); 379 399 380 400 foreach (IndexedItem<T> item in e.Items) … … 391 411 else { 392 412 T item = (T)sender; 393 foreach (ListViewItem listViewItem in itemsListView.Items) { 394 if (((T)listViewItem.Tag) == item) 395 UpdateListViewItemImage(listViewItem); 396 } 413 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 414 UpdateListViewItemImage(listViewItem); 397 415 } 398 416 } … … 402 420 else { 403 421 T item = (T)sender; 404 foreach (ListViewItem listViewItem in itemsListView.Items) { 405 if (((T)listViewItem.Tag) == item) 406 UpdateListViewItemText(listViewItem); 407 } 422 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 423 UpdateListViewItemText(listViewItem); 408 424 } 409 425 } … … 417 433 } 418 434 } 435 private void RebuildImageList() { 436 itemsListView.SmallImageList.Images.Clear(); 437 foreach (ListViewItem item in itemsListView.Items) { 438 itemsListView.SmallImageList.Images.Add(((T)item.Tag).ItemImage); 439 item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 440 } 441 } 419 442 #endregion 420 443 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.Designer.cs
r4096 r5237 20 20 #endregion 21 21 22 using System;23 22 using System.Windows.Forms; 24 23 … … 29 28 /// </summary> 30 29 private System.ComponentModel.IContainer components = null; 31 32 /// <summary>33 /// Clean up any resources being used.34 /// </summary>35 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>36 protected override void Dispose(bool disposing) {37 if (disposing) {38 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();39 foreach (ListViewItem item in itemsListView.Items) {40 ((T)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);41 ((T)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);42 }43 if (components != null) components.Dispose();44 }45 base.Dispose(disposing);46 }47 30 48 31 #region Windows Form Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r5068 r5237 34 34 [Content(typeof(IItemCollection<>), false)] 35 35 public partial class ItemCollectionView<T> : ItemView where T : class, IItem { 36 pr ivate Dictionary<T, List<ListViewItem>> listViewItemMapping;36 protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping; 37 37 protected TypeSelectorDialog typeSelectorDialog; 38 38 … … 48 48 public ItemCollectionView() { 49 49 InitializeComponent(); 50 listViewItemMapping = new Dictionary<T, List<ListViewItem>>(); 50 itemListViewItemMapping = new Dictionary<T, List<ListViewItem>>(); 51 } 52 53 protected override void Dispose(bool disposing) { 54 if (disposing) { 55 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 56 if (components != null) components.Dispose(); 57 } 58 base.Dispose(disposing); 51 59 } 52 60 … … 55 63 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved); 56 64 Content.CollectionReset -= new CollectionItemsChangedEventHandler<T>(Content_CollectionReset); 57 foreach (T item in listViewItemMapping.Keys) { 58 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 59 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 65 foreach (T item in itemListViewItemMapping.Keys) { 66 DeregisterItemEvents(item); 60 67 } 61 68 base.DeregisterContentEvents(); … … 67 74 Content.CollectionReset += new CollectionItemsChangedEventHandler<T>(Content_CollectionReset); 68 75 } 76 protected virtual void DeregisterItemEvents(T item) { 77 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 78 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 79 } 80 protected virtual void RegisterItemEvents(T item) { 81 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 82 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 83 } 69 84 70 85 protected override void OnContentChanged() { 71 86 base.OnContentChanged(); 72 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 87 itemsListView.Items.Clear(); 88 itemListViewItemMapping.Clear(); 73 89 RebuildImageList(); 74 90 viewHost.Content = null; … … 112 128 try { 113 129 return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 114 } catch (Exception ex) { 130 } 131 catch (Exception ex) { 115 132 ErrorHandling.ShowErrorDialog(this, ex); 116 133 } … … 120 137 protected virtual ListViewItem CreateListViewItem(T item) { 121 138 ListViewItem listViewItem = new ListViewItem(); 122 listViewItem.Text = item.ToString(); 123 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 124 listViewItem.Tag = item; 125 itemsListView.SmallImageList.Images.Add(item.ItemImage); 126 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 139 if (item == null) { 140 listViewItem.Text = "null"; 141 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing); 142 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 143 } else { 144 listViewItem.Text = item.ToString(); 145 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 146 itemsListView.SmallImageList.Images.Add(item.ItemImage); 147 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 148 listViewItem.Tag = item; 149 } 127 150 return listViewItem; 128 151 } … … 130 153 T item = (listViewItem.Tag as T); 131 154 itemsListView.Items.Add(listViewItem); 132 if (!listViewItemMapping.ContainsKey(item)) { 133 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 134 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 135 listViewItemMapping.Add(item, new List<ListViewItem>()); 136 } 137 listViewItemMapping[item].Add(listViewItem); 155 if (item != null) { 156 if (!itemListViewItemMapping.ContainsKey(item)) { 157 RegisterItemEvents(item); 158 itemListViewItemMapping.Add(item, new List<ListViewItem>()); 159 } 160 itemListViewItemMapping[item].Add(listViewItem); 161 } 138 162 sortAscendingButton.Enabled = itemsListView.Items.Count > 1; 139 163 sortDescendingButton.Enabled = itemsListView.Items.Count > 1; … … 141 165 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { 142 166 T item = (listViewItem.Tag as T); 143 listViewItemMapping[item].Remove(listViewItem); 144 if (listViewItemMapping[item].Count == 0) { 145 listViewItemMapping.Remove(item); 146 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 147 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 167 if (item != null) { 168 itemListViewItemMapping[item].Remove(listViewItem); 169 if (itemListViewItemMapping[item].Count == 0) { 170 itemListViewItemMapping.Remove(item); 171 DeregisterItemEvents(item); 172 } 148 173 } 149 174 listViewItem.Remove(); … … 152 177 } 153 178 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { 179 T item = listViewItem.Tag as T; 154 180 int i = listViewItem.ImageIndex; 155 listViewItem.ImageList.Images[i] = ((T)listViewItem.Tag).ItemImage;181 listViewItem.ImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage; 156 182 listViewItem.ImageIndex = -1; 157 183 listViewItem.ImageIndex = i; 158 184 } 159 185 protected virtual void UpdateListViewItemText(ListViewItem listViewItem) { 160 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) 161 listViewItem.Text = listViewItem.Tag.ToString(); 186 T item = listViewItem.Tag as T; 187 listViewItem.Text = item == null ? "null" : item.ToString(); 188 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 162 189 } 163 190 protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(T item) { 164 return listViewItemMapping[item]; 191 if (item == null) { 192 List<ListViewItem> listViewItems = new List<ListViewItem>(); 193 foreach (ListViewItem listViewItem in itemsListView.Items) { 194 if (listViewItem.Tag == null) listViewItems.Add(listViewItem); 195 } 196 return listViewItems; 197 } else { 198 return itemListViewItemMapping[item]; 199 } 165 200 } 166 201 … … 190 225 protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) { 191 226 if (itemsListView.SelectedItems.Count == 1) { 192 T item = (T)itemsListView.SelectedItems[0].Tag; 193 IContentView view = MainFormManager.MainForm.ShowContent(item); 194 if (view != null) { 195 view.ReadOnly = ReadOnly; 196 view.Locked = Locked; 227 T item = itemsListView.SelectedItems[0].Tag as T; 228 if (item != null) { 229 IContentView view = MainFormManager.MainForm.ShowContent(item); 230 if (view != null) { 231 view.ReadOnly = ReadOnly; 232 view.Locked = Locked; 233 } 197 234 } 198 235 } … … 201 238 if (!Locked) { 202 239 ListViewItem listViewItem = (ListViewItem)e.Item; 203 T item = (T)listViewItem.Tag; 204 DataObject data = new DataObject(); 205 data.SetData("Type", item.GetType()); 206 data.SetData("Value", item); 207 if (Content.IsReadOnly || ReadOnly) { 208 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 209 } else { 210 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 211 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 212 Content.Remove(item); 240 T item = listViewItem.Tag as T; 241 if (item != null) { 242 DataObject data = new DataObject(); 243 data.SetData("Type", item.GetType()); 244 data.SetData("Value", item); 245 if (Content.IsReadOnly || ReadOnly) { 246 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 247 } else { 248 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 249 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 250 Content.Remove(item); 251 } 213 252 } 214 253 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.Designer.cs
r4096 r5237 29 29 /// </summary> 30 30 private System.ComponentModel.IContainer components = null; 31 32 /// <summary>33 /// Clean up any resources being used.34 /// </summary>35 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>36 protected override void Dispose(bool disposing) {37 if (disposing) {38 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();39 foreach (ListViewItem item in itemsListView.Items) {40 ((T)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);41 ((T)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);42 }43 if (components != null) components.Dispose();44 }45 base.Dispose(disposing);46 }47 31 48 32 #region Windows Form Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r5070 r5237 30 30 31 31 namespace HeuristicLab.Core.Views { 32 /// <summary>33 /// The visual representation of all variables in a specified scope.34 /// </summary>35 32 [View("ItemList View")] 36 33 [Content(typeof(ItemList<>), true)] 37 34 [Content(typeof(IItemList<>), false)] 38 35 public partial class ItemListView<T> : ItemView where T : class, IItem { 36 protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping; 39 37 protected TypeSelectorDialog typeSelectorDialog; 40 38 41 /// <summary>42 /// Gets or sets the scope whose variables to represent visually.43 /// </summary>44 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.45 /// No won data storage present.</remarks>46 39 public new IItemList<T> Content { 47 40 get { return (IItemList<T>)base.Content; } … … 53 46 } 54 47 55 /// <summary>56 /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View".57 /// </summary>58 48 public ItemListView() { 59 49 InitializeComponent(); 60 } 61 62 /// <summary> 63 /// Removes the eventhandlers from the underlying <see cref="IScope"/>. 64 /// </summary> 65 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 50 itemListViewItemMapping = new Dictionary<T, List<ListViewItem>>(); 51 } 52 53 protected override void Dispose(bool disposing) { 54 if (disposing) { 55 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 56 if (components != null) components.Dispose(); 57 } 58 base.Dispose(disposing); 59 } 60 66 61 protected override void DeregisterContentEvents() { 67 62 Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsAdded); … … 70 65 Content.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsMoved); 71 66 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset); 72 foreach (T item in Content) { 73 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 74 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 67 foreach (T item in itemListViewItemMapping.Keys) { 68 DeregisterItemEvents(item); 75 69 } 76 70 base.DeregisterContentEvents(); 77 71 } 78 79 /// <summary>80 /// Adds eventhandlers to the underlying <see cref="IScope"/>.81 /// </summary>82 /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>83 72 protected override void RegisterContentEvents() { 84 73 base.RegisterContentEvents(); … … 89 78 Content.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset); 90 79 } 80 protected virtual void DeregisterItemEvents(T item) { 81 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 82 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 83 } 84 protected virtual void RegisterItemEvents(T item) { 85 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 86 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 87 } 91 88 92 89 protected override void OnContentChanged() { … … 96 93 if (itemsListView.SelectedItems.Count == 1) selectedIndex = itemsListView.SelectedIndices[0]; 97 94 98 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 95 itemsListView.Items.Clear(); 96 itemListViewItemMapping.Clear(); 97 RebuildImageList(); 99 98 viewHost.Content = null; 100 99 if (Content != null) { … … 143 142 try { 144 143 return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 145 } catch (Exception ex) { 144 } 145 catch (Exception ex) { 146 146 ErrorHandling.ShowErrorDialog(this, ex); 147 147 } … … 151 151 protected virtual ListViewItem CreateListViewItem(T item) { 152 152 ListViewItem listViewItem = new ListViewItem(); 153 listViewItem.Text = item.ToString(); 154 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 155 listViewItem.Tag = item; 156 itemsListView.SmallImageList.Images.Add(item.ItemImage); 157 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 153 if (item == null) { 154 listViewItem.Text = "null"; 155 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing); 156 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 157 } else { 158 listViewItem.Text = item.ToString(); 159 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 160 itemsListView.SmallImageList.Images.Add(item.ItemImage); 161 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 162 listViewItem.Tag = item; 163 } 158 164 return listViewItem; 159 165 } 160 166 protected virtual void AddListViewItem(ListViewItem listViewItem) { 167 T item = (listViewItem.Tag as T); 161 168 itemsListView.Items.Add(listViewItem); 162 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 163 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 169 if (item != null) { 170 if (!itemListViewItemMapping.ContainsKey(item)) { 171 RegisterItemEvents(item); 172 itemListViewItemMapping.Add(item, new List<ListViewItem>()); 173 } 174 itemListViewItemMapping[item].Add(listViewItem); 175 } 164 176 } 165 177 protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) { 178 T item = (listViewItem.Tag as T); 166 179 itemsListView.Items.Insert(index, listViewItem); 167 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 168 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 180 if (item != null) { 181 if (!itemListViewItemMapping.ContainsKey(item)) { 182 RegisterItemEvents(item); 183 itemListViewItemMapping.Add(item, new List<ListViewItem>()); 184 } 185 itemListViewItemMapping[item].Add(listViewItem); 186 } 169 187 } 170 188 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { 171 ((T)listViewItem.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 172 ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged); 189 T item = (listViewItem.Tag as T); 190 if (item != null) { 191 itemListViewItemMapping[item].Remove(listViewItem); 192 if (itemListViewItemMapping[item].Count == 0) { 193 itemListViewItemMapping.Remove(item); 194 DeregisterItemEvents(item); 195 } 196 } 173 197 listViewItem.Remove(); 174 foreach (ListViewItem other in itemsListView.Items)175 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--;176 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex);177 198 } 178 199 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { 200 T item = listViewItem.Tag as T; 179 201 int i = listViewItem.ImageIndex; 180 listViewItem.ImageList.Images[i] = ((T)listViewItem.Tag).ItemImage;202 listViewItem.ImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage; 181 203 listViewItem.ImageIndex = -1; 182 204 listViewItem.ImageIndex = i; 183 205 } 184 206 protected virtual void UpdateListViewItemText(ListViewItem listViewItem) { 185 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) 186 listViewItem.Text = listViewItem.Tag.ToString(); 207 T item = listViewItem.Tag as T; 208 listViewItem.Text = item == null ? "null" : item.ToString(); 209 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 210 } 211 protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(T item) { 212 return itemListViewItemMapping[item]; 187 213 } 188 214 … … 222 248 protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) { 223 249 if (itemsListView.SelectedItems.Count == 1) { 224 T item = (T)itemsListView.SelectedItems[0].Tag; 225 IContentView view = MainFormManager.MainForm.ShowContent(item); 226 if (view != null) { 227 view.ReadOnly = ReadOnly; 228 view.Locked = Locked; 250 T item = itemsListView.SelectedItems[0].Tag as T; 251 if (item != null) { 252 IContentView view = MainFormManager.MainForm.ShowContent(item); 253 if (view != null) { 254 view.ReadOnly = ReadOnly; 255 view.Locked = Locked; 256 } 229 257 } 230 258 } … … 234 262 if (!Locked) { 235 263 ListViewItem listViewItem = (ListViewItem)e.Item; 236 T item = (T)listViewItem.Tag; 237 DataObject data = new DataObject(); 238 data.SetData("Type", item.GetType()); 239 data.SetData("Value", item); 240 if (Content.IsReadOnly || ReadOnly) { 241 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 242 } else { 243 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 244 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 245 Content.RemoveAt(listViewItem.Index); 264 T item = listViewItem.Tag as T; 265 if (item != null) { 266 DataObject data = new DataObject(); 267 data.SetData("Type", item.GetType()); 268 data.SetData("Value", item); 269 if (Content.IsReadOnly || ReadOnly) { 270 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 271 } else { 272 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 273 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 274 Content.RemoveAt(listViewItem.Index); 275 } 246 276 } 247 277 } … … 337 367 foreach (ListViewItem listViewItem in listViewItems) 338 368 RemoveListViewItem(listViewItem); 369 RebuildImageList(); 339 370 } 340 371 } … … 351 382 foreach (ListViewItem listViewItem in listViewItems) 352 383 RemoveListViewItem(listViewItem); 384 RebuildImageList(); 353 385 354 386 foreach (IndexedItem<T> item in e.Items) … … 381 413 foreach (ListViewItem listViewItem in listViewItems) 382 414 RemoveListViewItem(listViewItem); 415 RebuildImageList(); 383 416 384 417 foreach (IndexedItem<T> item in e.Items) … … 395 428 else { 396 429 T item = (T)sender; 397 foreach (ListViewItem listViewItem in itemsListView.Items) { 398 if (((T)listViewItem.Tag) == item) 399 UpdateListViewItemImage(listViewItem); 400 } 430 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 431 UpdateListViewItemImage(listViewItem); 401 432 } 402 433 } … … 406 437 else { 407 438 T item = (T)sender; 408 foreach (ListViewItem listViewItem in itemsListView.Items) { 409 if (((T)listViewItem.Tag) == item) 410 UpdateListViewItemText(listViewItem); 411 } 439 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 440 UpdateListViewItemText(listViewItem); 412 441 } 413 442 } … … 421 450 } 422 451 } 452 private void RebuildImageList() { 453 itemsListView.SmallImageList.Images.Clear(); 454 foreach (ListViewItem item in itemsListView.Items) { 455 itemsListView.SmallImageList.Images.Add(((T)item.Tag).ItemImage); 456 item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 457 } 458 } 423 459 #endregion 424 460 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemSetView.cs
r4068 r5237 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Windows.Forms; 24 23 using HeuristicLab.MainForm; … … 34 33 } 35 34 36 private Dictionary<T, ListViewItem> listViewItemDictionary;37 protected Dictionary<T, ListViewItem> ListViewItemDictionary {38 get { return listViewItemDictionary; }39 }40 41 35 public ItemSetView() { 42 listViewItemDictionary = new Dictionary<T, ListViewItem>();43 36 InitializeComponent(); 44 }45 46 protected override void OnContentChanged() {47 base.OnContentChanged();48 if (Content != null)49 Caption += " (" + Content.GetType().Name + ")";50 }51 52 protected override void AddListViewItem(ListViewItem listViewItem) {53 ListViewItemDictionary.Add((T)listViewItem.Tag, listViewItem);54 base.AddListViewItem(listViewItem);55 }56 protected override void RemoveListViewItem(ListViewItem listViewItem) {57 base.RemoveListViewItem(listViewItem);58 ListViewItemDictionary.Remove((T)listViewItem.Tag);59 }60 protected override IEnumerable<ListViewItem> GetListViewItemsForItem(T item) {61 return new ListViewItem[] { listViewItemDictionary[item] };62 37 } 63 38 } -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemCollectionView.cs
r4715 r5237 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using System.Windows.Forms; 24 23 using HeuristicLab.Collections; … … 34 33 } 35 34 36 private Dictionary<T, ListViewItem> listViewItemDictionary;37 protected Dictionary<T, ListViewItem> ListViewItemDictionary {38 get { return listViewItemDictionary; }39 }40 41 35 public NamedItemCollectionView() { 42 listViewItemDictionary = new Dictionary<T, ListViewItem>();43 36 InitializeComponent(); 44 37 } … … 75 68 protected override ListViewItem CreateListViewItem(T item) { 76 69 ListViewItem listViewItem = base.CreateListViewItem(item); 77 listViewItem.ToolTipText = string.IsNullOrEmpty(item.Description) ? item.ItemName : item.ItemName + ": " + item.Description; 70 if ((item != null) && !string.IsNullOrEmpty(item.Description)) { 71 listViewItem.ToolTipText = item.ItemName + ": " + item.Description; 72 } 78 73 return listViewItem; 79 }80 protected override void AddListViewItem(ListViewItem listViewItem) {81 ListViewItemDictionary.Add((T)listViewItem.Tag, listViewItem);82 base.AddListViewItem(listViewItem);83 }84 protected override void RemoveListViewItem(ListViewItem listViewItem) {85 base.RemoveListViewItem(listViewItem);86 ListViewItemDictionary.Remove((T)listViewItem.Tag);87 }88 protected override IEnumerable<ListViewItem> GetListViewItemsForItem(T item) {89 ListViewItem listViewItem = null;90 listViewItemDictionary.TryGetValue(item, out listViewItem);91 if (listViewItem != null) return new ListViewItem[] { listViewItem };92 else return new ListViewItem[0];93 74 } 94 75 -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.Designer.cs
r2949 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (graphTreeView.Nodes.Count > 0) {36 RemoveTreeNode(graphTreeView.Nodes[0]);37 graphTreeView.Nodes.Clear();38 }39 if (components != null) components.Dispose();40 }41 base.Dispose(disposing);42 }43 28 44 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs
r5224 r5237 30 30 31 31 namespace HeuristicLab.Core.Views { 32 /// <summary>33 /// The visual representation of an <see cref="OperatorGraph"/>.34 /// </summary>35 32 [View("Operator View (Successors)")] 36 33 [Content(typeof(IOperator), false)] … … 40 37 private Dictionary<IKeyedItemCollection<string, IParameter>, IOperator> parametersOperatorTable; 41 38 42 /// <summary>43 /// Gets or sets the operator graph to represent visually.44 /// </summary>45 /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.46 /// No own data storage present.</remarks>47 39 public new IOperator Content { 48 40 get { return (IOperator)base.Content; } … … 61 53 } 62 54 63 /// <summary>64 /// Initializes a new instance of <see cref="OperatorGraphView"/> with caption "Operator Graph".65 /// </summary>66 55 public OperatorTreeView() { 67 56 InitializeComponent(); … … 72 61 } 73 62 74 /// <summary> 75 /// Updates all controls with the latest data of the model. 76 /// </summary> 77 /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks> 63 protected override void Dispose(bool disposing) { 64 if (disposing) { 65 if (graphTreeView.Nodes.Count > 0) { 66 RemoveTreeNode(graphTreeView.Nodes[0]); 67 graphTreeView.Nodes.Clear(); 68 } 69 if (components != null) components.Dispose(); 70 } 71 base.Dispose(disposing); 72 } 73 78 74 protected override void OnContentChanged() { 79 75 base.OnContentChanged(); -
trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.Designer.cs
r3742 r5237 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (createParameterDialog != null) createParameterDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 41 29 #region Component Designer generated code 42 30 -
trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs
r4068 r5237 38 38 } 39 39 40 protected override void Dispose(bool disposing) { 41 if (disposing) { 42 if (createParameterDialog != null) createParameterDialog.Dispose(); 43 if (components != null) components.Dispose(); 44 } 45 base.Dispose(disposing); 46 } 47 40 48 protected override IParameter CreateItem() { 41 49 if (createParameterDialog == null) createParameterDialog = new CreateParameterDialog(); -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.Designer.cs
r4477 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (scopesTreeView.Nodes.Count > 0) {36 ClearTreeNode(scopesTreeView.Nodes[0]);37 }38 if (components != null) components.Dispose();39 }40 base.Dispose(disposing);41 }42 28 43 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/ScopeView.cs
r4477 r5237 57 57 } 58 58 59 /// <summary> 60 /// Clean up any resources being used. 61 /// </summary> 62 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 63 protected override void Dispose(bool disposing) { 64 if (disposing) { 65 if (scopesTreeView.Nodes.Count > 0) { 66 ClearTreeNode(scopesTreeView.Nodes[0]); 67 } 68 if (components != null) components.Dispose(); 69 } 70 base.Dispose(disposing); 71 } 72 59 73 /// <summary> 60 74 /// Updates all controls with the latest data of the model. -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.Designer.cs
r4867 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/TypeSelector.cs
r4867 r5237 74 74 currentSearchString = string.Empty; 75 75 selectedType = null; 76 } 77 78 protected override void Dispose(bool disposing) { 79 if (disposing) { 80 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 81 if (components != null) components.Dispose(); 82 } 83 base.Dispose(disposing); 76 84 } 77 85 -
trunk/sources/HeuristicLab.Core.Views/3.3/ValueParameterCollectionView.Designer.cs
r3742 r5237 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (createParameterDialog != null) createParameterDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 41 29 #region Component Designer generated code 42 30 -
trunk/sources/HeuristicLab.Core.Views/3.3/ValueParameterCollectionView.cs
r4068 r5237 38 38 } 39 39 40 protected override void Dispose(bool disposing) { 41 if (disposing) { 42 if (createParameterDialog != null) createParameterDialog.Dispose(); 43 if (components != null) components.Dispose(); 44 } 45 base.Dispose(disposing); 46 } 47 40 48 protected override IValueParameter CreateItem() { 41 49 if (createParameterDialog == null) { -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.Designer.cs
r4477 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableView.cs
r4477 r5237 51 51 public VariableView() { 52 52 InitializeComponent(); 53 } 54 55 /// <summary> 56 /// Clean up any resources being used. 57 /// </summary> 58 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 59 protected override void Dispose(bool disposing) { 60 if (disposing) { 61 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 62 if (components != null) components.Dispose(); 63 } 64 base.Dispose(disposing); 53 65 } 54 66 -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/DockForm.Designer.cs
r3732 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (View != null)35 View.CaptionChanged -= new System.EventHandler(View_CaptionChanged);36 if (disposing && (components != null)) {37 components.Dispose();38 }39 base.Dispose(disposing);40 }41 28 42 29 #region Windows Form Designer generated code -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/DockForm.cs
r4068 r5237 73 73 } 74 74 } 75 76 protected override void Dispose(bool disposing) { 77 if (View != null) 78 View.CaptionChanged -= new System.EventHandler(View_CaptionChanged); 79 if (disposing && (components != null)) { 80 components.Dispose(); 81 } 82 base.Dispose(disposing); 83 } 84 75 85 private IView view; 76 86 public IView View { -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/DocumentForm.Designer.cs
r3732 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (view != null)35 view.CaptionChanged -= new System.EventHandler(View_CaptionChanged);36 if (disposing && (components != null)) {37 components.Dispose();38 }39 base.Dispose(disposing);40 }41 28 42 29 #region Windows Form Designer generated code -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/DocumentForm.cs
r4068 r5237 50 50 } 51 51 52 protected override void Dispose(bool disposing) { 53 if (view != null) 54 view.CaptionChanged -= new System.EventHandler(View_CaptionChanged); 55 if (disposing && (components != null)) { 56 components.Dispose(); 57 } 58 base.Dispose(disposing); 59 } 60 52 61 private void UpdateText() { 53 62 if (InvokeRequired) -
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForm.cs
r4234 r5237 430 430 private void ToolStripItemClicked(object sender, EventArgs e) { 431 431 System.Windows.Forms.ToolStripItem item = (System.Windows.Forms.ToolStripItem)sender; 432 ((IActionUserInterfaceItem)item.Tag).Execute(); 432 try { 433 ((IActionUserInterfaceItem)item.Tag).Execute(); 434 } 435 catch (Exception ex) { 436 ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex); 437 } 433 438 } 434 439 #endregion -
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.Designer.cs
r4522 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (problemTypeSelectorDialog != null) problemTypeSelectorDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs
r4540 r5237 49 49 public AlgorithmView() { 50 50 InitializeComponent(); 51 } 52 53 protected override void Dispose(bool disposing) { 54 if (disposing) { 55 if (problemTypeSelectorDialog != null) problemTypeSelectorDialog.Dispose(); 56 if (components != null) components.Dispose(); 57 } 58 base.Dispose(disposing); 51 59 } 52 60 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs
r4522 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs
r4540 r5237 47 47 public BatchRunView() { 48 48 InitializeComponent(); 49 } 50 51 protected override void Dispose(bool disposing) { 52 if (disposing) { 53 if (algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose(); 54 if (components != null) components.Dispose(); 55 } 56 base.Dispose(disposing); 49 57 } 50 58 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs
r4162 r5237 23 23 using System.Drawing; 24 24 using System.Windows.Forms; 25 using HeuristicLab.Collections;26 25 using HeuristicLab.Core; 27 26 using HeuristicLab.Core.Views; … … 60 59 protected override ListViewItem CreateListViewItem(IRunCollectionConstraint item) { 61 60 ListViewItem listViewItem = base.CreateListViewItem(item); 62 if (item.Active) 63 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Bold); 64 else 65 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 61 if (item != null) { 62 listViewItem.Font = item.Active ? new Font(listViewItem.Font, FontStyle.Bold) : new Font(listViewItem.Font, FontStyle.Regular); 63 } 66 64 return listViewItem; 67 65 } 68 66 69 protected override void RegisterContentEvents() { 70 base.RegisterContentEvents(); 71 foreach (IRunCollectionConstraint constraint in Content) 72 RegisterConstraintEvents(constraint); 67 protected override void DeregisterItemEvents(IRunCollectionConstraint item) { 68 item.ActiveChanged -= new EventHandler(Item_ActiveChanged); 69 base.DeregisterItemEvents(item); 73 70 } 74 protected override void DeregisterContentEvents() { 75 base.DeregisterContentEvents(); 76 foreach (IRunCollectionConstraint constraint in Content) 77 DeregisterConstraintEvents(constraint); 78 } 79 protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 80 base.Content_ItemsAdded(sender, e); 81 foreach (IRunCollectionConstraint constraint in e.Items) 82 RegisterConstraintEvents(constraint); 83 84 } 85 protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 86 base.Content_ItemsRemoved(sender, e); 87 foreach (IRunCollectionConstraint constraint in e.Items) 88 DeregisterConstraintEvents(constraint); 89 } 90 protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 91 base.Content_CollectionReset(sender, e); 92 foreach (IRunCollectionConstraint constraint in e.OldItems) 93 RegisterConstraintEvents(constraint); 94 foreach (IRunCollectionConstraint constraint in e.Items) 95 DeregisterConstraintEvents(constraint); 71 protected override void RegisterItemEvents(IRunCollectionConstraint item) { 72 base.RegisterItemEvents(item); 73 item.ActiveChanged += new EventHandler(Item_ActiveChanged); 96 74 } 97 75 98 protected virtual void RegisterConstraintEvents(IRunCollectionConstraint constraint) { 99 constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged); 100 } 101 protected virtual void DeregisterConstraintEvents(IRunCollectionConstraint constraint) { 102 constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged); 103 } 104 protected virtual void constraint_ActiveChanged(object sender, EventArgs e) { 76 protected virtual void Item_ActiveChanged(object sender, EventArgs e) { 105 77 IRunCollectionConstraint constraint = (IRunCollectionConstraint)sender; 106 78 foreach (ListViewItem listViewItem in GetListViewItemsForItem(constraint)) { -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.Designer.cs
r4883 r5237 20 20 #endregion 21 21 22 using System;23 22 using System.Windows.Forms; 24 23 … … 36 35 protected override void Dispose(bool disposing) { 37 36 if (disposing) { 38 foreach (ListViewItem item in itemsListView.Items) {39 ((IRun)item.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);40 ((IRun)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);41 }42 37 if (components != null) components.Dispose(); 43 38 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r4883 r5237 36 36 [Content(typeof(IItemCollection<IRun>), false)] 37 37 public sealed partial class RunCollectionView : ItemView { 38 private Dictionary<IRun, List<ListViewItem>> runListViewItemMapping;38 private Dictionary<IRun, List<ListViewItem>> itemListViewItemMapping; 39 39 40 40 public new IItemCollection<IRun> Content { … … 54 54 InitializeComponent(); 55 55 itemsGroupBox.Text = "Runs"; 56 runListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>();56 itemListViewItemMapping = new Dictionary<IRun, List<ListViewItem>>(); 57 57 } 58 58 … … 61 61 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 62 62 Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 63 DeregisterRunEvents(Content); 63 foreach (IRun run in itemListViewItemMapping.Keys) { 64 DeregisterItemEvents(run); 65 } 64 66 base.DeregisterContentEvents(); 65 67 } … … 69 71 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 70 72 Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 71 RegisterRunEvents(Content); 72 } 73 private void RegisterRunEvents(IEnumerable<IRun> runs) { 74 foreach (IRun run in runs) 75 run.Changed += new EventHandler(Run_Changed); 76 } 77 private void DeregisterRunEvents(IEnumerable<IRun> runs) { 78 foreach (IRun run in runs) 79 run.Changed -= new EventHandler(Run_Changed); 73 } 74 private void DeregisterItemEvents(IRun item) { 75 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 76 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 77 item.Changed -= new EventHandler(Item_Changed); 78 } 79 private void RegisterItemEvents(IRun item) { 80 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 81 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 82 item.Changed += new EventHandler(Item_Changed); 80 83 } 81 84 … … 101 104 selectedName = ((IRun)itemsListView.SelectedItems[0].Tag).Name; 102 105 103 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 106 itemsListView.Items.Clear(); 107 itemListViewItemMapping.Clear(); 108 RebuildImageList(); 104 109 viewHost.Content = null; 105 110 … … 148 153 private ListViewItem CreateListViewItem(IRun item) { 149 154 ListViewItem listViewItem = new ListViewItem(); 150 listViewItem.Text = item.ToString(); 151 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 152 itemsListView.SmallImageList.Images.Add(item.ItemImage); 153 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 154 listViewItem.Tag = item; 155 156 if (item.Visible) { 157 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 158 listViewItem.ForeColor = item.Color; 155 if (item == null) { 156 listViewItem.Text = "null"; 157 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing); 158 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 159 159 } else { 160 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 161 listViewItem.ForeColor = Color.LightGray; 160 listViewItem.Text = item.ToString(); 161 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 162 itemsListView.SmallImageList.Images.Add(item.ItemImage); 163 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 164 listViewItem.Tag = item; 165 166 if (item.Visible) { 167 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 168 listViewItem.ForeColor = item.Color; 169 } else { 170 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 171 listViewItem.ForeColor = Color.LightGray; 172 } 162 173 } 163 174 return listViewItem; … … 167 178 IRun run = listViewItem.Tag as IRun; 168 179 if (run != null) { 169 if (! runListViewItemMapping.ContainsKey(run))170 runListViewItemMapping.Add(run, new List<ListViewItem>());171 runListViewItemMapping[run].Add(listViewItem);172 run.ItemImageChanged += new EventHandler(Item_ItemImageChanged);173 run.ToStringChanged += new EventHandler(Item_ToStringChanged);180 if (!itemListViewItemMapping.ContainsKey(run)) { 181 itemListViewItemMapping.Add(run, new List<ListViewItem>()); 182 RegisterItemEvents(run); 183 } 184 itemListViewItemMapping[run].Add(listViewItem); 174 185 } 175 186 } … … 177 188 IRun run = listViewItem.Tag as IRun; 178 189 if (run != null) { 179 runListViewItemMapping[run].Remove(listViewItem); 180 if (runListViewItemMapping[run].Count == 0) { 181 runListViewItemMapping.Remove(run); 182 run.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 183 run.ToStringChanged -= new EventHandler(Item_ToStringChanged); 190 itemListViewItemMapping[run].Remove(listViewItem); 191 if (itemListViewItemMapping[run].Count == 0) { 192 DeregisterItemEvents(run); 193 itemListViewItemMapping.Remove(run); 184 194 } 185 195 } 186 196 listViewItem.Remove(); 187 foreach (ListViewItem other in itemsListView.Items)188 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--;189 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex);190 197 } 191 198 private void UpdateListViewItemImage(ListViewItem listViewItem) { 199 IRun item = listViewItem.Tag as IRun; 192 200 int i = listViewItem.ImageIndex; 193 listViewItem.ImageList.Images[i] = ((IRun)listViewItem.Tag).ItemImage;201 listViewItem.ImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage; 194 202 listViewItem.ImageIndex = -1; 195 203 listViewItem.ImageIndex = i; 196 204 } 197 205 private void UpdateListViewItemText(ListViewItem listViewItem) { 198 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) 199 listViewItem.Text = listViewItem.Tag.ToString(); 200 } 201 private IEnumerable<ListViewItem> GetListViewItemsForItem(IRun run) { 202 return runListViewItemMapping[run]; 206 IRun item = listViewItem.Tag as IRun; 207 listViewItem.Text = item == null ? "null" : item.ToString(); 208 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 209 } 210 private IEnumerable<ListViewItem> GetListViewItemsForItem(IRun item) { 211 if (item == null) { 212 List<ListViewItem> listViewItems = new List<ListViewItem>(); 213 foreach (ListViewItem listViewItem in itemsListView.Items) { 214 if (listViewItem.Tag == null) listViewItems.Add(listViewItem); 215 } 216 return listViewItems; 217 } else { 218 return itemListViewItemMapping[item]; 219 } 203 220 } 204 221 … … 228 245 private void itemsListView_DoubleClick(object sender, EventArgs e) { 229 246 if (itemsListView.SelectedItems.Count == 1) { 230 IRun item = (IRun)itemsListView.SelectedItems[0].Tag; 231 IContentView view = MainFormManager.MainForm.ShowContent(item); 232 if (view != null) { 233 view.ReadOnly = ReadOnly; 234 view.Locked = Locked; 247 IRun item = itemsListView.SelectedItems[0].Tag as IRun; 248 if (item != null) { 249 IContentView view = MainFormManager.MainForm.ShowContent(item); 250 if (view != null) { 251 view.ReadOnly = ReadOnly; 252 view.Locked = Locked; 253 } 235 254 } 236 255 } … … 239 258 if (!Locked) { 240 259 ListViewItem listViewItem = (ListViewItem)e.Item; 241 IRun item = (IRun)listViewItem.Tag; 242 DataObject data = new DataObject(); 243 data.SetData("Type", item.GetType()); 244 data.SetData("Value", item); 245 if (Content.IsReadOnly || ReadOnly) { 246 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 247 } else { 248 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 249 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 250 Content.Remove(item); 260 IRun item = listViewItem.Tag as IRun; 261 if (item != null) { 262 DataObject data = new DataObject(); 263 data.SetData("Type", item.GetType()); 264 data.SetData("Value", item); 265 if (Content.IsReadOnly || ReadOnly) { 266 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 267 } else { 268 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 269 if ((result & DragDropEffects.Move) == DragDropEffects.Move) 270 Content.Remove(item); 271 } 251 272 } 252 273 } … … 312 333 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e); 313 334 else { 314 RegisterRunEvents(e.Items);315 335 foreach (IRun item in e.Items) 316 336 AddListViewItem(CreateListViewItem(item)); … … 326 346 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e); 327 347 else { 328 DeregisterRunEvents(e.Items);329 348 foreach (IRun item in e.Items) { 330 349 //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection … … 332 351 if (listViewItem != null) RemoveListViewItem(listViewItem); 333 352 } 353 RebuildImageList(); 334 354 analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0; 335 355 clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly; … … 341 361 Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e); 342 362 else { 343 DeregisterRunEvents(e.OldItems);344 363 foreach (IRun item in e.OldItems) { 364 //remove only the first matching ListViewItem, because the IRun could be contained multiple times in the ItemCollection 345 365 ListViewItem listViewItem = GetListViewItemsForItem(item).FirstOrDefault(); 346 366 if (listViewItem != null) RemoveListViewItem(listViewItem); 347 367 } 348 Re gisterRunEvents(e.Items);368 RebuildImageList(); 349 369 foreach (IRun item in e.Items) 350 370 AddListViewItem(CreateListViewItem(item)); … … 378 398 } 379 399 } 380 private void Run_Changed(object sender, EventArgs e) {381 if (InvokeRequired) 382 this.Invoke(new EventHandler( Run_Changed), sender, e);400 private void Item_Changed(object sender, EventArgs e) { 401 if (InvokeRequired) 402 this.Invoke(new EventHandler(Item_Changed), sender, e); 383 403 else { 384 404 IRun run = (IRun)sender; … … 408 428 } 409 429 } 430 private void RebuildImageList() { 431 itemsListView.SmallImageList.Images.Clear(); 432 foreach (ListViewItem item in itemsListView.Items) { 433 itemsListView.SmallImageList.Images.Add(((IRun)item.Tag).ItemImage); 434 item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 435 } 436 } 410 437 #endregion 411 438 } -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.Designer.cs
r4522 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueLookupParameterView.cs
r4522 r5237 53 53 public ValueLookupParameterView() { 54 54 InitializeComponent(); 55 } 56 57 /// <summary> 58 /// Clean up any resources being used. 59 /// </summary> 60 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 61 protected override void Dispose(bool disposing) { 62 if (disposing) { 63 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 64 if (components != null) components.Dispose(); 65 } 66 base.Dispose(disposing); 55 67 } 56 68 -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.Designer.cs
r4522 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code … … 120 108 this.valueViewHost.Size = new System.Drawing.Size(374, 182); 121 109 this.valueViewHost.TabIndex = 3; 122 this.valueViewHost.ViewType = null; 110 this.valueViewHost.ViewType = null; 123 111 // 124 112 // clearValueButton -
trunk/sources/HeuristicLab.Parameters.Views/3.3/ValueParameterView.cs
r4522 r5237 54 54 public ValueParameterView() { 55 55 InitializeComponent(); 56 } 57 58 /// <summary> 59 /// Clean up any resources being used. 60 /// </summary> 61 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 62 protected override void Dispose(bool disposing) { 63 if (disposing) { 64 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 65 if (components != null) components.Dispose(); 66 } 67 base.Dispose(disposing); 56 68 } 57 69 -
trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/TravelingSalesmanProblemView.Designer.cs
r3764 r5237 26 26 /// </summary> 27 27 private System.ComponentModel.IContainer components = null; 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (tsplibImportDialog != null) tsplibImportDialog.Dispose();36 if (components != null) components.Dispose();37 }38 base.Dispose(disposing);39 }40 28 41 29 #region Component Designer generated code -
trunk/sources/HeuristicLab.Problems.TravelingSalesman.Views/3.3/TravelingSalesmanProblemView.cs
r4513 r5237 46 46 public TravelingSalesmanProblemView() { 47 47 InitializeComponent(); 48 } 49 50 protected override void Dispose(bool disposing) { 51 if (disposing) { 52 if (tsplibImportDialog != null) tsplibImportDialog.Dispose(); 53 if (components != null) components.Dispose(); 54 } 55 base.Dispose(disposing); 48 56 } 49 57
Note: See TracChangeset
for help on using the changeset viewer.