#region License Information /* HeuristicLab * Copyright (C) 2002-2013 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.Drawing; using System.Windows.Forms; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; namespace HeuristicLab.DataPreprocessing.Views { [View("Manipulation Chart View")] [Content(typeof(ManipulationContent), false)] public partial class ManipulationView : ItemView { private Action[] validators; private Action[] manipulations; public ManipulationView() { InitializeComponent(); tabsData.Appearance = TabAppearance.FlatButtons; tabsData.ItemSize = new Size(0, 1); tabsData.SizeMode = TabSizeMode.Fixed; tabsPreview.Appearance = TabAppearance.FlatButtons; tabsPreview.ItemSize = new Size(0, 1); tabsPreview.SizeMode = TabSizeMode.Fixed; validators = new Action[] { ()=>validateDoubleTextBox(txtDeleteColumnsInfo.Text), ()=>validateDoubleTextBox(txtDeleteColumnsVariance.Text), ()=>validateDoubleTextBox(txtDeleteRowsInfo.Text), ()=>{btnApply.Enabled = true;} //shuffle }; manipulations = new Action[] { ()=>{}, ()=>{}, ()=>{}, ()=>Content.ManipulationLogic.ShuffleWithRanges() }; } public new ManipulationContent Content { get { return (ManipulationContent)base.Content; } set { base.Content = value; } } private void lstMethods_SelectedIndexChanged(object sender, System.EventArgs e) { int index = lstMethods.SelectedIndex; tabsData.SelectedIndex = index + 1; tabsPreview.SelectedIndex = index + 1; btnApply.Enabled = false; //in order that button will be enabled if text is already valid if (index >= 0) { validators[index](); } } private void btnApply_Click(object sender, System.EventArgs e) { manipulations[lstMethods.SelectedIndex](); } private void validateDoubleTextBox(String text) { btnApply.Enabled = false; if (!string.IsNullOrEmpty(text)) { double percent; if (Double.TryParse(text, out percent)) { btnApply.Enabled = true; } } } private void txtDeleteColumnsInfo_TextChanged(object sender, EventArgs e) { validateDoubleTextBox(txtDeleteColumnsInfo.Text); } private void txtDeleteColumnsVariance_TextChanged(object sender, EventArgs e) { validateDoubleTextBox(txtDeleteColumnsVariance.Text); } private void txtDeleteRowsInfo_TextChanged(object sender, EventArgs e) { validateDoubleTextBox(txtDeleteRowsInfo.Text); } } }