Browse Source

工具条提示文字

代码优化
master
张剑 1 year ago
parent
commit
498a53a837

+ 1
- 1
XHWK.WKTool/App.config View File

5
   </startup>
5
   </startup>
6
   <appSettings>
6
   <appSettings>
7
     <!--0正式 1测试-->
7
     <!--0正式 1测试-->
8
-    <add key="IsDebug" value="0" />
8
+    <add key="IsDebug" value="1" />
9
     <!--参数是否加密 0不加密 1加密-->
9
     <!--参数是否加密 0不加密 1加密-->
10
     <add key="IsParameterEncryption" value="0" />
10
     <add key="IsParameterEncryption" value="0" />
11
     <!--版本号-->
11
     <!--版本号-->

+ 53
- 63
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

14
     /// <summary>
14
     /// <summary>
15
     /// 创建微课
15
     /// 创建微课
16
     /// </summary>
16
     /// </summary>
17
-    public partial class CreateAMicroLessonWindow : Window
17
+    public partial class CreateAMicroLessonWindow
18
     {
18
     {
19
         #region 字段
19
         #region 字段
20
 
20
 
21
-        private FolderBrowserDialog ofd;
22
-        private DialogResult result;
21
+        private FolderBrowserDialog _ofd;
22
+        private DialogResult _result;
23
 
23
 
24
         #endregion 字段
24
         #endregion 字段
25
 
25
 
56
         /// <summary>
56
         /// <summary>
57
         /// 图片宽度,每次切换的宽度
57
         /// 图片宽度,每次切换的宽度
58
         /// </summary>
58
         /// </summary>
59
-        private double ImgWidth = 502.00;
59
+        private double _imgWidth = 502.00;
60
 
60
 
61
         /// <summary>
61
         /// <summary>
62
         /// 轮播时移动增加的宽度
62
         /// 轮播时移动增加的宽度
63
         /// </summary>
63
         /// </summary>
64
-        private double ImgMove = 1;
64
+        private double _imgMove = 1;
65
 
65
 
66
         /// <summary>
66
         /// <summary>
67
         /// 当前展示的图片序号Index从0开始
67
         /// 当前展示的图片序号Index从0开始
68
         /// </summary>
68
         /// </summary>
69
-        private int ImgNumIndex = 0;
69
+        private int _imgNumIndex;
70
 
70
 
71
         /// <summary>
71
         /// <summary>
72
         /// 加载录播图
72
         /// 加载录播图
73
         /// </summary>
73
         /// </summary>
74
         private void LoadingCarouseImg()
74
         private void LoadingCarouseImg()
75
         {
75
         {
76
-            new Thread(new ThreadStart(new Action(() =>
76
+            new Thread(() =>
77
             {
77
             {
78
                 Thread.Sleep(3000);
78
                 Thread.Sleep(3000);
79
                 Dispatcher.Invoke(() =>
79
                 Dispatcher.Invoke(() =>
80
                 {
80
                 {
81
-                    ImgWidth = ImgCarouse1.ActualWidth;
82
-                    ImgMove = ImgWidth / 250.00;
81
+                    _imgWidth = ImgCarouse1.ActualWidth;
82
+                    _imgMove = _imgWidth / 250.00;
83
                     CarouseImg();
83
                     CarouseImg();
84
                     //timesCarouse = new System.Timers.Timer(2000);
84
                     //timesCarouse = new System.Timers.Timer(2000);
85
                     //timesCarouse.Elapsed += TimesCarouse_Elapsed; ;
85
                     //timesCarouse.Elapsed += TimesCarouse_Elapsed; ;
86
                     //timesCarouse.Start();
86
                     //timesCarouse.Start();
87
                 });
87
                 });
88
-            }))).Start();
88
+            }).Start();
89
         }
89
         }
90
 
90
 
91
         /// <summary>
91
         /// <summary>
93
         /// </summary>
93
         /// </summary>
94
         private void CarouseImg()
94
         private void CarouseImg()
95
         {
95
         {
96
-            new Thread(new ThreadStart(new Action(() =>
96
+            new Thread(() =>
97
             {
97
             {
98
                 while (true)
98
                 while (true)
99
                 {
99
                 {
100
-                    for (double i = ImgMove; i < ImgWidth; i += ImgMove)
100
+                    for (double i = _imgMove; i < _imgWidth; i += _imgMove)
101
                     {
101
                     {
102
+                        var i1 = i;
102
                         Dispatcher.Invoke(() =>
103
                         Dispatcher.Invoke(() =>
103
                         {
104
                         {
104
-                            if (Math.Abs(i + ImgMove) < ImgWidth)
105
+                            if (Math.Abs(
106
+                                    i1 + _imgMove) < _imgWidth)
105
                             {
107
                             {
106
                                 //图片移动轮播
108
                                 //图片移动轮播
107
-                                SplCarouse.Margin = new Thickness(SplCarouse.Margin.Left - ImgMove, 0, 0, 0);
109
+                                SplCarouse.Margin = new Thickness(SplCarouse.Margin.Left - _imgMove, 0, 0, 0);
108
                             }
110
                             }
109
                             else
111
                             else
110
                             {
112
                             {
111
-                                if (ImgNumIndex >= 2)
113
+                                if (_imgNumIndex >= 2)
112
                                 {
114
                                 {
113
-                                    ImgNumIndex = 0;
115
+                                    _imgNumIndex = 0;
114
                                     SplCarouse.Margin = new Thickness(0, 0, 0, 0);
116
                                     SplCarouse.Margin = new Thickness(0, 0, 0, 0);
115
                                 }
117
                                 }
116
                                 else
118
                                 else
117
                                 {
119
                                 {
118
-                                    ImgNumIndex++;
119
-                                    SplCarouse.Margin = new Thickness(-(ImgNumIndex * ImgWidth), 0, 0, 0);
120
+                                    _imgNumIndex++;
121
+                                    SplCarouse.Margin = new Thickness(-(_imgNumIndex * _imgWidth), 0, 0, 0);
120
                                 }
122
                                 }
121
                             }
123
                             }
122
                         });
124
                         });
123
                         Thread.Sleep(3);
125
                         Thread.Sleep(3);
124
                     }
126
                     }
125
-                    bool IsBreak = false;
127
+
128
+                    bool isBreak = false;
126
                     Dispatcher.Invoke(() =>
129
                     Dispatcher.Invoke(() =>
127
                     {
130
                     {
128
                         if (this.Visibility != Visibility.Visible)
131
                         if (this.Visibility != Visibility.Visible)
129
                         {
132
                         {
130
                             SplCarouse.Margin = new Thickness(0);
133
                             SplCarouse.Margin = new Thickness(0);
131
-                            IsBreak = true;
134
+                            isBreak = true;
132
                         }
135
                         }
133
                     });
136
                     });
134
                     Thread.Sleep(5000);
137
                     Thread.Sleep(5000);
135
-                    if (IsBreak)
138
+                    if (isBreak)
136
                     {
139
                     {
137
                         break;
140
                         break;
138
                     }
141
                     }
139
                 }
142
                 }
140
-            }))).Start();
141
-        }
142
-
143
-        /// <summary>
144
-        /// 轮播图切换
145
-        /// </summary>
146
-        /// <param name="sender">
147
-        /// </param>
148
-        /// <param name="e">
149
-        /// </param>
150
-        private void TimesCarouse_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
151
-        {
152
-            //SplCarouse
153
-            //ImgCarouse1
143
+            }).Start();
154
         }
144
         }
155
 
145
 
156
         #endregion 轮播图
146
         #endregion 轮播图
169
             MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
159
             MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
170
             if (dr == MessageBoxResult.OK)
160
             if (dr == MessageBoxResult.OK)
171
             {
161
             {
172
-                System.Environment.Exit(0);
173
-            }
174
-            else
175
-            {
176
-                return;
162
+                Environment.Exit(0);
177
             }
163
             }
178
         }
164
         }
179
 
165
 
187
         private void BtnBrowse_Click(object sender, RoutedEventArgs e)
173
         private void BtnBrowse_Click(object sender, RoutedEventArgs e)
188
         {
174
         {
189
             //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
175
             //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
190
-            ofd = new FolderBrowserDialog();
176
+            _ofd = new FolderBrowserDialog();
191
 
177
 
192
-            result = ofd.ShowDialog();
193
-            if (result == System.Windows.Forms.DialogResult.OK)
178
+            _result = _ofd.ShowDialog();
179
+            if (_result == System.Windows.Forms.DialogResult.OK)
194
             {
180
             {
195
-                if (ofd.SelectedPath != "")
181
+                if (_ofd.SelectedPath != "")
196
                 {
182
                 {
197
-                    txbStoragePath.Text = ofd.SelectedPath;
183
+                    txbStoragePath.Text = _ofd.SelectedPath;
198
                 }
184
                 }
199
             }
185
             }
200
         }
186
         }
201
 
187
 
202
-        private bool IsPressButton = false;
188
+        private bool _isPressButton;
203
 
189
 
204
         /// <summary>
190
         /// <summary>
205
         /// 开始
191
         /// 开始
212
         {
198
         {
213
             #region 防止连击
199
             #region 防止连击
214
 
200
 
215
-            if (IsPressButton)
201
+            if (_isPressButton)
216
             {
202
             {
217
                 return;
203
                 return;
218
             }
204
             }
219
             else
205
             else
220
             {
206
             {
221
-                IsPressButton = true;
222
-                new Thread(new ThreadStart(new Action(() =>
207
+                _isPressButton = true;
208
+                new Thread(() =>
223
                 {
209
                 {
224
                     Thread.Sleep(500);
210
                     Thread.Sleep(500);
225
-                    IsPressButton = false;
226
-                }))).Start();
211
+                    _isPressButton = false;
212
+                }).Start();
227
             }
213
             }
228
 
214
 
229
             #endregion 防止连击
215
             #endregion 防止连击
235
                 MessageWindow.Show("讲解名称不可为空!");
221
                 MessageWindow.Show("讲解名称不可为空!");
236
                 return;
222
                 return;
237
             }
223
             }
224
+
238
             if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
225
             if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
239
             {
226
             {
240
                 MessageWindow.Show("路径不可为空!");
227
                 MessageWindow.Show("路径不可为空!");
241
                 return;
228
                 return;
242
             }
229
             }
230
+
243
             try
231
             try
244
             {
232
             {
245
                 FileToolsCommon.CreateDirectory(txbStoragePath.Text.Trim());
233
                 FileToolsCommon.CreateDirectory(txbStoragePath.Text.Trim());
246
             }
234
             }
247
-            catch (Exception ex)
235
+            catch (Exception)
248
             {
236
             {
249
                 MessageWindow.Show("路径无法访问,解决方案:\r\n1,检查路径是否可访问。\r\n2,关闭杀毒软件或信任软件。");
237
                 MessageWindow.Show("路径无法访问,解决方案:\r\n1,检查路径是否可访问。\r\n2,关闭杀毒软件或信任软件。");
250
                 return;
238
                 return;
254
 
242
 
255
             LblCreate.Visibility = Visibility.Visible;
243
             LblCreate.Visibility = Visibility.Visible;
256
             string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
244
             string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
257
-            string StoragePath = txbStoragePath.Text;
258
-            string WkName = txbExplainName.Text;
245
+            string storagePath = txbStoragePath.Text;
246
+            string wkName = txbExplainName.Text;
259
             await Task.Run(() =>
247
             await Task.Run(() =>
260
             {
248
             {
261
                 try
249
                 try
267
                         APP.WKData = new Model_WKData
255
                         APP.WKData = new Model_WKData
268
                         {
256
                         {
269
                             WkPath = wkpath,
257
                             WkPath = wkpath,
270
-                            WkName = WkName,
258
+                            WkName = wkName,
271
                             WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
259
                             WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
272
                         };
260
                         };
273
                     }
261
                     }
285
                     }
273
                     }
286
 
274
 
287
                     //存储文件
275
                     //存储文件
288
-                    FileToolsCommon.SetConfigValue("VideoSavePath", StoragePath);
276
+                    FileToolsCommon.SetConfigValue("VideoSavePath", storagePath);
289
 
277
 
290
                     APP.ReadDrawData();
278
                     APP.ReadDrawData();
291
                 }
279
                 }
299
             {
287
             {
300
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
288
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
301
             }
289
             }
290
+
302
             APP.W_XHMicroLessonSystemWindow.Show();
291
             APP.W_XHMicroLessonSystemWindow.Show();
303
             LblCreate.Visibility = Visibility.Hidden;
292
             LblCreate.Visibility = Visibility.Hidden;
304
             Hide();
293
             Hide();
321
         /// <summary>
310
         /// <summary>
322
         /// 检测APP更新
311
         /// 检测APP更新
323
         /// </summary>
312
         /// </summary>
324
-        private void getNewApp()
313
+        private void GetNewApp()
325
         {
314
         {
326
             new Thread(o =>
315
             new Thread(o =>
327
             {
316
             {
333
                     //软件是否更新,版本号小于0不更新
322
                     //软件是否更新,版本号小于0不更新
334
                     return;
323
                     return;
335
                 }
324
                 }
325
+
336
                 string url = APP.apiUrl + "/sapi/apprecord/get_new";
326
                 string url = APP.apiUrl + "/sapi/apprecord/get_new";
337
 
327
 
338
                 string result = HttpHelper.PostAndRespStr(url, "{}");
328
                 string result = HttpHelper.PostAndRespStr(url, "{}");
339
-                Model.ResultVo<Model_App> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_App>>(result);
329
+                var resultObj = JsonHelper.JsonToObj<ResultVo<Model_App>>(result);
340
                 if (result != null && resultObj.code == 0)
330
                 if (result != null && resultObj.code == 0)
341
                 {
331
                 {
342
                     if (resultObj.obj != null)
332
                     if (resultObj.obj != null)
346
                             int versionCode = resultObj.obj.versioncode;
336
                             int versionCode = resultObj.obj.versioncode;
347
                             if (versionThis < versionCode)
337
                             if (versionThis < versionCode)
348
                             {
338
                             {
349
-                                Dispatcher.Invoke(new Action(() =>
339
+                                Dispatcher.Invoke(() =>
350
                                 {
340
                                 {
351
                                     string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
341
                                     string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
352
                                     FileToolsCommon.CreateDirectory(pathTemp);
342
                                     FileToolsCommon.CreateDirectory(pathTemp);
353
-                                    appUpdateShow(resultObj.obj);
354
-                                }));
343
+                                    AppUpdateShow(resultObj.obj);
344
+                                });
355
                             }
345
                             }
356
                         }
346
                         }
357
                         catch (Exception ex)
347
                         catch (Exception ex)
368
         /// </summary>
358
         /// </summary>
369
         /// <param name="app">
359
         /// <param name="app">
370
         /// </param>
360
         /// </param>
371
-        private void appUpdateShow(Model_App app)
361
+        private void AppUpdateShow(Model_App app)
372
         {
362
         {
373
             AppUpdateWin win = new AppUpdateWin(app)
363
             AppUpdateWin win = new AppUpdateWin(app)
374
             {
364
             {
380
 
370
 
381
         private void Window_Loaded(object sender, RoutedEventArgs e)
371
         private void Window_Loaded(object sender, RoutedEventArgs e)
382
         {
372
         {
383
-            getNewApp();
373
+            GetNewApp();
384
         }
374
         }
385
 
375
 
386
         private void Window_Closed(object sender, EventArgs e)
376
         private void Window_Closed(object sender, EventArgs e)

+ 103
- 101
XHWK.WKTool/DAL/DAL_Upload.cs View File

14
     /// <summary>
14
     /// <summary>
15
     /// 上传相关方法 创建人:赵耀 创建时间:2020年9月4日
15
     /// 上传相关方法 创建人:赵耀 创建时间:2020年9月4日
16
     /// </summary>
16
     /// </summary>
17
-    public class DAL_Upload
17
+    public class DalUpload
18
     {
18
     {
19
-        private string FileRequestAddress = APP.uploadUrl;
19
+        private readonly string _fileRequestAddress = APP.uploadUrl;
20
 
20
 
21
         //private string schoolfileRequestAddress = APP.showImageUrl;
21
         //private string schoolfileRequestAddress = APP.showImageUrl;
22
         /// <summary>
22
         /// <summary>
23
         /// 文件是否允许上传
23
         /// 文件是否允许上传
24
         /// </summary>
24
         /// </summary>
25
-        /// <param name="MD5">
25
+        /// <param name="md5">
26
         /// MD5
26
         /// MD5
27
         /// </param>
27
         /// </param>
28
-        /// <param name="Message">
28
+        /// <param name="message">
29
         /// 错误消息
29
         /// 错误消息
30
         /// </param>
30
         /// </param>
31
         /// <returns>
31
         /// <returns>
32
         /// </returns>
32
         /// </returns>
33
-        public bool IsAllowUploaded(string MD5, out string Message)
33
+        public bool IsAllowUploaded(string md5, out string message)
34
         {
34
         {
35
             Exception ex = null;
35
             Exception ex = null;
36
-            Message = "";//请求重试5次 共5秒
36
+            message = ""; //请求重试5次 共5秒
37
             for (int num = 0; num < 5; num++)
37
             for (int num = 0; num < 5; num++)
38
             {
38
             {
39
                 try
39
                 try
40
                 {
40
                 {
41
-                    JObject jo = HttpHelper.PostFunction(FileRequestAddress + @"/chunkdb/isexist", @"application/x-www-form-urlencoded", @"md5=" + MD5, "");
41
+                    JObject jo = HttpHelper.PostFunction(_fileRequestAddress + @"/chunkdb/isexist",
42
+                        @"application/x-www-form-urlencoded", @"md5=" + md5, "");
42
                     if (jo == null)
43
                     if (jo == null)
43
                     {
44
                     {
44
-                        Message = "无法访问文件服务器,请检查网络或文件服务器地址。";
45
+                        message = "无法访问文件服务器,请检查网络或文件服务器地址。";
45
                         return false;
46
                         return false;
46
                     }
47
                     }
47
 
48
 
48
                     //修改为0为之前上传成功,1为之前未上传成功
49
                     //修改为0为之前上传成功,1为之前未上传成功
49
-                    if (jo["code"].ToString() == "0")
50
+                    if (jo["code"]?.ToString() == "0")
50
                     {
51
                     {
51
-                        Message = "";
52
+                        message = "";
52
 
53
 
53
-                        Model.ResultVo<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
54
+                        Model.ResultVo<Model_ResourceAddTwo> resultObj =
55
+                            JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
54
 
56
 
55
                         APP.ResourceAddTwo = resultObj.obj;
57
                         APP.ResourceAddTwo = resultObj.obj;
56
                         //已存在 不允许上传
58
                         //已存在 不允许上传
58
                     }
60
                     }
59
                     else
61
                     else
60
                     {
62
                     {
61
-                        Message = "";
63
+                        message = "";
62
                         //不存在 允许上传
64
                         //不存在 允许上传
63
                         return true;
65
                         return true;
64
                     }
66
                     }
65
                 }
67
                 }
66
                 catch (Exception e)
68
                 catch (Exception e)
67
                 {
69
                 {
68
-                    Message = "上传失败,无法访问到服务器:" + e.Message;
70
+                    message = "上传失败,无法访问到服务器:" + e.Message;
69
                     ex = e;
71
                     ex = e;
70
                     Thread.Sleep(1000);
72
                     Thread.Sleep(1000);
71
                 }
73
                 }
72
             }
74
             }
73
-            string ErrMessage = "【文件是否存在】(IsUploaded):请求失败。" + Message;
74
-            LogHelper.WriteErrLog(ErrMessage, ex);
75
+
76
+            string errMessage = "【文件是否存在】(IsUploaded):请求失败。" + message;
77
+            LogHelper.WriteErrLog(errMessage, ex);
75
             return false;
78
             return false;
76
         }
79
         }
77
 
80
 
78
         /// <summary>
81
         /// <summary>
79
         /// 上报文件合并指令
82
         /// 上报文件合并指令
80
         /// </summary>
83
         /// </summary>
81
-        /// <param name="Savefolder">
84
+        /// <param name="savefolder">
82
         /// 保存文件位置 学校id/resource
85
         /// 保存文件位置 学校id/resource
83
         /// </param>
86
         /// </param>
84
-        /// <param name="FileCode">
87
+        /// <param name="fileCode">
85
         /// 文件唯一编号 Guid
88
         /// 文件唯一编号 Guid
86
         /// </param>
89
         /// </param>
87
-        /// <param name="Message">
90
+        /// <param name="message">
88
         /// 错误信息
91
         /// 错误信息
89
         /// </param>
92
         /// </param>
90
         /// <returns>
93
         /// <returns>
91
         /// </returns>
94
         /// </returns>
92
-        public bool ReportFileMerge(string Savefolder, string FileCode, out string Message)
95
+        public bool ReportFileMerge(string savefolder, string fileCode, out string message)
93
         {
96
         {
94
             Exception ex = null;
97
             Exception ex = null;
95
-            Message = "";//请求重试5次 共5秒
98
+            message = ""; //请求重试5次 共5秒
96
             for (int num = 0; num < 5; num++)
99
             for (int num = 0; num < 5; num++)
97
             {
100
             {
98
                 try
101
                 try
99
                 {
102
                 {
100
-                    JObject jo = HttpHelper.PostFunction(FileRequestAddress + @"/chunkdb/mergechunk", @"application/x-www-form-urlencoded", @"savefolder=" + Savefolder + "&identifier=" + FileCode, "");
103
+                    JObject jo = HttpHelper.PostFunction(_fileRequestAddress + @"/chunkdb/mergechunk",
104
+                        @"application/x-www-form-urlencoded", @"savefolder=" + savefolder + "&identifier=" + fileCode,
105
+                        "");
101
                     if (jo == null)
106
                     if (jo == null)
102
                     {
107
                     {
103
-                        Message = "无法访问文件服务器,请检查网络或文件服务器地址。";
108
+                        message = "无法访问文件服务器,请检查网络或文件服务器地址。";
104
                         return false;
109
                         return false;
105
                     }
110
                     }
106
                     Model.ResultVo<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
111
                     Model.ResultVo<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
114
                     else
119
                     else
115
                     {
120
                     {
116
                         //Message = "上传失败!";
121
                         //Message = "上传失败!";
117
-                        Message = jo["msg"].ToString();
122
+                        message = jo["msg"]?.ToString();
118
                         return false;
123
                         return false;
119
                     }
124
                     }
120
                 }
125
                 }
121
                 catch (Exception e)
126
                 catch (Exception e)
122
                 {
127
                 {
123
-                    Message = e.Message;
128
+                    message = e.Message;
124
                     ex = e;
129
                     ex = e;
125
                     Thread.Sleep(1000);
130
                     Thread.Sleep(1000);
126
                 }
131
                 }
127
             }
132
             }
128
-            string ErrMessage = "【上报合并文件】(ReportFileMerge):请求失败。" + Message;
129
-            LogHelper.WriteErrLog(ErrMessage, ex);
133
+
134
+            string errMessage = "【上报合并文件】(ReportFileMerge):请求失败。" + message;
135
+            LogHelper.WriteErrLog(errMessage, ex);
130
             return false;
136
             return false;
131
         }
137
         }
132
 
138
 
135
         /// </summary>
141
         /// </summary>
136
         /// <returns>
142
         /// <returns>
137
         /// </returns>
143
         /// </returns>
138
-        public bool UploadVideo(string VideoGuid, out string ErrMessage)
144
+        public bool UploadVideo(string videoGuid, out string errMessage)
139
         {
145
         {
140
-            ErrMessage = "";
146
+            errMessage = "";
141
             try
147
             try
142
             {
148
             {
143
-                Model_Video VideoInfo = null;
144
-                foreach (Model_WKData Vdata in APP.WKDataList)
149
+                Model_Video videoInfo = null;
150
+                foreach (Model_WKData vdata in APP.WKDataList)
145
                 {
151
                 {
146
-                    if (Vdata.VideoList == null)
152
+                    if (vdata.VideoList == null)
147
                     {
153
                     {
148
                         continue;
154
                         continue;
149
                     }
155
                     }
150
 
156
 
151
-                    foreach (Model_Video videoinfo in Vdata.VideoList)
157
+                    foreach (Model_Video videoinfo in vdata.VideoList)
152
                     {
158
                     {
153
-                        if (videoinfo.FileGuid == VideoGuid)
159
+                        if (videoinfo.FileGuid == videoGuid)
154
                         {
160
                         {
155
-                            VideoInfo = videoinfo;
161
+                            videoInfo = videoinfo;
156
                             break;
162
                             break;
157
                         }
163
                         }
158
                     }
164
                     }
159
-                    if (VideoInfo != null)
165
+
166
+                    if (videoInfo != null)
160
                     {
167
                     {
161
                         break;
168
                         break;
162
                     }
169
                     }
163
                 }
170
                 }
164
-                if (VideoInfo == null)
171
+
172
+                if (videoInfo == null)
165
                 {
173
                 {
166
-                    ErrMessage = "未找到课程!";
174
+                    errMessage = "未找到课程!";
167
                     return false;
175
                     return false;
168
                 }
176
                 }
169
-                string UploadUrl = FileRequestAddress + "/chunkdb/upchunk";//zxyceshi
170
-                if (VideoInfo.IsUpload)
177
+
178
+                if (videoInfo.IsUpload)
171
                 {
179
                 {
172
-                    ErrMessage = "视频已上传";
180
+                    errMessage = "视频已上传";
173
                     return false;
181
                     return false;
174
                 }
182
                 }
175
                 else
183
                 else
189
         /// </summary>
197
         /// </summary>
190
         /// <returns>
198
         /// <returns>
191
         /// </returns>
199
         /// </returns>
192
-        public bool UploadVideoTwo(string VideoGuid, out string ErrMessage)
200
+        public bool UploadVideoTwo(string videoGuid, out string errMessage)
193
         {
201
         {
194
-            ErrMessage = "";
202
+            errMessage = "";
195
             try
203
             try
196
             {
204
             {
197
-                Model_Video VideoInfo = null;
198
-                foreach (Model_WKData Vdata in APP.WKDataList)
205
+                Model_Video videoInfo = null;
206
+                foreach (Model_WKData vdata in APP.WKDataList)
199
                 {
207
                 {
200
-                    if (Vdata.VideoList == null)
208
+                    if (vdata.VideoList == null)
201
                     {
209
                     {
202
                         continue;
210
                         continue;
203
                     }
211
                     }
204
 
212
 
205
-                    foreach (Model_Video videoinfo in Vdata.VideoList)
213
+                    foreach (Model_Video videoinfo in vdata.VideoList)
206
                     {
214
                     {
207
-                        if (videoinfo.FileGuid == VideoGuid)
215
+                        if (videoinfo.FileGuid == videoGuid)
208
                         {
216
                         {
209
-                            VideoInfo = videoinfo;
217
+                            videoInfo = videoinfo;
210
                             break;
218
                             break;
211
                         }
219
                         }
212
                     }
220
                     }
213
-                    if (VideoInfo != null)
221
+
222
+                    if (videoInfo != null)
214
                     {
223
                     {
215
                         break;
224
                         break;
216
                     }
225
                     }
217
                 }
226
                 }
218
-                if (VideoInfo == null)
227
+
228
+                if (videoInfo == null)
219
                 {
229
                 {
220
-                    ErrMessage = "未找到课程!";
230
+                    errMessage = "未找到课程!";
221
                     return false;
231
                     return false;
222
                 }
232
                 }
223
-                string UploadUrl = FileRequestAddress + "/chunkdb/upchunk";//zxyceshi
224
-                if (VideoInfo.IsUpload)
233
+
234
+                string uploadUrl = _fileRequestAddress + "/chunkdb/upchunk"; //zxyceshi
235
+                if (videoInfo.IsUpload)
225
                 {
236
                 {
226
-                    ErrMessage = "视频已上传";
237
+                    errMessage = "视频已上传";
227
                     return false;
238
                     return false;
228
                 }
239
                 }
229
                 else
240
                 else
230
                 {
241
                 {
231
-                    if (string.IsNullOrWhiteSpace(VideoInfo.FileMD5))
242
+                    if (string.IsNullOrWhiteSpace(videoInfo.FileMD5))
232
                     {
243
                     {
233
-                        VideoInfo.FileMD5 = AESHelper.AESEncrypt(FileToolsCommon.ReadBigFileStr(VideoInfo.VideoPath, 1024));
244
+                        videoInfo.FileMD5 =
245
+                            AESHelper.AESEncrypt(FileToolsCommon.ReadBigFileStr(videoInfo.VideoPath, 1024));
234
                     }
246
                     }
235
 
247
 
236
                     //视频长度
248
                     //视频长度
237
-                    long filelen = FileToolsCommon.GetFileSize(VideoInfo.VideoPath);
249
+                    long filelen = FileToolsCommon.GetFileSize(videoInfo.VideoPath);
238
                     //每片的长度
250
                     //每片的长度
239
-                    double UploadSliceLenMB = double.Parse(FileToolsCommon.GetConfigValue("UploadSliceLen"));
240
-                    string fileName = FileToolsCommon.GetFileName(VideoInfo.VideoPath);
251
+                    double uploadSliceLenMb = double.Parse(FileToolsCommon.GetConfigValue("UploadSliceLen"));
252
+                    string fileName = FileToolsCommon.GetFileName(videoInfo.VideoPath);
241
                     //是否续传
253
                     //是否续传
242
-                    bool IsSequel = true;
243
                     //分块数为0时 从未上传过
254
                     //分块数为0时 从未上传过
244
-                    if (VideoInfo.Block > 0)
255
+                    if (videoInfo.Block > 0)
245
                     {
256
                     {
246
                         //是否已上传所有分块
257
                         //是否已上传所有分块
247
-                        if (VideoInfo.Block > VideoInfo.Uploaded)
258
+                        if (videoInfo.Block > videoInfo.Uploaded)
248
                         {
259
                         {
249
                             //已上传,未上传完
260
                             //已上传,未上传完
250
-                            IsSequel = true;
251
                         }
261
                         }
252
                         else
262
                         else
253
                         {
263
                         {
254
                             //上传完,未合并
264
                             //上传完,未合并
255
-                            IsSequel = false;
256
 
265
 
257
                             #region 合并文件
266
                             #region 合并文件
258
 
267
 
259
                             //合并文件
268
                             //合并文件
260
-                            bool isres = ReportFileMerge(APP.UserInfo.cloudcode + "/" + APP.UserInfo.Schoolid.ToString() + "/resource", VideoInfo.FileGuid, out ErrMessage);
269
+                            bool isres =
270
+                                ReportFileMerge(
271
+                                    APP.UserInfo.cloudcode + "/" + APP.UserInfo.Schoolid.ToString() + "/resource",
272
+                                    videoInfo.FileGuid, out errMessage);
261
                             if (isres)
273
                             if (isres)
262
                             {
274
                             {
263
-                                VideoInfo.IsUpload = true;
275
+                                videoInfo.IsUpload = true;
264
                                 return true;
276
                                 return true;
265
                             }
277
                             }
266
                             else
278
                             else
274
                     else
286
                     else
275
                     {
287
                     {
276
                         //是否允许上传
288
                         //是否允许上传
277
-                        if (IsAllowUploaded(VideoInfo.FileMD5, out ErrMessage))
289
+                        if (IsAllowUploaded(videoInfo.FileMD5, out errMessage))
278
                         {
290
                         {
279
-                            IsSequel = true;
280
-                            if (VideoInfo.SliceLen == 0)
291
+                            if (videoInfo.SliceLen == 0)
281
                             {
292
                             {
282
-                                VideoInfo.SliceLen = (long)(UploadSliceLenMB * 1024 * 1024);
283
-                                VideoInfo.Block = (int)(filelen / VideoInfo.SliceLen + (filelen % VideoInfo.SliceLen > 0 ? 1 : 0));
293
+                                videoInfo.SliceLen = (long)(uploadSliceLenMb * 1024 * 1024);
294
+                                videoInfo.Block = (int)(filelen / videoInfo.SliceLen +
295
+                                                        (filelen % videoInfo.SliceLen > 0 ? 1 : 0));
284
                             }
296
                             }
285
                         }
297
                         }
286
                         else
298
                         else
287
                         {
299
                         {
288
                             //文件在服务器上已存在  空间是否存在未知 若增加空间是否存在判断在此处添加
300
                             //文件在服务器上已存在  空间是否存在未知 若增加空间是否存在判断在此处添加
289
-                            IsSequel = false;
290
-                            VideoInfo.Block = 1;
291
-                            VideoInfo.Uploaded = 1;
301
+                            videoInfo.Block = 1;
302
+                            videoInfo.Uploaded = 1;
292
 
303
 
293
-                            VideoInfo.IsUpload = true;
304
+                            videoInfo.IsUpload = true;
294
                             return true;
305
                             return true;
295
                         }
306
                         }
296
                     }
307
                     }
297
 
308
 
298
                     ////临时修改 没有断点续传,每次上传都重新上传。
309
                     ////临时修改 没有断点续传,每次上传都重新上传。
299
                     //VideoInfo.Uploaded = 0;
310
                     //VideoInfo.Uploaded = 0;
300
-                    if (IsSequel)
301
                     {
311
                     {
302
                         //已上传长度
312
                         //已上传长度
303
-                        long len = VideoInfo.Uploaded * VideoInfo.SliceLen;
313
+                        long len;
304
 
314
 
305
                         //分块
315
                         //分块
306
                         do
316
                         do
307
                         {
317
                         {
308
-                            len = VideoInfo.Uploaded * VideoInfo.SliceLen;
318
+                            len = videoInfo.Uploaded * videoInfo.SliceLen;
309
                             //取指定长度的流
319
                             //取指定长度的流
310
-                            byte[] byteArray = FileToolsCommon.ReadBigFileSpecifyLength(VideoInfo.VideoPath, len, (int)VideoInfo.SliceLen);
320
+                            byte[] byteArray = FileToolsCommon.ReadBigFileSpecifyLength(videoInfo.VideoPath, len,
321
+                                (int)videoInfo.SliceLen);
311
                             //参数
322
                             //参数
312
                             NameValueCollection formFields = new NameValueCollection
323
                             NameValueCollection formFields = new NameValueCollection
313
                             {
324
                             {
314
-                                { "identifier", VideoInfo.FileGuid },
315
-                                { "chunkNumber", (VideoInfo.Uploaded + 1).ToString() },
325
+                                { "identifier", videoInfo.FileGuid },
326
+                                { "chunkNumber", (videoInfo.Uploaded + 1).ToString() },
316
                                 { "filename", fileName },
327
                                 { "filename", fileName },
317
-                                { "totalchunk", VideoInfo.Block.ToString() },
318
-                                { "md5", VideoInfo.FileMD5 }
328
+                                { "totalchunk", videoInfo.Block.ToString() },
329
+                                { "md5", videoInfo.FileMD5 }
319
                             };
330
                             };
320
                             //formFields.Add();///教材
331
                             //formFields.Add();///教材
321
                             //if()//章节若没选不传
332
                             //if()//章节若没选不传
323
                             //    formFields.Add();
334
                             //    formFields.Add();
324
                             //}
335
                             //}
325
 
336
 
326
-                            JObject jo = HttpHelper.UploadRequestflow(UploadUrl, byteArray, fileName, formFields);
337
+                            JObject jo = HttpHelper.UploadRequestflow(uploadUrl, byteArray, fileName, formFields);
327
                             //0成功,1失败
338
                             //0成功,1失败
328
-                            if (jo["code"].ToString() != "0")
339
+                            if (jo["code"]?.ToString() != "0")
329
                             {
340
                             {
330
-                                ErrMessage = jo["msg"].ToString();
341
+                                errMessage = jo["msg"]?.ToString();
331
                                 return false;
342
                                 return false;
332
                             }
343
                             }
333
                             else
344
                             else
334
                             {
345
                             {
335
-                                VideoInfo.Uploaded++;
346
+                                videoInfo.Uploaded++;
336
                             }
347
                             }
337
-                        } while (len + VideoInfo.SliceLen < filelen);
348
+                        } while (len + videoInfo.SliceLen < filelen);
338
 
349
 
339
                         #region 合并文件
350
                         #region 合并文件
340
 
351
 
341
                         //合并文件
352
                         //合并文件
342
-                        bool isres = ReportFileMerge(APP.UserInfo.cloudcode + "/" + APP.UserInfo.Schoolid.ToString() + "/resource", VideoInfo.FileGuid, out ErrMessage);
353
+                        bool isres =
354
+                            ReportFileMerge(
355
+                                APP.UserInfo.cloudcode + "/" + APP.UserInfo.Schoolid.ToString() + "/resource",
356
+                                videoInfo.FileGuid, out errMessage);
343
                         if (isres)
357
                         if (isres)
344
                         {
358
                         {
345
                             //VideoInfo.IsUpload = true;
359
                             //VideoInfo.IsUpload = true;
352
 
366
 
353
                         #endregion 合并文件
367
                         #endregion 合并文件
354
                     }
368
                     }
355
-                    else
356
-                    {
357
-                        if (string.IsNullOrWhiteSpace(ErrMessage))
358
-                        {
359
-                            //VideoInfo.IsUpload = true;
360
-                            return true;
361
-                        }
362
-                        else
363
-                        {
364
-                            return false;
365
-                        }
366
-                    }
367
                 }
369
                 }
368
             }
370
             }
369
             catch (Exception ex)
371
             catch (Exception ex)

+ 81
- 114
XHWK.WKTool/KeyVerification.xaml View File

2
     x:Class="XHWK.WKTool.KeyVerification"
2
     x:Class="XHWK.WKTool.KeyVerification"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
-    xmlns:Views="clr-namespace:XHWK.WKTool.Helpers"
6
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7
-    xmlns:local="clr-namespace:XHWK.WKTool"
8
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9
     Title="KeyVerification"
7
     Title="KeyVerification"
10
     Width="400"
8
     Width="400"
11
-    Height="230"
9
+    Height="200"
12
     AllowsTransparency="True"
10
     AllowsTransparency="True"
13
     Background="Transparent"
11
     Background="Transparent"
12
+    BorderBrush="#4597FF"
13
+    BorderThickness="1"
14
     ShowInTaskbar="False"
14
     ShowInTaskbar="False"
15
     WindowStartupLocation="CenterOwner"
15
     WindowStartupLocation="CenterOwner"
16
     WindowStyle="None"
16
     WindowStyle="None"
17
     mc:Ignorable="d">
17
     mc:Ignorable="d">
18
 
18
 
19
-    <Window.Resources>
20
-        <Style x:Key="oiliu" TargetType="ListBoxItem">
21
-            <!--  设置控件模板  -->
22
-            <Setter Property="Template">
23
-                <Setter.Value>
24
-                    <ControlTemplate TargetType="ListBoxItem">
25
-                        <Border
26
-                            Margin="4,0,0,0"
27
-                            Padding="0"
28
-                            Background="{TemplateBinding Background}">
29
-                            <ContentPresenter
30
-                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
31
-                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
32
-                                TextBlock.Foreground="{TemplateBinding Foreground}" />
33
-                        </Border>
34
-                    </ControlTemplate>
35
-                </Setter.Value>
36
-            </Setter>
37
-        </Style>
38
-        <DataTemplate x:Key="UserTpl">
39
-            <StackPanel
40
-                Width="70.5"
41
-                Height="auto"
42
-                Background="Transparent">
43
-                <TextBlock
44
-                    Padding="0,12,0,0"
45
-                    HorizontalAlignment="Left"
46
-                    FontSize="20"
47
-                    Foreground="#3C525B"
48
-                    Text="{Binding username}" />
49
-            </StackPanel>
50
-        </DataTemplate>
51
-    </Window.Resources>
52
-    <Views:ZJClippingBorder Background="White">
53
-        <Grid Margin="0,0,0,0">
54
-            <Grid.RowDefinitions>
55
-                <RowDefinition Height="50" />
56
-                <RowDefinition Height="*" />
57
-                <RowDefinition Height="75" />
58
-            </Grid.RowDefinitions>
59
-            <!--  头部  -->
60
-            <Grid
19
+    <Window.Resources />
20
+    <Grid Margin="0,0,0,0" Background="White">
21
+        <Grid.RowDefinitions>
22
+            <RowDefinition Height="50" />
23
+            <RowDefinition Height="*" />
24
+            <RowDefinition Height="75" />
25
+        </Grid.RowDefinitions>
26
+        <!--  头部  -->
27
+        <Grid
28
+            Grid.Row="0"
29
+            Height="50"
30
+            Background="#4597FF"
31
+            MouseLeftButtonDown="Window_MouseLeftButtonDown_1">
32
+            <TextBlock
33
+                x:Name="TitleTb"
61
                 Grid.Row="0"
34
                 Grid.Row="0"
62
-                Height="50"
63
-                Background="#4597FF">
64
-                <TextBlock
65
-                    x:Name="title_tb"
66
-                    Grid.Row="0"
67
-                    Margin="15,0,0,0"
68
-                    HorizontalAlignment="Left"
69
-                    VerticalAlignment="Center"
70
-                    FontSize="16"
71
-                    Foreground="White"
72
-                    Text="产品激活" />
73
-
74
-                <Button
75
-                    x:Name="btnDown"
76
-                    Grid.Row="0"
77
-                    Padding="10,0,10,0"
78
-                    HorizontalAlignment="Right"
79
-                    Click="close_click"
80
-                    Content="×"
81
-                    Cursor="Hand"
82
-                    FontSize="30"
83
-                    Foreground="#FFFFFF" />
84
-            </Grid>
85
-            <Grid Grid.Row="1" Margin="30,20,30,0">
86
-                <Grid.ColumnDefinitions>
87
-                    <ColumnDefinition Width="Auto" />
88
-                    <ColumnDefinition Width="*" />
89
-                </Grid.ColumnDefinitions>
90
-                <TextBlock
91
-                    Padding="0,0,0,0"
92
-                    VerticalAlignment="Center"
93
-                    FontSize="20"
94
-                    Text="密匙:" />
95
-                <TextBox
96
-                    x:Name="txbKey"
97
-                    Grid.Column="1"
98
-                    Height="46"
99
-                    VerticalAlignment="Center"
100
-                    VerticalContentAlignment="Center"
101
-                    FontSize="18"
102
-                    Foreground="gray"
103
-                    Text="" />
104
-            </Grid>
35
+                Margin="15,0,0,0"
36
+                HorizontalAlignment="Left"
37
+                VerticalAlignment="Center"
38
+                FontSize="18"
39
+                Foreground="White"
40
+                Text="产品激活" />
105
 
41
 
106
             <Button
42
             <Button
107
-                x:Name="btnEnd"
108
-                Grid.Row="2"
109
-                Height="48"
110
-                Margin="30,0,30,0"
111
-                Click="btnEnd_Click"
112
-                Content="验证"
43
+                x:Name="BtnDown"
44
+                Grid.Row="0"
45
+                Padding="10,0,10,0"
46
+                HorizontalAlignment="Right"
47
+                Click="close_click"
48
+                Content="×"
113
                 Cursor="Hand"
49
                 Cursor="Hand"
114
-                FontSize="18"
115
-                FontWeight="Bold"
116
-                Foreground="White"
117
-                IsDefault="True">
118
-                <Button.Template>
119
-                    <ControlTemplate TargetType="{x:Type Button}">
120
-                        <Border
121
-                            BorderBrush="{TemplateBinding Control.BorderBrush}"
122
-                            BorderThickness="0"
123
-                            CornerRadius="3">
124
-                            <Border.Background>#6098FF</Border.Background>
125
-                            <ContentPresenter
126
-                                HorizontalAlignment="Center"
127
-                                VerticalAlignment="Center"
128
-                                Content="{TemplateBinding ContentControl.Content}" />
129
-                        </Border>
130
-                    </ControlTemplate>
131
-                </Button.Template>
132
-            </Button>
50
+                FontSize="30"
51
+                Foreground="#FFFFFF" />
52
+        </Grid>
53
+        <Grid Grid.Row="1" Margin="30,20,30,0">
54
+            <Grid.ColumnDefinitions>
55
+                <ColumnDefinition Width="Auto" />
56
+                <ColumnDefinition Width="*" />
57
+            </Grid.ColumnDefinitions>
58
+            <TextBlock
59
+                Padding="0,0,0,0"
60
+                VerticalAlignment="Center"
61
+                FontSize="16"
62
+                Text="密匙:" />
63
+            <TextBox
64
+                x:Name="TxbKey"
65
+                Grid.Column="1"
66
+                Height="36"
67
+                VerticalAlignment="Center"
68
+                VerticalContentAlignment="Center"
69
+                FontSize="16"
70
+                Foreground="gray"
71
+                Text="" />
133
         </Grid>
72
         </Grid>
134
 
73
 
135
-    </Views:ZJClippingBorder>
74
+        <Button
75
+            x:Name="BtnEnd"
76
+            Grid.Row="2"
77
+            Width="138"
78
+            Height="36"
79
+            Margin="30,0,30,0"
80
+            Click="btnEnd_Click"
81
+            Content="验证"
82
+            Cursor="Hand"
83
+            FontSize="16"
84
+            FontWeight="Bold"
85
+            Foreground="White"
86
+            IsDefault="True">
87
+            <Button.Template>
88
+                <ControlTemplate TargetType="{x:Type Button}">
89
+                    <Border
90
+                        BorderBrush="{TemplateBinding Control.BorderBrush}"
91
+                        BorderThickness="0"
92
+                        CornerRadius="3">
93
+                        <Border.Background>#6098FF</Border.Background>
94
+                        <ContentPresenter
95
+                            HorizontalAlignment="Center"
96
+                            VerticalAlignment="Center"
97
+                            Content="{TemplateBinding ContentControl.Content}" />
98
+                    </Border>
99
+                </ControlTemplate>
100
+            </Button.Template>
101
+        </Button>
102
+    </Grid>
136
 </Window>
103
 </Window>

+ 34
- 34
XHWK.WKTool/KeyVerification.xaml.cs View File

4
 using System.Text;
4
 using System.Text;
5
 using System.Threading;
5
 using System.Threading;
6
 using System.Windows;
6
 using System.Windows;
7
-
7
+using System.Windows.Input;
8
 using XHWK.WKTool.DAL;
8
 using XHWK.WKTool.DAL;
9
-using XHWK.WKTool.Skin;
10
 
9
 
11
 namespace XHWK.WKTool
10
 namespace XHWK.WKTool
12
 {
11
 {
16
     /*
15
     /*
17
      输入code 调认证服务,成功跳登录 并且调用添加历史接口,失败继续输code
16
      输入code 调认证服务,成功跳登录 并且调用添加历史接口,失败继续输code
18
          */
17
          */
19
-
20
-    public partial class KeyVerification : Window
18
+    public partial class KeyVerification
21
     {
19
     {
22
-        private readonly XHApi registerController = new XHApi();
23
-        private int serverReturnCode = 0;
20
+        private readonly XHApi _registerController = new XHApi();
21
+        private int _serverReturnCode;
24
 
22
 
25
         public KeyVerification()
23
         public KeyVerification()
26
         {
24
         {
28
             Topmost = true;
26
             Topmost = true;
29
             WindowStartupLocation = WindowStartupLocation.CenterScreen;
27
             WindowStartupLocation = WindowStartupLocation.CenterScreen;
30
 
28
 
31
-            Console.WriteLine("初始化KeyVerification");
29
+            Console.WriteLine(@"初始化KeyVerification");
30
+        }
31
+
32
+        private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
33
+        {
34
+            DragMove();
32
         }
35
         }
33
 
36
 
34
         private void btnEnd_Click(object sender, RoutedEventArgs e)
37
         private void btnEnd_Click(object sender, RoutedEventArgs e)
35
         {
38
         {
36
-            if (string.IsNullOrWhiteSpace(txbKey.Text))
39
+            if (string.IsNullOrWhiteSpace(TxbKey.Text))
37
             {
40
             {
38
                 MessageWindow.Show("密匙未输入");
41
                 MessageWindow.Show("密匙未输入");
39
                 return;
42
                 return;
40
             }
43
             }
41
-            projectcode = txbKey.Text.Trim();
42
-            if (projectcode.Length > 8)
44
+
45
+            _projectcode = TxbKey.Text.Trim();
46
+            if (_projectcode.Length > 8)
43
             {
47
             {
44
                 MessageWindow.Show("密匙输入过长");
48
                 MessageWindow.Show("密匙输入过长");
45
-                txbKey.Text = projectcode.Substring(0, 8);
49
+                TxbKey.Text = _projectcode.Substring(0, 8);
46
                 return;
50
                 return;
47
             }
51
             }
48
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddServering, InvokeActivationAddServerCompate);
52
             APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddServering, InvokeActivationAddServerCompate);
49
         }
53
         }
50
 
54
 
51
-        private string projectcode = string.Empty;
55
+        private string _projectcode = string.Empty;
52
 
56
 
53
         /// <summary>
57
         /// <summary>
54
         /// 认证服务-调用
58
         /// 认证服务-调用
59
         {
63
         {
60
             string device = "pcwk";
64
             string device = "pcwk";
61
             string mac = GetMacAddress();
65
             string mac = GetMacAddress();
62
-            serverReturnCode = registerController.ActivationAdd(mac, device, projectcode);
66
+            _serverReturnCode = _registerController.ActivationAdd(mac, device, _projectcode);
63
             return APP.ServerMsg;
67
             return APP.ServerMsg;
64
         }
68
         }
65
 
69
 
70
         /// </returns>
74
         /// </returns>
71
         public void InvokeActivationAddServerCompate(object obj)
75
         public void InvokeActivationAddServerCompate(object obj)
72
         {
76
         {
73
-            if (serverReturnCode == 0)
77
+            if (_serverReturnCode == 0)
74
             {
78
             {
75
                 MessageWindow.Show("产品激活成功");
79
                 MessageWindow.Show("产品激活成功");
76
-                APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddHistoryServering, InvokeActivationAddHistoryServerCompate);
77
-                Dispatcher.Invoke(new Action(() =>
80
+                APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeActivationAddHistoryServering,
81
+                    InvokeActivationAddHistoryServerCompate);
82
+                Dispatcher.Invoke(() =>
78
                 {
83
                 {
79
                     Hide();
84
                     Hide();
80
                     CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
85
                     CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
83
 
88
 
84
                     Thread.Sleep(200);
89
                     Thread.Sleep(200);
85
                     Close();
90
                     Close();
86
-                }));
91
+                });
87
             }
92
             }
88
             else
93
             else
89
             {
94
             {
98
         /// </returns>
103
         /// </returns>
99
         private object InvokeActivationAddHistoryServering()
104
         private object InvokeActivationAddHistoryServering()
100
         {
105
         {
101
-            serverReturnCode = registerController.ActivationAddHistory();
106
+            _serverReturnCode = _registerController.ActivationAddHistory();
102
             return APP.ServerMsg;
107
             return APP.ServerMsg;
103
         }
108
         }
104
 
109
 
113
             {
118
             {
114
                 Directory.CreateDirectory(APP.DataPath);
119
                 Directory.CreateDirectory(APP.DataPath);
115
             }
120
             }
116
-            string ApplicationData = APP.DataPath + "signatureTime.txt";
117
-            string currentTime = DateTime.Now.ToLongDateString().ToString();//当前时间
118
-            System.IO.File.WriteAllText(ApplicationData, currentTime, Encoding.Default);//存放签名验证日期
121
+
122
+            string applicationData = APP.DataPath + "signatureTime.txt";
123
+            string currentTime = DateTime.Now.ToLongDateString(); //当前时间
124
+            File.WriteAllText(applicationData, currentTime, Encoding.Default); //存放签名验证日期
119
         }
125
         }
120
 
126
 
121
         /// <summary>
127
         /// <summary>
131
                 string strMac = string.Empty;
137
                 string strMac = string.Empty;
132
                 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
138
                 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
133
                 ManagementObjectCollection moc = mc.GetInstances();
139
                 ManagementObjectCollection moc = mc.GetInstances();
134
-                foreach (ManagementObject mo in moc)
140
+                foreach (var o in moc)
135
                 {
141
                 {
136
-                    if ((bool)mo["IPEnabled"] == true)
142
+                    var mo = (ManagementObject)o;
143
+                    if ((bool)mo["IPEnabled"])
137
                     {
144
                     {
138
                         strMac = mo["MacAddress"].ToString();
145
                         strMac = mo["MacAddress"].ToString();
139
                     }
146
                     }
140
                 }
147
                 }
141
-                moc = null;
142
-                mc = null;
148
+
143
                 return strMac;
149
                 return strMac;
144
             }
150
             }
145
             catch
151
             catch
150
 
156
 
151
         private void close_click(object sender, RoutedEventArgs e)
157
         private void close_click(object sender, RoutedEventArgs e)
152
         {
158
         {
153
-            closeAction();
159
+            CloseAction();
154
         }
160
         }
155
 
161
 
156
-        private void closeAction()
162
+        private void CloseAction()
157
         {
163
         {
158
             APP.myloading.Show();
164
             APP.myloading.Show();
159
-            new Thread(o =>
160
-            {
161
-                Dispatcher.Invoke(new Action(() =>
162
-                {
163
-                    System.Environment.Exit(0);
164
-                }));
165
-            }).Start();
165
+            new Thread(o => { Dispatcher.Invoke(() => { Environment.Exit(0); }); }).Start();
166
         }
166
         }
167
     }
167
     }
168
 }
168
 }

+ 16
- 16
XHWK.WKTool/MainWindow.xaml View File

9
     Height="700"
9
     Height="700"
10
     AllowsTransparency="False"
10
     AllowsTransparency="False"
11
     BorderBrush="#eee"
11
     BorderBrush="#eee"
12
-    BorderThickness="0"
12
+    BorderThickness="1"
13
     Closed="Window_Closed"
13
     Closed="Window_Closed"
14
     Loaded="Window_Loaded"
14
     Loaded="Window_Loaded"
15
     MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
15
     MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
20
     mc:Ignorable="d">
20
     mc:Ignorable="d">
21
 
21
 
22
     <Window.Resources>
22
     <Window.Resources>
23
-        <Style x:Key="radBase" TargetType="RadioButton">
23
+        <Style x:Key="RadBase" TargetType="RadioButton">
24
             <Setter Property="IsChecked" Value="False" />
24
             <Setter Property="IsChecked" Value="False" />
25
             <Setter Property="Background" Value="Transparent" />
25
             <Setter Property="Background" Value="Transparent" />
26
             <Setter Property="Foreground" Value="#555" />
26
             <Setter Property="Foreground" Value="#555" />
1106
                                     Cursor="Hand"
1106
                                     Cursor="Hand"
1107
                                     FontSize="12"
1107
                                     FontSize="12"
1108
                                     IsChecked="True"
1108
                                     IsChecked="True"
1109
-                                    Style="{StaticResource radBase}" />
1109
+                                    Style="{StaticResource RadBase}" />
1110
                                 <RadioButton
1110
                                 <RadioButton
1111
                                     x:Name="rbnIn"
1111
                                     x:Name="rbnIn"
1112
                                     Margin="5,0,0,0"
1112
                                     Margin="5,0,0,0"
1115
                                     Content=" 中"
1115
                                     Content=" 中"
1116
                                     Cursor="Hand"
1116
                                     Cursor="Hand"
1117
                                     FontSize="12"
1117
                                     FontSize="12"
1118
-                                    Style="{StaticResource radBase}" />
1118
+                                    Style="{StaticResource RadBase}" />
1119
                                 <RadioButton
1119
                                 <RadioButton
1120
                                     x:Name="rbnCrude"
1120
                                     x:Name="rbnCrude"
1121
                                     Margin="5,0,0,0"
1121
                                     Margin="5,0,0,0"
1124
                                     Content=" 粗"
1124
                                     Content=" 粗"
1125
                                     Cursor="Hand"
1125
                                     Cursor="Hand"
1126
                                     FontSize="12"
1126
                                     FontSize="12"
1127
-                                    Style="{StaticResource radBase}" />
1127
+                                    Style="{StaticResource RadBase}" />
1128
                             </StackPanel>
1128
                             </StackPanel>
1129
                             <StackPanel
1129
                             <StackPanel
1130
                                 Grid.Column="2"
1130
                                 Grid.Column="2"
1145
                                     Content=" 开"
1145
                                     Content=" 开"
1146
                                     Cursor="Hand"
1146
                                     Cursor="Hand"
1147
                                     FontSize="12"
1147
                                     FontSize="12"
1148
-                                    Style="{StaticResource radBase}" />
1148
+                                    Style="{StaticResource RadBase}" />
1149
                                 <RadioButton
1149
                                 <RadioButton
1150
                                     x:Name="rbnTurnOff"
1150
                                     x:Name="rbnTurnOff"
1151
                                     Margin="5,0,10,0"
1151
                                     Margin="5,0,10,0"
1155
                                     Cursor="Hand"
1155
                                     Cursor="Hand"
1156
                                     FontSize="12"
1156
                                     FontSize="12"
1157
                                     IsChecked="True"
1157
                                     IsChecked="True"
1158
-                                    Style="{StaticResource radBase}" />
1158
+                                    Style="{StaticResource RadBase}" />
1159
                             </StackPanel>
1159
                             </StackPanel>
1160
                         </Grid>
1160
                         </Grid>
1161
                     </Grid>
1161
                     </Grid>
1332
                                                     FontSize="16"
1332
                                                     FontSize="16"
1333
                                                     Foreground="#333333"
1333
                                                     Foreground="#333333"
1334
                                                     IsChecked="True"
1334
                                                     IsChecked="True"
1335
-                                                    Style="{StaticResource radBase}" />
1335
+                                                    Style="{StaticResource RadBase}" />
1336
                                                 <RadioButton
1336
                                                 <RadioButton
1337
                                                     x:Name="rbnFLV"
1337
                                                     x:Name="rbnFLV"
1338
                                                     Margin="15,0,0,0"
1338
                                                     Margin="15,0,0,0"
1341
                                                     Cursor="Hand"
1341
                                                     Cursor="Hand"
1342
                                                     FontSize="16"
1342
                                                     FontSize="16"
1343
                                                     Foreground="#333333"
1343
                                                     Foreground="#333333"
1344
-                                                    Style="{StaticResource radBase}"
1344
+                                                    Style="{StaticResource RadBase}"
1345
                                                     Visibility="Collapsed" />
1345
                                                     Visibility="Collapsed" />
1346
                                                 <RadioButton
1346
                                                 <RadioButton
1347
                                                     x:Name="rbnAVI"
1347
                                                     x:Name="rbnAVI"
1350
                                                     Cursor="Hand"
1350
                                                     Cursor="Hand"
1351
                                                     FontSize="16"
1351
                                                     FontSize="16"
1352
                                                     Foreground="#333333"
1352
                                                     Foreground="#333333"
1353
-                                                    Style="{StaticResource radBase}"
1353
+                                                    Style="{StaticResource RadBase}"
1354
                                                     Visibility="Collapsed" />
1354
                                                     Visibility="Collapsed" />
1355
                                             </StackPanel>
1355
                                             </StackPanel>
1356
                                         </Grid>
1356
                                         </Grid>
1390
                                                     Foreground="#333333"
1390
                                                     Foreground="#333333"
1391
                                                     GroupName="RbtnCamera"
1391
                                                     GroupName="RbtnCamera"
1392
                                                     IsChecked="True"
1392
                                                     IsChecked="True"
1393
-                                                    Style="{StaticResource radBase}" />
1393
+                                                    Style="{StaticResource RadBase}" />
1394
                                                 <RadioButton
1394
                                                 <RadioButton
1395
                                                     x:Name="rbnRightUnder"
1395
                                                     x:Name="rbnRightUnder"
1396
                                                     Margin="15,0"
1396
                                                     Margin="15,0"
1401
                                                     FontSize="16"
1401
                                                     FontSize="16"
1402
                                                     Foreground="#333333"
1402
                                                     Foreground="#333333"
1403
                                                     GroupName="RbtnCamera"
1403
                                                     GroupName="RbtnCamera"
1404
-                                                    Style="{StaticResource radBase}" />
1404
+                                                    Style="{StaticResource RadBase}" />
1405
                                             </StackPanel>
1405
                                             </StackPanel>
1406
                                         </Grid>
1406
                                         </Grid>
1407
                                         <Grid Grid.Row="2" Grid.Column="3">
1407
                                         <Grid Grid.Row="2" Grid.Column="3">
1420
                                                     FontSize="16"
1420
                                                     FontSize="16"
1421
                                                     Foreground="#333333"
1421
                                                     Foreground="#333333"
1422
                                                     GroupName="RbtnCamera"
1422
                                                     GroupName="RbtnCamera"
1423
-                                                    Style="{StaticResource radBase}" />
1423
+                                                    Style="{StaticResource RadBase}" />
1424
                                                 <RadioButton
1424
                                                 <RadioButton
1425
                                                     x:Name="rbnLeftUnder"
1425
                                                     x:Name="rbnLeftUnder"
1426
                                                     Margin="15,0"
1426
                                                     Margin="15,0"
1431
                                                     FontSize="16"
1431
                                                     FontSize="16"
1432
                                                     Foreground="#333333"
1432
                                                     Foreground="#333333"
1433
                                                     GroupName="RbtnCamera"
1433
                                                     GroupName="RbtnCamera"
1434
-                                                    Style="{StaticResource radBase}" />
1434
+                                                    Style="{StaticResource RadBase}" />
1435
                                             </StackPanel>
1435
                                             </StackPanel>
1436
                                         </Grid>
1436
                                         </Grid>
1437
                                         <Grid Grid.Row="2" Grid.Column="0">
1437
                                         <Grid Grid.Row="2" Grid.Column="0">
1456
                                                     FontSize="16"
1456
                                                     FontSize="16"
1457
                                                     Foreground="#333333"
1457
                                                     Foreground="#333333"
1458
                                                     IsChecked="True"
1458
                                                     IsChecked="True"
1459
-                                                    Style="{StaticResource radBase}" />
1459
+                                                    Style="{StaticResource RadBase}" />
1460
                                                 <RadioButton
1460
                                                 <RadioButton
1461
                                                     x:Name="rbnvisi"
1461
                                                     x:Name="rbnvisi"
1462
                                                     Margin="15,0,0,0"
1462
                                                     Margin="15,0,0,0"
1465
                                                     Cursor="Hand"
1465
                                                     Cursor="Hand"
1466
                                                     FontSize="16"
1466
                                                     FontSize="16"
1467
                                                     Foreground="#333333"
1467
                                                     Foreground="#333333"
1468
-                                                    Style="{StaticResource radBase}" />
1468
+                                                    Style="{StaticResource RadBase}" />
1469
                                             </StackPanel>
1469
                                             </StackPanel>
1470
                                         </Grid>
1470
                                         </Grid>
1471
                                         <Grid Grid.Row="2" Grid.Column="2" />
1471
                                         <Grid Grid.Row="2" Grid.Column="2" />

+ 29
- 26
XHWK.WKTool/MinToolbar.xaml View File

1
-<Window x:Class="XHWK.WKTool.MinToolbar"
2
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
-        xmlns:local="clr-namespace:XHWK.WKTool"
7
-        mc:Ignorable="d"
8
-        Title="MinToolbar" Height="50" Width="20" AllowsTransparency="True" 
9
-        Topmost="True"
1
+<Window
2
+    x:Class="XHWK.WKTool.MinToolbar"
3
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    Title="MinToolbar"
8
+    Width="20"
9
+    Height="50"
10
+    Margin="0"
11
+    AllowsTransparency="True"
12
+    Left="0"
10
     ShowInTaskbar="False"
13
     ShowInTaskbar="False"
11
-    WindowStyle="None" Margin="0" Left="0" Top="0">
14
+    Top="0"
15
+    Topmost="True"
16
+    WindowStyle="None"
17
+    mc:Ignorable="d">
12
     <Window.Background>
18
     <Window.Background>
13
         <SolidColorBrush Opacity="0" Color="#00000000" />
19
         <SolidColorBrush Opacity="0" Color="#00000000" />
14
     </Window.Background>
20
     </Window.Background>
15
     <Viewbox>
21
     <Viewbox>
16
         <Grid>
22
         <Grid>
17
             <Border Background="White" CornerRadius="3">
23
             <Border Background="White" CornerRadius="3">
18
-                <!--<Grid x:Name="buttonMin" Height="25" Width="3"
19
-                        Margin="0.5"  
20
-                        MouseEnter="buttonMin_MouseEnter">
21
-                    <Button.Template>
22
-                        <ControlTemplate TargetType="{x:Type Button}">
23
-                           
24
-                                <ContentPresenter
25
-                                    HorizontalAlignment="Center"
26
-                                    VerticalAlignment="Center"
27
-                                    Content="{TemplateBinding ContentControl.Content}" />
28
-                        </ControlTemplate>
29
-                    </Button.Template>
30
-                </Grid>-->
31
-                <Grid x:Name="buttonMin" Height="25" Width="3" Margin="0.5" MouseEnter="buttonMin_MouseEnter">
32
-                    <Border x:Name="BorderBlack" BorderBrush="{TemplateBinding Control.BorderBrush}" BorderThickness="0" CornerRadius="3" Background="#2d8cf0">
33
-                    </Border>
24
+
25
+                <Grid
26
+                    x:Name="ButtonMin"
27
+                    Width="3"
28
+                    Height="25"
29
+                    Margin="0.5"
30
+                    MouseEnter="buttonMin_MouseEnter">
31
+                    <Border
32
+                        x:Name="BorderBlack"
33
+                        Background="#2d8cf0"
34
+                        BorderBrush="{TemplateBinding Control.BorderBrush}"
35
+                        BorderThickness="0"
36
+                        CornerRadius="3" />
34
                 </Grid>
37
                 </Grid>
35
             </Border>
38
             </Border>
36
 
39
 

+ 122
- 538
XHWK.WKTool/PracticeWindow.xaml.cs View File

1
 using Common.system;
1
 using Common.system;
2
-
3
 using System;
2
 using System;
4
-using System.Collections.Generic;
5
 using System.Threading;
3
 using System.Threading;
6
 using System.Windows;
4
 using System.Windows;
7
 using System.Windows.Controls;
5
 using System.Windows.Controls;
8
 using System.Windows.Ink;
6
 using System.Windows.Ink;
9
 using System.Windows.Input;
7
 using System.Windows.Input;
10
 using System.Windows.Media;
8
 using System.Windows.Media;
11
-
12
 using XHWK.Model;
9
 using XHWK.Model;
13
 
10
 
14
 namespace XHWK.WKTool
11
 namespace XHWK.WKTool
16
     /// <summary>
13
     /// <summary>
17
     /// 录屏画板
14
     /// 录屏画板
18
     /// </summary>
15
     /// </summary>
19
-    public partial class PracticeWindow : Window
16
+    public partial class PracticeWindow
20
     {
17
     {
21
         //声明一个 DrawingAttributes 类型的变量
18
         //声明一个 DrawingAttributes 类型的变量
22
-        private DrawingAttributes drawingAttributes;
19
+        private DrawingAttributes _drawingAttributes;
23
 
20
 
24
-        private DrawingAttributes drawing;
25
-        private ViewModel viewModel;
21
+        private DrawingAttributes _drawing;
22
+        private ViewModel _viewModel;
26
 
23
 
27
         /// <summary>
24
         /// <summary>
28
         /// 0 画笔 1 矩形 2 圆形
25
         /// 0 画笔 1 矩形 2 圆形
29
         /// </summary>
26
         /// </summary>
30
-        private int flg = 0;
27
+#pragma warning disable CS0414
28
+        private int _flg;
29
+#pragma warning restore CS0414
31
 
30
 
32
         /// <summary>
31
         /// <summary>
33
         /// 当前画笔颜色
32
         /// 当前画笔颜色
34
         /// </summary>
33
         /// </summary>
35
-        private Color Colour = Colors.Red;
34
+        private Color _colour = Colors.Red;
36
 
35
 
37
         /// <summary>
36
         /// <summary>
38
         /// 当前画笔宽
37
         /// 当前画笔宽
39
         /// </summary>
38
         /// </summary>
40
-        private int Wit = 2;
39
+        private int _wit = 2;
41
 
40
 
42
         /// <summary>
41
         /// <summary>
43
         /// 当前画笔高
42
         /// 当前画笔高
44
         /// </summary>
43
         /// </summary>
45
-        private int Hei = 2;
44
+        private int _hei = 2;
46
 
45
 
47
         public PracticeWindow()
46
         public PracticeWindow()
48
         {
47
         {
49
             InitializeComponent();
48
             InitializeComponent();
50
 
49
 
51
-            InitTQLPPen();
50
+            InitTqlpPen();
52
         }
51
         }
53
 
52
 
54
-        public void Initialize(string _imgPath = null)
53
+        public void Initialize(string imgPath = null)
55
         {
54
         {
56
-            flg = 0;
55
+            _flg = 0;
57
             blackboard_canvas.Strokes.Clear();
56
             blackboard_canvas.Strokes.Clear();
58
             blackboard_canvas.UseCustomCursor = true;
57
             blackboard_canvas.UseCustomCursor = true;
59
             //blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
58
             //blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
64
             //}
63
             //}
65
 
64
 
66
             //创建 DrawingAttributes 类的一个实例
65
             //创建 DrawingAttributes 类的一个实例
67
-            drawingAttributes = new DrawingAttributes();
66
+            _drawingAttributes = new DrawingAttributes();
68
 
67
 
69
             //drawingAttributes.StylusTip = StylusTip.Rectangle;
68
             //drawingAttributes.StylusTip = StylusTip.Rectangle;
70
             //drawingAttributes.IsHighlighter = false;
69
             //drawingAttributes.IsHighlighter = false;
72
 
71
 
73
             ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
72
             ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
74
             ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
73
             ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
75
-            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
74
+            blackboard_canvas.DefaultDrawingAttributes = _drawingAttributes;
76
             Pen();
75
             Pen();
77
             //blackboard_canvas.Cursor = Cursors.Pen;
76
             //blackboard_canvas.Cursor = Cursors.Pen;
78
 
77
 
80
 
79
 
81
             //blackboard_canvas.Cursor = cus;
80
             //blackboard_canvas.Cursor = cus;
82
 
81
 
83
-            viewModel = new ViewModel
82
+            _viewModel = new ViewModel
84
             {
83
             {
85
                 InkStrokes = new StrokeCollection(),
84
                 InkStrokes = new StrokeCollection(),
86
             };
85
             };
87
 
86
 
88
-            DataContext = viewModel;
87
+            DataContext = _viewModel;
89
             //APP.W_ScreenRecordingToolbarWindow.Owner = this;
88
             //APP.W_ScreenRecordingToolbarWindow.Owner = this;
90
             //APP.W_ScreenRecordingToolbarWindow.Topmost = true;
89
             //APP.W_ScreenRecordingToolbarWindow.Topmost = true;
91
         }
90
         }
93
         /// <summary>
92
         /// <summary>
94
         /// 画笔颜色事件 白色
93
         /// 画笔颜色事件 白色
95
         /// </summary>
94
         /// </summary>
96
-        /// <param name="sender"></param>
97
-        /// <param name="e"></param>
98
         public void White()
95
         public void White()
99
         {
96
         {
100
             //flg = 0;
97
             //flg = 0;
101
-            drawingAttributes.Color = Colors.White;
102
-            Colour = Colors.White;
98
+            _drawingAttributes.Color = Colors.White;
99
+            _colour = Colors.White;
103
         }
100
         }
104
 
101
 
105
         /// <summary>
102
         /// <summary>
106
         /// 画笔颜色事件 红色
103
         /// 画笔颜色事件 红色
107
         /// </summary>
104
         /// </summary>
108
-        /// <param name="sender"></param>
109
-        /// <param name="e"></param>
110
         public void Red()
105
         public void Red()
111
         {
106
         {
112
-            drawingAttributes.Color = Colors.Red;
113
-            Colour = Colors.Red;
107
+            _drawingAttributes.Color = Colors.Red;
108
+            _colour = Colors.Red;
114
         }
109
         }
115
 
110
 
116
         /// <summary>
111
         /// <summary>
117
         /// 画笔颜色事件 黑色
112
         /// 画笔颜色事件 黑色
118
         /// </summary>
113
         /// </summary>
119
-        /// <param name="sender"></param>
120
-        /// <param name="e"></param>
121
         public void Gray()
114
         public void Gray()
122
         {
115
         {
123
             //flg = 0;
116
             //flg = 0;
124
-            drawingAttributes.Color = Colors.Black;
125
-            Colour = Colors.Black;
117
+            _drawingAttributes.Color = Colors.Black;
118
+            _colour = Colors.Black;
126
         }
119
         }
127
 
120
 
128
         /// <summary>
121
         /// <summary>
129
         /// 画笔颜色事件 青色
122
         /// 画笔颜色事件 青色
130
         /// </summary>
123
         /// </summary>
131
-        /// <param name="sender"></param>
132
-        /// <param name="e"></param>
133
         public void CyanBlue()
124
         public void CyanBlue()
134
         {
125
         {
135
             //flg = 0;
126
             //flg = 0;
136
-            drawingAttributes.Color = Colors.LimeGreen;
137
-            Colour = Colors.LimeGreen;
127
+            _drawingAttributes.Color = Colors.LimeGreen;
128
+            _colour = Colors.LimeGreen;
138
         }
129
         }
139
 
130
 
140
         /// <summary>
131
         /// <summary>
141
         /// 画笔颜色事件 黄色
132
         /// 画笔颜色事件 黄色
142
         /// </summary>
133
         /// </summary>
143
-        /// <param name="sender"></param>
144
-        /// <param name="e"></param>
145
         public void Yellow()
134
         public void Yellow()
146
         {
135
         {
147
             //flg = 0;
136
             //flg = 0;
148
-            drawingAttributes.Color = Colors.Gold;
149
-            Colour = Colors.Gold;
137
+            _drawingAttributes.Color = Colors.Gold;
138
+            _colour = Colors.Gold;
150
         }
139
         }
151
 
140
 
152
         /// <summary>
141
         /// <summary>
153
         /// 画笔颜色事件 蓝色
142
         /// 画笔颜色事件 蓝色
154
         /// </summary>
143
         /// </summary>
155
-        /// <param name="sender"></param>
156
-        /// <param name="e"></param>
157
         public void Blue()
144
         public void Blue()
158
         {
145
         {
159
             //flg = 0;
146
             //flg = 0;
160
-            drawingAttributes.Color = Colors.DeepSkyBlue;
161
-            Colour = Colors.DeepSkyBlue;
147
+            _drawingAttributes.Color = Colors.DeepSkyBlue;
148
+            _colour = Colors.DeepSkyBlue;
162
         }
149
         }
163
 
150
 
164
         /// <summary>
151
         /// <summary>
165
         /// 画笔粗细事件 细
152
         /// 画笔粗细事件 细
166
         /// </summary>
153
         /// </summary>
167
-        /// <param name="sender"></param>
168
-        /// <param name="e"></param>
169
         public void Fine()
154
         public void Fine()
170
         {
155
         {
171
             //flg = 0;
156
             //flg = 0;
172
-            drawingAttributes.Width = 1;
173
-            drawingAttributes.Height = 1;
174
-            Wit = 1;
175
-            Hei = 1;
157
+            _drawingAttributes.Width = 1;
158
+            _drawingAttributes.Height = 1;
159
+            _wit = 1;
160
+            _hei = 1;
176
         }
161
         }
177
 
162
 
178
         /// <summary>
163
         /// <summary>
179
         /// 画笔粗细事件 中
164
         /// 画笔粗细事件 中
180
         /// </summary>
165
         /// </summary>
181
-        /// <param name="sender"></param>
182
-        /// <param name="e"></param>
183
         public void In()
166
         public void In()
184
         {
167
         {
185
             //flg = 0;
168
             //flg = 0;
186
-            drawingAttributes.Width = 3;
187
-            drawingAttributes.Height = 3;
188
-            Wit = 3;
189
-            Hei = 3;
169
+            _drawingAttributes.Width = 3;
170
+            _drawingAttributes.Height = 3;
171
+            _wit = 3;
172
+            _hei = 3;
190
         }
173
         }
191
 
174
 
192
         /// <summary>
175
         /// <summary>
193
         /// 画笔粗细事件 粗
176
         /// 画笔粗细事件 粗
194
         /// </summary>
177
         /// </summary>
195
-        /// <param name="sender"></param>
196
-        /// <param name="e"></param>
197
         public void Crude()
178
         public void Crude()
198
         {
179
         {
199
             //flg = 0;
180
             //flg = 0;
200
-            drawingAttributes.Width = 5;
201
-            drawingAttributes.Height = 5;
202
-            Wit = 5;
203
-            Hei = 5;
181
+            _drawingAttributes.Width = 5;
182
+            _drawingAttributes.Height = 5;
183
+            _wit = 5;
184
+            _hei = 5;
204
         }
185
         }
205
 
186
 
206
         /// <summary>
187
         /// <summary>
208
         /// </summary>
189
         /// </summary>
209
         public void Eraser()
190
         public void Eraser()
210
         {
191
         {
211
-            flg = 0;
192
+            _flg = 0;
212
             //this.type = ZPenType.Erase;
193
             //this.type = ZPenType.Erase;
213
             blackboard_canvas.UseCustomCursor = false;
194
             blackboard_canvas.UseCustomCursor = false;
214
             blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
195
             blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
220
         /// </summary>
201
         /// </summary>
221
         public void Pen()
202
         public void Pen()
222
         {
203
         {
223
-            flg = 0;
204
+            _flg = 0;
224
             blackboard_canvas.EditingMode = InkCanvasEditingMode.Ink;
205
             blackboard_canvas.EditingMode = InkCanvasEditingMode.Ink;
225
             blackboard_canvas.UseCustomCursor = true;
206
             blackboard_canvas.UseCustomCursor = true;
226
-            drawingAttributes.FitToCurve = true;
227
-            drawingAttributes.IgnorePressure = false;
207
+            _drawingAttributes.FitToCurve = true;
208
+            _drawingAttributes.IgnorePressure = false;
228
 
209
 
229
             blackboard_canvas.Cursor = Cursors.Pen;
210
             blackboard_canvas.Cursor = Cursors.Pen;
230
         }
211
         }
234
         /// </summary>
215
         /// </summary>
235
         public void Round()
216
         public void Round()
236
         {
217
         {
237
-            flg = 2;
238
-            drawingAttributes = new DrawingAttributes
218
+            _flg = 2;
219
+            _drawingAttributes = new DrawingAttributes
239
             {
220
             {
240
-                Color = Colour,
241
-                Width = Wit,
242
-                Height = Hei,
221
+                Color = _colour,
222
+                Width = _wit,
223
+                Height = _hei,
243
                 StylusTip = StylusTip.Rectangle,
224
                 StylusTip = StylusTip.Rectangle,
244
                 //FitToCurve = true,
225
                 //FitToCurve = true,
245
                 IsHighlighter = false,
226
                 IsHighlighter = false,
246
                 IgnorePressure = true,
227
                 IgnorePressure = true,
247
             };
228
             };
248
-            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
229
+            blackboard_canvas.DefaultDrawingAttributes = _drawingAttributes;
249
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
230
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
250
             blackboard_canvas.Cursor = Cursors.Cross;
231
             blackboard_canvas.Cursor = Cursors.Cross;
251
         }
232
         }
255
         /// </summary>
236
         /// </summary>
256
         public void Rectangle()
237
         public void Rectangle()
257
         {
238
         {
258
-            flg = 1;
259
-            drawingAttributes = new DrawingAttributes
239
+            _flg = 1;
240
+            _drawingAttributes = new DrawingAttributes
260
             {
241
             {
261
-                Color = Colour,
262
-                Width = Wit,
263
-                Height = Hei,
242
+                Color = _colour,
243
+                Width = _wit,
244
+                Height = _hei,
264
                 StylusTip = StylusTip.Rectangle,
245
                 StylusTip = StylusTip.Rectangle,
265
                 //FitToCurve = true,
246
                 //FitToCurve = true,
266
                 IsHighlighter = false,
247
                 IsHighlighter = false,
267
                 IgnorePressure = true,
248
                 IgnorePressure = true,
268
             };
249
             };
269
-            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
250
+            blackboard_canvas.DefaultDrawingAttributes = _drawingAttributes;
270
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
251
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
271
             blackboard_canvas.Cursor = Cursors.Cross;
252
             blackboard_canvas.Cursor = Cursors.Cross;
272
         }
253
         }
273
 
254
 
274
-        private System.Windows.Point iniP;
275
-
276
-        private void blackboard_canvas_MouseDown(object sender, MouseButtonEventArgs e)
277
-        {
278
-            if (flg != 0)
279
-            {
280
-                if (e.LeftButton == MouseButtonState.Pressed)
281
-                {
282
-                    iniP = e.GetPosition(blackboard_canvas);
283
-                }
284
-            }
285
-        }
286
-
287
-        private Stroke StrokeRound;
288
-        private Stroke StrokeRectangle;
289
-
290
-        private void blackboard_canvas_MouseMove(object sender, MouseEventArgs e)
291
-        {
292
-            if (flg != 0)
293
-            {
294
-                if (e.LeftButton == MouseButtonState.Pressed)
295
-                {
296
-                    // Draw square
297
-                    if (flg == 1)
298
-                    {
299
-                        System.Windows.Point endP = e.GetPosition(blackboard_canvas);
300
-                        List<System.Windows.Point> pointList = new List<System.Windows.Point>
301
-                    {
302
-                        new System.Windows.Point(iniP.X, iniP.Y),
303
-                        new System.Windows.Point(iniP.X, endP.Y),
304
-                        new System.Windows.Point(endP.X, endP.Y),
305
-                        new System.Windows.Point(endP.X, iniP.Y),
306
-                        new System.Windows.Point(iniP.X, iniP.Y),
307
-                    };
308
-                        //Stroke stroke1 = new Stroke(drawingAttributesRound);
309
-                        StylusPointCollection point = new StylusPointCollection(pointList);
310
-                        Stroke stroke = new Stroke(point)
311
-                        {
312
-                            DrawingAttributes = blackboard_canvas.DefaultDrawingAttributes.Clone()
313
-                        };
314
-                        if (StrokeRectangle != null)
315
-                        {
316
-                            viewModel.InkStrokes.Remove(StrokeRectangle);
317
-                        }
318
-                        StrokeRectangle = stroke;
319
-
320
-                        viewModel.InkStrokes.Add(stroke);
321
-                    }
322
-                    // Draw Eclipse
323
-                    else if (flg == 2)
324
-                    {
325
-                        System.Windows.Point endP = e.GetPosition(blackboard_canvas);
326
-                        List<System.Windows.Point> pointList = GenerateEclipseGeometry(iniP, endP);
327
-                        StylusPointCollection point = new StylusPointCollection(pointList);
328
-                        Stroke stroke = new Stroke(point)
329
-                        {
330
-                            DrawingAttributes = blackboard_canvas.DefaultDrawingAttributes.Clone()
331
-                        };
332
-                        //viewModel.InkStrokes.Clear();
333
-                        if (StrokeRound != null)
334
-                        {
335
-                            viewModel.InkStrokes.Remove(StrokeRound);
336
-                        }
337
-                        StrokeRound = stroke;
338
-                        viewModel.InkStrokes.Add(stroke);
339
-                    }
340
-                }
341
-            }
342
-        }
343
-
344
-        private List<System.Windows.Point> GenerateEclipseGeometry(System.Windows.Point st, System.Windows.Point ed)
345
-        {
346
-            double a = 0.5 * (ed.X - st.X);
347
-            double b = 0.5 * (ed.Y - st.Y);
348
-            List<System.Windows.Point> pointList = new List<System.Windows.Point>();
349
-            for (double r = 0; r <= 2 * Math.PI; r = r + 0.01)
350
-            {
351
-                pointList.Add(new System.Windows.Point(0.5 * (st.X + ed.X) + a * Math.Cos(r), 0.5 * (st.Y + ed.Y) + b * Math.Sin(r)));
352
-            }
353
-            return pointList;
354
-        }
355
-
356
-        /// <summary>
357
-        /// 鼠标松开时
358
-        /// </summary>
359
-        /// <param name="sender"></param>
360
-        /// <param name="e"></param>
361
-        private void blackboard_canvas_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
362
-        {
363
-            StrokeRound = null;
364
-            StrokeRectangle = null;
365
-        }
366
-
367
-        /// <summary>
368
-        /// 鼠标右键
369
-        /// </summary>
370
-        /// <param name="sender"></param>
371
-        /// <param name="e"></param>
372
-        private void Window_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
373
-        {
374
-            if (APP.W_ScreenRecordingToolbarWindow.flg == 10)
375
-            {
376
-                APP.W_ScreenRecordingToolbarWindow.flg = 0;
377
-            }
378
-            else
379
-            {
380
-                APP.W_ScreenRecordingToolbarWindow.flg = 1;
381
-            }
382
-            Hide();
383
-        }
384
-
385
         /// <summary>
255
         /// <summary>
386
         /// 鼠标中键点击
256
         /// 鼠标中键点击
387
         /// </summary>
257
         /// </summary>
401
             }
271
             }
402
         }
272
         }
403
 
273
 
404
-        private void blackboard_canvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
405
-        {
406
-            if (APP.W_ScreenRecordingToolbarWindow.flg == 10)
407
-            {
408
-                APP.W_ScreenRecordingToolbarWindow.flg = 0;
409
-            }
410
-            else
411
-            {
412
-                APP.W_ScreenRecordingToolbarWindow.flg = 1;
413
-            }
414
-            Hide();
415
-        }
416
-
417
         private void blackboard_canvas_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
274
         private void blackboard_canvas_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
418
         {
275
         {
419
             if (APP.W_ScreenRecordingToolbarWindow.flg == 10)
276
             if (APP.W_ScreenRecordingToolbarWindow.flg == 10)
424
             {
281
             {
425
                 APP.W_ScreenRecordingToolbarWindow.flg = 1;
282
                 APP.W_ScreenRecordingToolbarWindow.flg = 1;
426
             }
283
             }
284
+
427
             ReturnPractice();
285
             ReturnPractice();
428
             //模拟切到ppt
286
             //模拟切到ppt
429
             SwitchPages();
287
             SwitchPages();
436
         public void ReturnPractice()
294
         public void ReturnPractice()
437
         {
295
         {
438
             blackboard_canvas.Strokes.Clear();
296
             blackboard_canvas.Strokes.Clear();
439
-            new Thread(new ThreadStart(new Action(() =>
297
+            new Thread(() =>
440
             {
298
             {
441
-                Dispatcher.Invoke(() =>
442
-                {
443
-                    APP.W_ScreenRecordingToolbarWindow.ModifyState();
444
-                });
445
-                flg = 0;
299
+                Dispatcher.Invoke(() => { APP.W_ScreenRecordingToolbarWindow.ModifyState(); });
300
+                _flg = 0;
446
                 Thread.Sleep(500);
301
                 Thread.Sleep(500);
447
                 Dispatcher.Invoke(() =>
302
                 Dispatcher.Invoke(() =>
448
                 {
303
                 {
449
                     Owner = null;
304
                     Owner = null;
450
                     APP.W_PracticeWindow.Hide();
305
                     APP.W_PracticeWindow.Hide();
451
                 });
306
                 });
452
-            }))).Start();
307
+            }).Start();
453
         }
308
         }
454
 
309
 
455
         #region 点阵笔相关
310
         #region 点阵笔相关
458
 
313
 
459
         // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
314
         // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
460
 
315
 
461
-        /// <summary>
462
-        /// A4点阵纸点阵宽度
463
-        /// </summary>
464
-        private const int A4_WIDTH = 5600;
465
-
466
-        /// <summary>
467
-        /// A4点阵纸点阵高度
468
-        /// </summary>
469
-        private const int A4_HEIGHT = 7920;
470
-
471
         ///// <summary>
316
         ///// <summary>
472
         ///// 画板
317
         ///// 画板
473
         ///// </summary>
318
         ///// </summary>
474
         //private Graphics graphics;
319
         //private Graphics graphics;
475
 
320
 
476
-        /// <summary>
477
-        /// 笔画坐标数组
478
-        /// </summary>
479
-        private List<System.Drawing.Point> stroke;
480
-
481
-        /// <summary>
482
-        /// 笔序列号
483
-        /// </summary>
484
-        private string penSerial;
485
-
486
-        /// <summary>
487
-        /// 笔是否在点
488
-        /// </summary>
489
-        private bool isPenDown;
490
-
491
         #endregion 值初始化
321
         #endregion 值初始化
492
 
322
 
493
-        /// <summary>
494
-        /// 落笔
495
-        /// </summary>
496
-        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
497
-        /// <param name="penSerial">点阵笔序列号</param>
498
-        /// <param name="penType">点阵笔型号编号</param>
499
-        private void OnPenDown(ulong time, string penSerial, int penType)
500
-        {
501
-            if (CheckAccess())
502
-            {
503
-                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
504
-                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
505
-            }
506
-            else
507
-            {
508
-                isPenDown = true;
509
-                APP.W_ScreenRecordingToolbarWindow.PenPractice();
510
-            }
511
-        }
512
-
513
-        /// <summary>
514
-        /// 抬笔
515
-        /// </summary>
516
-        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
517
-        /// <param name="penSerial">点阵笔序列号</param>
518
-        /// <param name="penType">点阵笔型号编号</param>
519
-        private void OnPenUp(ulong time, string penSerial, int penType)
520
-        {
521
-            if (CheckAccess())
522
-            {
523
-                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
524
-                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
525
-            }
526
-            else
527
-            {
528
-                isPenDown = false;
529
-                APP.PenSerial = penSerial;
530
-
531
-                stroke.Clear();
532
-            }
533
-
534
-            if (strokes != null && strokes.StylusPoints.Count > 1)
535
-            {
536
-                isFirst = true;
537
-            }
538
-            stylusPoints = new StylusPointCollection();
539
-            stylusPoint = new StylusPoint();
540
-            strokes = null;
541
-        }
542
-
543
-        /// <summary>
544
-        /// 笔断开
545
-        /// </summary>
546
-        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
547
-        /// <param name="penSerial">点阵笔序列号</param>
548
-        /// <param name="penType">点阵笔型号编号</param>
549
-        private void OnPenDisconnect(ulong time, string penSerial, int penType)
550
-        {
551
-            if (CheckAccess())
552
-            {
553
-                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
554
-                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
555
-            }
556
-            else
557
-            {
558
-                APP.PenSerial = penSerial;
559
-                APP.PenStatus = false;
560
-                //UpdateDevStatus();
561
-                ////Dispatcher.Invoke(new Action(() =>
562
-                ////{
563
-                ////    txbNotConnected.Text = "未连接";
564
-                ////    txbNotConnecteds.Text = "未连接";
565
-                ////}));
566
-            }
567
-        }
568
-
569
-        /// <summary>
570
-        /// 笔连接
571
-        /// </summary>
572
-        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
573
-        /// <param name="penSerial">点阵笔序列号</param>
574
-        /// <param name="penType">点阵笔型号编号</param>
575
-        private void OnPenConnect(ulong time, string penSerial, int penType)
576
-        {
577
-            if (CheckAccess())
578
-            {
579
-                Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
580
-                Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
581
-            }
582
-            else
583
-            {
584
-                APP.PenSerial = penSerial;
585
-                APP.PenStatus = true;
586
-                this.penSerial = penSerial;
587
-            }
588
-        }
589
-
590
-        /// <summary>
591
-        /// 电池电量
592
-        /// </summary>
593
-        /// <param name="time"></param>
594
-        /// <param name="penSerial"></param>
595
-        /// <param name="penType"></param>
596
-        /// <param name="capacity"></param>
597
-        private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
598
-        {
599
-            if (CheckAccess())
600
-            {
601
-                Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
602
-                Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
603
-            }
604
-            else
605
-            {
606
-                //System.Windows.MessageWindow.Show("电池电量:" + capacity.ToString());
607
-            }
608
-        }
609
-
610
-        /// <summary>
611
-        /// 已用存储
612
-        /// </summary>
613
-        /// <param name="time"></param>
614
-        /// <param name="penSerial"></param>
615
-        /// <param name="penType"></param>
616
-        /// <param name="fillLevel"></param>
617
-        private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
618
-        {
619
-            if (CheckAccess())
620
-            {
621
-                Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
622
-                Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
623
-            }
624
-            else
625
-            {
626
-                //System.Windows.MessageWindow.Show("存储:" + fillLevel.ToString());
627
-            }
628
-        }
629
-
630
-        /// <summary>
631
-        /// 笔书写,收到坐标
632
-        /// </summary>
633
-        /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
634
-        /// <param name="penSerial">点阵笔序列号</param>
635
-        /// <param name="penType">点阵笔型号编号</param>
636
-        /// <param name="pageSerial">点阵地址</param>
637
-        /// <param name="cx">x坐标</param>
638
-        /// <param name="cy">y坐标</param>
639
-        /// <param name="force">压力值</param>
640
-        private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
641
-        {
642
-            if (this.Visibility == Visibility.Visible)
643
-            {
644
-                if (CheckAccess())
645
-                {
646
-                    Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
647
-                    Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
648
-                }
649
-                else
650
-                {
651
-                    //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
652
-                    if (!isPenDown)
653
-                    {
654
-                        return;
655
-                    }
656
-                    stroke.Add(new System.Drawing.Point(cx, cy));
657
-
658
-                    double PropW = blackboard_canvas.ActualWidth / A4_HEIGHT;
659
-                    double PropH = blackboard_canvas.ActualHeight / A4_WIDTH;
660
-                    //点
661
-                    double testX = cy * PropW;
662
-                    double testY = (A4_WIDTH - cx) * PropH;
663
-                    //pageSerial //点阵IP地址  与打印的页面关联
664
-                    if (true)
665
-                    {
666
-                        Dispatcher.Invoke(new Action(() =>
667
-                        {
668
-                            float Pressure = force / 100f;
669
-                            ////添加笔画
670
-                            //myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1, Pressure);
671
-
672
-                            if (isFirst)
673
-                            {
674
-                                stylusPoint.X = testX;
675
-                                stylusPoint.Y = testY;
676
-                                //_color.A = (byte)(Pressure * 255f);
677
-                                //stylusPoint.PressureFactor = Pressure;
678
-
679
-                                //for(int i=0;i<100;i++)
680
-                                //{
681
-                                //    stylusPoint.X--;
682
-                                //    stylusPoint.Y--;
683
-                                //    stylusPoints.Add(stylusPoint);
684
-                                //}
685
-                                stylusPoints.Add(stylusPoint);
686
-                                if (stylusPoints.Count > 1)
687
-                                {
688
-                                    drawing = new DrawingAttributes
689
-                                    {
690
-                                        Color = Colour,
691
-                                        Width = Wit * 4.5,
692
-                                        Height = Wit * 4.5,
693
-                                        FitToCurve = true,
694
-                                        IgnorePressure = false
695
-                                    };
696
-
697
-                                    //blackboard_canvas.Strokes = new StrokeCollection();
698
-                                    strokes = new Stroke(stylusPoints);
699
-
700
-                                    strokes.DrawingAttributes = drawing;
701
-                                    //blackboard_canvas.Strokes.Add(strokes);
702
-
703
-                                    blackboard_canvas.Strokes.Add(strokes);
704
-                                    isFirst = false;
705
-                                }
706
-                            }
707
-                            else
708
-                            {
709
-                                if (blackboard_canvas.Strokes.Count > 0)
710
-                                {
711
-                                    stylusPoint.X = testX;
712
-                                    stylusPoint.Y = testY;
713
-                                    stylusPoints.Add(stylusPoint);
714
-                                    strokes = new Stroke(stylusPoints);
715
-                                    drawing = new DrawingAttributes
716
-                                    {
717
-                                        Color = Colour,
718
-                                        Width = Wit * 4.5,
719
-                                        Height = Wit * 4.5,
720
-                                        FitToCurve = true,
721
-                                        IgnorePressure = false
722
-                                    };
723
-                                    strokes.DrawingAttributes = drawing;
724
-
725
-                                    //viewModel.InkStrokes.Add(strokes);
726
-                                    blackboard_canvas.Strokes[blackboard_canvas.Strokes.Count - 1] = strokes;
727
-                                }
728
-                            }
729
-
730
-                            //设置鼠标位置
731
-                            if (testX > 0 && testY > 0)
732
-                            {
733
-                                //System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
734
-                                SetCursorPos((int)((float)testX * (PrimaryScreen.DpiX / 96f)), (int)((float)testY * (PrimaryScreen.DpiY / 96f)));
735
-                            }
736
-                        }));
737
-                    }
738
-                }
739
-            }
740
-        }
741
-
742
-        private bool isFirst = true;
743
-        private StylusPointCollection stylusPoints = new StylusPointCollection();
744
-        private StylusPoint stylusPoint = new StylusPoint();
745
-        private Stroke strokes;
323
+        private bool _isFirst = true;
324
+        private StylusPointCollection _stylusPoints = new StylusPointCollection();
325
+        private StylusPoint _stylusPoint;
326
+        private Stroke _strokes;
746
 
327
 
747
         /// <summary>
328
         /// <summary>
748
         /// 引用user32.dll动态链接库(windows api),
329
         /// 引用user32.dll动态链接库(windows api),
759
         /// <summary>
340
         /// <summary>
760
         /// 是否在书写
341
         /// 是否在书写
761
         /// </summary>
342
         /// </summary>
762
-        private bool isTQLPenDown = false;
343
+        private bool _isTqlPenDown;
763
 
344
 
764
         /// <summary>
345
         /// <summary>
765
         /// TQL点阵笔宽高
346
         /// TQL点阵笔宽高
766
         /// </summary>
347
         /// </summary>
767
-        //static float TQLA4_WIDTH = (float)1075 / (float)150 * (float)25.4 / (float)1.524; //OID4
768
-        //static float TQLA4_HEIGHT = (float)1512 / (float)150 * (float)25.4 / (float)1.524;
769
-        private static float TQLA4_WIDTH = (float)2480 / (float)300 * (float)25.4 / (float)1.524;
348
+//static float TQLA4_WIDTH = (float)1075 / (float)150 * (float)25.4 / (float)1.524; //OID4
349
+//static float TQLA4_HEIGHT = (float)1512 / (float)150 * (float)25.4 / (float)1.524;
350
+        private const float Tqla4Width = 2480 / (float)300 * (float)25.4 / (float)1.524;
770
 
351
 
771
-        private static float TQLA4_HEIGHT = (float)3509 / (float)300 * (float)25.4 / (float)1.524;
352
+        private const float Tqla4Height = 3509 / (float)300 * (float)25.4 / (float)1.524;
772
 
353
 
773
         /// <summary>
354
         /// <summary>
774
         /// 初始化
355
         /// 初始化
775
         /// </summary>
356
         /// </summary>
776
-        public void InitTQLPPen()
357
+        public void InitTqlpPen()
777
         {
358
         {
778
             if (APP.TQLPenevents == null)
359
             if (APP.TQLPenevents == null)
779
             {
360
             {
788
         /// <summary>
369
         /// <summary>
789
         /// 笔落下
370
         /// 笔落下
790
         /// </summary>
371
         /// </summary>
791
-        public void TQLDown()
372
+        public void TqlDown()
792
         {
373
         {
793
-            isTQLPenDown = true;
374
+            _isTqlPenDown = true;
794
             APP.W_ScreenRecordingToolbarWindow.PenPractice();
375
             APP.W_ScreenRecordingToolbarWindow.PenPractice();
795
-            if (strokes != null && strokes.StylusPoints.Count > 1)
376
+            if (_strokes != null && _strokes.StylusPoints.Count > 1)
796
             {
377
             {
797
-                isFirst = true;
378
+                _isFirst = true;
798
             }
379
             }
799
-            stylusPoints = new StylusPointCollection();
800
-            stylusPoint = new StylusPoint();
801
-            strokes = null;
380
+
381
+            _stylusPoints = new StylusPointCollection();
382
+            _stylusPoint = new StylusPoint();
383
+            _strokes = null;
802
         }
384
         }
803
 
385
 
804
         /// <summary>
386
         /// <summary>
805
         /// 笔抬起
387
         /// 笔抬起
806
         /// </summary>
388
         /// </summary>
807
-        public void TQLUp()
389
+        public void TqlUp()
808
         {
390
         {
809
-            isTQLPenDown = false;
391
+            _isTqlPenDown = false;
810
 
392
 
811
-            if (strokes != null && strokes.StylusPoints.Count > 1)
393
+            if (_strokes != null && _strokes.StylusPoints.Count > 1)
812
             {
394
             {
813
-                isFirst = true;
395
+                _isFirst = true;
814
             }
396
             }
815
-            stylusPoints = new StylusPointCollection();
816
-            stylusPoint = new StylusPoint();
817
-            strokes = null;
397
+
398
+            _stylusPoints = new StylusPointCollection();
399
+            _stylusPoint = new StylusPoint();
400
+            _strokes = null;
818
         }
401
         }
819
 
402
 
820
         /// <summary>
403
         /// <summary>
823
         /// <param name="cx"></param>
406
         /// <param name="cx"></param>
824
         /// <param name="cy"></param>
407
         /// <param name="cy"></param>
825
         /// <param name="force"></param>
408
         /// <param name="force"></param>
826
-        public void TQLPenWrite(double cx, double cy, int force)
409
+        public void TqlPenWrite(double cx, double cy, int force)
827
         {
410
         {
828
             if (this.Visibility == Visibility.Visible)
411
             if (this.Visibility == Visibility.Visible)
829
             {
412
             {
830
                 //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
413
                 //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
831
-                if (!isTQLPenDown)
414
+                if (!_isTqlPenDown)
832
                 {
415
                 {
833
                     return;
416
                     return;
834
                 }
417
                 }
835
-                double PropW = blackboard_canvas.ActualWidth / TQLA4_HEIGHT;
836
-                double PropH = blackboard_canvas.ActualHeight / TQLA4_WIDTH;
837
 
418
 
838
-                double tempX = cy * PropW;
839
-                double tempY = (TQLA4_WIDTH - cx) * PropH;
840
-                Dispatcher.Invoke(new Action(() =>
419
+                double propW = blackboard_canvas.ActualWidth / Tqla4Height;
420
+                double propH = blackboard_canvas.ActualHeight / Tqla4Width;
421
+
422
+                double tempX = cy * propW;
423
+                double tempY = (Tqla4Width - cx) * propH;
424
+                Dispatcher.Invoke(() =>
841
                 {
425
                 {
842
                     //0~1023,亦即有 1024 阶供应用软件后续应用之用,如笔锋笔触,暂无用
426
                     //0~1023,亦即有 1024 阶供应用软件后续应用之用,如笔锋笔触,暂无用
843
-                    float Pressure = (float)force / 1023f;
844
                     //添加笔画
427
                     //添加笔画
845
-                    if (isFirst)
428
+                    if (_isFirst)
846
                     {
429
                     {
847
-                        stylusPoint.X = tempX;
848
-                        stylusPoint.Y = tempY;
849
-                        stylusPoints.Add(stylusPoint);
850
-                        if (stylusPoints.Count > 1)
430
+                        _stylusPoint.X = tempX;
431
+                        _stylusPoint.Y = tempY;
432
+                        _stylusPoints.Add(_stylusPoint);
433
+                        if (_stylusPoints.Count > 1)
851
                         {
434
                         {
852
-                            drawing = new DrawingAttributes
435
+                            _drawing = new DrawingAttributes
853
                             {
436
                             {
854
-                                Color = Colour,
855
-                                Width = Wit * 4.5,
856
-                                Height = Wit * 4.5,
437
+                                Color = _colour,
438
+                                Width = _wit * 4.5,
439
+                                Height = _wit * 4.5,
857
                                 FitToCurve = true,
440
                                 FitToCurve = true,
858
                                 IgnorePressure = false
441
                                 IgnorePressure = false
859
                             };
442
                             };
860
 
443
 
861
-                            strokes = new Stroke(stylusPoints);
444
+                            _strokes = new Stroke(_stylusPoints);
862
 
445
 
863
-                            strokes.DrawingAttributes = drawing;
446
+                            _strokes.DrawingAttributes = _drawing;
864
 
447
 
865
-                            blackboard_canvas.Strokes.Add(strokes);
866
-                            isFirst = false;
448
+                            blackboard_canvas.Strokes.Add(_strokes);
449
+                            _isFirst = false;
867
                         }
450
                         }
868
                     }
451
                     }
869
                     else
452
                     else
870
                     {
453
                     {
871
                         if (blackboard_canvas.Strokes.Count > 0)
454
                         if (blackboard_canvas.Strokes.Count > 0)
872
                         {
455
                         {
873
-                            stylusPoint.X = tempX;
874
-                            stylusPoint.Y = tempY;
875
-                            stylusPoints.Add(stylusPoint);
876
-                            strokes = new Stroke(stylusPoints);
877
-                            drawing = new DrawingAttributes
456
+                            _stylusPoint.X = tempX;
457
+                            _stylusPoint.Y = tempY;
458
+                            _stylusPoints.Add(_stylusPoint);
459
+                            _strokes = new Stroke(_stylusPoints);
460
+                            _drawing = new DrawingAttributes
878
                             {
461
                             {
879
-                                Color = Colour,
880
-                                Width = Wit * 4.5,
881
-                                Height = Wit * 4.5,
462
+                                Color = _colour,
463
+                                Width = _wit * 4.5,
464
+                                Height = _wit * 4.5,
882
                                 FitToCurve = true,
465
                                 FitToCurve = true,
883
                                 IgnorePressure = false
466
                                 IgnorePressure = false
884
                             };
467
                             };
885
-                            strokes.DrawingAttributes = drawing;
468
+                            _strokes.DrawingAttributes = _drawing;
886
 
469
 
887
                             //viewModel.InkStrokes.Add(strokes);
470
                             //viewModel.InkStrokes.Add(strokes);
888
-                            blackboard_canvas.Strokes[blackboard_canvas.Strokes.Count - 1] = strokes;
471
+                            blackboard_canvas.Strokes[blackboard_canvas.Strokes.Count - 1] = _strokes;
889
                         }
472
                         }
890
                     }
473
                     }
891
 
474
 
893
                     if (tempX > 0 && tempY > 0)
476
                     if (tempX > 0 && tempY > 0)
894
                     {
477
                     {
895
                         //System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
478
                         //System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
896
-                        SetCursorPos((int)((float)tempX * (PrimaryScreen.DpiX / 96f)), (int)((float)tempY * (PrimaryScreen.DpiY / 96f)));
479
+                        SetCursorPos((int)((float)tempX * (PrimaryScreen.DpiX / 96f)),
480
+                            (int)((float)tempY * (PrimaryScreen.DpiY / 96f)));
897
                     }
481
                     }
898
-                }));
482
+                });
899
             }
483
             }
900
         }
484
         }
901
 
485
 

+ 2
- 10
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml View File

39
                     x:Name="BtnRecordingScreen"
39
                     x:Name="BtnRecordingScreen"
40
                     Click="BtnRecordingScreen_Click"
40
                     Click="BtnRecordingScreen_Click"
41
                     Cursor="Hand"
41
                     Cursor="Hand"
42
-                    
43
                     ToolTip="开始"
42
                     ToolTip="开始"
44
                     Visibility="Visible">
43
                     Visibility="Visible">
45
                     <Button.Template>
44
                     <Button.Template>
63
                     x:Name="BtnRecordingScreenPause"
62
                     x:Name="BtnRecordingScreenPause"
64
                     Click="BtnRecordingScreen_Click"
63
                     Click="BtnRecordingScreen_Click"
65
                     Cursor="Hand"
64
                     Cursor="Hand"
66
-                    
67
                     ToolTip="暂停"
65
                     ToolTip="暂停"
68
                     Visibility="Collapsed">
66
                     Visibility="Collapsed">
69
                     <Button.Template>
67
                     <Button.Template>
110
                         x:Name="BtnStopRecordingScreen"
108
                         x:Name="BtnStopRecordingScreen"
111
                         Click="BtnStopRecordingScreen_Click"
109
                         Click="BtnStopRecordingScreen_Click"
112
                         Cursor="Hand"
110
                         Cursor="Hand"
113
-                        
114
                         ToolTip="停止">
111
                         ToolTip="停止">
115
                         <Button.Template>
112
                         <Button.Template>
116
                             <ControlTemplate TargetType="{x:Type Button}">
113
                             <ControlTemplate TargetType="{x:Type Button}">
178
                         x:Name="BtnPenBlue"
175
                         x:Name="BtnPenBlue"
179
                         Click="BtnBrush_Click"
176
                         Click="BtnBrush_Click"
180
                         Cursor="Hand"
177
                         Cursor="Hand"
181
-                        
182
                         ToolTip="蓝笔">
178
                         ToolTip="蓝笔">
183
                         <Button.Template>
179
                         <Button.Template>
184
                             <ControlTemplate TargetType="{x:Type Button}">
180
                             <ControlTemplate TargetType="{x:Type Button}">
199
                         x:Name="BtnPenBlue_CL"
195
                         x:Name="BtnPenBlue_CL"
200
                         Click="BtnBrush_Click"
196
                         Click="BtnBrush_Click"
201
                         Cursor="Hand"
197
                         Cursor="Hand"
202
-                        
203
-                        ToolTip="批注"
198
+                        ToolTip="蓝笔"
204
                         Visibility="Collapsed">
199
                         Visibility="Collapsed">
205
                         <Button.Template>
200
                         <Button.Template>
206
                             <ControlTemplate TargetType="{x:Type Button}">
201
                             <ControlTemplate TargetType="{x:Type Button}">
215
                         x:Name="BtnPenRed"
210
                         x:Name="BtnPenRed"
216
                         Click="BtnBlackPenTwo_Click"
211
                         Click="BtnBlackPenTwo_Click"
217
                         Cursor="Hand"
212
                         Cursor="Hand"
218
-                        
219
-                        ToolTip="批注">
213
+                        ToolTip="红笔">
220
                         <Button.Template>
214
                         <Button.Template>
221
                             <ControlTemplate TargetType="{x:Type Button}">
215
                             <ControlTemplate TargetType="{x:Type Button}">
222
                                 <Image x:Name="BtnImages" Source="/SkinImages/SR/SR_PenRed.png" />
216
                                 <Image x:Name="BtnImages" Source="/SkinImages/SR/SR_PenRed.png" />
236
                         x:Name="BtnPenRed_CL"
230
                         x:Name="BtnPenRed_CL"
237
                         Click="BtnBlackPenTwo_Click"
231
                         Click="BtnBlackPenTwo_Click"
238
                         Cursor="Hand"
232
                         Cursor="Hand"
239
-                        
240
                         ToolTip="批注"
233
                         ToolTip="批注"
241
                         Visibility="Collapsed">
234
                         Visibility="Collapsed">
242
                         <Button.Template>
235
                         <Button.Template>
265
                         x:Name="BtnReturn"
258
                         x:Name="BtnReturn"
266
                         Click="BtnReturn_Click"
259
                         Click="BtnReturn_Click"
267
                         Cursor="Hand"
260
                         Cursor="Hand"
268
-                        
269
                         ToolTip="返回">
261
                         ToolTip="返回">
270
                         <Button.Template>
262
                         <Button.Template>
271
                             <ControlTemplate TargetType="{x:Type Button}">
263
                             <ControlTemplate TargetType="{x:Type Button}">

+ 37
- 70
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

113
                 //practiceWin.Owner = this;
113
                 //practiceWin.Owner = this;
114
             }
114
             }
115
 
115
 
116
-            APP.W_PracticeWindow.InitTQLPPen();
116
+            APP.W_PracticeWindow.InitTqlpPen();
117
             APP.W_PracticeWindow.Show();
117
             APP.W_PracticeWindow.Show();
118
             new Thread(new ThreadStart(new Action(() =>
118
             new Thread(new ThreadStart(new Action(() =>
119
             {
119
             {
120
                 Thread.Sleep(100);
120
                 Thread.Sleep(100);
121
-                Dispatcher.Invoke(() =>
122
-                {
123
-                    Topmost = true;
124
-                });
121
+                Dispatcher.Invoke(() => { Topmost = true; });
125
             }))).Start();
122
             }))).Start();
126
             APP.W_PracticeWindow.Hide();
123
             APP.W_PracticeWindow.Hide();
127
 
124
 
140
             BtnRecordingScreen.Visibility = Visibility.Visible;
137
             BtnRecordingScreen.Visibility = Visibility.Visible;
141
             BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
138
             BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
142
             BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
139
             BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
143
-            BtnPenBlue.IsEnabled = false;//蓝笔不可点击
144
-            BtnPenRed.IsEnabled = false;//红笔不可点击
140
+            BtnPenBlue.IsEnabled = false; //蓝笔不可点击
141
+            BtnPenRed.IsEnabled = false; //红笔不可点击
145
             BtnPenBlue.Visibility = Visibility.Visible;
142
             BtnPenBlue.Visibility = Visibility.Visible;
146
             BtnPenRed.Visibility = Visibility.Visible;
143
             BtnPenRed.Visibility = Visibility.Visible;
147
             BtnPenBlue_CL.Visibility = Visibility.Collapsed;
144
             BtnPenBlue_CL.Visibility = Visibility.Collapsed;
156
                 //开始,暂停
153
                 //开始,暂停
157
                 BtnRecordingScreen_Click(null, null);
154
                 BtnRecordingScreen_Click(null, null);
158
             }
155
             }
156
+
159
             if (e.KeyValue == (int)Keys.F6 && (int)Control.ModifierKeys == (int)Keys.Control)
157
             if (e.KeyValue == (int)Keys.F6 && (int)Control.ModifierKeys == (int)Keys.Control)
160
             {
158
             {
161
                 //结束
159
                 //结束
232
         //桌面录制
230
         //桌面录制
233
         private ZVideoRecordHelper helper0 = null;
231
         private ZVideoRecordHelper helper0 = null;
234
 
232
 
235
-        public IntPtr winHandle;// 当前窗体指针
233
+        public IntPtr winHandle; // 当前窗体指针
236
 
234
 
237
         /// <summary>
235
         /// <summary>
238
         /// 开始或暂停录制
236
         /// 开始或暂停录制
295
                 {
293
                 {
296
                     APP.W_CountdownWindow.Initialize(true, 3000);
294
                     APP.W_CountdownWindow.Initialize(true, 3000);
297
                 }
295
                 }
296
+
298
                 APP.W_CountdownWindow.Show();
297
                 APP.W_CountdownWindow.Show();
299
 
298
 
300
                 BtnRecordingScreen.Visibility = Visibility.Collapsed;
299
                 BtnRecordingScreen.Visibility = Visibility.Collapsed;
301
                 BtnRecordingScreenPause.Visibility = Visibility.Visible;
300
                 BtnRecordingScreenPause.Visibility = Visibility.Visible;
302
                 BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击
301
                 BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击
303
-                BtnPenBlue.IsEnabled = true;//蓝笔可点击
304
-                BtnPenRed.IsEnabled = true;//红笔可点击
302
+                BtnPenBlue.IsEnabled = true; //蓝笔可点击
303
+                BtnPenRed.IsEnabled = true; //红笔可点击
305
                 BtnPenBlue.Visibility = Visibility.Visible;
304
                 BtnPenBlue.Visibility = Visibility.Visible;
306
                 BtnPenRed.Visibility = Visibility.Visible;
305
                 BtnPenRed.Visibility = Visibility.Visible;
307
                 BtnPenBlue_CL.Visibility = Visibility.Collapsed;
306
                 BtnPenBlue_CL.Visibility = Visibility.Collapsed;
308
                 BtnPenRed_CL.Visibility = Visibility.Collapsed;
307
                 BtnPenRed_CL.Visibility = Visibility.Collapsed;
309
-                TxbTime.Visibility = Visibility.Visible;//时间显示
308
+                TxbTime.Visibility = Visibility.Visible; //时间显示
310
 
309
 
311
                 #region 隐藏工具栏
310
                 #region 隐藏工具栏
312
 
311
 
316
                     {
315
                     {
317
                         APP.W_MinToolbar = new MinToolbar();
316
                         APP.W_MinToolbar = new MinToolbar();
318
                     }
317
                     }
318
+
319
                     APP.W_MinToolbar.Topmost = true;
319
                     APP.W_MinToolbar.Topmost = true;
320
                     double MinToolTop = Top;
320
                     double MinToolTop = Top;
321
                     GridSrToobar.Visibility = Visibility.Hidden;
321
                     GridSrToobar.Visibility = Visibility.Hidden;
347
                     helper1.StartRecordAudio();
347
                     helper1.StartRecordAudio();
348
                     helper2.StartRecordAudio();
348
                     helper2.StartRecordAudio();
349
                     helper0.StartRecordVideo();
349
                     helper0.StartRecordVideo();
350
-                    k_hook.Start();//安装键盘钩子
350
+                    k_hook.Start(); //安装键盘钩子
351
                 }
351
                 }
352
                 catch (Exception)
352
                 catch (Exception)
353
                 {
353
                 {
397
             {
397
             {
398
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
398
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
399
             }
399
             }
400
+
400
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
401
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
401
 
402
 
402
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
403
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
407
                 t.Stop();
408
                 t.Stop();
408
                 t = null;
409
                 t = null;
409
             }
410
             }
411
+
410
             helper0.StopRecordVideo();
412
             helper0.StopRecordVideo();
411
             helper1.StopRecordAudio();
413
             helper1.StopRecordAudio();
412
             helper2.StopRecordAudio();
414
             helper2.StopRecordAudio();
457
             {
459
             {
458
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
460
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
459
             }
461
             }
462
+
460
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
463
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
461
 
464
 
462
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
465
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
476
                 {
479
                 {
477
                     FFMpegConverter ffMpeg = new FFMpegConverter();
480
                     FFMpegConverter ffMpeg = new FFMpegConverter();
478
 
481
 
479
-                    FFMpegInput[] input = new FFMpegInput[] {
482
+                    FFMpegInput[] input = new FFMpegInput[]
483
+                    {
480
                         new FFMpegInput(TempVideoPathName),
484
                         new FFMpegInput(TempVideoPathName),
481
                         new FFMpegInput(TempAudioPathName1),
485
                         new FFMpegInput(TempAudioPathName1),
482
                         new FFMpegInput(TempAudioPathName2),
486
                         new FFMpegInput(TempAudioPathName2),
498
                         string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
502
                         string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
499
                         FileToolsCommon.CreateDirectory(ThumbnailPath);
503
                         FileToolsCommon.CreateDirectory(ThumbnailPath);
500
                         //缩略图存储位置
504
                         //缩略图存储位置
501
-                        string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
505
+                        string ThumbnailPathName = ThumbnailPath +
506
+                                                   FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") +
507
+                                                   ".JPG";
502
 
508
 
503
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
509
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
504
                         VideoInfo.VideoPath = VideoSavePathName;
510
                         VideoInfo.VideoPath = VideoSavePathName;
507
                         VideoInfo.FileGuid = Guid.NewGuid().ToString();
513
                         VideoInfo.FileGuid = Guid.NewGuid().ToString();
508
                         VideoInfo.IsUpload = false;
514
                         VideoInfo.IsUpload = false;
509
                         VideoInfo.Uploaded = 0;
515
                         VideoInfo.Uploaded = 0;
510
-                        if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
516
+                        if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) ||
517
+                            !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
511
                         {
518
                         {
512
                             APP.VideoList.Add(VideoInfo);
519
                             APP.VideoList.Add(VideoInfo);
513
                             //保存数据
520
                             //保存数据
522
                     FileToolsCommon.DeleteDirectory(temppath);
529
                     FileToolsCommon.DeleteDirectory(temppath);
523
                 }))).Start();
530
                 }))).Start();
524
             }
531
             }
532
+
525
             Click_stopRecordingScreen();
533
             Click_stopRecordingScreen();
526
             Hide();
534
             Hide();
527
 
535
 
534
             Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
542
             Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
535
             float DIP = graphics.DpiX;
543
             float DIP = graphics.DpiX;
536
             //float DIPY = graphics.DpiY;
544
             //float DIPY = graphics.DpiY;
537
-            APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width;
545
+            APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) -
546
+                                                      APP.W_ScreenRecordingToolbarWindow.Width;
538
             GridSrToobar.Visibility = Visibility.Visible;
547
             GridSrToobar.Visibility = Visibility.Visible;
539
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
548
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
540
         }
549
         }
585
                             };
594
                             };
586
                         }
595
                         }
587
 
596
 
588
-                        APP.W_PracticeWindow.Initialize();// imagePath);
597
+                        APP.W_PracticeWindow.Initialize(); // imagePath);
589
                         flg = 11;
598
                         flg = 11;
590
                         APP.W_PracticeWindow.Blue();
599
                         APP.W_PracticeWindow.Blue();
591
                         APP.W_PracticeWindow.Show();
600
                         APP.W_PracticeWindow.Show();
595
 
604
 
596
                     new Thread(new ThreadStart(new Action(() =>
605
                     new Thread(new ThreadStart(new Action(() =>
597
                     {
606
                     {
598
-                        Dispatcher.Invoke(() =>
599
-                        {
600
-                            APP.W_PracticeWindow.Topmost = false;
601
-                        });
607
+                        Dispatcher.Invoke(() => { APP.W_PracticeWindow.Topmost = false; });
602
                         Thread.Sleep(500);
608
                         Thread.Sleep(500);
603
-                        Dispatcher.Invoke(() =>
604
-                        {
605
-                            Topmost = true;
606
-                        });
609
+                        Dispatcher.Invoke(() => { Topmost = true; });
607
                     }))).Start();
610
                     }))).Start();
608
                 }
611
                 }
609
                 catch (Exception ex)
612
                 catch (Exception ex)
696
                         //practiceWin.Owner = this;
699
                         //practiceWin.Owner = this;
697
                     }
700
                     }
698
 
701
 
699
-                    APP.W_PracticeWindow.InitTQLPPen();
700
-                    APP.W_PracticeWindow.Initialize();// imagePath);
702
+                    APP.W_PracticeWindow.InitTqlpPen();
703
+                    APP.W_PracticeWindow.Initialize(); // imagePath);
701
                     flg = 11;
704
                     flg = 11;
702
                     APP.W_PracticeWindow.Blue();
705
                     APP.W_PracticeWindow.Blue();
703
                     APP.W_PracticeWindow.Show();
706
                     APP.W_PracticeWindow.Show();
740
             return Convert.ToInt64(ts.TotalMilliseconds).ToString();
743
             return Convert.ToInt64(ts.TotalMilliseconds).ToString();
741
         }
744
         }
742
 
745
 
743
-        /// <summary>
744
-        /// 橡皮
745
-        /// </summary>
746
-        /// <param name="sender"></param>
747
-        /// <param name="e"></param>
748
-        private void BtnEraser_Click(object sender, RoutedEventArgs e)
749
-        {
750
-            APP.W_PracticeWindow.Eraser();
751
-        }
752
-
753
-        /// <summary>
754
-        /// 🖊
755
-        /// </summary>
756
-        /// <param name="sender"></param>
757
-        /// <param name="e"></param>
758
-        private void BtnPen_Click(object sender, RoutedEventArgs e)
759
-        {
760
-            APP.W_PracticeWindow.Pen();
761
-        }
762
-
763
-        /// <summary>
764
-        /// ⚪
765
-        /// </summary>
766
-        /// <param name="sender"></param>
767
-        /// <param name="e"></param>
768
-        private void BtnRound_Click(object sender, RoutedEventArgs e)
769
-        {
770
-            APP.W_PracticeWindow.Round();
771
-        }
772
-
773
-        /// <summary>
774
-        /// 矩形
775
-        /// </summary>
776
-        /// <param name="sender"></param>
777
-        /// <param name="e"></param>
778
-        private void BtnRectangle_Click(object sender, RoutedEventArgs e)
779
-        {
780
-            APP.W_PracticeWindow.Rectangle();
781
-        }
782
-
783
         #endregion 画笔相关
746
         #endregion 画笔相关
784
 
747
 
785
         #endregion 事件
748
         #endregion 事件
872
                         };
835
                         };
873
                     }
836
                     }
874
 
837
 
875
-                    APP.W_PracticeWindow.InitTQLPPen();
876
-                    APP.W_PracticeWindow.Initialize();//imagePath);
838
+                    APP.W_PracticeWindow.InitTqlpPen();
839
+                    APP.W_PracticeWindow.Initialize(); //imagePath);
877
                     flg = 10;
840
                     flg = 10;
878
                     APP.W_PracticeWindow.Red();
841
                     APP.W_PracticeWindow.Red();
879
                     APP.W_PracticeWindow.Show();
842
                     APP.W_PracticeWindow.Show();
909
                 {
872
                 {
910
                     return;
873
                     return;
911
                 }
874
                 }
875
+
912
                 BtnStopRecordingScreen_Click(null, null);
876
                 BtnStopRecordingScreen_Click(null, null);
913
             }
877
             }
878
+
914
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
879
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
915
             //APP.W_XHMicroLessonSystemWindow.InitPen();
880
             //APP.W_XHMicroLessonSystemWindow.InitPen();
916
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
881
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
952
                     {
917
                     {
953
                         APP.W_MinToolbar = new MinToolbar();
918
                         APP.W_MinToolbar = new MinToolbar();
954
                     }
919
                     }
920
+
955
                     APP.W_MinToolbar.Topmost = true;
921
                     APP.W_MinToolbar.Topmost = true;
956
                     double MinToolTop = Top;
922
                     double MinToolTop = Top;
957
 
923
 
961
                         Dispatcher.Invoke(() =>
927
                         Dispatcher.Invoke(() =>
962
                         {
928
                         {
963
                             MouseEventCommon.GetCursorPos(out MouseEventCommon.POINT pointRecord);
929
                             MouseEventCommon.GetCursorPos(out MouseEventCommon.POINT pointRecord);
964
-                            if (pointRecord.X >= this.Left && pointRecord.X < this.Left + this.ActualWidth && pointRecord.Y >= this.Top && pointRecord.Y < this.Top + this.ActualHeight)
930
+                            if (pointRecord.X >= this.Left && pointRecord.X < this.Left + this.ActualWidth &&
931
+                                pointRecord.Y >= this.Top && pointRecord.Y < this.Top + this.ActualHeight)
965
                             {
932
                             {
966
                                 //LblMessage.Content = "在区域内:("+ pointRecord.X+","+pointRecord.Y+") ("+ Left + ","+Top+")";
933
                                 //LblMessage.Content = "在区域内:("+ pointRecord.X+","+pointRecord.Y+") ("+ Left + ","+Top+")";
967
                             }
934
                             }

+ 1
- 1
XHWK.WKTool/UControl/Uc_VideoItem.xaml.cs View File

326
                 //BtnUpload.IsEnabled = false;
326
                 //BtnUpload.IsEnabled = false;
327
                 //BtnUpload.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9EA0A7"));
327
                 //BtnUpload.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9EA0A7"));
328
                 //BtnUpload.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#999999"));
328
                 //BtnUpload.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#999999"));
329
-                DAL_Upload dAL_Upload = new DAL_Upload();
329
+                DalUpload dAL_Upload = new DalUpload();
330
 
330
 
331
                 if (dAL_Upload.UploadVideo(VideoModel.FileGuid, out string ErrMessage))
331
                 if (dAL_Upload.UploadVideo(VideoModel.FileGuid, out string ErrMessage))
332
                 {
332
                 {

+ 1
- 1
XHWK.WKTool/UploadWindow.xaml.cs View File

280
         {
280
         {
281
             try
281
             try
282
             {
282
             {
283
-                DAL_Upload dAL_Upload = new DAL_Upload();
283
+                DalUpload dAL_Upload = new DalUpload();
284
                 if (dAL_Upload.UploadVideoTwo(Guid, out string ErrMessage))
284
                 if (dAL_Upload.UploadVideoTwo(Guid, out string ErrMessage))
285
                 {
285
                 {
286
                     //        converted: 0
286
                     //        converted: 0

+ 4
- 9
XHWK.WKTool/Utils/ZAudioRecordHelper.cs View File

155
                     mWaveIn = new WaveInEvent();
155
                     mWaveIn = new WaveInEvent();
156
                     mWriter = new WaveFileWriter(mAudioFile, mWaveIn.WaveFormat);
156
                     mWriter = new WaveFileWriter(mAudioFile, mWaveIn.WaveFormat);
157
                     //开始录音,写数据
157
                     //开始录音,写数据
158
-                    mWaveIn.DataAvailable += (s, a) =>
159
-                    {
160
-                        mWriter.Write(a.Buffer, 0, a.BytesRecorded);
161
-                    };
158
+                    mWaveIn.DataAvailable += (s, a) => { mWriter.Write(a.Buffer, 0, a.BytesRecorded); };
162
 
159
 
163
                     //结束录音
160
                     //结束录音
164
                     mWaveIn.RecordingStopped += (s, a) =>
161
                     mWaveIn.RecordingStopped += (s, a) =>
187
                     mCapture = new WasapiLoopbackCapture();
184
                     mCapture = new WasapiLoopbackCapture();
188
                     mWriter = new WaveFileWriter(mAudioFile, mCapture.WaveFormat);
185
                     mWriter = new WaveFileWriter(mAudioFile, mCapture.WaveFormat);
189
 
186
 
190
-                    mCapture.DataAvailable += (s, a) =>
191
-                    {
192
-                        mWriter.Write(a.Buffer, 0, a.BytesRecorded);
193
-                    };
187
+                    mCapture.DataAvailable += (s, a) => { mWriter.Write(a.Buffer, 0, a.BytesRecorded); };
194
                     //结束录音
188
                     //结束录音
195
                     mCapture.RecordingStopped += (s, a) =>
189
                     mCapture.RecordingStopped += (s, a) =>
196
                     {
190
                     {
211
                     });
205
                     });
212
                 }
206
                 }
213
             }
207
             }
214
-            catch (Exception ex)
208
+            catch (Exception)
215
             {
209
             {
216
                 if (mWriter != null)
210
                 if (mWriter != null)
217
                 {
211
                 {
218
                     mWriter.Dispose();
212
                     mWriter.Dispose();
219
                     mWriter = null;
213
                     mWriter = null;
220
                 }
214
                 }
215
+
221
                 return false;
216
                 return false;
222
             }
217
             }
223
 
218
 

+ 2
- 2
XHWK.WKTool/Utils/ZVideoRecordHelper.cs View File

58
                 }
58
                 }
59
 
59
 
60
                 System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0, 0, _width, _height);
60
                 System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0, 0, _width, _height);
61
-                videoStreamer = new ScreenCaptureStream(rec, 1000 / _rate);//帧间隔需要和帧率关联,不然录的10秒视频文件不是10s
61
+                videoStreamer = new ScreenCaptureStream(rec, 1000 / _rate); //帧间隔需要和帧率关联,不然录的10秒视频文件不是10s
62
                 videoStreamer.NewFrame += VideoNewFrame;
62
                 videoStreamer.NewFrame += VideoNewFrame;
63
                 videoStreamer.Start();
63
                 videoStreamer.Start();
64
             }
64
             }
65
-            catch (Exception ex)
65
+            catch (Exception)
66
             {
66
             {
67
             }
67
             }
68
         }
68
         }

+ 3
- 4
XHWK.WKTool/Utils/pen/TQLPen/PenEvents.cs View File

354
                 }
354
                 }
355
                 else if (dot.type == DotType.PEN_DOWN)
355
                 else if (dot.type == DotType.PEN_DOWN)
356
                 {
356
                 {
357
-                    APP.W_PracticeWindow.TQLDown();
357
+                    APP.W_PracticeWindow.TqlDown();
358
                 }
358
                 }
359
                 else if (dot.type == DotType.PEN_UP)
359
                 else if (dot.type == DotType.PEN_UP)
360
                 {
360
                 {
361
-                    APP.W_PracticeWindow.TQLUp();
361
+                    APP.W_PracticeWindow.TqlUp();
362
                 }
362
                 }
363
                 else if (dot.type == DotType.PEN_MOVE)
363
                 else if (dot.type == DotType.PEN_MOVE)
364
                 {
364
                 {
365
                     double CX = (double)dot.x + (double)dot.fx / 100.00;
365
                     double CX = (double)dot.x + (double)dot.fx / 100.00;
366
                     double CY = (double)dot.y + (double)dot.fy / 100.00;
366
                     double CY = (double)dot.y + (double)dot.fy / 100.00;
367
-                    APP.W_PracticeWindow.TQLPenWrite(CX, CY, dot.force);
367
+                    APP.W_PracticeWindow.TqlPenWrite(CX, CY, dot.force);
368
                     //form.AddLog("x:" + (dot.x + dot.fx / 100f).ToString() + ", " + "y:" + (dot.y + dot.fy / 100f).ToString());
368
                     //form.AddLog("x:" + (dot.x + dot.fx / 100f).ToString() + ", " + "y:" + (dot.y + dot.fy / 100f).ToString());
369
                 }
369
                 }
370
             }
370
             }
376
             //}
376
             //}
377
 
377
 
378
 
378
 
379
-
380
             //if (dot.type == DotType.PEN_HOVER) return;
379
             //if (dot.type == DotType.PEN_HOVER) return;
381
             //if (this.S != dot.sectionId || this.O != dot.ownerId || this.B != dot.noteId || this.P != dot.pageId)
380
             //if (this.S != dot.sectionId || this.O != dot.ownerId || this.B != dot.noteId || this.P != dot.pageId)
382
             //{
381
             //{

Loading…
Cancel
Save