Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5768 for trunk


Ignore:
Timestamp:
03/20/11 02:36:00 (14 years ago)
Author:
swagner
Message:

Enabled hiding of parameters (#1377)

Location:
trunk/sources
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common.Resources/3.3/HeuristicLab.Common.Resources-3.3.csproj

    r5432 r5768  
    431431    <Content Include="Resources\VS2008ImageLibrary\VS2008ImageLibrary_Actions_Checkout.png" />
    432432    <Content Include="Resources\VS2008ImageLibrary\VS2008ImageLibrary_Actions_Clone.png" />
     433    <None Include="Resources\VS2008ImageLibrary\VS2008ImageLibrary_Objects_HiddenField.png" />
    433434    <None Include="Resources\VS2010ImageLibrary\VS2010ImageLibrary_Actions_Filter.png" />
    434435    <None Include="Resources\VS2008ImageLibrary\VS2008ImageLibrary_Objects_Cab.png" />
  • trunk/sources/HeuristicLab.Common.Resources/3.3/VSImageLibrary.Designer.cs

    r5287 r5768  
    425425        }
    426426       
     427        public static System.Drawing.Bitmap HiddenField {
     428            get {
     429                object obj = ResourceManager.GetObject("HiddenField", resourceCulture);
     430                return ((System.Drawing.Bitmap)(obj));
     431            }
     432        }
     433       
    427434        public static System.Drawing.Bitmap HighPriorityLarge {
    428435            get {
  • trunk/sources/HeuristicLab.Common.Resources/3.3/VSImageLibrary.resx

    r5432 r5768  
    275275    <value>Resources\VS2008ImageLibrary\VS2008ImageLibrary_Actions_Graph.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
    276276  </data>
     277  <data name="HiddenField" type="System.Resources.ResXFileRef, System.Windows.Forms">
     278    <value>Resources\VS2008ImageLibrary\VS2008ImageLibrary_Objects_HiddenField.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
     279  </data>
    277280  <data name="HighPriorityLarge" type="System.Resources.ResXFileRef, System.Windows.Forms">
    278281    <value>Resources\VS2008ImageLibrary\VS2008ImageLibrary_Annotations&amp;Buttons_HighPriority_Large.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj

    r5163 r5768  
    1212    <AssemblyName>HeuristicLab.Core.Views-3.3</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile></TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617    <SignAssembly>true</SignAssembly>
  • trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.Designer.cs

    r5445 r5768  
    2020#endregion
    2121
     22using System.Windows.Forms;
    2223namespace HeuristicLab.Core.Views {
    2324  partial class ParameterCollectionView {
     
    3536    private void InitializeComponent() {
    3637      components = new System.ComponentModel.Container();
     38      this.showHiddenParametersCheckBox = new System.Windows.Forms.CheckBox();
     39      this.itemsListViewContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     40      this.showHideParametersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     41      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     42      this.splitContainer.Panel1.SuspendLayout();
     43      this.splitContainer.Panel2.SuspendLayout();
     44      this.splitContainer.SuspendLayout();
     45      this.detailsGroupBox.SuspendLayout();
     46      this.itemsGroupBox.SuspendLayout();
     47      this.itemsListViewContextMenuStrip.SuspendLayout();
     48      this.SuspendLayout();
     49      //
     50      // splitContainer.Panel1
     51      //
     52      this.splitContainer.Panel1.Controls.Add(this.showHiddenParametersCheckBox);
     53      //
     54      // itemsListView
     55      //
     56      this.itemsListView.ContextMenuStrip = this.itemsListViewContextMenuStrip;
     57      this.itemsListView.TabIndex = 6;
     58      //
     59      // showHiddenParametersCheckBox
     60      //
     61      this.showHiddenParametersCheckBox.Appearance = System.Windows.Forms.Appearance.Button;
     62      this.showHiddenParametersCheckBox.Checked = false;
     63      this.showHiddenParametersCheckBox.CheckState = System.Windows.Forms.CheckState.Unchecked;
     64      this.showHiddenParametersCheckBox.Image = HeuristicLab.Common.Resources.VSImageLibrary.HiddenField;
     65      this.showHiddenParametersCheckBox.Location = new System.Drawing.Point(153, 3);
     66      this.showHiddenParametersCheckBox.Name = "showHiddenParametersCheckBox";
     67      this.showHiddenParametersCheckBox.Size = new System.Drawing.Size(24, 24);
     68      this.showHiddenParametersCheckBox.TabIndex = 5;
     69      this.toolTip.SetToolTip(this.showHiddenParametersCheckBox, "Show Hidden Parameters");
     70      this.showHiddenParametersCheckBox.UseVisualStyleBackColor = true;
     71      this.showHiddenParametersCheckBox.CheckedChanged += new System.EventHandler(showHiddenParametersCheckBox_CheckedChanged);
     72      //
     73      // itemsListViewContextMenuStrip
     74      //
     75      this.itemsListViewContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     76            this.showHideParametersToolStripMenuItem});
     77      this.itemsListViewContextMenuStrip.Name = "itemsListViewContextMenuStrip";
     78      this.itemsListViewContextMenuStrip.Size = new System.Drawing.Size(161, 26);
     79      this.itemsListViewContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(itemsListViewContextMenuStrip_Opening);
     80      //
     81      // showHideParametersToolStripMenuItem
     82      //
     83      this.showHideParametersToolStripMenuItem.Name = "showHideParametersToolStripMenuItem";
     84      this.showHideParametersToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
     85      this.showHideParametersToolStripMenuItem.Text = "Show/Hide Parameters";
     86      this.showHideParametersToolStripMenuItem.Click += new System.EventHandler(showHideParametersToolStripMenuItem_Click);
     87      //
     88      // ParameterCollectionView
     89      //
    3790      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     91      this.Name = "ParameterCollectionView";
     92      this.splitContainer.Panel1.ResumeLayout(false);
     93      this.splitContainer.Panel2.ResumeLayout(false);
     94      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     95      this.splitContainer.ResumeLayout(false);
     96      this.detailsGroupBox.ResumeLayout(false);
     97      this.itemsGroupBox.ResumeLayout(false);
     98      this.itemsListViewContextMenuStrip.ResumeLayout(false);
     99      this.ResumeLayout(false);
    38100    }
    39101
    40102    #endregion
     103
     104    protected CheckBox showHiddenParametersCheckBox;
     105    protected ContextMenuStrip itemsListViewContextMenuStrip;
     106    protected ToolStripMenuItem showHideParametersToolStripMenuItem;
    41107  }
    42108}
  • trunk/sources/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs

    r5445 r5768  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Drawing;
     25using System.Linq;
    2326using System.Windows.Forms;
    2427using HeuristicLab.MainForm;
     
    4649    }
    4750
     51    protected override void DeregisterItemEvents(IParameter item) {
     52      item.HiddenChanged -= new EventHandler(Item_HiddenChanged);
     53      base.DeregisterItemEvents(item);
     54    }
     55    protected override void RegisterItemEvents(IParameter item) {
     56      base.RegisterItemEvents(item);
     57      item.HiddenChanged += new EventHandler(Item_HiddenChanged);
     58    }
     59
    4860    protected override IParameter CreateItem() {
    4961      if (createParameterDialog == null) createParameterDialog = new CreateParameterDialog();
     
    5769      return null;
    5870    }
     71
     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)) {
     78        listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic);
     79        listViewItem.ForeColor = Color.LightGray;
     80      }
     81      base.AddListViewItem(listViewItem);
     82    }
     83
     84    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          }
     91        } 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      }
     107      AdjustListViewColumnSizes();
     108    }
     109
     110    #region Control Events
     111    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));
     115        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      }
     123    }
     124    protected virtual void itemsListViewContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) {
     125      if ((itemsListView.SelectedItems.Count == 0) || ReadOnly || Locked) {
     126        showHideParametersToolStripMenuItem.Enabled = false;
     127      } else {
     128        List<IParameter> parameters = new List<IParameter>();
     129        foreach (ListViewItem listViewItem in itemsListView.SelectedItems) {
     130          IParameter parameter = listViewItem.Tag as IParameter;
     131          if (parameter != null) parameters.Add(parameter);
     132        }
     133        showHideParametersToolStripMenuItem.Enabled = (parameters.Count > 0) && (parameters.All(x => x.Hidden == parameters[0].Hidden));
     134        if (parameters.Count == 1) showHideParametersToolStripMenuItem.Text = parameters[0].Hidden ? "Show Parameter" : "Hide Parameter";
     135        else showHideParametersToolStripMenuItem.Text = parameters[0].Hidden ? "Show Parameters" : "Hide Parameters";
     136        showHideParametersToolStripMenuItem.Tag = parameters;
     137      }
     138    }
     139    protected virtual void showHideParametersToolStripMenuItem_Click(object sender, System.EventArgs e) {
     140      foreach (IParameter parameter in (IEnumerable<IParameter>)showHideParametersToolStripMenuItem.Tag)
     141        parameter.Hidden = !parameter.Hidden;
     142    }
     143    #endregion
     144
     145    #region Item Events
     146    protected virtual void Item_HiddenChanged(object sender, EventArgs e) {
     147      if (InvokeRequired)
     148        Invoke(new EventHandler(Item_HiddenChanged), sender, e);
     149      else
     150        UpdateParameterVisibility((IParameter)sender);
     151    }
     152    #endregion
    59153  }
    60154}
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IParameter.cs

    r5445 r5768  
    2525  public interface IParameter : INamedItem {
    2626    Type DataType { get; }
     27    bool Hidden { get; set; }
    2728    IItem ActualValue { get; set; }
    2829    IExecutionContext ExecutionContext { get; set; }
     30
     31    event EventHandler HiddenChanged;
    2932  }
    3033}
  • trunk/sources/HeuristicLab.Parameters/3.3/Parameter.cs

    r5445 r5768  
    5555    }
    5656
     57    [Storable(DefaultValue = false)]
     58    private bool hidden;
     59    public bool Hidden {
     60      get { return hidden; }
     61      set {
     62        if (value != hidden) {
     63          hidden = value;
     64          OnHiddenChanged();
     65        }
     66      }
     67    }
     68
    5769    private Lazy<ThreadLocal<IItem>> cachedActualValues;
    5870    public IItem ActualValue {
     
    8698      : base(original, cloner) {
    8799      dataType = original.dataType;
     100      hidden = original.hidden;
    88101      cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
    89102      executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
     
    92105      : base("Anonymous") {
    93106      dataType = typeof(IItem);
     107      hidden = false;
    94108      cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
    95109      executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
     
    99113      if (dataType == null) throw new ArgumentNullException();
    100114      this.dataType = dataType;
     115      hidden = false;
    101116      cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
    102117      executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
     
    106121      if (dataType == null) throw new ArgumentNullException();
    107122      this.dataType = dataType;
     123      hidden = false;
    108124      cachedActualValues = new Lazy<ThreadLocal<IItem>>(() => { return new ThreadLocal<IItem>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
    109125      executionContexts = new Lazy<ThreadLocal<IExecutionContext>>(() => { return new ThreadLocal<IExecutionContext>(); }, LazyThreadSafetyMode.ExecutionAndPublication);
     
    116132    protected abstract IItem GetActualValue();
    117133    protected abstract void SetActualValue(IItem value);
     134
     135    public event EventHandler HiddenChanged;
     136    protected virtual void OnHiddenChanged() {
     137      EventHandler handler = HiddenChanged;
     138      if (handler != null) handler(this, EventArgs.Empty);
     139    }
    118140  }
    119141}
Note: See TracChangeset for help on using the changeset viewer.