#region License Information
/* HeuristicLab
* Copyright (C) 2002-2016 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 System.Windows.Forms;
using HeuristicLab.Common.Resources;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
using HeuristicLab.Parameters.Views;
using HeuristicLab.PluginInfrastructure;
namespace HeuristicLab.Optimization.Views {
[View("ResultParameter View")]
[Content(typeof(ResultParameter<>), true)]
[Content(typeof(IResultParameter<>), false)]
public partial class ResultParameterView : LookupParameterView where T : class, IItem {
protected TypeSelectorDialog typeSelectorDialog;
public new IResultParameter Content {
get { return (IResultParameter)base.Content; }
set { base.Content = value; }
}
public ResultParameterView() {
InitializeComponent();
setDefaultValueButton.Text = string.Empty;
setDefaultValueButton.Image = VSImageLibrary.Edit;
removeDefaultValueButton.Text = string.Empty;
removeDefaultValueButton.Image = VSImageLibrary.Remove;
actualNameLabel.Text = "Result Name:";
dataTypeLabel.Text = "Result Type:";
}
///
/// Clean up any resources being used.
///
/// true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing) {
if (disposing) {
if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
if (components != null) components.Dispose();
}
base.Dispose(disposing);
}
protected override void DeregisterContentEvents() {
Content.ResultCollectionNameChanged -= ContentOnResultCollectionNameChanged;
Content.DefaultValueChanged -= ContentOnDefaultValueChanged;
base.DeregisterContentEvents();
}
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.ResultCollectionNameChanged += ContentOnResultCollectionNameChanged;
Content.DefaultValueChanged += ContentOnDefaultValueChanged;
}
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content == null) {
resultCollectionNameTextBox.Text = "-";
defaultValueViewHost.Content = null;
} else {
resultCollectionNameTextBox.Text = Content.ResultCollectionName;
defaultValueViewHost.Content = Content.DefaultValue;
}
}
protected override void SetEnabledStateOfControls() {
base.SetEnabledStateOfControls();
resultCollectionNameTextBox.Enabled = Content != null;
resultCollectionNameTextBox.ReadOnly = ReadOnly;
setDefaultValueButton.Enabled = Content != null && !ReadOnly && !Locked;
removeDefaultValueButton.Enabled = Content != null && !ReadOnly && !Locked;
}
private void ContentOnDefaultValueChanged(object sender, EventArgs e) {
if (InvokeRequired) Invoke((Action