#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 HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views; using HeuristicLab.MainForm; using HeuristicLab.Problems.GeneticProgramming.GlucosePrediction; namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { [View("RealGlucoseVariable View")] [Content(typeof(RealGlucoseVariableSymbol), true)] public partial class RealGlucoseVariableView : SymbolView { public new RealGlucoseVariableSymbol Content { get { return (RealGlucoseVariableSymbol)base.Content; } set { base.Content = value; } } public RealGlucoseVariableView() { InitializeComponent(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); Content.Changed += new EventHandler(Content_Changed); } protected override void DeregisterContentEvents() { base.DeregisterContentEvents(); Content.Changed -= new EventHandler(Content_Changed); } protected override void OnContentChanged() { base.OnContentChanged(); UpdateControl(); } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); minRowOffsetTextBox.Enabled = Content != null; minRowOffsetTextBox.ReadOnly = ReadOnly; maxRowOffsetTextBox.Enabled = Content != null; maxRowOffsetTextBox.ReadOnly = ReadOnly; } #region content event handlers private void Content_Changed(object sender, EventArgs e) { UpdateControl(); } #endregion private void minValueTextBox_TextChanged(object sender, EventArgs e) { int min; if (int.TryParse(minRowOffsetTextBox.Text, out min)) { Content.MinRowOffset = min; errorProvider.SetError(minRowOffsetTextBox, string.Empty); } else { errorProvider.SetError(minRowOffsetTextBox, "Invalid value"); } } private void maxValueTextBox_TextChanged(object sender, EventArgs e) { int max; if (int.TryParse(maxRowOffsetTextBox.Text, out max)) { Content.MaxRowOffset = max; errorProvider.SetError(maxRowOffsetTextBox, string.Empty); } else { errorProvider.SetError(maxRowOffsetTextBox, "Invalid value"); } } #region helpers private void UpdateControl() { if (Content == null) { minRowOffsetTextBox.Text = string.Empty; maxRowOffsetTextBox.Text = string.Empty; minRowOffsetTextBox.Text = string.Empty; } else { minRowOffsetTextBox.Text = Content.MinRowOffset.ToString(); maxRowOffsetTextBox.Text = Content.MaxRowOffset.ToString(); } SetEnabledStateOfControls(); } #endregion } }