Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/08/12 19:13:14 (12 years ago)
Author:
gkronber
Message:

#1669 merged r7209:7283 from trunk into regression benchmark branch

Location:
branches/RegressionBenchmarks
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/RegressionBenchmarks

  • branches/RegressionBenchmarks/HeuristicLab.Optimization.Views/3.3/ResultValueView.cs

    r5896 r7290  
    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.
     
    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.