Changeset 3341 for trunk/sources/HeuristicLab.Optimization.Views/3.3
- Timestamp:
- 04/14/10 05:09:59 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3280 r3341 83 83 84 84 protected virtual ListViewItem CreateListViewItem(IRun item) { 85 if (!itemsListView.SmallImageList.Images.ContainsKey(item.GetType().FullName))86 itemsListView.SmallImageList.Images.Add(item.GetType().FullName, item.ItemImage);87 88 85 ListViewItem listViewItem = new ListViewItem(); 89 86 listViewItem.Text = item.ToString(); 90 87 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 91 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.IndexOfKey(item.GetType().FullName); 88 itemsListView.SmallImageList.Images.Add(item.ItemImage); 89 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 92 90 listViewItem.Tag = item; 93 91 return listViewItem; … … 95 93 protected virtual void AddListViewItem(ListViewItem listViewItem) { 96 94 itemsListView.Items.Add(listViewItem); 95 ((IRun)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 97 96 ((IRun)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 98 97 } 99 98 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { 99 ((IRun)listViewItem.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 100 100 ((IRun)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged); 101 101 listViewItem.Remove(); 102 } 103 protected virtual void UpdateListViewItem(ListViewItem listViewItem) { 104 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) { 102 foreach (ListViewItem other in itemsListView.Items) 103 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 104 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 105 } 106 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { 107 int i = listViewItem.ImageIndex; 108 listViewItem.ImageList.Images[i] = ((IRun)listViewItem.Tag).ItemImage; 109 listViewItem.ImageIndex = -1; 110 listViewItem.ImageIndex = i; 111 } 112 protected virtual void UpdateListViewItemText(ListViewItem listViewItem) { 113 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) 105 114 listViewItem.Text = listViewItem.Tag.ToString(); 106 }107 115 } 108 116 protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(IRun item) { … … 226 234 227 235 #region Item Events 228 protected virtual void Item_ ToStringChanged(object sender, EventArgs e) {229 if (InvokeRequired) 230 Invoke(new EventHandler(Item_ ToStringChanged), sender, e);236 protected virtual void Item_ItemImageChanged(object sender, EventArgs e) { 237 if (InvokeRequired) 238 Invoke(new EventHandler(Item_ItemImageChanged), sender, e); 231 239 else { 232 240 IRun item = (IRun)sender; 233 241 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 234 UpdateListViewItem(listViewItem); 242 UpdateListViewItemImage(listViewItem); 243 } 244 } 245 protected virtual void Item_ToStringChanged(object sender, EventArgs e) { 246 if (InvokeRequired) 247 Invoke(new EventHandler(Item_ToStringChanged), sender, e); 248 else { 249 IRun item = (IRun)sender; 250 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 251 UpdateListViewItemText(listViewItem); 235 252 } 236 253 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r3300 r3341 75 75 76 76 private void FillListView() { 77 if (!listView.SmallImageList.Images.ContainsKey("Default"))78 listView.SmallImageList.Images.Add("Default", HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing);79 80 77 listView.Items.Clear(); 78 listView.SmallImageList.Images.Clear(); 81 79 if (Content != null) { 82 foreach (string key in Content.Parameters.Keys) { 83 IItem value = Content.Parameters[key]; 84 if ((value != null) && (!listView.SmallImageList.Images.ContainsKey(value.GetType().FullName))) 85 listView.SmallImageList.Images.Add(value.GetType().FullName, value.ItemImage); 86 87 ListViewItem item = new ListViewItem(new string[] { key, value != null ? value.ToString() : "-" }); 88 item.Tag = value; 89 item.Group = listView.Groups["parametersGroup"]; 90 item.ImageIndex = listView.SmallImageList.Images.IndexOfKey(value != null ? value.GetType().FullName : "Default"); 91 listView.Items.Add(item); 92 } 93 foreach (string key in Content.Results.Keys) { 94 IItem value = Content.Results[key]; 95 if ((value != null) && (!listView.SmallImageList.Images.ContainsKey(value.GetType().FullName))) 96 listView.SmallImageList.Images.Add(value.GetType().FullName, value.ItemImage); 97 98 ListViewItem item = new ListViewItem(new string[] { key, value != null ? value.ToString() : "-" }); 99 item.Tag = value; 100 item.Group = listView.Groups["resultsGroup"]; 101 item.ImageIndex = listView.SmallImageList.Images.IndexOfKey(value != null ? value.GetType().FullName : "Default"); 102 listView.Items.Add(item); 103 } 80 foreach (string key in Content.Parameters.Keys) 81 CreateListViewItem(key, Content.Parameters[key], listView.Groups["parametersGroup"]); 82 foreach (string key in Content.Results.Keys) 83 CreateListViewItem(key, Content.Results[key], listView.Groups["resultsGroup"]); 104 84 if (listView.Items.Count > 0) { 105 85 for (int i = 0; i < listView.Columns.Count; i++) … … 107 87 } 108 88 } 89 } 90 91 private void CreateListViewItem(string name, IItem value, ListViewGroup group) { 92 ListViewItem item = new ListViewItem(new string[] { name, value != null ? value.ToString() : "-" }); 93 item.Tag = value; 94 item.Group = group; 95 listView.SmallImageList.Images.Add(value == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : value.ItemImage); 96 item.ImageIndex = listView.SmallImageList.Images.Count - 1; 97 listView.Items.Add(item); 109 98 } 110 99 … … 130 119 data.SetData("Type", item.GetType()); 131 120 data.SetData("Value", item); 132 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);121 DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy); 133 122 } 134 123 private void showAlgorithmButton_Click(object sender, EventArgs e) { 135 MainFormManager.CreateDefaultView(Content.Algorithm ).Show();124 MainFormManager.CreateDefaultView(Content.Algorithm.Clone()).Show(); 136 125 } 137 126 }
Note: See TracChangeset
for help on using the changeset viewer.