[3260] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[3274] | 22 | using HeuristicLab.Collections;
|
---|
[3507] | 23 | using HeuristicLab.Common;
|
---|
[3393] | 24 | using HeuristicLab.Core;
|
---|
[3260] | 25 | using HeuristicLab.Core.Views;
|
---|
| 26 | using HeuristicLab.MainForm;
|
---|
[3277] | 27 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 28 | using System.Windows.Forms;
|
---|
| 29 | using System;
|
---|
[3449] | 30 | using System.Drawing;
|
---|
[3277] | 31 | using System.Collections.Generic;
|
---|
[3507] | 32 | using System.Linq;
|
---|
[3260] | 33 |
|
---|
| 34 | namespace HeuristicLab.Optimization.Views {
|
---|
| 35 | [View("RunCollection View")]
|
---|
| 36 | [Content(typeof(RunCollection), true)]
|
---|
[3393] | 37 | [Content(typeof(IItemCollection<IRun>), false)]
|
---|
[3483] | 38 | public partial class RunCollectionView : ItemView {
|
---|
[3393] | 39 | public new IItemCollection<IRun> Content {
|
---|
| 40 | get { return (IItemCollection<IRun>)base.Content; }
|
---|
[3277] | 41 | set { base.Content = value; }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[3614] | 44 | public RunCollection RunCollection {
|
---|
| 45 | get { return Content as RunCollection; }
|
---|
| 46 | }
|
---|
| 47 |
|
---|
[3277] | 48 | public ListView ItemsListView {
|
---|
| 49 | get { return itemsListView; }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[3260] | 52 | public RunCollectionView() {
|
---|
| 53 | InitializeComponent();
|
---|
[3505] | 54 | itemsGroupBox.Text = "Runs";
|
---|
[3260] | 55 | }
|
---|
[3277] | 56 |
|
---|
| 57 | protected override void DeregisterContentEvents() {
|
---|
[3280] | 58 | Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
|
---|
| 59 | Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
|
---|
| 60 | Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
|
---|
[3449] | 61 | DeregisterRunEvents(Content);
|
---|
[3277] | 62 | base.DeregisterContentEvents();
|
---|
[3260] | 63 | }
|
---|
[3277] | 64 | protected override void RegisterContentEvents() {
|
---|
| 65 | base.RegisterContentEvents();
|
---|
[3280] | 66 | Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
|
---|
| 67 | Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
|
---|
| 68 | Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
|
---|
[3449] | 69 | RegisterRunEvents(Content);
|
---|
[3277] | 70 | }
|
---|
[3449] | 71 | protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) {
|
---|
| 72 | foreach (IRun run in runs)
|
---|
[3507] | 73 | run.Changed += new EventHandler(Run_Changed);
|
---|
[3449] | 74 | }
|
---|
| 75 | protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) {
|
---|
| 76 | foreach (IRun run in runs)
|
---|
[3507] | 77 | run.Changed -= new EventHandler(Run_Changed);
|
---|
[3449] | 78 | }
|
---|
[3277] | 79 |
|
---|
[3507] | 80 | protected override void OnInitialized(EventArgs e) {
|
---|
| 81 | base.OnInitialized(e);
|
---|
| 82 | var viewTypes = MainFormManager.GetViewTypes(typeof(RunCollection), true);
|
---|
| 83 | foreach (Type viewType in viewTypes.OrderBy(x => ViewAttribute.GetViewName(x))) {
|
---|
| 84 | if ((viewType != typeof(ItemCollectionView<IRun>)) && (viewType != typeof(ViewHost))) {
|
---|
| 85 | ToolStripMenuItem menuItem = new ToolStripMenuItem();
|
---|
| 86 | menuItem.Text = ViewAttribute.GetViewName(viewType);
|
---|
| 87 | menuItem.Tag = viewType;
|
---|
| 88 | menuItem.Click += new EventHandler(menuItem_Click);
|
---|
| 89 | analyzeRunsToolStripDropDownButton.DropDownItems.Add(menuItem);
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[3277] | 94 | protected override void OnContentChanged() {
|
---|
| 95 | base.OnContentChanged();
|
---|
[3775] | 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 |
|
---|
[3277] | 101 | while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]);
|
---|
| 102 | viewHost.Content = null;
|
---|
| 103 |
|
---|
| 104 | if (Content != null) {
|
---|
[3614] | 105 | if (RunCollection != null) {
|
---|
[3709] | 106 | if (!tabControl.TabPages.Contains(constraintPage))
|
---|
| 107 | tabControl.TabPages.Add(constraintPage);
|
---|
[3614] | 108 | runCollectionConstraintCollectionView.Content = RunCollection.Constraints;
|
---|
| 109 | runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
|
---|
| 110 | }
|
---|
| 111 | foreach (IRun item in Content) {
|
---|
[3775] | 112 | ListViewItem listViewItem = CreateListViewItem(item);
|
---|
| 113 | AddListViewItem(listViewItem);
|
---|
[3614] | 114 | UpdateRun(item);
|
---|
[3775] | 115 | if ((selectedName != null) && item.Name.Equals(selectedName))
|
---|
| 116 | listViewItem.Selected = true;
|
---|
[3614] | 117 | }
|
---|
[3709] | 118 | } else {
|
---|
| 119 | runCollectionConstraintCollectionView.Content = null;
|
---|
| 120 | if (tabControl.TabPages.Contains(constraintPage))
|
---|
| 121 | tabControl.TabPages.Remove(constraintPage);
|
---|
[3277] | 122 | }
|
---|
[3362] | 123 | SetEnabledStateOfControls();
|
---|
[3277] | 124 | }
|
---|
| 125 |
|
---|
[3350] | 126 | protected override void OnReadOnlyChanged() {
|
---|
| 127 | base.OnReadOnlyChanged();
|
---|
[3362] | 128 | SetEnabledStateOfControls();
|
---|
[3350] | 129 | }
|
---|
[3362] | 130 | private void SetEnabledStateOfControls() {
|
---|
[3350] | 131 | if (Content == null) {
|
---|
[3507] | 132 | analyzeRunsToolStripDropDownButton.Enabled = false;
|
---|
[3614] | 133 | runCollectionConstraintCollectionView.ReadOnly = true;
|
---|
[3350] | 134 | itemsListView.Enabled = false;
|
---|
| 135 | detailsGroupBox.Enabled = false;
|
---|
| 136 | viewHost.Enabled = false;
|
---|
| 137 | removeButton.Enabled = false;
|
---|
[3716] | 138 | clearButton.Enabled = false;
|
---|
[3350] | 139 | } else {
|
---|
[3507] | 140 | analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
|
---|
[3614] | 141 | runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
|
---|
[3350] | 142 | itemsListView.Enabled = true;
|
---|
| 143 | detailsGroupBox.Enabled = true;
|
---|
[3435] | 144 | removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && !Content.IsReadOnly && !ReadOnly;
|
---|
[3716] | 145 | clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
|
---|
[3350] | 146 | viewHost.Enabled = true;
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 |
|
---|
[3280] | 150 | protected virtual ListViewItem CreateListViewItem(IRun item) {
|
---|
[3277] | 151 | ListViewItem listViewItem = new ListViewItem();
|
---|
| 152 | listViewItem.Text = item.ToString();
|
---|
| 153 | listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
|
---|
[3341] | 154 | itemsListView.SmallImageList.Images.Add(item.ItemImage);
|
---|
| 155 | listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
|
---|
[3277] | 156 | listViewItem.Tag = item;
|
---|
| 157 | return listViewItem;
|
---|
| 158 | }
|
---|
| 159 | protected virtual void AddListViewItem(ListViewItem listViewItem) {
|
---|
| 160 | itemsListView.Items.Add(listViewItem);
|
---|
[3341] | 161 | ((IRun)listViewItem.Tag).ItemImageChanged += new EventHandler(Item_ItemImageChanged);
|
---|
[3280] | 162 | ((IRun)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged);
|
---|
[3829] | 163 | AdjustListViewColumnSizes();
|
---|
[3277] | 164 | }
|
---|
| 165 | protected virtual void RemoveListViewItem(ListViewItem listViewItem) {
|
---|
[3341] | 166 | ((IRun)listViewItem.Tag).ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
|
---|
[3280] | 167 | ((IRun)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
|
---|
[3277] | 168 | listViewItem.Remove();
|
---|
[3341] | 169 | foreach (ListViewItem other in itemsListView.Items)
|
---|
| 170 | if (other.ImageIndex > listViewItem.ImageIndex) other.ImageIndex--;
|
---|
| 171 | itemsListView.SmallImageList.Images.RemoveAt(listViewItem.ImageIndex);
|
---|
[3277] | 172 | }
|
---|
[3341] | 173 | protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) {
|
---|
| 174 | int i = listViewItem.ImageIndex;
|
---|
| 175 | listViewItem.ImageList.Images[i] = ((IRun)listViewItem.Tag).ItemImage;
|
---|
| 176 | listViewItem.ImageIndex = -1;
|
---|
| 177 | listViewItem.ImageIndex = i;
|
---|
| 178 | }
|
---|
| 179 | protected virtual void UpdateListViewItemText(ListViewItem listViewItem) {
|
---|
| 180 | if (!listViewItem.Text.Equals(listViewItem.Tag.ToString()))
|
---|
[3277] | 181 | listViewItem.Text = listViewItem.Tag.ToString();
|
---|
| 182 | }
|
---|
[3280] | 183 | protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(IRun item) {
|
---|
[3277] | 184 | foreach (ListViewItem listViewItem in itemsListView.Items) {
|
---|
[3280] | 185 | if (((IRun)listViewItem.Tag) == item)
|
---|
[3277] | 186 | yield return listViewItem;
|
---|
| 187 | }
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | #region ListView Events
|
---|
| 191 | protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
|
---|
[3456] | 192 | removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && (Content != null) && !Content.IsReadOnly && !ReadOnly;
|
---|
[3829] | 193 | AdjustListViewColumnSizes();
|
---|
[3277] | 194 | if (itemsListView.SelectedItems.Count == 1) {
|
---|
[3280] | 195 | IRun item = (IRun)itemsListView.SelectedItems[0].Tag;
|
---|
[3277] | 196 | detailsGroupBox.Enabled = true;
|
---|
| 197 | viewHost.Content = item;
|
---|
| 198 | } else {
|
---|
| 199 | viewHost.Content = null;
|
---|
| 200 | detailsGroupBox.Enabled = false;
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 | protected virtual void itemsListView_KeyDown(object sender, KeyEventArgs e) {
|
---|
| 204 | if (e.KeyCode == Keys.Delete) {
|
---|
[3435] | 205 | if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) {
|
---|
[3277] | 206 | foreach (ListViewItem item in itemsListView.SelectedItems)
|
---|
[3280] | 207 | Content.Remove((IRun)item.Tag);
|
---|
[3277] | 208 | }
|
---|
| 209 | }
|
---|
| 210 | }
|
---|
| 211 | protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
|
---|
| 212 | if (itemsListView.SelectedItems.Count == 1) {
|
---|
[3280] | 213 | IRun item = (IRun)itemsListView.SelectedItems[0].Tag;
|
---|
[3557] | 214 | IContentView view = MainFormManager.MainForm.ShowContent(item);
|
---|
[3416] | 215 | if (view != null) {
|
---|
| 216 | view.ReadOnly = ReadOnly;
|
---|
[3423] | 217 | view.Locked = Locked;
|
---|
[3416] | 218 | }
|
---|
[3277] | 219 | }
|
---|
| 220 | }
|
---|
| 221 | protected virtual void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) {
|
---|
[3432] | 222 | if (!Locked) {
|
---|
| 223 | ListViewItem listViewItem = (ListViewItem)e.Item;
|
---|
| 224 | IRun item = (IRun)listViewItem.Tag;
|
---|
| 225 | DataObject data = new DataObject();
|
---|
| 226 | data.SetData("Type", item.GetType());
|
---|
| 227 | data.SetData("Value", item);
|
---|
[3435] | 228 | if (Content.IsReadOnly || ReadOnly) {
|
---|
[3432] | 229 | DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);
|
---|
| 230 | } else {
|
---|
| 231 | DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);
|
---|
| 232 | if ((result & DragDropEffects.Move) == DragDropEffects.Move)
|
---|
| 233 | Content.Remove(item);
|
---|
| 234 | }
|
---|
[3277] | 235 | }
|
---|
| 236 | }
|
---|
| 237 | protected virtual void itemsListView_DragEnterOver(object sender, DragEventArgs e) {
|
---|
| 238 | e.Effect = DragDropEffects.None;
|
---|
| 239 | Type type = e.Data.GetData("Type") as Type;
|
---|
[3435] | 240 | if (!Content.IsReadOnly && !ReadOnly && (type != null) && (typeof(IRun).IsAssignableFrom(type))) {
|
---|
[3694] | 241 | if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key
|
---|
[3277] | 242 | else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key
|
---|
| 243 | else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;
|
---|
| 244 | else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;
|
---|
[3526] | 245 | else if ((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;
|
---|
[3277] | 246 | }
|
---|
| 247 | }
|
---|
| 248 | protected virtual void itemsListView_DragDrop(object sender, DragEventArgs e) {
|
---|
| 249 | if (e.Effect != DragDropEffects.None) {
|
---|
[3280] | 250 | IRun item = e.Data.GetData("Value") as IRun;
|
---|
| 251 | if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) item = (IRun)item.Clone();
|
---|
[3277] | 252 | Content.Add(item);
|
---|
| 253 | }
|
---|
| 254 | }
|
---|
| 255 | #endregion
|
---|
| 256 |
|
---|
| 257 | #region Button Events
|
---|
[3507] | 258 | protected virtual void menuItem_Click(object sender, EventArgs e) {
|
---|
| 259 | ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
|
---|
[3796] | 260 | Type viewType = (Type)menuItem.Tag;
|
---|
| 261 | IContentView view = MainFormManager.MainForm.ShowContent(Content, viewType);
|
---|
[3507] | 262 | if (view != null) {
|
---|
| 263 | view.Locked = Locked;
|
---|
| 264 | view.ReadOnly = ReadOnly;
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
[3277] | 267 | protected virtual void removeButton_Click(object sender, EventArgs e) {
|
---|
| 268 | if (itemsListView.SelectedItems.Count > 0) {
|
---|
| 269 | foreach (ListViewItem item in itemsListView.SelectedItems)
|
---|
[3280] | 270 | Content.Remove((IRun)item.Tag);
|
---|
[3277] | 271 | itemsListView.SelectedItems.Clear();
|
---|
| 272 | }
|
---|
| 273 | }
|
---|
[3716] | 274 | protected virtual void clearButton_Click(object sender, EventArgs e) {
|
---|
| 275 | Content.Clear();
|
---|
| 276 | }
|
---|
[3277] | 277 | #endregion
|
---|
| 278 |
|
---|
| 279 | #region Content Events
|
---|
[3280] | 280 | protected virtual void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
|
---|
[3277] | 281 | if (InvokeRequired)
|
---|
[3280] | 282 | Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
|
---|
[3449] | 283 | else {
|
---|
| 284 | RegisterRunEvents(e.Items);
|
---|
[3280] | 285 | foreach (IRun item in e.Items)
|
---|
[3277] | 286 | AddListViewItem(CreateListViewItem(item));
|
---|
[3507] | 287 | analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
|
---|
[3716] | 288 | clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
|
---|
[3614] | 289 | runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
|
---|
[3449] | 290 | }
|
---|
[3277] | 291 | }
|
---|
[3280] | 292 | protected virtual void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
|
---|
[3277] | 293 | if (InvokeRequired)
|
---|
[3280] | 294 | Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
|
---|
[3277] | 295 | else {
|
---|
[3449] | 296 | DeregisterRunEvents(e.Items);
|
---|
[3280] | 297 | foreach (IRun item in e.Items) {
|
---|
[3277] | 298 | foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) {
|
---|
| 299 | RemoveListViewItem(listViewItem);
|
---|
| 300 | break;
|
---|
| 301 | }
|
---|
| 302 | }
|
---|
[3507] | 303 | analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
|
---|
[3716] | 304 | clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
|
---|
[3614] | 305 | runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
|
---|
[3277] | 306 | }
|
---|
| 307 | }
|
---|
[3280] | 308 | protected virtual void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
|
---|
[3277] | 309 | if (InvokeRequired)
|
---|
[3280] | 310 | Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
|
---|
[3277] | 311 | else {
|
---|
[3449] | 312 | DeregisterRunEvents(e.OldItems);
|
---|
[3280] | 313 | foreach (IRun item in e.OldItems) {
|
---|
[3277] | 314 | foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) {
|
---|
| 315 | RemoveListViewItem(listViewItem);
|
---|
| 316 | break;
|
---|
| 317 | }
|
---|
| 318 | }
|
---|
[3449] | 319 | RegisterRunEvents(e.Items);
|
---|
[3280] | 320 | foreach (IRun item in e.Items)
|
---|
[3277] | 321 | AddListViewItem(CreateListViewItem(item));
|
---|
[3507] | 322 | analyzeRunsToolStripDropDownButton.Enabled = itemsListView.Items.Count > 0;
|
---|
[3716] | 323 | clearButton.Enabled = itemsListView.Items.Count > 0 && !Content.IsReadOnly && !ReadOnly;
|
---|
[3614] | 324 | runCollectionConstraintCollectionView.ReadOnly = itemsListView.Items.Count == 0;
|
---|
[3277] | 325 | }
|
---|
| 326 | }
|
---|
| 327 | #endregion
|
---|
| 328 |
|
---|
| 329 | #region Item Events
|
---|
[3341] | 330 | protected virtual void Item_ItemImageChanged(object sender, EventArgs e) {
|
---|
| 331 | if (InvokeRequired)
|
---|
| 332 | Invoke(new EventHandler(Item_ItemImageChanged), sender, e);
|
---|
| 333 | else {
|
---|
| 334 | IRun item = (IRun)sender;
|
---|
| 335 | foreach (ListViewItem listViewItem in GetListViewItemsForItem(item))
|
---|
| 336 | UpdateListViewItemImage(listViewItem);
|
---|
| 337 | }
|
---|
| 338 | }
|
---|
[3277] | 339 | protected virtual void Item_ToStringChanged(object sender, EventArgs e) {
|
---|
| 340 | if (InvokeRequired)
|
---|
| 341 | Invoke(new EventHandler(Item_ToStringChanged), sender, e);
|
---|
| 342 | else {
|
---|
[3280] | 343 | IRun item = (IRun)sender;
|
---|
[3277] | 344 | foreach (ListViewItem listViewItem in GetListViewItemsForItem(item))
|
---|
[3341] | 345 | UpdateListViewItemText(listViewItem);
|
---|
[3829] | 346 | AdjustListViewColumnSizes();
|
---|
[3277] | 347 | }
|
---|
| 348 | }
|
---|
[3507] | 349 | protected virtual void Run_Changed(object sender, EventArgs e) {
|
---|
[3632] | 350 | if (InvokeRequired)
|
---|
| 351 | this.Invoke(new EventHandler(Run_Changed), sender, e);
|
---|
| 352 | else {
|
---|
| 353 | IRun run = (IRun)sender;
|
---|
| 354 | UpdateRun(run);
|
---|
| 355 | }
|
---|
[3614] | 356 | }
|
---|
| 357 |
|
---|
| 358 | protected virtual void UpdateRun(IRun run) {
|
---|
[3507] | 359 | foreach (ListViewItem listViewItem in GetListViewItemsForItem(run)) {
|
---|
| 360 | if (run.Visible) {
|
---|
| 361 | listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
|
---|
| 362 | listViewItem.ForeColor = run.Color;
|
---|
| 363 | } else {
|
---|
| 364 | listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic);
|
---|
| 365 | listViewItem.ForeColor = Color.LightGray;
|
---|
| 366 | }
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
[3277] | 369 | #endregion
|
---|
[3716] | 370 |
|
---|
[3829] | 371 | #region Helpers
|
---|
| 372 | protected virtual void AdjustListViewColumnSizes() {
|
---|
| 373 | if (itemsListView.Items.Count > 0) {
|
---|
| 374 | for (int i = 0; i < itemsListView.Columns.Count; i++) {
|
---|
| 375 | itemsListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
|
---|
| 376 | }
|
---|
| 377 | }
|
---|
| 378 | }
|
---|
| 379 | #endregion
|
---|
[3260] | 380 | }
|
---|
| 381 | }
|
---|
[3277] | 382 |
|
---|