[4998] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7268] | 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4998] | 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 |
|
---|
| 22 | using System;
|
---|
[5146] | 23 | using System.Drawing;
|
---|
[4904] | 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.Collections;
|
---|
[4909] | 26 | using HeuristicLab.Common.Resources;
|
---|
[4904] | 27 | using HeuristicLab.Core;
|
---|
| 28 | using HeuristicLab.MainForm;
|
---|
[4993] | 29 | using HeuristicLab.MainForm.WindowsForms;
|
---|
[4909] | 30 | using HeuristicLab.Operators;
|
---|
[4904] | 31 |
|
---|
| 32 | namespace HeuristicLab.DebugEngine {
|
---|
| 33 |
|
---|
| 34 | [View("Operator Trace View")]
|
---|
[4993] | 35 | [Content(typeof(OperatorTrace), IsDefaultView = true)]
|
---|
[5002] | 36 | public partial class OperatorTraceView : AsynchronousContentView {
|
---|
[4904] | 37 |
|
---|
[4993] | 38 | public new OperatorTrace Content {
|
---|
| 39 | get { return (OperatorTrace)base.Content; }
|
---|
[4904] | 40 | set { base.Content = value; }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public OperatorTraceView() {
|
---|
| 44 | InitializeComponent();
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | protected override void DeregisterContentEvents() {
|
---|
| 48 | Content.CollectionReset -= Content_CollectionChanged;
|
---|
| 49 | Content.ItemsAdded -= Content_CollectionChanged;
|
---|
| 50 | Content.ItemsMoved -= Content_CollectionChanged;
|
---|
| 51 | Content.ItemsRemoved -= Content_CollectionChanged;
|
---|
| 52 | Content.ItemsReplaced -= Content_CollectionChanged;
|
---|
[5174] | 53 | Content.IsEnabledChanged -= Content_IsEnabledChanged;
|
---|
[4904] | 54 | base.DeregisterContentEvents();
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | protected override void RegisterContentEvents() {
|
---|
| 58 | base.RegisterContentEvents();
|
---|
| 59 | Content.CollectionReset += Content_CollectionChanged;
|
---|
| 60 | Content.ItemsAdded += Content_CollectionChanged;
|
---|
| 61 | Content.ItemsMoved += Content_CollectionChanged;
|
---|
| 62 | Content.ItemsRemoved += Content_CollectionChanged;
|
---|
| 63 | Content.ItemsReplaced += Content_CollectionChanged;
|
---|
[5174] | 64 | Content.IsEnabledChanged += Content_IsEnabledChanged;
|
---|
[4904] | 65 | }
|
---|
| 66 |
|
---|
| 67 | #region Event Handlers (Content)
|
---|
| 68 | void Content_CollectionChanged(object sender, CollectionItemsChangedEventArgs<Collections.IndexedItem<IOperator>> e) {
|
---|
| 69 | if (InvokeRequired)
|
---|
| 70 | Invoke(new EventHandler<CollectionItemsChangedEventArgs<IndexedItem<IOperator>>>(Content_CollectionChanged), sender, e);
|
---|
| 71 | else
|
---|
| 72 | UpdateOperatorTrace();
|
---|
| 73 | }
|
---|
[5174] | 74 | void Content_IsEnabledChanged(object sender, EventArgs e) {
|
---|
| 75 | if (InvokeRequired)
|
---|
| 76 | Invoke(new EventHandler(Content_IsEnabledChanged), sender, e);
|
---|
| 77 | else
|
---|
| 78 | isEnabledCheckbox.Checked = Content.IsEnabled;
|
---|
| 79 | }
|
---|
[4904] | 80 | #endregion
|
---|
| 81 |
|
---|
| 82 | private void UpdateOperatorTrace() {
|
---|
| 83 | listView.BeginUpdate();
|
---|
| 84 | listView.Items.Clear();
|
---|
[4909] | 85 | listView.SmallImageList.Images.Clear();
|
---|
[5287] | 86 | listView.SmallImageList.Images.Add(VSImageLibrary.Method);
|
---|
| 87 | listView.SmallImageList.Images.Add(VSImageLibrary.Module);
|
---|
| 88 | listView.SmallImageList.Images.Add(VSImageLibrary.BreakpointActive);
|
---|
[4904] | 89 | foreach (var item in Content) {
|
---|
| 90 | var viewItem = listView.Items.Add(item.Name ?? item.ItemName);
|
---|
[4909] | 91 | viewItem.ToolTipText = string.Format("{0}{1}{1}{2}",
|
---|
| 92 | Utils.TypeName(item), Environment.NewLine,
|
---|
| 93 | Utils.Wrap(item.Description, 60));
|
---|
[4904] | 94 | viewItem.Tag = item;
|
---|
[5146] | 95 | if (item.Breakpoint) {
|
---|
| 96 | viewItem.ForeColor = Color.Red;
|
---|
| 97 | viewItem.ImageIndex = 2;
|
---|
| 98 | } else {
|
---|
| 99 | viewItem.ImageIndex = item is CombinedOperator ? 1 : 0;
|
---|
| 100 | }
|
---|
[4904] | 101 | }
|
---|
[4909] | 102 | if (listView.Items.Count > 0) {
|
---|
| 103 | for (int i = 0; i < listView.Columns.Count; i++)
|
---|
| 104 | listView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
|
---|
| 105 | }
|
---|
[4904] | 106 | listView.EndUpdate();
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | protected override void OnContentChanged() {
|
---|
| 110 | base.OnContentChanged();
|
---|
| 111 | if (Content == null) {
|
---|
| 112 | listView.Items.Clear();
|
---|
[5174] | 113 | isEnabledCheckbox.Checked = false;
|
---|
[4904] | 114 | } else {
|
---|
| 115 | UpdateOperatorTrace();
|
---|
[5174] | 116 | isEnabledCheckbox.Checked = Content.IsEnabled;
|
---|
[4904] | 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[5117] | 120 | protected override void SetEnabledStateOfControls() {
|
---|
| 121 | base.SetEnabledStateOfControls();
|
---|
| 122 | isEnabledCheckbox.Enabled = Content != null;
|
---|
[5221] | 123 | listView.Enabled = Content != null && Content.IsEnabled;
|
---|
[5117] | 124 | }
|
---|
| 125 |
|
---|
[4904] | 126 | #region Event Handlers (child controls)
|
---|
| 127 | private void listView_ItemActivate(object sender, EventArgs e) {
|
---|
| 128 | if (listView.SelectedItems.Count > 0) {
|
---|
| 129 | IOperator op = listView.SelectedItems[0].Tag as IOperator;
|
---|
| 130 | if (op != null) {
|
---|
| 131 | MainFormManager.MainForm.ShowContent(op);
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
[5174] | 135 | private void isEnabledCheckbox_CheckedChanged(object sender, EventArgs e) {
|
---|
| 136 | if (Content != null)
|
---|
| 137 | Content.IsEnabled = isEnabledCheckbox.Checked;
|
---|
[5221] | 138 | SetEnabledStateOfControls();
|
---|
[5174] | 139 | }
|
---|
[4904] | 140 | #endregion
|
---|
[5117] | 141 |
|
---|
[5287] | 142 |
|
---|
[4904] | 143 | }
|
---|
| 144 |
|
---|
| 145 | }
|
---|