Changeset 5783
- Timestamp:
- 03/22/11 01:23:39 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs
r5768 r5783 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Collections; 27 28 using HeuristicLab.MainForm; 28 29 … … 33 34 public partial class ParameterCollectionView : NamedItemCollectionView<IParameter> { 34 35 protected CreateParameterDialog createParameterDialog; 35 /// <summary> 36 /// Initializes a new instance of <see cref="VariablesScopeView"/> with caption "Variables Scope View". 37 /// </summary> 36 38 37 public ParameterCollectionView() { 39 38 InitializeComponent(); … … 56 55 base.RegisterItemEvents(item); 57 56 item.HiddenChanged += new EventHandler(Item_HiddenChanged); 57 } 58 59 protected override void OnContentChanged() { 60 base.OnContentChanged(); 61 if ((Content == null) || !Content.Any(x => x.Hidden)) 62 showHiddenParametersCheckBox.Checked = false; 63 } 64 65 protected override void SetEnabledStateOfControls() { 66 base.SetEnabledStateOfControls(); 67 showHiddenParametersCheckBox.Enabled = (Content != null) && Content.Any(x => x.Hidden); 58 68 } 59 69 … … 70 80 } 71 81 72 protected override void AddListViewItem(ListViewItem listViewItem) { 73 IParameter parameter = listViewItem.Tag as IParameter; 74 if ((parameter != null) && (parameter.Hidden) && (!showHiddenParametersCheckBox.Checked)) { 75 return; // skip parameter 76 } 77 if ((parameter != null) && (parameter.Hidden) && (showHiddenParametersCheckBox.Checked)) { 82 protected override ListViewItem CreateListViewItem(IParameter item) { 83 ListViewItem listViewItem = base.CreateListViewItem(item); 84 if ((item != null) && item.Hidden) { 78 85 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 79 86 listViewItem.ForeColor = Color.LightGray; 80 87 } 88 return listViewItem; 89 } 90 91 protected override void AddListViewItem(ListViewItem listViewItem) { 81 92 base.AddListViewItem(listViewItem); 93 IParameter parameter = listViewItem.Tag as IParameter; 94 if ((parameter != null) && parameter.Hidden && !showHiddenParametersCheckBox.Checked) { 95 itemsListView.Items.Remove(listViewItem); 96 RebuildImageList(); 97 } 82 98 } 83 99 84 100 protected virtual void UpdateParameterVisibility(IParameter parameter) { 85 if (parameter.Hidden) {86 if ( showHiddenParametersCheckBox.Checked) {87 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter)) {88 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic);89 listViewItem.ForeColor = Color.LightGray;90 }101 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter)) { 102 if (parameter.Hidden) { 103 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic); 104 listViewItem.ForeColor = Color.LightGray; 105 if (!showHiddenParametersCheckBox.Checked) 106 itemsListView.Items.Remove(listViewItem); 91 107 } else { 92 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter).ToArray()) 93 RemoveListViewItem(listViewItem); 94 RebuildImageList(); 95 } 96 } else { 97 if (showHiddenParametersCheckBox.Checked) { 98 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter)) { 99 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 100 listViewItem.ForeColor = itemsListView.ForeColor; 101 } 102 } else { 103 for (int i = 0; i < Content.Count(x => x == parameter); i++) 104 AddListViewItem(CreateListViewItem(parameter)); 105 } 106 } 108 listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular); 109 listViewItem.ForeColor = itemsListView.ForeColor; 110 if (!showHiddenParametersCheckBox.Checked) 111 itemsListView.Items.Add(listViewItem); 112 } 113 } 114 RebuildImageList(); 107 115 AdjustListViewColumnSizes(); 116 if (!Content.Any(x => x.Hidden)) showHiddenParametersCheckBox.Checked = false; 117 showHiddenParametersCheckBox.Enabled = (Content != null) && Content.Any(x => x.Hidden); 108 118 } 109 119 110 120 #region Control Events 111 121 protected virtual void showHiddenParametersCheckBox_CheckedChanged(object sender, System.EventArgs e) { 112 if (showHiddenParametersCheckBox.Checked) { 113 foreach (IParameter parameter in Content.Where(x => x.Hidden)) 114 AddListViewItem(CreateListViewItem(parameter)); 122 if (Content != null) { 123 foreach (IParameter parameter in itemListViewItemMapping.Keys.Where(x => x.Hidden).OrderBy(x => x.ToString())) { 124 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter)) { 125 if (showHiddenParametersCheckBox.Checked) 126 itemsListView.Items.Add(listViewItem); 127 else 128 itemsListView.Items.Remove(listViewItem); 129 } 130 } 131 RebuildImageList(); 115 132 AdjustListViewColumnSizes(); 116 } else {117 foreach (IParameter parameter in Content.Where(x => x.Hidden)) {118 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter).ToArray())119 RemoveListViewItem(listViewItem);120 }121 RebuildImageList();122 133 } 123 134 } 124 135 protected virtual void itemsListViewContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) { 125 if ((itemsListView.SelectedItems.Count == 0) || ReadOnly || Locked) {126 127 } else{136 showHideParametersToolStripMenuItem.Text = "Show/Hide Parameters"; 137 showHideParametersToolStripMenuItem.Enabled = false; 138 if ((itemsListView.SelectedItems.Count > 0) && !ReadOnly && !Locked) { 128 139 List<IParameter> parameters = new List<IParameter>(); 129 140 foreach (ListViewItem listViewItem in itemsListView.SelectedItems) { … … 143 154 #endregion 144 155 156 #region Content Events 157 protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IParameter> e) { 158 if (InvokeRequired) 159 Invoke(new CollectionItemsChangedEventHandler<IParameter>(Content_ItemsAdded), sender, e); 160 else { 161 base.Content_ItemsAdded(sender, e); 162 showHiddenParametersCheckBox.Enabled = Content.Any(x => x.Hidden); 163 } 164 } 165 protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IParameter> e) { 166 if (InvokeRequired) 167 Invoke(new CollectionItemsChangedEventHandler<IParameter>(Content_ItemsRemoved), sender, e); 168 else { 169 base.Content_ItemsRemoved(sender, e); 170 if (!Content.Any(x => x.Hidden)) showHiddenParametersCheckBox.Checked = false; 171 showHiddenParametersCheckBox.Enabled = Content.Any(x => x.Hidden); 172 } 173 } 174 protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IParameter> e) { 175 if (InvokeRequired) 176 Invoke(new CollectionItemsChangedEventHandler<IParameter>(Content_CollectionReset), sender, e); 177 else { 178 base.Content_CollectionReset(sender, e); 179 if (!Content.Any(x => x.Hidden)) showHiddenParametersCheckBox.Checked = false; 180 showHiddenParametersCheckBox.Enabled = Content.Any(x => x.Hidden); 181 } 182 } 183 #endregion 184 145 185 #region Item Events 146 186 protected virtual void Item_HiddenChanged(object sender, EventArgs e) { … … 151 191 } 152 192 #endregion 193 194 #region Helpers 195 protected override void RebuildImageList() { 196 base.RebuildImageList(); 197 if (!showHiddenParametersCheckBox.Checked) { 198 // update image of hidden list view items 199 foreach (IParameter parameter in itemListViewItemMapping.Keys.Where(x => x.Hidden)) { 200 foreach (ListViewItem listViewItem in GetListViewItemsForItem(parameter)) { 201 itemsListView.SmallImageList.Images.Add(parameter.ItemImage); 202 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 203 } 204 } 205 } 206 } 207 #endregion 153 208 } 154 209 }
Note: See TracChangeset
for help on using the changeset viewer.