Changeset 3775
- Timestamp:
- 05/11/10 18:16:41 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs
r3764 r3775 84 84 protected override void OnContentChanged() { 85 85 base.OnContentChanged(); 86 87 int selectedIndex = -1; 88 if (itemsListView.SelectedItems.Count == 1) selectedIndex = itemsListView.SelectedIndices[0]; 89 86 90 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 87 91 viewHost.Content = null; … … 90 94 foreach (T item in Content) 91 95 AddListViewItem(CreateListViewItem(item)); 96 if ((selectedIndex != -1) && (selectedIndex < itemsListView.Items.Count)) 97 itemsListView.Items[selectedIndex].Selected = true; 92 98 } 93 99 SetEnabledStateOfControls(); -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r3764 r3775 88 88 protected override void OnContentChanged() { 89 89 base.OnContentChanged(); 90 91 int selectedIndex = -1; 92 if (itemsListView.SelectedItems.Count == 1) selectedIndex = itemsListView.SelectedIndices[0]; 93 90 94 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 91 95 viewHost.Content = null; … … 93 97 foreach (T item in Content) 94 98 AddListViewItem(CreateListViewItem(item)); 99 if ((selectedIndex != -1) && (selectedIndex < itemsListView.Items.Count)) 100 itemsListView.Items[selectedIndex].Selected = true; 95 101 } 96 102 SetEnabledStateOfControls(); -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemCollectionView.cs
r3764 r3775 51 51 base.RegisterContentEvents(); 52 52 Content.ItemsReplaced += new CollectionItemsChangedEventHandler<T>(Content_ItemsReplaced); 53 } 54 55 protected override void OnContentChanged() { 56 string selectedName = null; 57 if ((itemsListView.SelectedItems.Count == 1) && (itemsListView.SelectedItems[0].Tag != null)) 58 selectedName = ((T)itemsListView.SelectedItems[0].Tag).Name; 59 base.OnContentChanged(); 60 if (selectedName != null) { 61 foreach (ListViewItem item in itemsListView.Items) { 62 if ((item.Tag != null) && (((T)item.Tag).Name.Equals(selectedName))) 63 item.Selected = true; 64 } 65 } 53 66 } 54 67 -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs
r3764 r3775 94 94 protected override void OnContentChanged() { 95 95 base.OnContentChanged(); 96 97 string selectedName = null; 98 if ((itemsListView.SelectedItems.Count == 1) && (itemsListView.SelectedItems[0].Tag != null)) 99 selectedName = ((IRun)itemsListView.SelectedItems[0].Tag).Name; 100 96 101 while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]); 97 102 viewHost.Content = null; … … 105 110 } 106 111 foreach (IRun item in Content) { 107 AddListViewItem(CreateListViewItem(item)); 112 ListViewItem listViewItem = CreateListViewItem(item); 113 AddListViewItem(listViewItem); 108 114 UpdateRun(item); 115 if ((selectedName != null) && item.Name.Equals(selectedName)) 116 listViewItem.Selected = true; 109 117 } 110 118 } else { -
trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs
r3766 r3775 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Windows.Forms; 24 25 using HeuristicLab.Common; … … 69 70 protected override void OnContentChanged() { 70 71 base.OnContentChanged(); 71 FillListView();72 viewHost.ViewType = null;73 72 viewHost.Content = null; 74 73 if (Content != null) 75 74 UpdateColorPictureBox(); 75 FillListView(); 76 76 77 77 SetEnabledStateOfControls(); … … 112 112 113 113 private void FillListView() { 114 string selectedName = null; 115 if (listView.SelectedItems.Count == 1) selectedName = listView.SelectedItems[0].SubItems[0].Text; 116 114 117 listView.Items.Clear(); 115 118 listView.SmallImageList.Images.Clear(); 116 119 if (Content != null) { 117 120 foreach (string key in Content.Parameters.Keys) 118 CreateListViewItem(key, Content.Parameters[key], listView.Groups["parametersGroup"] );121 CreateListViewItem(key, Content.Parameters[key], listView.Groups["parametersGroup"], selectedName); 119 122 foreach (string key in Content.Results.Keys) 120 CreateListViewItem(key, Content.Results[key], listView.Groups["resultsGroup"] );123 CreateListViewItem(key, Content.Results[key], listView.Groups["resultsGroup"], selectedName); 121 124 if (listView.Items.Count > 0) { 122 125 for (int i = 0; i < listView.Columns.Count; i++) … … 126 129 } 127 130 128 private void CreateListViewItem(string name, IItem value, ListViewGroup group ) {131 private void CreateListViewItem(string name, IItem value, ListViewGroup group, string selectedName) { 129 132 ListViewItem item = new ListViewItem(new string[] { name, value != null ? value.ToString() : "-" }); 130 133 item.Tag = value; … … 133 136 item.ImageIndex = listView.SmallImageList.Images.Count - 1; 134 137 listView.Items.Add(item); 138 if ((selectedName != null) && name.Equals(selectedName)) item.Selected = true; 135 139 } 136 140 137 141 private void listView_SelectedIndexChanged(object sender, EventArgs e) { 138 if (listView.SelectedItems.Count == 1) { 139 viewHost.ViewType = null; 142 if (listView.SelectedItems.Count == 1) 140 143 viewHost.Content = (IContent)listView.SelectedItems[0].Tag; 141 } else {144 else 142 145 viewHost.Content = null; 143 }144 146 } 145 147 private void listView_DoubleClick(object sender, EventArgs e) {
Note: See TracChangeset
for help on using the changeset viewer.