Changeset 7235 for trunk/sources/HeuristicLab.Core.Views
- Timestamp:
- 12/27/11 02:37:02 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Core.Views/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemCollectionView.cs
r5837 r7235 77 77 return listViewItem; 78 78 } 79 protected override void UpdateListViewItemText(ListViewItem listViewItem) { 80 base.UpdateListViewItemText(listViewItem); 81 T item = listViewItem.Tag as T; 82 if ((item != null) && !string.IsNullOrEmpty(item.Description)) { 83 listViewItem.ToolTipText = item.ItemName + ": " + item.Description; 84 } 85 } 79 86 80 87 #region ListView Events -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemView.cs
r5833 r7235 26 26 27 27 namespace HeuristicLab.Core.Views { 28 /// <summary>29 /// The visual representation of a <see cref="Variable"/>.30 /// </summary>31 28 [View("NamedItem View")] 32 29 [Content(typeof(NamedItem), false)] -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.Designer.cs
r5445 r7235 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 49 this.infoLabel = new System.Windows.Forms.Label(); 50 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 48 51 this.SuspendLayout(); 49 52 // 50 53 // viewHost 51 54 // 55 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 56 | System.Windows.Forms.AnchorStyles.Left) 57 | System.Windows.Forms.AnchorStyles.Right))); 52 58 this.viewHost.Caption = "View"; 53 59 this.viewHost.Content = null; 54 this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;55 60 this.viewHost.Enabled = false; 56 61 this.viewHost.Location = new System.Drawing.Point(0, 0); 57 62 this.viewHost.Name = "viewHost"; 58 63 this.viewHost.ReadOnly = false; 59 this.viewHost.Size = new System.Drawing.Size(3 59, 274);64 this.viewHost.Size = new System.Drawing.Size(334, 274); 60 65 this.viewHost.TabIndex = 0; 66 this.viewHost.ViewsLabelVisible = true; 61 67 this.viewHost.ViewType = null; 68 // 69 // infoLabel 70 // 71 this.infoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 72 this.infoLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Information; 73 this.infoLabel.Location = new System.Drawing.Point(340, 3); 74 this.infoLabel.Name = "infoLabel"; 75 this.infoLabel.Size = new System.Drawing.Size(16, 16); 76 this.infoLabel.TabIndex = 1; 77 this.toolTip.SetToolTip(this.infoLabel, "Double-click to open description editor."); 78 this.infoLabel.DoubleClick += new System.EventHandler(this.infoLabel_DoubleClick); 62 79 // 63 80 // VariableValueView 64 81 // 82 this.AllowDrop = true; 65 83 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 66 84 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 67 this. AllowDrop = true;85 this.Controls.Add(this.infoLabel); 68 86 this.Controls.Add(this.viewHost); 69 87 this.Name = "VariableValueView"; … … 79 97 80 98 protected MainForm.WindowsForms.ViewHost viewHost; 99 private System.Windows.Forms.Label infoLabel; 100 private System.Windows.Forms.ToolTip toolTip; 81 101 82 102 } -
trunk/sources/HeuristicLab.Core.Views/3.3/VariableValueView.cs
r5837 r7235 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.