Changeset 3341
- Timestamp:
- 04/14/10 05:09:59 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs
r3299 r3341 90 90 else { 91 91 if (!itemListViewItemTable.ContainsKey(item)) { 92 if (!listView.SmallImageList.Images.ContainsKey(item.GetType().FullName))93 listView.SmallImageList.Images.Add(item.GetType().FullName, item.ItemImage);94 95 92 ListViewItem listViewItem = new ListViewItem(item.ToString()); 96 93 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 97 listViewItem.ImageIndex = listView.SmallImageList.Images.IndexOfKey(item.GetType().FullName); 94 listView.SmallImageList.Images.Add(item.ItemImage); 95 listViewItem.ImageIndex = listView.SmallImageList.Images.Count - 1; 98 96 listViewItem.Tag = item; 99 97 listView.Items.Add(listViewItem); 100 98 itemListViewItemTable.Add(item, listViewItem); 99 item.ItemImageChanged += new EventHandler(Item_ItemImageChanged); 101 100 item.ToStringChanged += new EventHandler(Item_ToStringChanged); 102 101 sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1; … … 105 104 } 106 105 } 106 107 107 private void RemoveItem(T item) { 108 108 if (InvokeRequired) … … 110 110 else { 111 111 if (itemListViewItemTable.ContainsKey(item)) { 112 item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 112 113 item.ToStringChanged -= new EventHandler(Item_ToStringChanged); 113 itemListViewItemTable[item].Remove(); 114 ListViewItem listViewItem = itemListViewItemTable[item]; 115 listViewItem.Remove(); 116 foreach (ListViewItem other in listView.Items) 117 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 118 listView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 114 119 itemListViewItemTable.Remove(item); 115 120 sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1; … … 282 287 283 288 #region Item Events 289 private void Item_ItemImageChanged(object sender, EventArgs e) { 290 if (InvokeRequired) 291 Invoke(new EventHandler(Item_ItemImageChanged), sender, e); 292 else { 293 T item = (T)sender; 294 ListViewItem listViewItem = itemListViewItemTable[item]; 295 int i = listViewItem.ImageIndex; 296 listViewItem.ImageList.Images[i] = item.ItemImage; 297 listViewItem.ImageIndex = -1; 298 listViewItem.ImageIndex = i; 299 } 300 } 284 301 private void Item_ToStringChanged(object sender, EventArgs e) { 285 302 if (InvokeRequired) -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs
r3281 r3341 63 63 this.itemsGroupBox = new System.Windows.Forms.GroupBox(); 64 64 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 65 this.removeButton = new System.Windows.Forms.Button(); 66 this.addButton = new System.Windows.Forms.Button(); 65 67 this.splitContainer.Panel1.SuspendLayout(); 66 68 this.splitContainer.Panel2.SuspendLayout(); … … 79 81 // splitContainer.Panel1 80 82 // 83 this.splitContainer.Panel1.Controls.Add(this.addButton); 81 84 this.splitContainer.Panel1.Controls.Add(this.moveUpButton); 85 this.splitContainer.Panel1.Controls.Add(this.removeButton); 82 86 this.splitContainer.Panel1.Controls.Add(this.moveDownButton); 83 87 this.splitContainer.Panel1.Controls.Add(this.itemsListView); … … 94 98 this.moveUpButton.Enabled = false; 95 99 this.moveUpButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.ArrowUp; 96 this.moveUpButton.Location = new System.Drawing.Point(3 , 3);100 this.moveUpButton.Location = new System.Drawing.Point(33, 3); 97 101 this.moveUpButton.Name = "moveUpButton"; 98 102 this.moveUpButton.Size = new System.Drawing.Size(24, 24); 99 this.moveUpButton.TabIndex = 0;103 this.moveUpButton.TabIndex = 1; 100 104 this.toolTip.SetToolTip(this.moveUpButton, "Move Up"); 101 105 this.moveUpButton.UseVisualStyleBackColor = true; … … 106 110 this.moveDownButton.Enabled = false; 107 111 this.moveDownButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.ArrowDown; 108 this.moveDownButton.Location = new System.Drawing.Point( 33, 3);112 this.moveDownButton.Location = new System.Drawing.Point(63, 3); 109 113 this.moveDownButton.Name = "moveDownButton"; 110 114 this.moveDownButton.Size = new System.Drawing.Size(24, 24); 111 this.moveDownButton.TabIndex = 1;115 this.moveDownButton.TabIndex = 2; 112 116 this.toolTip.SetToolTip(this.moveDownButton, "Move Down"); 113 117 this.moveDownButton.UseVisualStyleBackColor = true; … … 129 133 this.itemsListView.Size = new System.Drawing.Size(194, 286); 130 134 this.itemsListView.SmallImageList = this.imageList; 131 this.itemsListView.TabIndex = 2;135 this.itemsListView.TabIndex = 4; 132 136 this.itemsListView.UseCompatibleStateImageBehavior = false; 133 137 this.itemsListView.View = System.Windows.Forms.View.Details; … … 170 174 this.viewHost.Size = new System.Drawing.Size(271, 269); 171 175 this.viewHost.TabIndex = 0; 176 this.viewHost.ViewType = null; 172 177 // 173 178 // itemsGroupBox … … 181 186 this.itemsGroupBox.TabStop = false; 182 187 this.itemsGroupBox.Text = "Items"; 188 // 189 // removeButton 190 // 191 this.removeButton.Enabled = false; 192 this.removeButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Remove; 193 this.removeButton.Location = new System.Drawing.Point(93, 3); 194 this.removeButton.Name = "removeButton"; 195 this.removeButton.Size = new System.Drawing.Size(24, 24); 196 this.removeButton.TabIndex = 3; 197 this.toolTip.SetToolTip(this.removeButton, "Clear"); 198 this.removeButton.UseVisualStyleBackColor = true; 199 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); 200 // 201 // addButton 202 // 203 this.addButton.Enabled = false; 204 this.addButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Add; 205 this.addButton.Location = new System.Drawing.Point(3, 3); 206 this.addButton.Name = "addButton"; 207 this.addButton.Size = new System.Drawing.Size(24, 24); 208 this.addButton.TabIndex = 0; 209 this.toolTip.SetToolTip(this.addButton, "Set"); 210 this.addButton.UseVisualStyleBackColor = true; 211 this.addButton.Click += new System.EventHandler(this.addButton_Click); 183 212 // 184 213 // ItemArrayView … … 209 238 protected ImageList imageList; 210 239 protected HeuristicLab.MainForm.WindowsForms.ViewHost viewHost; 240 protected Button removeButton; 241 protected Button addButton; 211 242 } 212 243 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs
r3228 r3341 112 112 } 113 113 protected virtual ListViewItem CreateListViewItem(T item) { 114 if (item == null) { 115 return new ListViewItem("null"); 116 } else { 117 if (!itemsListView.SmallImageList.Images.ContainsKey(item.GetType().FullName)) 118 itemsListView.SmallImageList.Images.Add(item.GetType().FullName, item.ItemImage); 119 120 ListViewItem listViewItem = new ListViewItem(); 121 listViewItem.Text = item.ToString(); 122 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 123 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.IndexOfKey(item.GetType().FullName); 124 listViewItem.Tag = item; 125 return listViewItem; 126 } 114 ListViewItem listViewItem = new ListViewItem(); 115 listViewItem.Text = item == null ? "null" : item.ToString(); 116 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 117 itemsListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage); 118 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 119 listViewItem.Tag = item; 120 return listViewItem; 127 121 } 128 122 protected virtual void AddListViewItem(ListViewItem listViewItem) { 129 123 itemsListView.Items.Add(listViewItem); 130 if (listViewItem.Tag != null) 124 if (listViewItem.Tag != null) { 125 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 131 126 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 127 } 132 128 } 133 129 protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) { 134 130 itemsListView.Items.Insert(index, listViewItem); 135 if (listViewItem.Tag != null) 131 if (listViewItem.Tag != null) { 132 ((T)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged); 136 133 ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged); 134 } 137 135 } 138 136 protected virtual void RemoveListViewItem(ListViewItem listViewItem) { 139 if (listViewItem.Tag != null) 137 if (listViewItem.Tag != null) { 138 ((T)listViewItem.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged); 140 139 ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged); 140 } 141 141 listViewItem.Remove(); 142 } 143 protected virtual void UpdateListViewItem(ListViewItem listViewItem) { 142 foreach (ListViewItem other in itemsListView.Items) 143 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 144 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 145 } 146 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { 144 147 T item = listViewItem.Tag as T; 145 if ((item != null) && (!itemsListView.SmallImageList.Images.ContainsKey(item.GetType().FullName))) 146 itemsListView.SmallImageList.Images.Add(item.GetType().FullName, item.ItemImage); 147 148 int i = listViewItem.ImageIndex; 149 listViewItem.ImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing : item.ItemImage; 150 listViewItem.ImageIndex = -1; 151 listViewItem.ImageIndex = i; 152 } 153 protected virtual void UpdateListViewItemText(ListViewItem listViewItem) { 154 T item = listViewItem.Tag as T; 148 155 listViewItem.Text = item == null ? "null" : item.ToString(); 149 156 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; 150 listViewItem.ImageIndex = item == null ? -1 : itemsListView.SmallImageList.Images.IndexOfKey(item.GetType().FullName);151 157 } 152 158 153 159 protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) { 160 addButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly; 154 161 moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 && 155 162 itemsListView.SelectedIndices[0] != 0 && … … 158 165 itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 && 159 166 !Content.IsReadOnly; 167 removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly; 160 168 161 169 if (itemsListView.SelectedItems.Count == 1) { … … 239 247 240 248 #region Button Events 249 protected virtual void addButton_Click(object sender, EventArgs e) { 250 if (itemsListView.SelectedItems.Count > 0) { 251 T item = CreateItem(); 252 if (item != null) { 253 foreach (ListViewItem listViewItem in itemsListView.SelectedItems) 254 Content[listViewItem.Index] = item; 255 } 256 } 257 } 241 258 protected virtual void moveUpButton_Click(object sender, EventArgs e) { 242 259 if (itemsListView.SelectedItems.Count == 1) { … … 259 276 } 260 277 } 278 protected virtual void removeButton_Click(object sender, EventArgs e) { 279 if (itemsListView.SelectedItems.Count > 0) { 280 foreach (ListViewItem item in itemsListView.SelectedItems) 281 Content[item.Index] = null; 282 } 283 } 261 284 #endregion 262 285 … … 289 312 ListViewItem listViewItem = itemsListView.Items[item.Index]; 290 313 listViewItem.Tag = item.Value; 291 UpdateListViewItem(listViewItem); 314 UpdateListViewItemImage(listViewItem); 315 UpdateListViewItemText(listViewItem); 292 316 } 293 317 } … … 310 334 311 335 #region Item Events 312 protected virtual void Item_ ToStringChanged(object sender, EventArgs e) {313 if (InvokeRequired) 314 Invoke(new EventHandler(Item_ ToStringChanged), sender, e);336 protected virtual void Item_ItemImageChanged(object sender, EventArgs e) { 337 if (InvokeRequired) 338 Invoke(new EventHandler(Item_ItemImageChanged), sender, e); 315 339 else { 316 340 T item = (T)sender; 317 341 foreach (ListViewItem listViewItem in itemsListView.Items) { 318 342 if (((T)listViewItem.Tag) == item) 319 UpdateListViewItem(listViewItem); 343 UpdateListViewItemImage(listViewItem); 344 } 345 } 346 } 347 protected virtual void Item_ToStringChanged(object sender, EventArgs e) { 348 if (InvokeRequired) 349 Invoke(new EventHandler(Item_ToStringChanged), sender, e); 350 else { 351 T item = (T)sender; 352 foreach (ListViewItem listViewItem in itemsListView.Items) { 353 if (((T)listViewItem.Tag) == item) 354 UpdateListViewItemText(listViewItem); 320 355 } 321 356 } -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r3327 r3341 117 117 ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged); 118 118 listViewItem.Remove(); 119 foreach (ListViewItem other in itemsListView.Items) 120 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 121 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 119 122 sortAscendingButton.Enabled = itemsListView.Items.Count > 0; 120 123 sortDescendingButton.Enabled = itemsListView.Items.Count > 0; -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r3327 r3341 141 141 ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged); 142 142 listViewItem.Remove(); 143 foreach (ListViewItem other in itemsListView.Items) 144 if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--; 145 itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex); 143 146 } 144 147 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { -
trunk/sources/HeuristicLab.Core.Views/3.3/OperatorTreeView.cs
r3135 r3341 124 124 private void FillTreeNode(TreeNode node, IOperator op) { 125 125 if (op == null) { 126 if (!graphTreeView.ImageList.Images.ContainsKey("Default"))127 graphTreeView.ImageList.Images.Add("Default", HeuristicLab.Common.Resources.VS2008ImageLibrary.Method);128 129 126 node.Text += "-"; 130 127 node.ToolTipText = ""; 131 node.ImageIndex = graphTreeView.ImageList.Images.IndexOfKey("Default"); ; 128 graphTreeView.ImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Nothing); 129 node.ImageIndex = graphTreeView.ImageList.Images.Count - 1; 132 130 node.SelectedImageIndex = node.ImageIndex; 133 131 node.ForeColor = graphTreeView.ForeColor; 134 132 } else { 135 if (!graphTreeView.ImageList.Images.ContainsKey(op.GetType().FullName))136 graphTreeView.ImageList.Images.Add(op.GetType().FullName, op.ItemImage);137 138 133 node.Text += op.Name; 139 134 node.ToolTipText = op.ItemName + ": " + op.ItemDescription; 140 node.ImageIndex = graphTreeView.ImageList.Images.IndexOfKey(op.GetType().FullName); 135 graphTreeView.ImageList.Images.Add(op.ItemImage); 136 node.ImageIndex = graphTreeView.ImageList.Images.Count - 1; 141 137 node.SelectedImageIndex = node.ImageIndex; 142 138 SetOperatorTag(node, op); … … 144 140 if (!operatorNodeTable.ContainsKey(op)) { 145 141 operatorNodeTable.Add(op, new List<TreeNode>()); 142 op.ItemImageChanged += new EventHandler(op_ItemImageChanged); 146 143 op.NameChanged += new EventHandler(op_NameChanged); 147 144 op.BreakpointChanged += new EventHandler(op_BreakpointChanged); … … 168 165 RemoveTreeNode(node.Nodes[0]); 169 166 167 if (node.ImageIndex != -1) { 168 int i = node.ImageIndex; 169 CorrectImageIndexes(graphTreeView.Nodes, i); 170 graphTreeView.ImageList.Images.RemoveAt(i); 171 } 172 170 173 IOperator op = GetOperatorTag(node); 171 174 if (op != null) { 172 175 operatorNodeTable[op].Remove(node); 173 176 if (operatorNodeTable[op].Count == 0) { 177 op.ItemImageChanged -= new EventHandler(op_ItemImageChanged); 174 178 op.NameChanged -= new EventHandler(op_NameChanged); 175 179 op.BreakpointChanged -= new EventHandler(op_BreakpointChanged); … … 229 233 node.Text = opParam.Name + ": "; 230 234 FillTreeNode(node, opParam.Value); 235 } 236 } 237 } 238 void op_ItemImageChanged(object sender, EventArgs e) { 239 if (InvokeRequired) 240 Invoke(new EventHandler(op_ItemImageChanged), sender, e); 241 else { 242 IOperator op = (IOperator)sender; 243 foreach (TreeNode node in operatorNodeTable[op]) { 244 int i = node.ImageIndex; 245 graphTreeView.ImageList.Images[i] = op.ItemImage; 246 node.ImageIndex = -1; 247 node.SelectedImageIndex = -1; 248 node.ImageIndex = i; 249 node.SelectedImageIndex = i; 231 250 } 232 251 } … … 433 452 ((Tuple<IValueParameter<IOperator>, IOperator>)node.Tag).Item2 = op; 434 453 } 454 455 private void CorrectImageIndexes(TreeNodeCollection nodes, int removedIndex) { 456 foreach (TreeNode node in nodes) { 457 if (node.ImageIndex > removedIndex) { 458 node.ImageIndex--; 459 node.SelectedImageIndex--; 460 } 461 CorrectImageIndexes(node.Nodes, removedIndex); 462 } 463 } 435 464 #endregion 436 465 } -
trunk/sources/HeuristicLab.Core/3.3/Variable.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 31 32 [StorableClass] 32 33 public sealed class Variable : NamedItem, IVariable { 34 public override Image ItemImage { 35 get { 36 if (value != null) return value.ItemImage; 37 else return base.ItemImage; 38 } 39 } 40 33 41 [Storable] 34 42 private IItem value; … … 39 47 set { 40 48 if (this.value != value) { 41 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);49 DeregisterValueEvents(); 42 50 this.value = value; 43 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);51 RegisterValueEvents(); 44 52 OnValueChanged(); 45 53 } … … 84 92 [StorableHook(HookType.AfterDeserialization)] 85 93 private void Initialize() { 86 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);94 RegisterValueEvents(); 87 95 } 88 96 … … 120 128 if (ValueChanged != null) 121 129 ValueChanged(this, EventArgs.Empty); 130 OnItemImageChanged(); 122 131 OnToStringChanged(); 123 132 } 124 133 134 private void RegisterValueEvents() { 135 if (value != null) { 136 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 137 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 138 } 139 } 140 private void DeregisterValueEvents() { 141 if (value != null) { 142 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 143 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 144 } 145 } 146 private void Value_ItemImageChanged(object sender, EventArgs e) { 147 OnItemImageChanged(); 148 } 125 149 private void Value_ToStringChanged(object sender, EventArgs e) { 126 150 OnToStringChanged(); -
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 } -
trunk/sources/HeuristicLab.Optimization/3.3/Result.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 32 33 [StorableClass] 33 34 public sealed class Result : NamedItem, IResult { 35 public override Image ItemImage { 36 get { 37 if (value != null) return value.ItemImage; 38 else return base.ItemImage; 39 } 40 } 41 34 42 public override bool CanChangeName { 35 43 get { return false; } … … 57 65 ); 58 66 59 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);67 DeregisterValueEvents(); 60 68 this.value = value; 61 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);69 RegisterValueEvents(); 62 70 OnValueChanged(); 63 71 } … … 97 105 [StorableHook(HookType.AfterDeserialization)] 98 106 private void Initialize() { 99 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);107 RegisterValueEvents(); 100 108 } 101 109 … … 117 125 if (ValueChanged != null) 118 126 ValueChanged(this, EventArgs.Empty); 127 OnItemImageChanged(); 119 128 OnToStringChanged(); 120 129 } 121 130 131 private void RegisterValueEvents() { 132 if (value != null) { 133 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 134 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 135 } 136 } 137 private void DeregisterValueEvents() { 138 if (value != null) { 139 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 140 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 141 } 142 } 143 private void Value_ItemImageChanged(object sender, EventArgs e) { 144 OnItemImageChanged(); 145 } 122 146 private void Value_ToStringChanged(object sender, EventArgs e) { 123 147 OnToStringChanged(); -
trunk/sources/HeuristicLab.Parameters/3.3/ConstrainedValueParameter.cs
r3017 r3341 49 49 public ConstrainedValueParameter(string name, string description, ItemSet<T> validValues, T value) : base(name, description, validValues, value) { } 50 50 51 protected override void validValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) {51 protected override void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { 52 52 if (Value == null) Value = ValidValues.First(); 53 53 } -
trunk/sources/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Collections; 24 25 using HeuristicLab.Common; … … 33 34 [StorableClass] 34 35 public class OptionalConstrainedValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem { 36 public override Image ItemImage { 37 get { 38 if (value != null) return value.ItemImage; 39 else return base.ItemImage; 40 } 41 } 42 35 43 [Storable] 36 44 private ItemSet<T> validValues; … … 46 54 if (value != this.value) { 47 55 if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value."); 48 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);56 DeregisterValueEvents(); 49 57 this.value = value; 50 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);58 RegisterValueEvents(); 51 59 OnValueChanged(); 52 60 } … … 110 118 private void Initialize() { 111 119 RegisterValidValuesEvents(); 112 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);120 RegisterValueEvents(); 113 121 } 114 122 … … 136 144 if (ValueChanged != null) 137 145 ValueChanged(this, EventArgs.Empty); 146 OnItemImageChanged(); 138 147 OnToStringChanged(); 139 148 } … … 141 150 private void RegisterValidValuesEvents() { 142 151 if (validValues != null) { 143 validValues.ItemsAdded += new CollectionItemsChangedEventHandler<T>( validValues_ItemsAdded);152 validValues.ItemsAdded += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded); 144 153 validValues.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); 145 154 validValues.CollectionReset += new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset); 146 155 } 147 156 } 148 149 157 private void DeregisterValidValuesEvents() { 150 158 if (validValues != null) { 151 validValues.ItemsAdded -= new CollectionItemsChangedEventHandler<T>( validValues_ItemsAdded);159 validValues.ItemsAdded -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsAdded); 152 160 validValues.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved); 153 161 validValues.CollectionReset -= new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset); 154 162 } 155 163 } 156 157 protected virtual void validValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { } 164 protected virtual void ValidValues_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { } 158 165 protected virtual void ValidValues_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) { 159 166 if ((Value != null) && !validValues.Contains(Value)) Value = null; … … 162 169 if ((Value != null) && !validValues.Contains(Value)) Value = null; 163 170 } 164 protected virtual void Value_ToStringChanged(object sender, EventArgs e) { 171 172 private void RegisterValueEvents() { 173 if (value != null) { 174 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 175 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 176 } 177 } 178 private void DeregisterValueEvents() { 179 if (value != null) { 180 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 181 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 182 } 183 } 184 private void Value_ItemImageChanged(object sender, EventArgs e) { 185 OnItemImageChanged(); 186 } 187 private void Value_ToStringChanged(object sender, EventArgs e) { 165 188 OnToStringChanged(); 166 189 } -
trunk/sources/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 32 33 [StorableClass] 33 34 public class OptionalValueParameter<T> : Parameter, IValueParameter<T> where T : class, IItem { 35 public override Image ItemImage { 36 get { 37 if (value != null) return value.ItemImage; 38 else return base.ItemImage; 39 } 40 } 41 34 42 [Storable] 35 43 private T value; … … 38 46 set { 39 47 if (value != this.value) { 40 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);48 DeregisterValueEvents(); 41 49 this.value = value; 42 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);50 RegisterValueEvents(); 43 51 OnValueChanged(); 44 52 } … … 82 90 [StorableHook(HookType.AfterDeserialization)] 83 91 private void Initialize() { 84 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);92 RegisterValueEvents(); 85 93 } 86 94 … … 107 115 if (ValueChanged != null) 108 116 ValueChanged(this, EventArgs.Empty); 117 OnItemImageChanged(); 109 118 OnToStringChanged(); 119 } 120 121 private void RegisterValueEvents() { 122 if (value != null) { 123 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 124 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 125 } 126 } 127 private void DeregisterValueEvents() { 128 if (value != null) { 129 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 130 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 131 } 132 } 133 private void Value_ItemImageChanged(object sender, EventArgs e) { 134 OnItemImageChanged(); 110 135 } 111 136 private void Value_ToStringChanged(object sender, EventArgs e) { -
trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs
r3317 r3341 21 21 22 22 using System; 23 using System.Drawing; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 32 33 [StorableClass] 33 34 public class ValueLookupParameter<T> : LookupParameter<T>, IValueLookupParameter<T> where T : class, IItem { 35 public override Image ItemImage { 36 get { 37 if (value != null) return value.ItemImage; 38 else return base.ItemImage; 39 } 40 } 41 34 42 [Storable] 35 43 private T value; … … 38 46 set { 39 47 if (value != this.value) { 40 if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);48 DeregisterValueEvents(); 41 49 this.value = value; 42 if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);50 RegisterValueEvents(); 43 51 OnValueChanged(); 44 52 } … … 85 93 [StorableHook(HookType.AfterDeserialization)] 86 94 private void Initialize() { 87 if (value != null) value.ToStringChanged += new EventHandler(Value_ToStringChanged);95 RegisterValueEvents(); 88 96 } 89 97 … … 103 111 if (ValueChanged != null) 104 112 ValueChanged(this, EventArgs.Empty); 113 OnItemImageChanged(); 105 114 OnToStringChanged(); 115 } 116 117 private void RegisterValueEvents() { 118 if (value != null) { 119 value.ItemImageChanged += new EventHandler(Value_ItemImageChanged); 120 value.ToStringChanged += new EventHandler(Value_ToStringChanged); 121 } 122 } 123 private void DeregisterValueEvents() { 124 if (value != null) { 125 value.ItemImageChanged -= new EventHandler(Value_ItemImageChanged); 126 value.ToStringChanged -= new EventHandler(Value_ToStringChanged); 127 } 128 } 129 private void Value_ItemImageChanged(object sender, EventArgs e) { 130 OnItemImageChanged(); 106 131 } 107 132 private void Value_ToStringChanged(object sender, EventArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.