ExtensionFunction.cs
6.8 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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace Model
//{
// public abstract class ExtensionFunction
// {
// protected List<ExtensionControl> extensions;
// private Dictionary<string, int> reelID;
// private void ReelIDInit()
// {
// reelID = new();
// if (System.IO.File.Exists(FilePath.CONFIG_REELID))
// {
// string[] lines = System.IO.File.ReadAllLines(FilePath.CONFIG_REELID);
// for (int i = 0; i < lines.Length; i++)
// {
// string[] arr = lines[i].Split(',');
// if (arr.Length != 2) continue;
// reelID.Add(arr[0], Convert.ToInt32(arr[1]));
// }
// }
// }
// protected void ClearText()
// {
// for (int i = 0; i < extensions.Count; i++)
// {
// if (!extensions[i].CanClear) continue;
// if (extensions[i].Control is Asa.FaceControl.FaceComboBox box)
// box.Items.Clear();
// extensions[i].Control.Text = "";
// }
// }
// protected void SetControlText(Dictionary<string, string> key)
// {
// for (int i = 0; i < extensions.Count; i++)
// {
// if (key.ContainsKey(extensions[i].Key))
// extensions[i].Control.Text = key[extensions[i].Key];
// }
// }
// protected void SetControlText(string name, string text)
// {
// int index = extensions.FindIndex(match => match.Control.Name == name);
// if (index > -1) extensions[index].Control.Text = text;
// }
// protected void SetComboItem(string name, string[] text)
// {
// int index = extensions.FindIndex(match => match.Control.Name == name);
// if (index == -1) return;
// Asa.FaceControl.FaceComboBox cbo = (Asa.FaceControl.FaceComboBox)extensions[index].Control;
// cbo.Items.AddRange(text);
// cbo.SelectedIndex = -1;
// }
// protected void SetComboSelected(string name, int index)
// {
// int idx = extensions.FindIndex(match => match.Control.Name == name);
// if (idx == -1) return;
// ((Asa.FaceControl.FaceComboBox)extensions[idx].Control).SelectedIndex = index;
// }
// protected string GetControlText(string name)
// {
// int index = extensions.FindIndex(match => match.Control.Name == name);
// if (index == -1) return "";
// return extensions[index].Control.Text;
// }
// //protected string GetControlTextFromKey(string key)
// //{
// // int index = extensions.FindIndex(match => match.Key == key);
// // if (index == -1) return "";
// // return extensions[index].Control.Text;
// //}
// protected void SetControlEnabled(bool value, params string[] name)
// {
// for (int i = 0; i < name.Length; i++)
// {
// int index = extensions.FindIndex(match => match.Control.Name == name[i]);
// if (index == -1) continue;
// extensions[index].Control.Enabled = value;
// }
// }
// protected void GetReelID(out string key, out string value)
// {
// //读取参数
// string matchID = AppConfig.Read(AppConfigKey.REEL_ID_MATCH);
// AppConfig.Read(AppConfigKey.REEL_ID_PLACES, out int matchPlace);
// AppConfig.Read(AppConfigKey.REEL_ID_FILL_ZERO, out bool matchFill);
// string matchPrefix = AppConfig.Read(AppConfigKey.REEL_ID_PREFIX);
// string matchPostfix = AppConfig.Read(AppConfigKey.REEL_ID_POSTFIX);
// //把key替换成实际值
// string[] keys = ObjConversion.StrGetKey(matchID);
// for (int i = 0; i < keys.Length; i++)
// {
// int index = extensions.FindIndex(match => match.Key == keys[i]);
// if (index == -1) continue;
// string oldValue = string.Format("[{0}]", keys[i]);
// matchID = matchID.Replace(oldValue, extensions[index].Control.Text);
// }
// //查找是否存在
// if (reelID == null) ReelIDInit();
// if (!reelID.ContainsKey(matchID))
// reelID.Add(matchID, 0);
// int val = reelID[matchID] + 1;
// //填充0
// string text = matchPrefix;
// if (matchFill)
// text += string.Format("{0:d" + matchPlace + "}", val);
// else
// text += val.ToString();
// text += matchPostfix;
// key = matchID;
// value = text;
// }
// protected void SetReelIDAdd(string key)
// {
// reelID[key]++;
// int idx = 0;
// string[] lines = new string[reelID.Count];
// foreach (string s in reelID.Keys)
// lines[idx++] = string.Format("{0},{1}", s, reelID[s]);
// System.IO.File.WriteAllLines(FilePath.CONFIG_REELID, lines);
// }
// protected Dictionary<string, string> GetPrintKey()
// {
// Dictionary<string, string> key = new();
// for (int i = 0; i < extensions.Count; i++)
// {
// if (extensions[i].Key == "") continue;
// if (key.ContainsKey(extensions[i].Key))
// key[extensions[i].Key] = extensions[i].Control.Text;
// else
// key.Add(extensions[i].Key, extensions[i].Control.Text);
// }
// return key;
// }
// protected bool CheckEmptyContent()
// {
// //返回true有空内容不打印
// AppConfig.Read(AppConfigKey.LABEL_EMPTY_CHECK, out bool check);
// if (!check) return false;
// if (extensions == null) return true;
// bool find = false;
// for (int i = 0; i < extensions.Count; i++)
// {
// if (extensions[i].Key != "" && extensions[i].Control.Text == "")
// {
// find = true;
// break;
// }
// }
// if (find)
// {
// string text = Asa.FaceControl.Language.Dialog("LabelEmpty");
// Asa.FaceControl.FaceMessageBox dlg = new("", text, System.Windows.Forms.MessageBoxButtons.YesNo);
// System.Windows.Forms.DialogResult dr = dlg.ShowDialog();
// return dr == System.Windows.Forms.DialogResult.No;
// }
// return false;
// }
// }
//}