Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/03/12 11:22:21 (12 years ago)
Author:
gkronber
Message:

#1081: merged r7214:7266 from trunk into time series branch.

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Core.Views/3.3/VariableValueView.cs

    r5837 r7268  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525
    2626namespace HeuristicLab.Core.Views {
    27   /// <summary>
    28   /// The visual representation of a <see cref="Variable"/>.
    29   /// </summary>
    3027  [View("Variable Value View")]
    3128  [Content(typeof(Variable), false)]
    3229  [Content(typeof(IVariable), false)]
    3330  public partial class VariableValueView : ItemView {
    34     /// <summary>
    35     /// Gets or sets the variable to represent visually.
    36     /// </summary>
    37     /// <remarks>Uses property <see cref="ViewBase.Item"/> of base class <see cref="ViewBase"/>.
    38     /// No own data storage present.</remarks>
     31    private const string infoLabelToolTipSuffix = "Double-click to open description editor.";
     32
    3933    public new IVariable Content {
    4034      get { return (IVariable)base.Content; }
     
    4236    }
    4337
    44     /// <summary>
    45     /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable".
    46     /// </summary>
    4738    public VariableValueView() {
    4839      InitializeComponent();
    4940    }
    5041
    51     /// <summary>
    52     /// Removes the eventhandlers from the underlying <see cref="Variable"/>.
    53     /// </summary>
    54     /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    5542    protected override void DeregisterContentEvents() {
     43      Content.NameChanged -= new EventHandler(Content_NameChanged);
     44      Content.DescriptionChanged -= new EventHandler(Content_DescriptionChanged);
    5645      Content.ValueChanged -= new EventHandler(Content_ValueChanged);
    5746      base.DeregisterContentEvents();
    5847    }
    59 
    60     /// <summary>
    61     /// Adds eventhandlers to the underlying <see cref="Variable"/>.
    62     /// </summary>
    63     /// <remarks>Calls <see cref="ViewBase.AddItemEvents"/> of base class <see cref="ViewBase"/>.</remarks>
    6448    protected override void RegisterContentEvents() {
    6549      base.RegisterContentEvents();
     50      Content.NameChanged += new EventHandler(Content_NameChanged);
     51      Content.DescriptionChanged += new EventHandler(Content_DescriptionChanged);
    6652      Content.ValueChanged += new EventHandler(Content_ValueChanged);
    6753    }
     
    7157      if (Content == null) {
    7258        viewHost.Content = null;
     59        toolTip.SetToolTip(infoLabel, string.Empty);
     60        if (ViewAttribute.HasViewAttribute(this.GetType()))
     61          this.Caption = ViewAttribute.GetViewName(this.GetType());
     62        else
     63          this.Caption = "VariableValue View";
    7364      } else {
    7465        viewHost.ViewType = null;
    7566        viewHost.Content = Content.Value;
     67        toolTip.SetToolTip(infoLabel, string.IsNullOrEmpty(Content.Description) ? infoLabelToolTipSuffix : Content.Description + Environment.NewLine + Environment.NewLine + infoLabelToolTipSuffix);
     68        Caption = Content.Name;
    7669      }
    7770    }
    7871
     72    protected override void SetEnabledStateOfControls() {
     73      base.SetEnabledStateOfControls();
     74      viewHost.Enabled = Content != null;
     75      viewHost.ReadOnly = this.ReadOnly;
     76      infoLabel.Enabled = Content != null;
     77    }
     78
     79    protected virtual void Content_NameChanged(object sender, EventArgs e) {
     80      if (InvokeRequired)
     81        Invoke(new EventHandler(Content_NameChanged), sender, e);
     82      else
     83        Caption = Content.Name;
     84    }
     85    protected virtual void Content_DescriptionChanged(object sender, EventArgs e) {
     86      if (InvokeRequired)
     87        Invoke(new EventHandler(Content_DescriptionChanged), sender, e);
     88      else
     89        toolTip.SetToolTip(infoLabel, string.IsNullOrEmpty(Content.Description) ? infoLabelToolTipSuffix : Content.Description + Environment.NewLine + Environment.NewLine + infoLabelToolTipSuffix);
     90    }
    7991    protected virtual void Content_ValueChanged(object sender, EventArgs e) {
    8092      if (InvokeRequired)
     
    103115      }
    104116    }
     117    protected virtual void infoLabel_DoubleClick(object sender, EventArgs e) {
     118      using (TextDialog dialog = new TextDialog("Description of " + Content.Name, Content.Description, ReadOnly || !Content.CanChangeDescription)) {
     119        if (dialog.ShowDialog(this) == DialogResult.OK)
     120          Content.Description = dialog.Content;
     121      }
     122    }
    105123  }
    106124}
Note: See TracChangeset for help on using the changeset viewer.