Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/12 16:45:02 (13 years ago)
Author:
spimming
Message:

#1680:

  • merged changes from trunk into branch
Location:
branches/HeuristicLab.Hive.Azure
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Optimizer/3.3/NewItemDialog.cs

    r5445 r7270  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
    23 using System.Collections.Generic;
     23using System.Drawing;
    2424using System.Linq;
    2525using System.Windows.Forms;
     
    3030  internal partial class NewItemDialog : Form {
    3131    private bool initialized;
    32     private List<IItem> items;
    3332
    3433    private IItem item;
     
    3938    public NewItemDialog() {
    4039      initialized = false;
    41       items = new List<IItem>();
    4240      item = null;
    4341      InitializeComponent();
     
    5351
    5452        itemsListView.SmallImageList = new ImageList();
     53        itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Class);  // default icon
    5554        foreach (var category in categories) {
    5655          ListViewGroup group = new ListViewGroup(category.Key);
    5756          itemsListView.Groups.Add(group);
    5857          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;
    6569            itemsListView.Items.Add(item);
    6670          }
     
    8286    private void okButton_Click(object sender, EventArgs e) {
    8387      if (itemsListView.SelectedItems.Count == 1) {
    84         item = (IItem)((IItem)itemsListView.SelectedItems[0].Tag).Clone();
     88        item = (IItem)Activator.CreateInstance((Type)itemsListView.SelectedItems[0].Tag);
    8589        DialogResult = DialogResult.OK;
    8690        Close();
     
    8993    private void itemTypesListView_DoubleClick(object sender, EventArgs e) {
    9094      if (itemsListView.SelectedItems.Count == 1) {
    91         item = (IItem)((IItem)itemsListView.SelectedItems[0].Tag).Clone();
     95        item = (IItem)Activator.CreateInstance((Type)itemsListView.SelectedItems[0].Tag);
    9296        DialogResult = DialogResult.OK;
    9397        Close();
Note: See TracChangeset for help on using the changeset viewer.