#region License Information
/* HeuristicLab
* Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.Parameters.Views {
///
/// The visual representation of a .
///
[View("LookupParameter View")]
[Content(typeof(LookupParameter<>), true)]
[Content(typeof(ILookupParameter<>), false)]
public partial class LookupParameterView : ParameterView where T : class, IItem {
///
/// Gets or sets the variable to represent visually.
///
/// Uses property of base class .
/// No own data storage present.
public new ILookupParameter Content {
get { return (ILookupParameter)base.Content; }
set { base.Content = value; }
}
///
/// Initializes a new instance of with caption "Variable".
///
public LookupParameterView() {
InitializeComponent();
}
///
/// Removes the eventhandlers from the underlying .
///
/// Calls of base class .
protected override void DeregisterContentEvents() {
Content.ActualNameChanged -= new EventHandler(Content_ActualNameChanged);
base.DeregisterContentEvents();
}
///
/// Adds eventhandlers to the underlying .
///
/// Calls of base class .
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.ActualNameChanged += new EventHandler(Content_ActualNameChanged);
}
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content == null)
actualNameTextBox.Text = "-";
else
actualNameTextBox.Text = Content.ActualName;
}
protected override void SetEnabledStateOfControls() {
base.SetEnabledStateOfControls();
actualNameTextBox.Enabled = Content != null;
actualNameTextBox.ReadOnly = ReadOnly;
}
protected virtual void Content_ActualNameChanged(object sender, EventArgs e) {
if (InvokeRequired)
Invoke(new EventHandler(Content_ActualNameChanged), sender, e);
else
actualNameTextBox.Text = Content.ActualName;
}
protected virtual void actualNameTextBox_Validated(object sender, EventArgs e) {
Content.ActualName = actualNameTextBox.Text;
}
}
}