瀏覽代碼

工具条提示文字

代码优化
master
张剑 1 年之前
父節點
當前提交
498a53a837

+ 1
- 1
XHWK.WKTool/App.config 查看文件

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

+ 53
- 63
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs 查看文件

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

+ 103
- 101
XHWK.WKTool/DAL/DAL_Upload.cs 查看文件

@@ -14,43 +14,45 @@ namespace XHWK.WKTool.DAL
14 14
     /// <summary>
15 15
     /// 上传相关方法 创建人:赵耀 创建时间:2020年9月4日
16 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 21
         //private string schoolfileRequestAddress = APP.showImageUrl;
22 22
         /// <summary>
23 23
         /// 文件是否允许上传
24 24
         /// </summary>
25
-        /// <param name="MD5">
25
+        /// <param name="md5">
26 26
         /// MD5
27 27
         /// </param>
28
-        /// <param name="Message">
28
+        /// <param name="message">
29 29
         /// 错误消息
30 30
         /// </param>
31 31
         /// <returns>
32 32
         /// </returns>
33
-        public bool IsAllowUploaded(string MD5, out string Message)
33
+        public bool IsAllowUploaded(string md5, out string message)
34 34
         {
35 35
             Exception ex = null;
36
-            Message = "";//请求重试5次 共5秒
36
+            message = ""; //请求重试5次 共5秒
37 37
             for (int num = 0; num < 5; num++)
38 38
             {
39 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 43
                     if (jo == null)
43 44
                     {
44
-                        Message = "无法访问文件服务器,请检查网络或文件服务器地址。";
45
+                        message = "无法访问文件服务器,请检查网络或文件服务器地址。";
45 46
                         return false;
46 47
                     }
47 48
 
48 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 57
                         APP.ResourceAddTwo = resultObj.obj;
56 58
                         //已存在 不允许上传
@@ -58,49 +60,52 @@ namespace XHWK.WKTool.DAL
58 60
                     }
59 61
                     else
60 62
                     {
61
-                        Message = "";
63
+                        message = "";
62 64
                         //不存在 允许上传
63 65
                         return true;
64 66
                     }
65 67
                 }
66 68
                 catch (Exception e)
67 69
                 {
68
-                    Message = "上传失败,无法访问到服务器:" + e.Message;
70
+                    message = "上传失败,无法访问到服务器:" + e.Message;
69 71
                     ex = e;
70 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 78
             return false;
76 79
         }
77 80
 
78 81
         /// <summary>
79 82
         /// 上报文件合并指令
80 83
         /// </summary>
81
-        /// <param name="Savefolder">
84
+        /// <param name="savefolder">
82 85
         /// 保存文件位置 学校id/resource
83 86
         /// </param>
84
-        /// <param name="FileCode">
87
+        /// <param name="fileCode">
85 88
         /// 文件唯一编号 Guid
86 89
         /// </param>
87
-        /// <param name="Message">
90
+        /// <param name="message">
88 91
         /// 错误信息
89 92
         /// </param>
90 93
         /// <returns>
91 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 97
             Exception ex = null;
95
-            Message = "";//请求重试5次 共5秒
98
+            message = ""; //请求重试5次 共5秒
96 99
             for (int num = 0; num < 5; num++)
97 100
             {
98 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 106
                     if (jo == null)
102 107
                     {
103
-                        Message = "无法访问文件服务器,请检查网络或文件服务器地址。";
108
+                        message = "无法访问文件服务器,请检查网络或文件服务器地址。";
104 109
                         return false;
105 110
                     }
106 111
                     Model.ResultVo<Model_ResourceAddTwo> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_ResourceAddTwo>>(jo.ToString());
@@ -114,19 +119,20 @@ namespace XHWK.WKTool.DAL
114 119
                     else
115 120
                     {
116 121
                         //Message = "上传失败!";
117
-                        Message = jo["msg"].ToString();
122
+                        message = jo["msg"]?.ToString();
118 123
                         return false;
119 124
                     }
120 125
                 }
121 126
                 catch (Exception e)
122 127
                 {
123
-                    Message = e.Message;
128
+                    message = e.Message;
124 129
                     ex = e;
125 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 136
             return false;
131 137
         }
132 138
 
@@ -135,41 +141,43 @@ namespace XHWK.WKTool.DAL
135 141
         /// </summary>
136 142
         /// <returns>
137 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 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 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 162
                             break;
157 163
                         }
158 164
                     }
159
-                    if (VideoInfo != null)
165
+
166
+                    if (videoInfo != null)
160 167
                     {
161 168
                         break;
162 169
                     }
163 170
                 }
164
-                if (VideoInfo == null)
171
+
172
+                if (videoInfo == null)
165 173
                 {
166
-                    ErrMessage = "未找到课程!";
174
+                    errMessage = "未找到课程!";
167 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 181
                     return false;
174 182
                 }
175 183
                 else
@@ -189,78 +197,82 @@ namespace XHWK.WKTool.DAL
189 197
         /// </summary>
190 198
         /// <returns>
191 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 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 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 218
                             break;
211 219
                         }
212 220
                     }
213
-                    if (VideoInfo != null)
221
+
222
+                    if (videoInfo != null)
214 223
                     {
215 224
                         break;
216 225
                     }
217 226
                 }
218
-                if (VideoInfo == null)
227
+
228
+                if (videoInfo == null)
219 229
                 {
220
-                    ErrMessage = "未找到课程!";
230
+                    errMessage = "未找到课程!";
221 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 238
                     return false;
228 239
                 }
229 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 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 262
                         else
253 263
                         {
254 264
                             //上传完,未合并
255
-                            IsSequel = false;
256 265
 
257 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 273
                             if (isres)
262 274
                             {
263
-                                VideoInfo.IsUpload = true;
275
+                                videoInfo.IsUpload = true;
264 276
                                 return true;
265 277
                             }
266 278
                             else
@@ -274,48 +286,47 @@ namespace XHWK.WKTool.DAL
274 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 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 305
                             return true;
295 306
                         }
296 307
                     }
297 308
 
298 309
                     ////临时修改 没有断点续传,每次上传都重新上传。
299 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 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 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 327
                                 { "filename", fileName },
317
-                                { "totalchunk", VideoInfo.Block.ToString() },
318
-                                { "md5", VideoInfo.FileMD5 }
328
+                                { "totalchunk", videoInfo.Block.ToString() },
329
+                                { "md5", videoInfo.FileMD5 }
319 330
                             };
320 331
                             //formFields.Add();///教材
321 332
                             //if()//章节若没选不传
@@ -323,23 +334,26 @@ namespace XHWK.WKTool.DAL
323 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 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 342
                                 return false;
332 343
                             }
333 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 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 357
                         if (isres)
344 358
                         {
345 359
                             //VideoInfo.IsUpload = true;
@@ -352,18 +366,6 @@ namespace XHWK.WKTool.DAL
352 366
 
353 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 371
             catch (Exception ex)

+ 81
- 114
XHWK.WKTool/KeyVerification.xaml 查看文件

@@ -2,135 +2,102 @@
2 2
     x:Class="XHWK.WKTool.KeyVerification"
3 3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
-    xmlns:Views="clr-namespace:XHWK.WKTool.Helpers"
6 5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7
-    xmlns:local="clr-namespace:XHWK.WKTool"
8 6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9 7
     Title="KeyVerification"
10 8
     Width="400"
11
-    Height="230"
9
+    Height="200"
12 10
     AllowsTransparency="True"
13 11
     Background="Transparent"
12
+    BorderBrush="#4597FF"
13
+    BorderThickness="1"
14 14
     ShowInTaskbar="False"
15 15
     WindowStartupLocation="CenterOwner"
16 16
     WindowStyle="None"
17 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 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 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 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 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 103
 </Window>

+ 34
- 34
XHWK.WKTool/KeyVerification.xaml.cs 查看文件

@@ -4,9 +4,8 @@ using System.Management;
4 4
 using System.Text;
5 5
 using System.Threading;
6 6
 using System.Windows;
7
-
7
+using System.Windows.Input;
8 8
 using XHWK.WKTool.DAL;
9
-using XHWK.WKTool.Skin;
10 9
 
11 10
 namespace XHWK.WKTool
12 11
 {
@@ -16,11 +15,10 @@ namespace XHWK.WKTool
16 15
     /*
17 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 23
         public KeyVerification()
26 24
         {
@@ -28,27 +26,33 @@ namespace XHWK.WKTool
28 26
             Topmost = true;
29 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 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 41
                 MessageWindow.Show("密匙未输入");
39 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 48
                 MessageWindow.Show("密匙输入过长");
45
-                txbKey.Text = projectcode.Substring(0, 8);
49
+                TxbKey.Text = _projectcode.Substring(0, 8);
46 50
                 return;
47 51
             }
48 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 57
         /// <summary>
54 58
         /// 认证服务-调用
@@ -59,7 +63,7 @@ namespace XHWK.WKTool
59 63
         {
60 64
             string device = "pcwk";
61 65
             string mac = GetMacAddress();
62
-            serverReturnCode = registerController.ActivationAdd(mac, device, projectcode);
66
+            _serverReturnCode = _registerController.ActivationAdd(mac, device, _projectcode);
63 67
             return APP.ServerMsg;
64 68
         }
65 69
 
@@ -70,11 +74,12 @@ namespace XHWK.WKTool
70 74
         /// </returns>
71 75
         public void InvokeActivationAddServerCompate(object obj)
72 76
         {
73
-            if (serverReturnCode == 0)
77
+            if (_serverReturnCode == 0)
74 78
             {
75 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 84
                     Hide();
80 85
                     CreateAMicroLessonWindow win = new CreateAMicroLessonWindow();
@@ -83,7 +88,7 @@ namespace XHWK.WKTool
83 88
 
84 89
                     Thread.Sleep(200);
85 90
                     Close();
86
-                }));
91
+                });
87 92
             }
88 93
             else
89 94
             {
@@ -98,7 +103,7 @@ namespace XHWK.WKTool
98 103
         /// </returns>
99 104
         private object InvokeActivationAddHistoryServering()
100 105
         {
101
-            serverReturnCode = registerController.ActivationAddHistory();
106
+            _serverReturnCode = _registerController.ActivationAddHistory();
102 107
             return APP.ServerMsg;
103 108
         }
104 109
 
@@ -113,9 +118,10 @@ namespace XHWK.WKTool
113 118
             {
114 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 127
         /// <summary>
@@ -131,15 +137,15 @@ namespace XHWK.WKTool
131 137
                 string strMac = string.Empty;
132 138
                 ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
133 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 145
                         strMac = mo["MacAddress"].ToString();
139 146
                     }
140 147
                 }
141
-                moc = null;
142
-                mc = null;
148
+
143 149
                 return strMac;
144 150
             }
145 151
             catch
@@ -150,19 +156,13 @@ namespace XHWK.WKTool
150 156
 
151 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 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 查看文件

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

+ 29
- 26
XHWK.WKTool/MinToolbar.xaml 查看文件

@@ -1,36 +1,39 @@
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 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 18
     <Window.Background>
13 19
         <SolidColorBrush Opacity="0" Color="#00000000" />
14 20
     </Window.Background>
15 21
     <Viewbox>
16 22
         <Grid>
17 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 37
                 </Grid>
35 38
             </Border>
36 39
 

+ 122
- 538
XHWK.WKTool/PracticeWindow.xaml.cs 查看文件

@@ -1,14 +1,11 @@
1 1
 using Common.system;
2
-
3 2
 using System;
4
-using System.Collections.Generic;
5 3
 using System.Threading;
6 4
 using System.Windows;
7 5
 using System.Windows.Controls;
8 6
 using System.Windows.Ink;
9 7
 using System.Windows.Input;
10 8
 using System.Windows.Media;
11
-
12 9
 using XHWK.Model;
13 10
 
14 11
 namespace XHWK.WKTool
@@ -16,44 +13,46 @@ namespace XHWK.WKTool
16 13
     /// <summary>
17 14
     /// 录屏画板
18 15
     /// </summary>
19
-    public partial class PracticeWindow : Window
16
+    public partial class PracticeWindow
20 17
     {
21 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 24
         /// <summary>
28 25
         /// 0 画笔 1 矩形 2 圆形
29 26
         /// </summary>
30
-        private int flg = 0;
27
+#pragma warning disable CS0414
28
+        private int _flg;
29
+#pragma warning restore CS0414
31 30
 
32 31
         /// <summary>
33 32
         /// 当前画笔颜色
34 33
         /// </summary>
35
-        private Color Colour = Colors.Red;
34
+        private Color _colour = Colors.Red;
36 35
 
37 36
         /// <summary>
38 37
         /// 当前画笔宽
39 38
         /// </summary>
40
-        private int Wit = 2;
39
+        private int _wit = 2;
41 40
 
42 41
         /// <summary>
43 42
         /// 当前画笔高
44 43
         /// </summary>
45
-        private int Hei = 2;
44
+        private int _hei = 2;
46 45
 
47 46
         public PracticeWindow()
48 47
         {
49 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 56
             blackboard_canvas.Strokes.Clear();
58 57
             blackboard_canvas.UseCustomCursor = true;
59 58
             //blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
@@ -64,7 +63,7 @@ namespace XHWK.WKTool
64 63
             //}
65 64
 
66 65
             //创建 DrawingAttributes 类的一个实例
67
-            drawingAttributes = new DrawingAttributes();
66
+            _drawingAttributes = new DrawingAttributes();
68 67
 
69 68
             //drawingAttributes.StylusTip = StylusTip.Rectangle;
70 69
             //drawingAttributes.IsHighlighter = false;
@@ -72,7 +71,7 @@ namespace XHWK.WKTool
72 71
 
73 72
             ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
74 73
             ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
75
-            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
74
+            blackboard_canvas.DefaultDrawingAttributes = _drawingAttributes;
76 75
             Pen();
77 76
             //blackboard_canvas.Cursor = Cursors.Pen;
78 77
 
@@ -80,12 +79,12 @@ namespace XHWK.WKTool
80 79
 
81 80
             //blackboard_canvas.Cursor = cus;
82 81
 
83
-            viewModel = new ViewModel
82
+            _viewModel = new ViewModel
84 83
             {
85 84
                 InkStrokes = new StrokeCollection(),
86 85
             };
87 86
 
88
-            DataContext = viewModel;
87
+            DataContext = _viewModel;
89 88
             //APP.W_ScreenRecordingToolbarWindow.Owner = this;
90 89
             //APP.W_ScreenRecordingToolbarWindow.Topmost = true;
91 90
         }
@@ -93,114 +92,96 @@ namespace XHWK.WKTool
93 92
         /// <summary>
94 93
         /// 画笔颜色事件 白色
95 94
         /// </summary>
96
-        /// <param name="sender"></param>
97
-        /// <param name="e"></param>
98 95
         public void White()
99 96
         {
100 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 102
         /// <summary>
106 103
         /// 画笔颜色事件 红色
107 104
         /// </summary>
108
-        /// <param name="sender"></param>
109
-        /// <param name="e"></param>
110 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 111
         /// <summary>
117 112
         /// 画笔颜色事件 黑色
118 113
         /// </summary>
119
-        /// <param name="sender"></param>
120
-        /// <param name="e"></param>
121 114
         public void Gray()
122 115
         {
123 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 121
         /// <summary>
129 122
         /// 画笔颜色事件 青色
130 123
         /// </summary>
131
-        /// <param name="sender"></param>
132
-        /// <param name="e"></param>
133 124
         public void CyanBlue()
134 125
         {
135 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 131
         /// <summary>
141 132
         /// 画笔颜色事件 黄色
142 133
         /// </summary>
143
-        /// <param name="sender"></param>
144
-        /// <param name="e"></param>
145 134
         public void Yellow()
146 135
         {
147 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 141
         /// <summary>
153 142
         /// 画笔颜色事件 蓝色
154 143
         /// </summary>
155
-        /// <param name="sender"></param>
156
-        /// <param name="e"></param>
157 144
         public void Blue()
158 145
         {
159 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 151
         /// <summary>
165 152
         /// 画笔粗细事件 细
166 153
         /// </summary>
167
-        /// <param name="sender"></param>
168
-        /// <param name="e"></param>
169 154
         public void Fine()
170 155
         {
171 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 163
         /// <summary>
179 164
         /// 画笔粗细事件 中
180 165
         /// </summary>
181
-        /// <param name="sender"></param>
182
-        /// <param name="e"></param>
183 166
         public void In()
184 167
         {
185 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 175
         /// <summary>
193 176
         /// 画笔粗细事件 粗
194 177
         /// </summary>
195
-        /// <param name="sender"></param>
196
-        /// <param name="e"></param>
197 178
         public void Crude()
198 179
         {
199 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 187
         /// <summary>
@@ -208,7 +189,7 @@ namespace XHWK.WKTool
208 189
         /// </summary>
209 190
         public void Eraser()
210 191
         {
211
-            flg = 0;
192
+            _flg = 0;
212 193
             //this.type = ZPenType.Erase;
213 194
             blackboard_canvas.UseCustomCursor = false;
214 195
             blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
@@ -220,11 +201,11 @@ namespace XHWK.WKTool
220 201
         /// </summary>
221 202
         public void Pen()
222 203
         {
223
-            flg = 0;
204
+            _flg = 0;
224 205
             blackboard_canvas.EditingMode = InkCanvasEditingMode.Ink;
225 206
             blackboard_canvas.UseCustomCursor = true;
226
-            drawingAttributes.FitToCurve = true;
227
-            drawingAttributes.IgnorePressure = false;
207
+            _drawingAttributes.FitToCurve = true;
208
+            _drawingAttributes.IgnorePressure = false;
228 209
 
229 210
             blackboard_canvas.Cursor = Cursors.Pen;
230 211
         }
@@ -234,18 +215,18 @@ namespace XHWK.WKTool
234 215
         /// </summary>
235 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 224
                 StylusTip = StylusTip.Rectangle,
244 225
                 //FitToCurve = true,
245 226
                 IsHighlighter = false,
246 227
                 IgnorePressure = true,
247 228
             };
248
-            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
229
+            blackboard_canvas.DefaultDrawingAttributes = _drawingAttributes;
249 230
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
250 231
             blackboard_canvas.Cursor = Cursors.Cross;
251 232
         }
@@ -255,133 +236,22 @@ namespace XHWK.WKTool
255 236
         /// </summary>
256 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 245
                 StylusTip = StylusTip.Rectangle,
265 246
                 //FitToCurve = true,
266 247
                 IsHighlighter = false,
267 248
                 IgnorePressure = true,
268 249
             };
269
-            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
250
+            blackboard_canvas.DefaultDrawingAttributes = _drawingAttributes;
270 251
             blackboard_canvas.EditingMode = InkCanvasEditingMode.None;
271 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 255
         /// <summary>
386 256
         /// 鼠标中键点击
387 257
         /// </summary>
@@ -401,19 +271,6 @@ namespace XHWK.WKTool
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 274
         private void blackboard_canvas_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
418 275
         {
419 276
             if (APP.W_ScreenRecordingToolbarWindow.flg == 10)
@@ -424,6 +281,7 @@ namespace XHWK.WKTool
424 281
             {
425 282
                 APP.W_ScreenRecordingToolbarWindow.flg = 1;
426 283
             }
284
+
427 285
             ReturnPractice();
428 286
             //模拟切到ppt
429 287
             SwitchPages();
@@ -436,20 +294,17 @@ namespace XHWK.WKTool
436 294
         public void ReturnPractice()
437 295
         {
438 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 301
                 Thread.Sleep(500);
447 302
                 Dispatcher.Invoke(() =>
448 303
                 {
449 304
                     Owner = null;
450 305
                     APP.W_PracticeWindow.Hide();
451 306
                 });
452
-            }))).Start();
307
+            }).Start();
453 308
         }
454 309
 
455 310
         #region 点阵笔相关
@@ -458,291 +313,17 @@ namespace XHWK.WKTool
458 313
 
459 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 316
         ///// <summary>
472 317
         ///// 画板
473 318
         ///// </summary>
474 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 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 328
         /// <summary>
748 329
         /// 引用user32.dll动态链接库(windows api),
@@ -759,21 +340,21 @@ namespace XHWK.WKTool
759 340
         /// <summary>
760 341
         /// 是否在书写
761 342
         /// </summary>
762
-        private bool isTQLPenDown = false;
343
+        private bool _isTqlPenDown;
763 344
 
764 345
         /// <summary>
765 346
         /// TQL点阵笔宽高
766 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 354
         /// <summary>
774 355
         /// 初始化
775 356
         /// </summary>
776
-        public void InitTQLPPen()
357
+        public void InitTqlpPen()
777 358
         {
778 359
             if (APP.TQLPenevents == null)
779 360
             {
@@ -788,33 +369,35 @@ namespace XHWK.WKTool
788 369
         /// <summary>
789 370
         /// 笔落下
790 371
         /// </summary>
791
-        public void TQLDown()
372
+        public void TqlDown()
792 373
         {
793
-            isTQLPenDown = true;
374
+            _isTqlPenDown = true;
794 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 386
         /// <summary>
805 387
         /// 笔抬起
806 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 403
         /// <summary>
@@ -823,69 +406,69 @@ namespace XHWK.WKTool
823 406
         /// <param name="cx"></param>
824 407
         /// <param name="cy"></param>
825 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 411
             if (this.Visibility == Visibility.Visible)
829 412
             {
830 413
                 //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
831
-                if (!isTQLPenDown)
414
+                if (!_isTqlPenDown)
832 415
                 {
833 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 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 440
                                 FitToCurve = true,
858 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 452
                     else
870 453
                     {
871 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 465
                                 FitToCurve = true,
883 466
                                 IgnorePressure = false
884 467
                             };
885
-                            strokes.DrawingAttributes = drawing;
468
+                            _strokes.DrawingAttributes = _drawing;
886 469
 
887 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,9 +476,10 @@ namespace XHWK.WKTool
893 476
                     if (tempX > 0 && tempY > 0)
894 477
                     {
895 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 查看文件

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

+ 37
- 70
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs 查看文件

@@ -113,15 +113,12 @@ namespace XHWK.WKTool
113 113
                 //practiceWin.Owner = this;
114 114
             }
115 115
 
116
-            APP.W_PracticeWindow.InitTQLPPen();
116
+            APP.W_PracticeWindow.InitTqlpPen();
117 117
             APP.W_PracticeWindow.Show();
118 118
             new Thread(new ThreadStart(new Action(() =>
119 119
             {
120 120
                 Thread.Sleep(100);
121
-                Dispatcher.Invoke(() =>
122
-                {
123
-                    Topmost = true;
124
-                });
121
+                Dispatcher.Invoke(() => { Topmost = true; });
125 122
             }))).Start();
126 123
             APP.W_PracticeWindow.Hide();
127 124
 
@@ -140,8 +137,8 @@ namespace XHWK.WKTool
140 137
             BtnRecordingScreen.Visibility = Visibility.Visible;
141 138
             BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
142 139
             BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
143
-            BtnPenBlue.IsEnabled = false;//蓝笔不可点击
144
-            BtnPenRed.IsEnabled = false;//红笔不可点击
140
+            BtnPenBlue.IsEnabled = false; //蓝笔不可点击
141
+            BtnPenRed.IsEnabled = false; //红笔不可点击
145 142
             BtnPenBlue.Visibility = Visibility.Visible;
146 143
             BtnPenRed.Visibility = Visibility.Visible;
147 144
             BtnPenBlue_CL.Visibility = Visibility.Collapsed;
@@ -156,6 +153,7 @@ namespace XHWK.WKTool
156 153
                 //开始,暂停
157 154
                 BtnRecordingScreen_Click(null, null);
158 155
             }
156
+
159 157
             if (e.KeyValue == (int)Keys.F6 && (int)Control.ModifierKeys == (int)Keys.Control)
160 158
             {
161 159
                 //结束
@@ -232,7 +230,7 @@ namespace XHWK.WKTool
232 230
         //桌面录制
233 231
         private ZVideoRecordHelper helper0 = null;
234 232
 
235
-        public IntPtr winHandle;// 当前窗体指针
233
+        public IntPtr winHandle; // 当前窗体指针
236 234
 
237 235
         /// <summary>
238 236
         /// 开始或暂停录制
@@ -295,18 +293,19 @@ namespace XHWK.WKTool
295 293
                 {
296 294
                     APP.W_CountdownWindow.Initialize(true, 3000);
297 295
                 }
296
+
298 297
                 APP.W_CountdownWindow.Show();
299 298
 
300 299
                 BtnRecordingScreen.Visibility = Visibility.Collapsed;
301 300
                 BtnRecordingScreenPause.Visibility = Visibility.Visible;
302 301
                 BtnStopRecordingScreen.IsEnabled = true; //停止录制按钮可点击
303
-                BtnPenBlue.IsEnabled = true;//蓝笔可点击
304
-                BtnPenRed.IsEnabled = true;//红笔可点击
302
+                BtnPenBlue.IsEnabled = true; //蓝笔可点击
303
+                BtnPenRed.IsEnabled = true; //红笔可点击
305 304
                 BtnPenBlue.Visibility = Visibility.Visible;
306 305
                 BtnPenRed.Visibility = Visibility.Visible;
307 306
                 BtnPenBlue_CL.Visibility = Visibility.Collapsed;
308 307
                 BtnPenRed_CL.Visibility = Visibility.Collapsed;
309
-                TxbTime.Visibility = Visibility.Visible;//时间显示
308
+                TxbTime.Visibility = Visibility.Visible; //时间显示
310 309
 
311 310
                 #region 隐藏工具栏
312 311
 
@@ -316,6 +315,7 @@ namespace XHWK.WKTool
316 315
                     {
317 316
                         APP.W_MinToolbar = new MinToolbar();
318 317
                     }
318
+
319 319
                     APP.W_MinToolbar.Topmost = true;
320 320
                     double MinToolTop = Top;
321 321
                     GridSrToobar.Visibility = Visibility.Hidden;
@@ -347,7 +347,7 @@ namespace XHWK.WKTool
347 347
                     helper1.StartRecordAudio();
348 348
                     helper2.StartRecordAudio();
349 349
                     helper0.StartRecordVideo();
350
-                    k_hook.Start();//安装键盘钩子
350
+                    k_hook.Start(); //安装键盘钩子
351 351
                 }
352 352
                 catch (Exception)
353 353
                 {
@@ -397,6 +397,7 @@ namespace XHWK.WKTool
397 397
             {
398 398
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
399 399
             }
400
+
400 401
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
401 402
 
402 403
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
@@ -407,6 +408,7 @@ namespace XHWK.WKTool
407 408
                 t.Stop();
408 409
                 t = null;
409 410
             }
411
+
410 412
             helper0.StopRecordVideo();
411 413
             helper1.StopRecordAudio();
412 414
             helper2.StopRecordAudio();
@@ -457,6 +459,7 @@ namespace XHWK.WKTool
457 459
             {
458 460
                 APP.W_XHMicroLessonSystemWindow = new MainWindow();
459 461
             }
462
+
460 463
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
461 464
 
462 465
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
@@ -476,7 +479,8 @@ namespace XHWK.WKTool
476 479
                 {
477 480
                     FFMpegConverter ffMpeg = new FFMpegConverter();
478 481
 
479
-                    FFMpegInput[] input = new FFMpegInput[] {
482
+                    FFMpegInput[] input = new FFMpegInput[]
483
+                    {
480 484
                         new FFMpegInput(TempVideoPathName),
481 485
                         new FFMpegInput(TempAudioPathName1),
482 486
                         new FFMpegInput(TempAudioPathName2),
@@ -498,7 +502,9 @@ namespace XHWK.WKTool
498 502
                         string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
499 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 509
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
504 510
                         VideoInfo.VideoPath = VideoSavePathName;
@@ -507,7 +513,8 @@ namespace XHWK.WKTool
507 513
                         VideoInfo.FileGuid = Guid.NewGuid().ToString();
508 514
                         VideoInfo.IsUpload = false;
509 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 519
                             APP.VideoList.Add(VideoInfo);
513 520
                             //保存数据
@@ -522,6 +529,7 @@ namespace XHWK.WKTool
522 529
                     FileToolsCommon.DeleteDirectory(temppath);
523 530
                 }))).Start();
524 531
             }
532
+
525 533
             Click_stopRecordingScreen();
526 534
             Hide();
527 535
 
@@ -534,7 +542,8 @@ namespace XHWK.WKTool
534 542
             Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
535 543
             float DIP = graphics.DpiX;
536 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 547
             GridSrToobar.Visibility = Visibility.Visible;
539 548
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
540 549
         }
@@ -585,7 +594,7 @@ namespace XHWK.WKTool
585 594
                             };
586 595
                         }
587 596
 
588
-                        APP.W_PracticeWindow.Initialize();// imagePath);
597
+                        APP.W_PracticeWindow.Initialize(); // imagePath);
589 598
                         flg = 11;
590 599
                         APP.W_PracticeWindow.Blue();
591 600
                         APP.W_PracticeWindow.Show();
@@ -595,15 +604,9 @@ namespace XHWK.WKTool
595 604
 
596 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 608
                         Thread.Sleep(500);
603
-                        Dispatcher.Invoke(() =>
604
-                        {
605
-                            Topmost = true;
606
-                        });
609
+                        Dispatcher.Invoke(() => { Topmost = true; });
607 610
                     }))).Start();
608 611
                 }
609 612
                 catch (Exception ex)
@@ -696,8 +699,8 @@ namespace XHWK.WKTool
696 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 704
                     flg = 11;
702 705
                     APP.W_PracticeWindow.Blue();
703 706
                     APP.W_PracticeWindow.Show();
@@ -740,46 +743,6 @@ namespace XHWK.WKTool
740 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 746
         #endregion 画笔相关
784 747
 
785 748
         #endregion 事件
@@ -872,8 +835,8 @@ namespace XHWK.WKTool
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 840
                     flg = 10;
878 841
                     APP.W_PracticeWindow.Red();
879 842
                     APP.W_PracticeWindow.Show();
@@ -909,8 +872,10 @@ namespace XHWK.WKTool
909 872
                 {
910 873
                     return;
911 874
                 }
875
+
912 876
                 BtnStopRecordingScreen_Click(null, null);
913 877
             }
878
+
914 879
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
915 880
             //APP.W_XHMicroLessonSystemWindow.InitPen();
916 881
             APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
@@ -952,6 +917,7 @@ namespace XHWK.WKTool
952 917
                     {
953 918
                         APP.W_MinToolbar = new MinToolbar();
954 919
                     }
920
+
955 921
                     APP.W_MinToolbar.Topmost = true;
956 922
                     double MinToolTop = Top;
957 923
 
@@ -961,7 +927,8 @@ namespace XHWK.WKTool
961 927
                         Dispatcher.Invoke(() =>
962 928
                         {
963 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 933
                                 //LblMessage.Content = "在区域内:("+ pointRecord.X+","+pointRecord.Y+") ("+ Left + ","+Top+")";
967 934
                             }

+ 1
- 1
XHWK.WKTool/UControl/Uc_VideoItem.xaml.cs 查看文件

@@ -326,7 +326,7 @@ namespace XHWK.WKTool.UControl
326 326
                 //BtnUpload.IsEnabled = false;
327 327
                 //BtnUpload.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9EA0A7"));
328 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 331
                 if (dAL_Upload.UploadVideo(VideoModel.FileGuid, out string ErrMessage))
332 332
                 {

+ 1
- 1
XHWK.WKTool/UploadWindow.xaml.cs 查看文件

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

+ 4
- 9
XHWK.WKTool/Utils/ZAudioRecordHelper.cs 查看文件

@@ -155,10 +155,7 @@ namespace XHWK.WKTool.Utils
155 155
                     mWaveIn = new WaveInEvent();
156 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 161
                     mWaveIn.RecordingStopped += (s, a) =>
@@ -187,10 +184,7 @@ namespace XHWK.WKTool.Utils
187 184
                     mCapture = new WasapiLoopbackCapture();
188 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 189
                     mCapture.RecordingStopped += (s, a) =>
196 190
                     {
@@ -211,13 +205,14 @@ namespace XHWK.WKTool.Utils
211 205
                     });
212 206
                 }
213 207
             }
214
-            catch (Exception ex)
208
+            catch (Exception)
215 209
             {
216 210
                 if (mWriter != null)
217 211
                 {
218 212
                     mWriter.Dispose();
219 213
                     mWriter = null;
220 214
                 }
215
+
221 216
                 return false;
222 217
             }
223 218
 

+ 2
- 2
XHWK.WKTool/Utils/ZVideoRecordHelper.cs 查看文件

@@ -58,11 +58,11 @@ namespace XHWK.WKTool.Utils
58 58
                 }
59 59
 
60 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 62
                 videoStreamer.NewFrame += VideoNewFrame;
63 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 查看文件

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

Loading…
取消
儲存