SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
GraphLimitsDialog.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 
10 namespace SeciControls.Graphing
11 {
12  public partial class GraphLimitsDialog : Form
13  {
14  public Double Min = Double.NaN;
15  public Double Max = Double.NaN;
16 
18  {
19  InitializeComponent();
20  }
21 
22  private void GraphLimitsDialog_Load(object sender, EventArgs e)
23  {
24  if (Double.IsNaN(Min))
25  {
26  chkMin.Checked = true;
27  txtMin.Text = "0";
28  }
29  else
30  {
31  chkMin.Checked = false;
32  txtMin.Text = Min.ToString();
33  }
34 
35  if (Double.IsNaN(Max))
36  {
37  chkMax.Checked = true;
38  txtMax.Text = "1";
39  }
40  else
41  {
42  chkMax.Checked = false;
43  txtMax.Text = Max.ToString();
44  }
45  }
46 
47  private void chkMin_CheckedChanged(object sender, EventArgs e)
48  {
49  txtMin.Enabled = !chkMin.Checked;
50  }
51 
52  private void chkMax_CheckedChanged(object sender, EventArgs e)
53  {
54  txtMax.Enabled = !chkMax.Checked;
55  }
56 
57  private void btnOK_Click(object sender, EventArgs e)
58  {
59  if (chkMin.Checked)
60  {
61  Min = Double.NaN;
62  }
63  else
64  {
65  Double result;
66  if (!Double.TryParse(txtMin.Text, out result))
67  {
68  MessageBox.Show("Minimum value is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
69  return;
70  }
71 
72  Min = result;
73  }
74 
75  if (chkMax.Checked)
76  {
77  Max = Double.NaN;
78  }
79  else
80  {
81  Double result;
82  if (!Double.TryParse(txtMax.Text, out result))
83  {
84  MessageBox.Show("Maximum value is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
85  return;
86  }
87 
88  Max = result;
89  }
90 
91  if (!chkMin.Checked && !chkMax.Checked && Min == Max)
92  {
93  MessageBox.Show("Minimum and Maximum values must be different!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
94  return;
95  }
96 
97  if (Min > Max)
98  {
99  Double temp = Max;
100  Max = Min;
101  Min = temp;
102  }
103 
104  DialogResult = DialogResult.OK;
105  Close();
106  }
107  }
108 }
void GraphLimitsDialog_Load(object sender, EventArgs e)
void btnOK_Click(object sender, EventArgs e)
void chkMin_CheckedChanged(object sender, EventArgs e)
void chkMax_CheckedChanged(object sender, EventArgs e)