-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOption.cs
169 lines (140 loc) · 4.33 KB
/
Option.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Created by SharpDevelop.
* User: oferfrid
* Date: 30/03/2008
* Time: 13:28
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Configuration ;
using System.Text.RegularExpressions;
namespace envRoom
{
/// <summary>
/// Description of Option.
/// </summary>
public partial class Option : Form
{
public ShowValues MainForm;
public Option()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.btnCancel.CausesValidation = false;
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void OptionLoad(object sender, EventArgs e)
{
txtTimeInterval.Text = (Convert.ToDecimal( this.MainForm.Recordtimer.Interval )/60000).ToString();
txtHdiff.Text = this.MainForm.AlertsHdiff.ToString();
txtPdiff.Text = this.MainForm.AlertsPdiff.ToString();
txtPtime.Text = this.MainForm.AlertsPtime.ToString();
txtTdiff.Text = this.MainForm.AlertsTdiff.ToString();
checkBoxActiveAlerts.Checked = this.MainForm.AlertsActive;
txtPhone.Text = this.MainForm.AlertsPhone;
txtEmail.Text = this.MainForm.AlertsEmail;
}
void BtnOKClick(object sender, EventArgs e)
{
UpdateInterval();
UpdateAlerts();
this.Close();
}
private void UpdateInterval()
{
this.MainForm.Recordtimer.Interval = Convert.ToInt32(Convert.ToDecimal(txtTimeInterval.Text) *60000);
}
private void UpdateAlerts()
{
this.MainForm.AlertsActive = this.checkBoxActiveAlerts.Checked ;
this.MainForm.AlertsHdiff = Convert.ToDouble(this.txtHdiff.Text);
this.MainForm.AlertsPdiff = Convert.ToDouble(this.txtPdiff.Text);
this.MainForm.AlertsPtime = Convert.ToDouble(this.txtPtime.Text);
this.MainForm.AlertsTdiff = Convert.ToDouble(this.txtTdiff.Text);
this.MainForm.AlertsPhone = this.txtPhone.Text;
this.MainForm.AlertsEmail = this.txtEmail.Text;
}
void BtnApplyClick(object sender, EventArgs e)
{
UpdateInterval();
UpdateAlerts();
}
void BtnCancelClick(object sender, EventArgs e)
{
this.Close();
}
void TxtEmailValidated(object sender, EventArgs e)
{
if (this.txtEmail.Text!=string.Empty )
{
if (!isEmail(this.txtEmail.Text))
{
this.OptionErrorProvider.SetError(this.txtEmail,"Email invalid");
}
else
{
OptionErrorProvider.Clear();
}
}
else
{
OptionErrorProvider.Clear();
}
}
private bool isEmail(string inputEmail)
{
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
void TxtPhoneMaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
if (txtPhone.MaskFull)
{
//toolTip1.ToolTipTitle = "Input Rejected - Too Much Data";
//toolTip1.Show("You cannot enter any more data into the date field. Delete some characters in order to insert more data.", maskedTextBox1, 0, -20, 5000);
this.OptionErrorProvider.SetError(this.txtPhone,"Phone to long use +(972)XX-XXXXXXX");
}
else if (e.Position == txtPhone.Mask.Length)
{
//toolTip1.ToolTipTitle = "Input Rejected - End of Field";
//toolTip1.Show("You cannot add extra characters to the end of this date field.", maskedTextBox1, 0, -20, 5000);
this.OptionErrorProvider.SetError(this.txtPhone,"Phone to long You cannot add extra characters \nuse +(972)XX-XXXXXXX");
}
else
{
//toolTip1.ToolTipTitle = "Input Rejected";
//toolTip1.Show("You can only add numeric characters (0-9) into this date field.", maskedTextBox1, 0, -20, 5000);
this.OptionErrorProvider.SetError(this.txtPhone,"Phone can includ numbers only us +(972)XX-XXXXXXX format");
}
}
void TxtPhoneValidated(object sender, EventArgs e)
{
if( !txtPhone.MaskCompleted && txtPhone.Text.Length !=0)
{
this.OptionErrorProvider.SetError(this.txtPhone,"Phone not valid \nuse +(972)XX-XXXXXXX format");
}
else
{
this.OptionErrorProvider.Clear();
}
}
void TxtPhoneKeyDown(object sender, KeyEventArgs e)
{
this.OptionErrorProvider.Clear();
}
}
}
//***************