Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/LinearTransformationCommandView.cs @ 16994

Last change on this file since 16994 was 16994, checked in by gkronber, 5 years ago

#2520 Update plugin dependencies and references for HL.DataImporter for new persistence

File size: 2.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.ComponentModel;
23using System.Windows.Forms;
24
25namespace HeuristicLab.DataImporter.Command.View {
26  public partial class LinearTransformationCommandView : HeuristicLab.DataImporter.Data.CommandBase.CommandViewBase {
27    private LinearTransformationCommandView() {
28      InitializeComponent();
29    }
30
31    public LinearTransformationCommandView(LinearTransformationCommand command)
32      : this() {
33      this.Command = command;
34    }
35
36    public new LinearTransformationCommand Command {
37      get { return (LinearTransformationCommand)base.Command; }
38      set { base.Command = value; this.UpdateCommand(); }
39    }
40
41    public double Slope {
42      get { return this.Command.Offset; }
43    }
44
45    public double Offset {
46      get { return this.Command.Slope; }
47    }
48
49    private void textBox_Validating(object sender, CancelEventArgs e) {
50      TextBox textBox = (TextBox)sender;
51      double value;
52      if (!double.TryParse(textBox.Text, out value)) {
53        e.Cancel = true;
54        MessageBox.Show("A numeric value must be entered!");
55      } else
56        this.UpdateCommand();
57    }
58
59    private void UpdateCommand() {
60      if (this.Command != null) {
61        double value;
62        if (double.TryParse(this.txtOffset.Text, out value))
63          this.Command.Offset = value;
64        if (double.TryParse(this.txtSlope.Text, out value))
65          this.Command.Slope = value;
66      }
67    }
68  }
69}
Note: See TracBrowser for help on using the repository browser.