Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/27/11 02:37:02 (12 years ago)
Author:
swagner
Message:

Added information icon in VariableValueView and ResultValueView, corrected tooltip update in NamedItemCollectionView and reverted changes of r6631 (#1054).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ResultValueView.cs

    r5896 r7235  
    3030  [Content(typeof(IResult), false)]
    3131  public sealed partial class ResultValueView : ItemView {
     32    private const string infoLabelToolTipSuffix = "Double-click to open description editor.";
     33
    3234    public new IResult Content {
    3335      get { return (IResult)base.Content; }
     
    4547
    4648    protected override void DeregisterContentEvents() {
     49      Content.NameChanged -= new EventHandler(Content_NameChanged);
     50      Content.DescriptionChanged -= new EventHandler(Content_DescriptionChanged);
    4751      Content.ValueChanged -= new EventHandler(Content_ValueChanged);
    4852      base.DeregisterContentEvents();
     
    5054    protected override void RegisterContentEvents() {
    5155      base.RegisterContentEvents();
     56      Content.NameChanged += new EventHandler(Content_NameChanged);
     57      Content.DescriptionChanged += new EventHandler(Content_DescriptionChanged);
    5258      Content.ValueChanged += new EventHandler(Content_ValueChanged);
    5359    }
     
    5763      if (Content == null) {
    5864        viewHost.Content = null;
     65        toolTip.SetToolTip(infoLabel, string.Empty);
     66        if (ViewAttribute.HasViewAttribute(this.GetType()))
     67          this.Caption = ViewAttribute.GetViewName(this.GetType());
     68        else
     69          this.Caption = "ResultValue View";
    5970      } else {
    6071        viewHost.ViewType = null;
    6172        viewHost.Content = Content.Value;
     73        toolTip.SetToolTip(infoLabel, string.IsNullOrEmpty(Content.Description) ? infoLabelToolTipSuffix : Content.Description + Environment.NewLine + Environment.NewLine + infoLabelToolTipSuffix);
     74        Caption = Content.Name;
    6275      }
    6376    }
     
    6780      viewHost.Enabled = Content != null;
    6881      viewHost.ReadOnly = this.ReadOnly;
     82      infoLabel.Enabled = Content != null;
    6983    }
    7084
     85    private void Content_NameChanged(object sender, EventArgs e) {
     86      if (InvokeRequired)
     87        Invoke(new EventHandler(Content_NameChanged), sender, e);
     88      else
     89        Caption = Content.Name;
     90    }
     91    private void Content_DescriptionChanged(object sender, EventArgs e) {
     92      if (InvokeRequired)
     93        Invoke(new EventHandler(Content_DescriptionChanged), sender, e);
     94      else
     95        toolTip.SetToolTip(infoLabel, string.IsNullOrEmpty(Content.Description) ? infoLabelToolTipSuffix : Content.Description + Environment.NewLine + Environment.NewLine + infoLabelToolTipSuffix);
     96    }
    7197    private void Content_ValueChanged(object sender, EventArgs e) {
    7298      if (InvokeRequired)
     
    76102      }
    77103    }
     104
     105    private void infoLabel_DoubleClick(object sender, System.EventArgs e) {
     106      using (TextDialog dialog = new TextDialog("Description of " + Content.Name, Content.Description, ReadOnly || !Content.CanChangeDescription)) {
     107        if (dialog.ShowDialog(this) == DialogResult.OK)
     108          Content.Description = dialog.Content;
     109      }
     110    }
    78111  }
    79112}
Note: See TracChangeset for help on using the changeset viewer.