Changeset 7268 for branches/HeuristicLab.TimeSeries/HeuristicLab.Core.Views/3.3/VariableValueView.cs
- Timestamp:
- 01/03/12 11:22:21 (12 years ago)
- Location:
- branches/HeuristicLab.TimeSeries
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries
- Property svn:mergeinfo changed
/trunk/sources merged: 7214,7216-7230,7233-7239,7241,7243-7252,7254,7256-7261,7265-7266
- Property svn:mergeinfo changed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Core.Views/3.3/VariableValueView.cs
r5837 r7268 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 1Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 26 26 namespace HeuristicLab.Core.Views { 27 /// <summary>28 /// The visual representation of a <see cref="Variable"/>.29 /// </summary>30 27 [View("Variable Value View")] 31 28 [Content(typeof(Variable), false)] 32 29 [Content(typeof(IVariable), false)] 33 30 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 39 33 public new IVariable Content { 40 34 get { return (IVariable)base.Content; } … … 42 36 } 43 37 44 /// <summary>45 /// Initializes a new instance of <see cref="VariableView"/> with caption "Variable".46 /// </summary>47 38 public VariableValueView() { 48 39 InitializeComponent(); 49 40 } 50 41 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>55 42 protected override void DeregisterContentEvents() { 43 Content.NameChanged -= new EventHandler(Content_NameChanged); 44 Content.DescriptionChanged -= new EventHandler(Content_DescriptionChanged); 56 45 Content.ValueChanged -= new EventHandler(Content_ValueChanged); 57 46 base.DeregisterContentEvents(); 58 47 } 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>64 48 protected override void RegisterContentEvents() { 65 49 base.RegisterContentEvents(); 50 Content.NameChanged += new EventHandler(Content_NameChanged); 51 Content.DescriptionChanged += new EventHandler(Content_DescriptionChanged); 66 52 Content.ValueChanged += new EventHandler(Content_ValueChanged); 67 53 } … … 71 57 if (Content == null) { 72 58 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"; 73 64 } else { 74 65 viewHost.ViewType = null; 75 66 viewHost.Content = Content.Value; 67 toolTip.SetToolTip(infoLabel, string.IsNullOrEmpty(Content.Description) ? infoLabelToolTipSuffix : Content.Description + Environment.NewLine + Environment.NewLine + infoLabelToolTipSuffix); 68 Caption = Content.Name; 76 69 } 77 70 } 78 71 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 } 79 91 protected virtual void Content_ValueChanged(object sender, EventArgs e) { 80 92 if (InvokeRequired) … … 103 115 } 104 116 } 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 } 105 123 } 106 124 }
Note: See TracChangeset
for help on using the changeset viewer.