- Timestamp:
- 12/20/11 11:45:18 (13 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Optimizer/3.3/NewItemDialog.cs
r5445 r7213 21 21 22 22 using System; 23 using System. Collections.Generic;23 using System.Drawing; 24 24 using System.Linq; 25 25 using System.Windows.Forms; … … 30 30 internal partial class NewItemDialog : Form { 31 31 private bool initialized; 32 private List<IItem> items;33 32 34 33 private IItem item; … … 39 38 public NewItemDialog() { 40 39 initialized = false; 41 items = new List<IItem>();42 40 item = null; 43 41 InitializeComponent(); … … 53 51 54 52 itemsListView.SmallImageList = new ImageList(); 53 itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class); // default icon 55 54 foreach (var category in categories) { 56 55 ListViewGroup group = new ListViewGroup(category.Key); 57 56 itemsListView.Groups.Add(group); 58 57 foreach (var creatable in category) { 59 IItem i = (IItem)Activator.CreateInstance(creatable); 60 items.Add(i); 61 ListViewItem item = new ListViewItem(new string[] { i.ItemName, i.ItemVersion.ToString(), i.ItemDescription }, group); 62 itemsListView.SmallImageList.Images.Add(i.ItemImage); 63 item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 64 item.Tag = i; 58 string name = ItemAttribute.GetName(creatable); 59 string version = ItemAttribute.GetVersion(creatable).ToString(); 60 string description = ItemAttribute.GetDescription(creatable); 61 ListViewItem item = new ListViewItem(new string[] { name, version, description }, group); 62 item.ImageIndex = 0; 63 Image image = ItemAttribute.GetImage(creatable); 64 if (image != null) { 65 itemsListView.SmallImageList.Images.Add(image); 66 item.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 67 } 68 item.Tag = creatable; 65 69 itemsListView.Items.Add(item); 66 70 } … … 82 86 private void okButton_Click(object sender, EventArgs e) { 83 87 if (itemsListView.SelectedItems.Count == 1) { 84 item = (IItem) ((IItem)itemsListView.SelectedItems[0].Tag).Clone();88 item = (IItem)Activator.CreateInstance((Type)itemsListView.SelectedItems[0].Tag); 85 89 DialogResult = DialogResult.OK; 86 90 Close(); … … 89 93 private void itemTypesListView_DoubleClick(object sender, EventArgs e) { 90 94 if (itemsListView.SelectedItems.Count == 1) { 91 item = (IItem) ((IItem)itemsListView.SelectedItems[0].Tag).Clone();95 item = (IItem)Activator.CreateInstance((Type)itemsListView.SelectedItems[0].Tag); 92 96 DialogResult = DialogResult.OK; 93 97 Close();
Note: See TracChangeset
for help on using the changeset viewer.