Blame view
sources/RoboforkApp/View/EditNodeView.xaml.cs
3.79 KB
729be9a6d
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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; |
99c770eb8
|
15 |
using System.Globalization; |
729be9a6d
|
16 17 18 19 20 21 22 23 24 25 26 27 |
namespace RoboforkApp { /// <summary> /// Interaction logic for EditNode.xaml /// </summary> public partial class EditNodeWindow : Window { public EditNodeWindow() { InitializeComponent(); } |
b338e1ff5
|
28 29 30 31 32 33 |
public string txtMode; public string _txtMode { get { return txtMode; } set { txtMode = value; } } |
729be9a6d
|
34 35 36 |
public string txtMode1; public string _txtMode1 { |
b338e1ff5
|
37 |
get { return txtMode1; } |
6312cbd86
|
38 |
} |
729be9a6d
|
39 40 41 42 |
public string txtMode2; public string _txtMode2 { get { return txtMode2; } |
6312cbd86
|
43 |
} |
729be9a6d
|
44 45 46 47 48 49 50 51 52 53 |
public string txtMode3; public string _txtMode3 { get { return txtMode3; } } public bool ExitFlg = false; public bool _ExitFlg { get { return ExitFlg; } } |
6312cbd86
|
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
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>(); |
729be9a6d
|
71 |
|
729be9a6d
|
72 73 74 75 76 77 78 |
private void btnEditNode_Click(object sender, RoutedEventArgs e) { string tag = ((Button)sender).Tag.ToString(); switch (tag) { case "ADDMODE": |
99c770eb8
|
79 80 81 82 83 |
if (!checkFloat(txtSpeed.Text) || !checkFloat(txtAngle.Text) || !checkFloat(txtHight.Text)) { MessageBox.Show("Please Check Again!"); break; } |
b338e1ff5
|
84 |
NewDoBeginSave(); |
729be9a6d
|
85 86 87 88 89 90 91 |
clearField(); break; case "No": ExitFlg = true; this.Close(); break; case "Save": |
99c770eb8
|
92 93 94 95 96 |
if (!checkFloat(txtSpeed.Text) || !checkFloat(txtAngle.Text) || !checkFloat(txtHight.Text)) { MessageBox.Show("Please Check Again!"); break; } |
b338e1ff5
|
97 98 |
NewDoBeginSave(); MessageBox.Show("Data is saved"); |
729be9a6d
|
99 100 101 102 103 104 105 |
this.Close(); break; default: break; } } |
b338e1ff5
|
106 107 |
public void NewDoBeginSave() { |
6312cbd86
|
108 109 |
NodeInf ni = new NodeInf(); ni.Mode = cbMode.Text; |
b338e1ff5
|
110 111 |
if (txtSpeed.Text != "") { |
6312cbd86
|
112 |
ni.Speed = double.Parse(txtSpeed.Text); |
b338e1ff5
|
113 114 115 |
} if (txtAngle.Text != "") { |
6312cbd86
|
116 |
ni.Angle = double.Parse(txtAngle.Text); |
b338e1ff5
|
117 118 119 |
} if (txtHight.Text != "") { |
6312cbd86
|
120 |
ni.Height = double.Parse(txtHight.Text); |
b338e1ff5
|
121 |
} |
b338e1ff5
|
122 |
|
6312cbd86
|
123 |
NodeInf_Lst.Add(ni); |
b338e1ff5
|
124 |
|
6312cbd86
|
125 |
} |
b338e1ff5
|
126 |
|
99c770eb8
|
127 128 129 130 131 |
//Check input string is Float format public bool checkFloat(string st) { bool flg = false; Regex regex = new Regex(@"^[0-9]*(?:\.[0-9]*)?$"); |
b338e1ff5
|
132 |
|
99c770eb8
|
133 134 135 |
flg = regex.IsMatch(st); return flg; } |
729be9a6d
|
136 137 |
public void clearField() |
6312cbd86
|
138 |
{ |
729be9a6d
|
139 140 141 142 143 144 145 146 |
cbMode.Text = ""; txtSpeed.Text = ""; txtAngle.Text = ""; txtHight.Text = ""; } } } |