EditNodeView.xaml.cs
3.2 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Text.RegularExpressions;
namespace RoboforkApp
{
/// <summary>
/// Interaction logic for EditNode.xaml
/// </summary>
public partial class EditNodeWindow : Window
{
public EditNodeWindow()
{
InitializeComponent();
}
public string txtMode;
public string _txtMode
{
get { return txtMode; }
set { txtMode = value; }
}
public string txtMode1;
public string _txtMode1
{
get { return txtMode1; }
}
public string txtMode2;
public string _txtMode2
{
get { return txtMode2; }
}
public string txtMode3;
public string _txtMode3
{
get { return txtMode3; }
}
public bool ExitFlg = false;
public bool _ExitFlg
{
get { return ExitFlg; }
}
public struct NodeInf
{
public string Mode;
public double Speed;
public double Angle;
public double Height;
}
public List<NodeInf> NodeInf_List
{
get { return NodeInf_Lst; }
set { NodeInf_Lst = value; }
}
List<NodeInf> NodeInf_Lst = new List<NodeInf>();
private void IsDigit(object sender, TextCompositionEventArgs e)
{
Regex regex = new Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
private void btnEditNode_Click(object sender, RoutedEventArgs e)
{
string tag = ((Button)sender).Tag.ToString();
switch (tag)
{
case "ADDMODE":
NewDoBeginSave();
clearField();
break;
case "No":
ExitFlg = true;
this.Close();
break;
case "Save":
NewDoBeginSave();
MessageBox.Show("Data is saved");
this.Close();
break;
default:
break;
}
}
public void NewDoBeginSave()
{
NodeInf ni = new NodeInf();
ni.Mode = cbMode.Text;
if (txtSpeed.Text != "")
{
ni.Speed = double.Parse(txtSpeed.Text);
}
if (txtAngle.Text != "")
{
ni.Angle = double.Parse(txtAngle.Text);
}
if (txtHight.Text != "")
{
ni.Height = double.Parse(txtHight.Text);
}
NodeInf_Lst.Add(ni);
}
public void clearField()
{
cbMode.Text = "";
txtSpeed.Text = "";
txtAngle.Text = "";
txtHight.Text = "";
}
}
}