Преглед изворни кода

打印变更

UI优化
tags/录制修改前^0
张剑 пре 3 година
родитељ
комит
484bbe5f83

+ 98
- 30
XHWK.WKTool/App.cs Прегледај датотеку

@@ -24,167 +24,210 @@ namespace XHWK.WKTool
24 24
     public partial class APP : Application
25 25
     {
26 26
         #region 全局变量
27
+
27 28
         #region 更新需改动
29
+
28 30
         /// <summary>
29 31
         /// 是否为测试版
30 32
         /// </summary>
31 33
         public static bool isDebug = FileToolsCommon.GetConfigValue("IsDebug") != "0";
34
+
32 35
         /// <summary>
33 36
         /// 参数是否加密
34 37
         /// </summary>
35 38
         public static bool IsParameterEncryption = FileToolsCommon.GetConfigValue("IsParameterEncryption") != "0";
36
-        #endregion
39
+
40
+        #endregion 更新需改动
37 41
 
38 42
         #region 接口地址
43
+
39 44
         /// <summary>
40 45
         /// 是否为校外接口
41 46
         /// </summary>
42 47
         public static bool IsOutsideSchool = FileToolsCommon.GetConfigValue("IsOutsideSchool") == "1";
48
+
43 49
         /// <summary>
44 50
         /// 服务地址
45 51
         /// </summary>
46 52
         public static Model_ServiceAddress ServiceAddress = null;
53
+
47 54
         /// <summary>
48 55
         /// 接口地址
49 56
         /// </summary>
50 57
         public static string apiUrl = isDebug ? "http://schoolapitest.xhkjedu.com" : FileToolsCommon.GetConfigValue("APIRequestAddress");
58
+
51 59
         /// <summary>
52 60
         /// 图片地址
53 61
         /// </summary>
54 62
         public static string uploadUrl = isDebug ? "http://schoolfiletest.xhkjedu.com/" : FileToolsCommon.GetConfigValue("FileRequestAddress");
63
+
55 64
         /// <summary>
56 65
         /// 展示文件
57 66
         /// </summary>
58 67
         public static string showImageUrl = isDebug ? "http://schoolfiletest.xhkjedu.com/static/" : FileToolsCommon.GetConfigValue("SchoolfileRequestAddress") + "/static/";
68
+
59 69
         /// <summary>
60 70
         /// 认证接口地址
61 71
         /// </summary>
62 72
         public static string certapiUrl = isDebug ? "http://certapitest.xhkjedu.com" : FileToolsCommon.GetConfigValue("CertapiRequestAddress");
63
-        #endregion
73
+
74
+        #endregion 接口地址
64 75
 
65 76
         #region 配置项
77
+
66 78
         /// <summary>
67 79
         /// 是否输出测试记录日志
68 80
         /// </summary>
69 81
         public static bool IsOutputInfoLog = FileToolsCommon.GetConfigValue("IsOutputInfoLog") != "0";
82
+
70 83
         /// <summary>
71 84
         /// 是否隐藏录屏工具栏
72 85
         /// </summary>
73 86
         public static bool IsHideSRTool = FileToolsCommon.GetConfigValue("IsHideSRTool") != "0";
87
+
74 88
         /// <summary>
75 89
         /// 皮肤样式 0白 1蓝 2黑色
76 90
         /// </summary>
77 91
         public static string SkinStyle = FileToolsCommon.GetConfigValue("SkinStyle");
92
+
78 93
         /// <summary>
79 94
         /// 数据存放目录
80 95
         /// </summary>
81 96
         public static string DataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XHMicroLesson\\";
97
+
82 98
         /// <summary>
83 99
         /// 摄像头位置
84 100
         /// </summary>
85 101
         public static string CameraPosition = string.Empty;
102
+
86 103
         /// <summary>
87 104
         /// 摄像头名
88 105
         /// </summary>
89 106
         public static string CameraName = "";
107
+
90 108
         /// <summary>
91 109
         /// 麦克风名
92 110
         /// </summary>
93 111
         public static string MicrophoneName = "";
94
-        #endregion
112
+
113
+        #endregion 配置项
95 114
 
96 115
         #region 记录数据
116
+
97 117
         /// <summary>
98 118
         /// 全局页面数据变量
99 119
         /// </summary>
100 120
         public static readonly Model_Page PageContextData = new Model.Model_Page();
121
+
101 122
         /// <summary>
102 123
         /// 录屏工具
103 124
         /// </summary>
104 125
         public static FFMpeg FFmpeg = new FFMpeg();
126
+
105 127
         /// <summary>
106 128
         /// 后台线程帮助类
107 129
         /// </summary>
108 130
         public static BackgroundWorkerHelper BackgroundWorkerHelper => BackgroundWorkerHelper.GetInstance();
131
+
109 132
         /// <summary>
110 133
         /// 签名
111 134
         /// </summary>
112 135
         public static string Signature = "";
136
+
113 137
         public static string secretKey = "nanhuakaizhangjianwangni";
138
+
114 139
         /// <summary>
115 140
         /// 用户信息
116 141
         /// </summary>
117 142
         public static Model_UserInfo UserInfo = null;
143
+
118 144
         /// <summary>
119 145
         /// 接口返回消息
120 146
         /// </summary>
121 147
         public static string ServerMsg = string.Empty;
148
+
122 149
         /// <summary>
123 150
         /// 登录状态 false 未登录 true已登录
124 151
         /// </summary>
125 152
         public static bool IsLoginType = false;
153
+
126 154
         /// <summary>
127 155
         /// 截图地址
128 156
         /// </summary>
129 157
         public static string ImgPath = string.Empty;
158
+
130 159
         /// <summary>
131 160
         /// 教材列表
132 161
         /// </summary>
133 162
         public static List<Model_TsubjectbookList> TsubjectbookList = null;
163
+
134 164
         /// <summary>
135 165
         /// 章节列表
136 166
         /// </summary>
137 167
         public static List<Model_DirectorList> DirectorList = null;
168
+
138 169
         /// <summary>
139 170
         /// 上传个人空间 入参
140 171
         /// </summary>
141 172
         public static Model_ResourceAddTwo ResourceAddTwo = null;
173
+
142 174
         /// <summary>
143 175
         /// 是否正在上传
144 176
         /// </summary>
145 177
         public static bool IsUpLoad = false;
146
-        #endregion
178
+
179
+        #endregion 记录数据
147 180
 
148 181
         #region 微课数据记录
182
+
149 183
         /// <summary>
150 184
         /// 用户微课列表模型
151 185
         /// </summary>
152 186
         public static List<Model_WKData> WKDataList = null;
187
+
153 188
         /// <summary>
154 189
         /// 微课模型
155 190
         /// </summary>
156 191
         public static Model_WKData WKData = null;
192
+
157 193
         /// <summary>
158 194
         /// 微课视频列表
159 195
         /// </summary>
160 196
         public static List<Model_Video> VideoList = null;
197
+
161 198
         /// <summary>
162 199
         /// 画板模型
163 200
         /// </summary>
164 201
         public static List<Model_DrawData> PageDrawList = null;
165 202
 
166
-        #endregion
203
+        #endregion 微课数据记录
167 204
 
168 205
         #region 点阵笔
206
+
169 207
         /// <summary>
170 208
         /// 点阵笔
171 209
         /// </summary>
172 210
         public static DigitalPenHID digitalPen;
211
+
173 212
         /// <summary>
174 213
         /// 笔序号
175 214
         /// </summary>
176 215
         public static string PenSerial;
216
+
177 217
         /// <summary>
178 218
         /// 笔状态,是否已连接
179 219
         /// </summary>
180 220
         public static bool PenStatus = false;
221
+
181 222
         /// <summary>
182 223
         /// 手写板状态,是否已连接
183 224
         /// </summary>
184 225
         public static bool BoardStatus = false;
185
-        #endregion
226
+
227
+        #endregion 点阵笔
186 228
 
187 229
         #region 腾千里手写笔
230
+
188 231
         ///// <summary>
189 232
         ///// 铺码服务请求
190 233
         ///// </summary>
@@ -193,89 +236,99 @@ namespace XHWK.WKTool
193 236
         /// 腾千里手写笔事件
194 237
         /// </summary>
195 238
         public static PenEvents TQLPenevents;
239
+
196 240
         /// <summary>
197 241
         /// 腾千里手写笔是否已连接
198 242
         /// </summary>
199 243
         public static bool TQLPenStatus = false;
200 244
 
201 245
         #region 打印
246
+
202 247
         public static bool gbGenerateBGWithVImage = false;
203 248
         public static bool gbGenerateVImage = false;
204 249
         public static bool gbGenerateBGWithoutVImage = false;
205 250
         public static bool gbGenerateBGWithImage = false;
206 251
         public static bool gbGenPageSet = false;
207
-        public static int[] gPointType = new int[4];
208
-        public static int[] gPointDPI = new int[4];
252
+        public static int[] gPointType = new int[5];
253
+        public static int[] gPointDPI = new int[5];
209 254
         public static string gTMXElementFileName;
210 255
         public static string gNewProjectDirectory;
211 256
         public static bool gbElementFileExist { get; set; }
212
-        #endregion
213 257
 
214
-        #endregion
258
+        #endregion 打印
259
+
260
+        #endregion 腾千里手写笔
215 261
 
216 262
         #region 页面
263
+
217 264
         /// <summary>
218 265
         /// 主页面
219 266
         /// </summary>
220 267
         public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
268
+
221 269
         /// <summary>
222 270
         /// 创建微课页面
223 271
         /// </summary>
224 272
         public static CreateAMicroLessonWindow W_CreateAMicroLessonWindow = null;
273
+
225 274
         /// <summary>
226 275
         /// 开始录像
227 276
         /// </summary>
228 277
         public static CountdownWindow W_CountdownWindow = null;
278
+
229 279
         /// <summary>
230 280
         /// 录像工具栏
231 281
         /// </summary>
232 282
         public static ScreenRecordingToolbarWindow W_ScreenRecordingToolbarWindow = null;
283
+
233 284
         /// <summary>
234 285
         /// 登录
235 286
         /// </summary>
236 287
         public static LoginWindow W_LoginWindow = null;
288
+
237 289
         /// <summary>
238 290
         /// 截图
239 291
         /// </summary>
240 292
         public static JieTuWindow W_JieTuWindow = null;
293
+
241 294
         /// <summary>
242 295
         /// 批注
243 296
         /// </summary>
244 297
         public static PracticeWindow W_PracticeWindow = null;
245
-        /// <summary>
246
-        /// 我的视频
247
-        /// </summary>
248
-        public static FileDirectoryWindow fileDirectoryWindow = null;
249
-        /// <summary>
250
-        /// 打印
251
-        /// </summary>
252
-        public static PrintWindow W_PrintWindow = null;
298
+
253 299
         /// <summary>
254 300
         /// 提示窗口
255 301
         /// </summary>
256 302
         public static PromptWindow W_PromptWindow = null;
303
+
257 304
         /// <summary>
258 305
         /// loding页面
259 306
         /// </summary>
260 307
         public static LoadDialog myloading;
308
+
261 309
         /// <summary>
262 310
         /// 上传页面
263 311
         /// </summary>
264 312
         public static UploadWindow W_UploadWindow = null;
313
+
265 314
         /// <summary>
266 315
         /// 最小化工具栏
267 316
         /// </summary>
268 317
         public static MinToolbar W_MinToolbar = null;
318
+
269 319
         /// <summary>
270 320
         /// 视频剪辑
271 321
         /// </summary>
272 322
         public static VideoClipWindow W_VideoClipWindow = null;
323
+
273 324
         /// <summary>
274 325
         /// 设备检测
275 326
         /// </summary>
276 327
         public static DeviceWindow W_DeviceWindow = null;
277
-        #endregion
278
-        #endregion
328
+
329
+        #endregion 页面
330
+
331
+        #endregion 全局变量
279 332
 
280 333
         [STAThread]
281 334
         private static void Main()
@@ -290,7 +343,9 @@ namespace XHWK.WKTool
290 343
                 UserInfo = new Model_UserInfo();
291 344
                 WKDataList = new List<Model_WKData>();
292 345
                 VideoList = new List<Model_Video>();
346
+
293 347
                 #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
348
+
294 349
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
295 350
                 WindowsPrincipal principal = new WindowsPrincipal(identity);
296 351
                 //判断当前登录用户是否为管理员
@@ -327,7 +382,9 @@ namespace XHWK.WKTool
327 382
                 //    Environment.Exit(0);
328 383
 
329 384
                 //}
330
-                #endregion
385
+
386
+                #endregion 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
387
+
331 388
                 try
332 389
                 {
333 390
                     if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "Temp"))//清除临时文件
@@ -374,7 +431,6 @@ namespace XHWK.WKTool
374 431
                         //退出
375 432
                         //Current.Shutdown();
376 433
                         Environment.Exit(0);
377
-
378 434
                     }
379 435
                 }
380 436
                 else
@@ -408,20 +464,18 @@ namespace XHWK.WKTool
408 464
                         //退出
409 465
                         //Current.Shutdown();
410 466
                         Environment.Exit(0);
411
-
412 467
                     }
413
-
414 468
                 }
415 469
             }
416 470
             catch (Exception ex)
417 471
             {
418
-
419 472
                 string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
420 473
                 LogHelper.WriteErrLog(ErrMessage, ex);
421 474
             }
422 475
         }
423 476
 
424 477
         #region 杀死已存在的进程
478
+
425 479
         /// <summary>
426 480
         /// 结束已运行的程序
427 481
         /// </summary>
@@ -446,6 +500,7 @@ namespace XHWK.WKTool
446 500
                 }
447 501
             }
448 502
         }
503
+
449 504
         /// <summary>
450 505
         /// 杀死正在运行的ffmpeg
451 506
         /// </summary>
@@ -457,7 +512,8 @@ namespace XHWK.WKTool
457 512
                 KillProcess.Kill();
458 513
             }
459 514
         }
460
-        #endregion
515
+
516
+        #endregion 杀死已存在的进程
461 517
 
462 518
         /// <summary>
463 519
         /// 错误处理
@@ -472,6 +528,7 @@ namespace XHWK.WKTool
472 528
         }
473 529
 
474 530
         #region 数据保存和读取
531
+
475 532
         /// <summary>
476 533
         /// 保存微课信息
477 534
         /// </summary>
@@ -503,8 +560,9 @@ namespace XHWK.WKTool
503 560
                 LogHelper.WriteErrLog("【微课数据保存】(SaveWkData)保存失败:" + ex.Message, ex);
504 561
             }
505 562
         }
563
+
506 564
         /// <summary>
507
-        /// 读取微课信息 
565
+        /// 读取微课信息
508 566
         /// </summary>
509 567
         public static void ReadWkData(string WkPath)
510 568
         {
@@ -540,6 +598,7 @@ namespace XHWK.WKTool
540 598
                 LogHelper.WriteErrLog("【微课数据读取】(ReadWkData)读取失败:" + ex.Message, ex);
541 599
             }
542 600
         }
601
+
543 602
         /// <summary>
544 603
         /// 保存画板数据
545 604
         /// </summary>
@@ -566,6 +625,7 @@ namespace XHWK.WKTool
566 625
                 LogHelper.WriteErrLog("【画板数据保存】(SaveDraw)保存失败:" + ex.Message, ex);
567 626
             }
568 627
         }
628
+
569 629
         /// <summary>
570 630
         /// 读取文件
571 631
         /// </summary>
@@ -586,9 +646,11 @@ namespace XHWK.WKTool
586 646
                 LogHelper.WriteErrLog("【画板数据读取】(ReadDraw)读取失败:" + ex.Message, ex);
587 647
             }
588 648
         }
589
-        #endregion
649
+
650
+        #endregion 数据保存和读取
590 651
 
591 652
         #region 服务地址数据
653
+
592 654
         /// <summary>
593 655
         /// 服务地址存储到本地
594 656
         /// </summary>
@@ -612,6 +674,7 @@ namespace XHWK.WKTool
612 674
                 LogHelper.WriteErrLog("【服务地址存储】(SaveServiceAddressData)保存失败:" + ex.Message, ex);
613 675
             }
614 676
         }
677
+
615 678
         /// <summary>
616 679
         /// 从本地读取服务地址
617 680
         /// </summary>
@@ -635,6 +698,7 @@ namespace XHWK.WKTool
635 698
                 LogHelper.WriteErrLog("【服务地址读取】(ReadServiceAddressData)读取失败:" + ex.Message, ex);
636 699
             }
637 700
         }
701
+
638 702
         /// <summary>
639 703
         /// 切换校内外网
640 704
         /// </summary>
@@ -651,9 +715,11 @@ namespace XHWK.WKTool
651 715
                 LogHelper.WriteErrLog("【服务地址切换】(SwitchAddress)服务复制切换失败,请求地址为空!", ex);
652 716
             }
653 717
         }
654
-        #endregion
718
+
719
+        #endregion 服务地址数据
655 720
 
656 721
         #region 检测安装Screen Capturer Recorder
722
+
657 723
         /// <summary>
658 724
         /// 检测是否安装了Screen Capturer Recorder
659 725
         /// </summary>
@@ -670,6 +736,7 @@ namespace XHWK.WKTool
670 736
                 return false;
671 737
             }
672 738
         }
739
+
673 740
         /// <summary>
674 741
         /// 安装Screen Capturer Recorder
675 742
         /// </summary>
@@ -727,6 +794,7 @@ namespace XHWK.WKTool
727 794
                 return false;
728 795
             }
729 796
         }
797
+
730 798
         /// <summary>
731 799
         /// 安装失败信息
732 800
         /// </summary>
@@ -738,7 +806,7 @@ namespace XHWK.WKTool
738 806
             //MessageWindow.Show(e.Data);
739 807
         }
740 808
 
741
-        #endregion
809
+        #endregion 检测安装Screen Capturer Recorder
742 810
 
743 811
         #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
744 812
 

+ 661
- 154
XHWK.WKTool/DeviceWindow.xaml
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 33
- 219
XHWK.WKTool/FileDirectoryWindow.xaml.cs Прегледај датотеку

@@ -11,6 +11,7 @@ using System.Windows.Media;
11 11
 
12 12
 using XHWK.Model;
13 13
 using XHWK.WKTool.DAL;
14
+using XHWK.WKTool.Models;
14 15
 
15 16
 namespace XHWK.WKTool
16 17
 {
@@ -23,18 +24,22 @@ namespace XHWK.WKTool
23 24
         /// 视频模型
24 25
         /// </summary>
25 26
         private List<Model_Video> model_VideoList = null;
27
+
26 28
         /// <summary>
27 29
         /// 数据列表
28 30
         /// </summary>
29 31
         internal FileDirectoryData pageData = new FileDirectoryData();
32
+
30 33
         /// <summary>
31 34
         /// 下标
32 35
         /// </summary>
33 36
         private int Subscript = 0;
37
+
34 38
         /// <summary>
35 39
         /// 是否是修改状态
36 40
         /// </summary>
37 41
         private bool IsModify = false;
42
+
38 43
         /// <summary>
39 44
         /// 文件目录
40 45
         /// </summary>
@@ -43,6 +48,7 @@ namespace XHWK.WKTool
43 48
             InitializeComponent();
44 49
             Initialize();
45 50
         }
51
+
46 52
         /// <summary>
47 53
         /// 初始化
48 54
         /// </summary>
@@ -111,14 +117,13 @@ namespace XHWK.WKTool
111 117
                     }); ;
112 118
                 }
113 119
 
114
-
115
-
116 120
                 i++;
117 121
             }
118 122
             txbSum.Text = pageData.menuList.Count.ToString();
119 123
             APP.myloading.Hide();
120 124
             DataContext = pageData;
121 125
         }
126
+
122 127
         /// <summary>
123 128
         /// 加载视频列表
124 129
         /// </summary>
@@ -161,6 +166,7 @@ namespace XHWK.WKTool
161 166
                 LogHelper.WriteErrLog("【加载视频列表】(LoadingVideoList)" + ex.Message, ex);
162 167
             }
163 168
         }
169
+
164 170
         /// <summary>
165 171
         /// 关闭
166 172
         /// </summary>
@@ -171,6 +177,7 @@ namespace XHWK.WKTool
171 177
             APP.SaveWkData();
172 178
             Hide();
173 179
         }
180
+
174 181
         /// <summary>
175 182
         /// 窗口移动
176 183
         /// </summary>
@@ -180,6 +187,7 @@ namespace XHWK.WKTool
180 187
         {
181 188
             DragMove();
182 189
         }
190
+
183 191
         /// <summary>
184 192
         /// 上传
185 193
         /// </summary>
@@ -208,11 +216,10 @@ namespace XHWK.WKTool
208 216
                     {
209 217
                         MessageWindow.Show(ErrMessage);
210 218
                     }
211
-
212
-
213 219
                 }
214 220
             }
215 221
         }
222
+
216 223
         /// <summary>
217 224
         /// 删除
218 225
         /// </summary>
@@ -220,14 +227,12 @@ namespace XHWK.WKTool
220 227
         /// <param name="e"></param>
221 228
         private void BtnDelete_Click(object sender, RoutedEventArgs e)
222 229
         {
223
-
224 230
             pageData.menuList[Subscript].IsEnabled = false;
225 231
             List<Button> buttons = FindChilds<Button>(listView1, "btnDelete");
226 232
             for (int i = 0; i < buttons.Count; i++)
227 233
             {
228 234
                 if (buttons[i] == sender)
229 235
                 {
230
-
231 236
                     //if (APP.W_PromptWindow == null)
232 237
                     //{
233 238
                     //    APP.W_PromptWindow = new PromptWindow();
@@ -263,6 +268,7 @@ namespace XHWK.WKTool
263 268
                 }
264 269
             }
265 270
         }
271
+
266 272
         /// <summary>
267 273
         /// 播放
268 274
         /// </summary>
@@ -337,6 +343,7 @@ namespace XHWK.WKTool
337 343
 
338 344
             return list;
339 345
         }
346
+
340 347
         /// <summary>
341 348
         /// 修改
342 349
         /// </summary>
@@ -395,55 +402,25 @@ namespace XHWK.WKTool
395 402
 
396 403
         private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
397 404
         {
398
-            //    if (IsModify)
399
-            //    {
400
-            //        if (MouseNumber > 0 && pageData.menuList.Count > Subscript)
401
-            //        {
402
-            //        MouseNumber = 0;
403
-            //            pageData.menuList[Subscript].IsEnabled = false;
404
-            //            try
405
-            //            {
406
-            //                if (!pageData.menuList[Subscript].Name.Equals(pageData.menuList[Subscript].VideoName))
407
-            //                {
408
-            //                    MouseNumber = 0;
409
-            //                    string tempPath = pageData.menuList[Subscript].FilePath + pageData.menuList[Subscript].VideoName + "." + pageData.menuList[Subscript].VideoType;
410
-            //                    if (FileToolsCommon.IsExistFile(tempPath))
411
-            //                    {
412
-            //                        MessageWindow.Show("文件名已存在!");
413
-            //                        return;
414
-            //                    }
415
-            //                    foreach (Model_WKData wKData in APP.WKDataList)
416
-            //                    {
417
-            //                        if (wKData.VideoList == null)
418
-            //                            continue;
419
-            //                        if (wKData.VideoList.Exists(x => x.FileGuid == pageData.menuList[Subscript].FileGuid))
420
-            //                        {
421
-            //                            try
422
-            //                            {
423
-            //                                //FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[Subscript].FileGuid).VideoPath);
424
-            //                                //FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[Subscript].FileGuid).ThumbnailPath);
425
-            //                                //wKData.VideoList.Remove(wKData.VideoList.Find(x => x.FileGuid == pageData.menuList[Subscript].FileGuid));
426
-            //                                //Initialize();
427
-            //                                //return;
428
-            //                            }
429
-            //                            catch (Exception ex)
430
-            //                            {
431
-            //                                MessageWindow.Show("无法删除视频!" + ex.Message);
432
-            //                                return;
433
-            //                            }
434
-            //                        }
435
-            //                    }
436
-            //                    FileToolsCommon.Copy(pageData.menuList[Subscript].Path, tempPath);
437
-            //                }
438
-            //            }
439
-            //            catch (Exception ex)
440
-            //            {
441
-            //                MessageWindow.Show("无法修改视频名称!" + ex.Message);
442
-            //                return;
443
-            //            }
444
-            //        }
445
-            //        MouseNumber++;
446
-            //    }
405
+            // if (IsModify) { if (MouseNumber > 0 && pageData.menuList.Count > Subscript) {
406
+            // MouseNumber = 0; pageData.menuList[Subscript].IsEnabled = false; try { if
407
+            // (!pageData.menuList[Subscript].Name.Equals(pageData.menuList[Subscript].VideoName)) {
408
+            // MouseNumber = 0; string tempPath = pageData.menuList[Subscript].FilePath +
409
+            // pageData.menuList[Subscript].VideoName + "." +
410
+            // pageData.menuList[Subscript].VideoType; if (FileToolsCommon.IsExistFile(tempPath)) {
411
+            // MessageWindow.Show("文件名已存在!"); return; } foreach (Model_WKData wKData in
412
+            // APP.WKDataList) { if (wKData.VideoList == null) continue; if
413
+            // (wKData.VideoList.Exists(x => x.FileGuid == pageData.menuList[Subscript].FileGuid)) {
414
+            // try { //FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid ==
415
+            // pageData.menuList[Subscript].FileGuid).VideoPath);
416
+            // //FileToolsCommon.DeleteFile(wKData.VideoList.Find(x => x.FileGuid ==
417
+            // pageData.menuList[Subscript].FileGuid).ThumbnailPath);
418
+            // //wKData.VideoList.Remove(wKData.VideoList.Find(x => x.FileGuid ==
419
+            // pageData.menuList[Subscript].FileGuid)); //Initialize(); //return; } catch (Exception
420
+            // ex) { MessageWindow.Show("无法删除视频!" + ex.Message); return; } } }
421
+            // FileToolsCommon.Copy(pageData.menuList[Subscript].Path, tempPath); } } catch
422
+            // (Exception ex) { MessageWindow.Show("无法修改视频名称!" + ex.Message); return; } }
423
+            // MouseNumber++; }
447 424
         }
448 425
 
449 426
         /// <summary>
@@ -483,168 +460,5 @@ namespace XHWK.WKTool
483 460
                 return true;
484 461
             }
485 462
         }
486
-
487
-    }
488
-
489
-    public class FileDirectoryData : NotifyModel
490
-    {
491
-        public ObservableCollection<FileDirectoryModel> menuList { get; set; }
492
-
493
-        public FileDirectoryData()
494
-        {
495
-            menuList = new ObservableCollection<FileDirectoryModel>();
496
-        }
497
-    }
498
-
499
-    public class FileDirectoryModel : NotifyModel
500
-    {
501
-        private int _serialNumber;
502
-        /// <summary>
503
-        /// 序号
504
-        /// </summary>
505
-        public int SerialNumber
506
-        {
507
-            get => _serialNumber;
508
-            set
509
-            {
510
-                _serialNumber = value;
511
-                OnPropertyChanged("SerialNumber");
512
-            }
513
-        }
514
-        private string _videoName;
515
-        /// <summary>
516
-        /// 视频名称
517
-        /// </summary>
518
-        public string VideoName
519
-        {
520
-            get => _videoName;
521
-            set
522
-            {
523
-                _videoName = value;
524
-                OnPropertyChanged("VideoName");
525
-            }
526
-        }
527
-        private int _videoDuration;
528
-        /// <summary>
529
-        /// 视频时长
530
-        /// </summary>
531
-        public int VideoDuration
532
-        {
533
-            get => _videoDuration;
534
-            set
535
-            {
536
-                _videoDuration = value;
537
-                OnPropertyChanged("VideoDuration");
538
-            }
539
-        }
540
-        private string _videoSize;
541
-        /// <summary>
542
-        /// 视频大小
543
-        /// </summary>
544
-        public string VideoSize
545
-        {
546
-            get => _videoSize;
547
-            set
548
-            {
549
-                _videoSize = value;
550
-                OnPropertyChanged("VideoSize");
551
-            }
552
-        }
553
-        private long _videoSizes;
554
-        /// <summary>
555
-        /// 视频大小
556
-        /// </summary>
557
-        public long VideoSizes
558
-        {
559
-            get => _videoSizes;
560
-            set
561
-            {
562
-                _videoSizes = value;
563
-                OnPropertyChanged("VideoSizes");
564
-            }
565
-        }
566
-        private string _videoTime;
567
-        /// <summary>
568
-        /// 日期
569
-        /// </summary>
570
-        public string VideoTime
571
-        {
572
-            get => _videoTime;
573
-            set
574
-            {
575
-                _videoTime = value;
576
-                OnPropertyChanged("VideoTime");
577
-            }
578
-        }
579
-        private string _colour;
580
-        /// <summary>
581
-        /// 颜色
582
-        /// </summary>
583
-        public string Colour
584
-        {
585
-            get => _colour;
586
-            set
587
-            {
588
-                _colour = value;
589
-                OnPropertyChanged("Colour");
590
-            }
591
-        }
592
-        private bool _isEnabled;
593
-        /// <summary>
594
-        /// 是否可编辑
595
-        /// </summary>
596
-        public bool IsEnabled
597
-        {
598
-            get => _isEnabled;
599
-            set
600
-            {
601
-                _isEnabled = value;
602
-                OnPropertyChanged("IsEnabled");
603
-            }
604
-        }
605
-        public string Path { get; set; }
606
-        private string _visi;
607
-        /// <summary>
608
-        /// 显示
609
-        /// </summary>
610
-        public string Visi
611
-        {
612
-            get => _visi;
613
-            set
614
-            {
615
-                _visi = value;
616
-                OnPropertyChanged("Visi");
617
-            }
618
-        }
619
-        private string _coll;
620
-        /// <summary>
621
-        /// 显示
622
-        /// </summary>
623
-        public string Coll
624
-        {
625
-            get => _coll;
626
-            set
627
-            {
628
-                _coll = value;
629
-                OnPropertyChanged("Coll");
630
-            }
631
-        }
632
-        /// <summary>
633
-        /// 唯一编号
634
-        /// </summary>
635
-        public string FileGuid { get; set; }
636
-        /// <summary>
637
-        /// 视频类型
638
-        /// </summary>
639
-        public string VideoType { get; set; }
640
-        /// <summary>
641
-        /// 初始名称
642
-        /// </summary>
643
-        public string Name { get; set; }
644
-        /// <summary>
645
-        /// 文件路径
646
-        /// </summary>
647
-        public string FilePath { get; set; }
648
-
649 463
     }
650
-}
464
+}

+ 35
- 40
XHWK.WKTool/LoginWindow.xaml.cs Прегледај датотеку

@@ -4,6 +4,7 @@ using System;
4 4
 using System.Configuration;
5 5
 using System.Text;
6 6
 using System.Text.RegularExpressions;
7
+
7 8
 //using System.Text.RegularExpressions;
8 9
 using System.Windows;
9 10
 using System.Windows.Input;
@@ -21,17 +22,21 @@ namespace XHWK.WKTool
21 22
         /// 调用接口
22 23
         /// </summary>
23 24
         private readonly Interface @interface = new Interface();
25
+
24 26
         public LoginWindow()
25 27
         {
26 28
             InitializeComponent();
27 29
 
28 30
             #region 获取服务接口地址 --2021年7月9日赵耀
31
+
29 32
             if (APP.ServiceAddress == null)
30 33
             {
31 34
                 MessageWindow.Show("首次使用需设置服务地址。");
32 35
                 BtnServiceAddress_Click(null, null);
33 36
             }
34
-            #endregion
37
+
38
+            #endregion 获取服务接口地址 --2021年7月9日赵耀
39
+
35 40
             //if (APP.SkinStyle == "1")
36 41
             //{
37 42
             //    GridTitle.Visibility = Visibility.Visible;
@@ -49,6 +54,7 @@ namespace XHWK.WKTool
49 54
             //}
50 55
             Initialize();
51 56
         }
57
+
52 58
         public void Initialize()
53 59
         {
54 60
             if (FileToolsCommon.IsExistFile(APP.DataPath + "accountNumber.txt"))
@@ -67,6 +73,7 @@ namespace XHWK.WKTool
67 73
             //    txbAccountNumber.Text = GetSettingString("userName");
68 74
             //}
69 75
         }
76
+
70 77
         /// <summary>
71 78
         /// 关闭事件
72 79
         /// </summary>
@@ -78,6 +85,7 @@ namespace XHWK.WKTool
78 85
             pobPassword.Password = string.Empty;
79 86
             Hide();
80 87
         }
88
+
81 89
         /// <summary>
82 90
         /// 登录事件
83 91
         /// </summary>
@@ -86,13 +94,16 @@ namespace XHWK.WKTool
86 94
         private void BtnStart_Click(object sender, RoutedEventArgs e)
87 95
         {
88 96
             #region 获取服务接口地址 --2021年7月9日赵耀
97
+
89 98
             if (APP.ServiceAddress == null)
90 99
             {
91 100
                 MessageWindow.Show("首次使用需设置服务地址。");
92 101
                 BtnServiceAddress_Click(null, null);
93 102
                 return;
94 103
             }
95
-            #endregion
104
+
105
+            #endregion 获取服务接口地址 --2021年7月9日赵耀
106
+
96 107
             if (string.IsNullOrEmpty(txbAccountNumber.Text))
97 108
             {
98 109
                 MessageWindow.Show("账号未输入");
@@ -116,6 +127,7 @@ namespace XHWK.WKTool
116 127
             APP.myloading.Show();
117 128
             Login();
118 129
         }
130
+
119 131
         /// <summary>
120 132
         /// 登录
121 133
         /// </summary>
@@ -135,7 +147,6 @@ namespace XHWK.WKTool
135 147
                 string applicationData = APP.DataPath + "accountNumber.txt";
136 148
                 if (ckSaveName.IsChecked == true)
137 149
                 {
138
-
139 150
                     string accountNumbers = txbAccountNumber.Text;
140 151
                     System.IO.File.WriteAllText(applicationData, accountNumbers, Encoding.Default);//存放账号
141 152
                 }
@@ -150,37 +161,17 @@ namespace XHWK.WKTool
150 161
                 APP.IsLoginType = true;
151 162
                 txbAccountNumber.Text = string.Empty;
152 163
                 pobPassword.Password = string.Empty;
164
+
153 165
                 #region 下载头像
166
+
154 167
                 string HeadpicPath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + ".png");
155 168
                 if (!string.IsNullOrWhiteSpace(APP.UserInfo.Headpic))
156 169
                 {
157 170
                     //FileToolsCommon.
158 171
                     @interface.DownloadAvatar(APP.UserInfo.Headpic, HeadpicPath);
159 172
                 }
160
-                #endregion
161
-                #region 登录后 根据用户名设置微课路径 废弃
162
-                //APP.WKData.WkPath += APP.UserInfo.Username + "/";
163
-                ////判断微课是否存在,存在则询问
164
-                //if (APP.WKDataList != null)
165
-                //{
166
-                //    if(APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
167
-                //    {
168
-                //        MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
169
-                //        if (dr == MessageBoxResult.OK)
170
-                //        {
171
-                //            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
172
-                //            FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
173
-                //            APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
174
-                //        }
175
-                //        else
176
-                //        {
177
-                //            APP.W_CreateAMicroLessonWindow.Owner = this;
178
-                //            //APP.W_CreateAMicroLessonWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
179
-                //            APP.W_CreateAMicroLessonWindow.ShowDialog();
180
-                //        }
181
-                //    }
182
-                //}
183
-                #endregion
173
+
174
+                #endregion 下载头像
184 175
 
185 176
                 Hide();
186 177
             }
@@ -191,6 +182,7 @@ namespace XHWK.WKTool
191 182
                 MessageWindow.Show(APP.ServerMsg);
192 183
             }
193 184
         }
185
+
194 186
         /// <summary>
195 187
         /// 记住账号
196 188
         /// </summary>
@@ -198,15 +190,8 @@ namespace XHWK.WKTool
198 190
         /// <param name="e"></param>
199 191
         private void CkSaveName_Click(object sender, RoutedEventArgs e)
200 192
         {
201
-            //if (ckSaveName.IsChecked == false)
202
-            //{
203
-            //    UpdateSettingString("isRemind", ckSaveName.IsChecked.ToString());
204
-            //}
205
-            //else
206
-            //{
207
-            //    UpdateSettingString("isRemind", ckSaveName.IsChecked.ToString());
208
-            //}
209 193
         }
194
+
210 195
         /// <summary>
211 196
         /// 读取客户设置
212 197
         /// </summary>
@@ -224,6 +209,7 @@ namespace XHWK.WKTool
224 209
                 return null;
225 210
             }
226 211
         }
212
+
227 213
         /// <summary>
228 214
         /// 更新设置
229 215
         /// </summary>
@@ -241,6 +227,7 @@ namespace XHWK.WKTool
241 227
             config.Save(ConfigurationSaveMode.Modified);
242 228
             ConfigurationManager.RefreshSection("appSettings");
243 229
         }
230
+
244 231
         /// <summary>
245 232
         /// 限制输入特殊字符
246 233
         /// </summary>
@@ -264,7 +251,6 @@ namespace XHWK.WKTool
264 251
                 {
265 252
                     e.Handled = true;
266 253
                 }
267
-
268 254
             }
269 255
             catch (Exception)
270 256
             {
@@ -277,6 +263,7 @@ namespace XHWK.WKTool
277 263
         }
278 264
 
279 265
         #region 服务地址
266
+
280 267
         /// <summary>
281 268
         /// 打开服务地址
282 269
         /// </summary>
@@ -287,6 +274,7 @@ namespace XHWK.WKTool
287 274
             GridLoginPage.Visibility = Visibility.Collapsed;
288 275
             GridServiceAddress.Visibility = Visibility.Visible;
289 276
         }
277
+
290 278
         /// <summary>
291 279
         /// 取消
292 280
         /// </summary>
@@ -297,6 +285,7 @@ namespace XHWK.WKTool
297 285
             GridLoginPage.Visibility = Visibility.Visible;
298 286
             GridServiceAddress.Visibility = Visibility.Collapsed;
299 287
         }
288
+
300 289
         /// <summary>
301 290
         /// 服务地址设置
302 291
         /// </summary>
@@ -305,6 +294,7 @@ namespace XHWK.WKTool
305 294
         private void BtnSetServiceAddress_Click(object sender, RoutedEventArgs e)
306 295
         {
307 296
             #region 获取服务地址 -- 2021年7月8日赵耀
297
+
308 298
             if (!string.IsNullOrWhiteSpace(TbxServiceAddress.Text))
309 299
             {
310 300
                 if (@interface.GetServiceAddress(TbxServiceAddress.Text, out string Message))
@@ -321,10 +311,12 @@ namespace XHWK.WKTool
321 311
                     return;
322 312
                 }
323 313
             }
324
-            #endregion
314
+
315
+            #endregion 获取服务地址 -- 2021年7月8日赵耀
325 316
         }
326 317
 
327 318
         #region 切换校内外
319
+
328 320
         /// <summary>
329 321
         /// 校外
330 322
         /// </summary>
@@ -339,6 +331,7 @@ namespace XHWK.WKTool
339 331
                 APP.SwitchAddress();
340 332
             }
341 333
         }
334
+
342 335
         /// <summary>
343 336
         /// 校内
344 337
         /// </summary>
@@ -353,7 +346,9 @@ namespace XHWK.WKTool
353 346
                 APP.SwitchAddress();
354 347
             }
355 348
         }
356
-        #endregion
357
-        #endregion
349
+
350
+        #endregion 切换校内外
351
+
352
+        #endregion 服务地址
358 353
     }
359
-}
354
+}

+ 21
- 0
XHWK.WKTool/Models/FileDirectoryData.cs Прегледај датотеку

@@ -0,0 +1,21 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Collections.ObjectModel;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+using XHWK.Model;
9
+
10
+namespace XHWK.WKTool.Models
11
+{
12
+    public class FileDirectoryData : NotifyModel
13
+    {
14
+        public ObservableCollection<FileDirectoryModel> menuList { get; set; }
15
+
16
+        public FileDirectoryData()
17
+        {
18
+            menuList = new ObservableCollection<FileDirectoryModel>();
19
+        }
20
+    }
21
+}

+ 184
- 0
XHWK.WKTool/Models/FileDirectoryModel.cs Прегледај датотеку

@@ -0,0 +1,184 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using XHWK.Model;
8
+
9
+namespace XHWK.WKTool.Models
10
+{
11
+    public class FileDirectoryModel : NotifyModel
12
+    {
13
+        private int _serialNumber;
14
+
15
+        /// <summary>
16
+        /// 序号
17
+        /// </summary>
18
+        public int SerialNumber
19
+        {
20
+            get => _serialNumber;
21
+            set
22
+            {
23
+                _serialNumber = value;
24
+                OnPropertyChanged("SerialNumber");
25
+            }
26
+        }
27
+
28
+        private string _videoName;
29
+
30
+        /// <summary>
31
+        /// 视频名称
32
+        /// </summary>
33
+        public string VideoName
34
+        {
35
+            get => _videoName;
36
+            set
37
+            {
38
+                _videoName = value;
39
+                OnPropertyChanged("VideoName");
40
+            }
41
+        }
42
+
43
+        private int _videoDuration;
44
+
45
+        /// <summary>
46
+        /// 视频时长
47
+        /// </summary>
48
+        public int VideoDuration
49
+        {
50
+            get => _videoDuration;
51
+            set
52
+            {
53
+                _videoDuration = value;
54
+                OnPropertyChanged("VideoDuration");
55
+            }
56
+        }
57
+
58
+        private string _videoSize;
59
+
60
+        /// <summary>
61
+        /// 视频大小
62
+        /// </summary>
63
+        public string VideoSize
64
+        {
65
+            get => _videoSize;
66
+            set
67
+            {
68
+                _videoSize = value;
69
+                OnPropertyChanged("VideoSize");
70
+            }
71
+        }
72
+
73
+        private long _videoSizes;
74
+
75
+        /// <summary>
76
+        /// 视频大小
77
+        /// </summary>
78
+        public long VideoSizes
79
+        {
80
+            get => _videoSizes;
81
+            set
82
+            {
83
+                _videoSizes = value;
84
+                OnPropertyChanged("VideoSizes");
85
+            }
86
+        }
87
+
88
+        private string _videoTime;
89
+
90
+        /// <summary>
91
+        /// 日期
92
+        /// </summary>
93
+        public string VideoTime
94
+        {
95
+            get => _videoTime;
96
+            set
97
+            {
98
+                _videoTime = value;
99
+                OnPropertyChanged("VideoTime");
100
+            }
101
+        }
102
+
103
+        private string _colour;
104
+
105
+        /// <summary>
106
+        /// 颜色
107
+        /// </summary>
108
+        public string Colour
109
+        {
110
+            get => _colour;
111
+            set
112
+            {
113
+                _colour = value;
114
+                OnPropertyChanged("Colour");
115
+            }
116
+        }
117
+
118
+        private bool _isEnabled;
119
+
120
+        /// <summary>
121
+        /// 是否可编辑
122
+        /// </summary>
123
+        public bool IsEnabled
124
+        {
125
+            get => _isEnabled;
126
+            set
127
+            {
128
+                _isEnabled = value;
129
+                OnPropertyChanged("IsEnabled");
130
+            }
131
+        }
132
+
133
+        public string Path { get; set; }
134
+        private string _visi;
135
+
136
+        /// <summary>
137
+        /// 显示
138
+        /// </summary>
139
+        public string Visi
140
+        {
141
+            get => _visi;
142
+            set
143
+            {
144
+                _visi = value;
145
+                OnPropertyChanged("Visi");
146
+            }
147
+        }
148
+
149
+        private string _coll;
150
+
151
+        /// <summary>
152
+        /// 显示
153
+        /// </summary>
154
+        public string Coll
155
+        {
156
+            get => _coll;
157
+            set
158
+            {
159
+                _coll = value;
160
+                OnPropertyChanged("Coll");
161
+            }
162
+        }
163
+
164
+        /// <summary>
165
+        /// 唯一编号
166
+        /// </summary>
167
+        public string FileGuid { get; set; }
168
+
169
+        /// <summary>
170
+        /// 视频类型
171
+        /// </summary>
172
+        public string VideoType { get; set; }
173
+
174
+        /// <summary>
175
+        /// 初始名称
176
+        /// </summary>
177
+        public string Name { get; set; }
178
+
179
+        /// <summary>
180
+        /// 文件路径
181
+        /// </summary>
182
+        public string FilePath { get; set; }
183
+    }
184
+}

+ 20
- 0
XHWK.WKTool/Models/PrintModel.cs Прегледај датотеку

@@ -0,0 +1,20 @@
1
+namespace XHWK.WKTool.Models
2
+{
3
+    internal class PrintModel
4
+    {
5
+        /// <summary>
6
+        /// 打印文件路径
7
+        /// </summary>
8
+        public string filepath { get; set; }
9
+
10
+        /// <summary>
11
+        /// 打印数量
12
+        /// </summary>
13
+        public int num { get; set; }
14
+
15
+        /// <summary>
16
+        /// 打印机名称
17
+        /// </summary>
18
+        public string printname { get; set; }
19
+    }
20
+}

+ 116
- 149
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs Прегледај датотеку

@@ -21,6 +21,7 @@ namespace XHWK.WKTool
21 21
     public partial class ScreenRecordingToolbarWindow : Window
22 22
     {
23 23
         #region 初始变量
24
+
24 25
         /// <summary>
25 26
         /// 视频保存名称
26 27
         /// </summary>
@@ -41,9 +42,11 @@ namespace XHWK.WKTool
41 42
         /// </summary>
42 43
         private Model_Video VideoInfo = null;
43 44
 
44
-        //声明一个 DrawingAttributes 类型的变量  
45
+        //声明一个 DrawingAttributes 类型的变量
45 46
         private DrawingAttributes drawingAttributes;
47
+
46 48
         private DispatcherTimer t = null;
49
+
47 50
         /// <summary>
48 51
         /// 计时器状态
49 52
         /// </summary>
@@ -53,20 +56,25 @@ namespace XHWK.WKTool
53 56
             Pause,
54 57
             End
55 58
         }
59
+
56 60
         /// <summary>
57 61
         /// 状态
58 62
         /// </summary>
59 63
         private State _state = State.End;
60 64
 
61 65
         private KeyboardHookCommon k_hook;
66
+
62 67
         /// <summary>
63 68
         /// 🖊状态 0红色 1蓝色 10红色批注内 11蓝色批注内
64 69
         /// </summary>
65 70
         public int flg = 0;
71
+
66 72
         private System.Timers.Timer timer = new System.Timers.Timer();
67
-        #endregion
73
+
74
+        #endregion 初始变量
68 75
 
69 76
         #region 初始化
77
+
70 78
         /// <summary>
71 79
         /// 录屏工具栏
72 80
         /// </summary>
@@ -75,6 +83,7 @@ namespace XHWK.WKTool
75 83
             InitializeComponent();
76 84
             ResizeMode = ResizeMode.NoResize;
77 85
         }
86
+
78 87
         /// <summary>
79 88
         /// 初始化
80 89
         /// </summary>
@@ -111,14 +120,13 @@ namespace XHWK.WKTool
111 120
             //borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
112 121
             flg = 0;
113 122
 
114
-
115 123
             k_hook = new KeyboardHookCommon();
116 124
             k_hook.KeyDownEvent += K_hook_KeyDownEvent;
117 125
 
118
-            //创建 DrawingAttributes 类的一个实例  
126
+            //创建 DrawingAttributes 类的一个实例
119 127
             drawingAttributes = new DrawingAttributes();
120
-            //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
121
-            //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型  
128
+            //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
129
+            //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
122 130
             blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
123 131
             drawingAttributes.FitToCurve = true;
124 132
             //隐藏画笔工具栏
@@ -160,7 +168,7 @@ namespace XHWK.WKTool
160 168
                 double mouse_y = Form.MousePosition.Y;
161 169
 
162 170
                 bool is_in_collasped_range = (mouse_y > Left + Height) || (mouse_x < Left || mouse_x > Left + Width);//缩起的条件
163
-                bool is_in_visiable_range = (mouse_y < 1 && mouse_x >= Left && mouse_x <= Left + Width); //展开的条件         
171
+                bool is_in_visiable_range = (mouse_y < 1 && mouse_x >= Left && mouse_x <= Left + Width); //展开的条件
164 172
 
165 173
                 if (Left < 1630 && Left >= 0 && is_in_collasped_range)
166 174
                 {
@@ -173,6 +181,7 @@ namespace XHWK.WKTool
173 181
                 }
174 182
             });
175 183
         }
184
+
176 185
         private void K_hook_KeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
177 186
         {
178 187
             if (e.KeyValue == (int)System.Windows.Forms.Keys.F5 && (int)Control.ModifierKeys == (int)Keys.Control)
@@ -185,16 +194,19 @@ namespace XHWK.WKTool
185 194
                 //结束
186 195
                 BtnStopRecordingScreen_Click(null, null);
187 196
             }
188
-
189 197
         }
190
-        #endregion
198
+
199
+        #endregion 初始化
191 200
 
192 201
         #region 事件
202
+
193 203
         /// <summary>
194 204
         /// 记录上次执行时间
195 205
         /// </summary>
196 206
         private DateTime Recorddt = DateTime.Now;
197
-        DateTime SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
207
+
208
+        private DateTime SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
209
+
198 210
         /// <summary>
199 211
         /// 时钟回调
200 212
         /// </summary>
@@ -207,7 +219,7 @@ namespace XHWK.WKTool
207 219
                 case State.Start:
208 220
                     {
209 221
                         DateTime dt = DateTime.Now;
210
-                        TimeSpan ts = dt.Subtract(Recorddt);//时间差   
222
+                        TimeSpan ts = dt.Subtract(Recorddt);//时间差
211 223
                         double tsmi = ts.TotalMilliseconds;
212 224
                         if (tsmi > 1000.0)
213 225
                         {
@@ -259,6 +271,7 @@ namespace XHWK.WKTool
259 271
             Recorddt = DateTime.Now;
260 272
             _state = State.Start;
261 273
         }
274
+
262 275
         /// <summary>
263 276
         /// 暂停
264 277
         /// </summary>
@@ -266,6 +279,7 @@ namespace XHWK.WKTool
266 279
         {
267 280
             _state = State.Pause;
268 281
         }
282
+
269 283
         /// <summary>
270 284
         /// 结束
271 285
         /// </summary>
@@ -277,6 +291,7 @@ namespace XHWK.WKTool
277 291
         }
278 292
 
279 293
         #region 录屏
294
+
280 295
         /// <summary>
281 296
         /// 设置录屏文件地址
282 297
         /// </summary>
@@ -298,6 +313,7 @@ namespace XHWK.WKTool
298 313
         /// 是否已经按下按钮
299 314
         /// </summary>
300 315
         private bool IsPressButton = false;
316
+
301 317
         /// <summary>
302 318
         /// 开始或暂停录制
303 319
         /// </summary>
@@ -306,6 +322,7 @@ namespace XHWK.WKTool
306 322
         private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
307 323
         {
308 324
             #region 防止连击
325
+
309 326
             if (IsPressButton)
310 327
             {
311 328
                 return;
@@ -319,12 +336,15 @@ namespace XHWK.WKTool
319 336
                     IsPressButton = false;
320 337
                 }))).Start();
321 338
             }
322
-            #endregion
339
+
340
+            #endregion 防止连击
341
+
323 342
             if (IsSuspend)
324 343
             {
325 344
                 if (IsFirstRS)
326 345
                 {
327 346
                     #region 检测麦克风扬声器是否可用
347
+
328 348
                     string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
329 349
                     FileToolsCommon.CreateDirectory(AudioPath);
330 350
                     string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
@@ -336,7 +356,6 @@ namespace XHWK.WKTool
336 356
                     }
337 357
                     catch (Exception)
338 358
                     {
339
-
340 359
                     }
341 360
                     //扬声器
342 361
                     if (APP.FFmpeg.StartRecordSpeakerAudio(audioSpeakerPath))
@@ -367,7 +386,8 @@ namespace XHWK.WKTool
367 386
                             return;
368 387
                         }
369 388
                     }
370
-                    #endregion
389
+
390
+                    #endregion 检测麦克风扬声器是否可用
371 391
 
372 392
                     VideoInfo = new Model_Video
373 393
                     {
@@ -404,6 +424,7 @@ namespace XHWK.WKTool
404 424
                 TxbTime.Visibility = Visibility.Visible;//时间显示
405 425
 
406 426
                 #region 隐藏工具栏
427
+
407 428
                 if (APP.IsHideSRTool)
408 429
                 {
409 430
                     if (APP.W_MinToolbar == null)
@@ -413,31 +434,19 @@ namespace XHWK.WKTool
413 434
                     APP.W_MinToolbar.Topmost = true;
414 435
                     double MinToolTop = Top;
415 436
                     GridSrToobar.Visibility = Visibility.Hidden;
416
-                    //if (APP.SkinStyle == "1")
417
-                    //{
418
-                    //    ColorType = 0;
419
-                    //    MinToolTop = this.Top + ((this.ActualHeight - btnReturn.ActualHeight) / 2);//(VbxBlue.ActualHeight -) 
420
-                    //}
421
-                    //else if (APP.SkinStyle == "2")
422
-                    //{
423
-                    //MinToolTop = this.Top + ((this.ActualHeight - VbxBlack.ActualHeight) / 2);
424
-                    //}
425
-                    APP.W_MinToolbar.Initialize(MinToolTop,ActualHeight);
437
+
438
+                    APP.W_MinToolbar.Initialize(MinToolTop, ActualHeight);
426 439
                     APP.W_MinToolbar.Show();
427 440
                 }
428
-                #endregion
441
+
442
+                #endregion 隐藏工具栏
443
+
429 444
                 try
430 445
                 {
431 446
                     #region 4秒内不可点击
447
+
432 448
                     new Thread(new ThreadStart(new Action(() =>
433 449
                     {
434
-                        //Dispatcher.Invoke(() =>
435
-                        //{
436
-                        //    ImgEndRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/Toobar15.png"));
437
-                        //    BtnRecordingScreen.IsEnabled = false;
438
-                        //    BtnStopRecordingScreen.IsEnabled = false;
439
-                        //});
440
-                        //Thread.Sleep(4000);
441 450
                         Dispatcher.Invoke(() =>
442 451
                         {
443 452
                             BtnRecordingScreen.IsEnabled = true;
@@ -445,7 +454,9 @@ namespace XHWK.WKTool
445 454
                             BtnRecordingScreenPause.IsEnabled = true;
446 455
                         });
447 456
                     }))).Start();
448
-                    #endregion
457
+
458
+                    #endregion 4秒内不可点击
459
+
449 460
                     new Thread(new ThreadStart(new Action(() =>
450 461
                     {
451 462
                         if (IsFirstRS)
@@ -457,7 +468,7 @@ namespace XHWK.WKTool
457 468
                             Thread.Sleep(100);
458 469
                         }
459 470
                         System.Drawing.Size DesktopSize = PrimaryScreen.DESKTOP;
460
-                        bool IsRecordingSound = FileToolsCommon.GetConfigValue("IsRecordingSound") == "1"; 
471
+                        bool IsRecordingSound = FileToolsCommon.GetConfigValue("IsRecordingSound") == "1";
461 472
                         bool IsRecordingMicrophone = FileToolsCommon.GetConfigValue("IsRecordingMicrophone") == "1";
462 473
                         bool SynRes = APP.FFmpeg.StartRecordingVideo(VideoSavePathName, DesktopSize, IsRecordingSound, IsRecordingMicrophone, out string ErrMessage, APP.MicrophoneName);
463 474
 
@@ -467,11 +478,7 @@ namespace XHWK.WKTool
467 478
                             if (!SynRes)
468 479
                             {
469 480
                                 MessageWindow.Show(ErrMessage);
470
-                                //隐藏画笔工具栏
471
-                                //BtnToolbarDown_Click(null, null);
472
-                                //gridToolbar.Visibility = Visibility.Hidden;
473
-                                //gridColour.Visibility = Visibility.Hidden;
474
-                                //gridThickness.Visibility = Visibility.Hidden;
481
+
475 482
                                 BtnRecordingScreen.Visibility = Visibility.Visible;
476 483
                                 BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
477 484
                                 BtnStopRecordingScreen.IsEnabled = false; //停止录制按钮不点击
@@ -508,6 +515,7 @@ namespace XHWK.WKTool
508 515
                 //btnBlackPenTwo.IsEnabled = false;//红笔不可点击
509 516
 
510 517
                 #region 2秒内不可点击
518
+
511 519
                 new Thread(new ThreadStart(new Action(() =>
512 520
                 {
513 521
                     //Dispatcher.Invoke(() =>
@@ -523,7 +531,9 @@ namespace XHWK.WKTool
523 531
                         BtnStopRecordingScreen.IsEnabled = true;
524 532
                     });
525 533
                 }))).Start();
526
-                #endregion
534
+
535
+                #endregion 2秒内不可点击
536
+
527 537
                 try
528 538
                 {
529 539
                     APP.FFmpeg.SuspendFFmpeg();
@@ -534,6 +544,7 @@ namespace XHWK.WKTool
534 544
                 }
535 545
             }
536 546
         }
547
+
537 548
         /// <summary>
538 549
         /// 停止录像
539 550
         /// </summary>
@@ -542,6 +553,7 @@ namespace XHWK.WKTool
542 553
         private void BtnStopRecordingScreen_Click(object sender, RoutedEventArgs e)
543 554
         {
544 555
             #region 防止连击
556
+
545 557
             if (IsPressButton)
546 558
             {
547 559
                 return;
@@ -555,7 +567,9 @@ namespace XHWK.WKTool
555 567
                     IsPressButton = false;
556 568
                 }))).Start();
557 569
             }
558
-            #endregion
570
+
571
+            #endregion 防止连击
572
+
559 573
             BtnRecordingScreen.ToolTip = "开始";
560 574
             k_hook.Stop();
561 575
             IsSuspend = true;
@@ -656,6 +670,7 @@ namespace XHWK.WKTool
656 670
             }
657 671
             Hide();
658 672
         }
673
+
659 674
         public void MaxToobar()
660 675
         {
661 676
             Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
@@ -665,9 +680,11 @@ namespace XHWK.WKTool
665 680
             GridSrToobar.Visibility = Visibility.Visible;
666 681
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
667 682
         }
668
-        #endregion
683
+
684
+        #endregion 录屏
669 685
 
670 686
         #region 画笔相关
687
+
671 688
         /// <summary>
672 689
         /// 画笔工具栏关闭事件
673 690
         /// </summary>
@@ -680,6 +697,7 @@ namespace XHWK.WKTool
680 697
             gridThickness.Visibility = Visibility.Hidden;
681 698
             APP.W_PracticeWindow.Hide();
682 699
         }
700
+
683 701
         /// <summary>
684 702
         /// 笔调用批注
685 703
         /// </summary>
@@ -690,6 +708,7 @@ namespace XHWK.WKTool
690 708
                 if (flg != 11 && flg != 10)
691 709
                 {
692 710
                     #region 防止连击
711
+
693 712
                     if (IsPressButton)
694 713
                     {
695 714
                         return;
@@ -703,7 +722,9 @@ namespace XHWK.WKTool
703 722
                             IsPressButton = false;
704 723
                         }))).Start();
705 724
                     }
706
-                    #endregion
725
+
726
+                    #endregion 防止连击
727
+
707 728
                     string time = GetTimeStamp();
708 729
                     string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
709 730
                     if (!Directory.Exists(tempPath))
@@ -737,7 +758,6 @@ namespace XHWK.WKTool
737 758
                             APP.W_PracticeWindow.Focus();
738 759
                         });
739 760
 
740
-
741 761
                         new Thread(new ThreadStart(new Action(() =>
742 762
                         {
743 763
                             Dispatcher.Invoke(() =>
@@ -759,6 +779,7 @@ namespace XHWK.WKTool
759 779
                 }
760 780
             }
761 781
         }
782
+
762 783
         /// <summary>
763 784
         /// 画笔点击事件
764 785
         /// </summary>
@@ -766,11 +787,13 @@ namespace XHWK.WKTool
766 787
         /// <param name="e"></param>
767 788
         private void BtnBrush_Click(object sender, RoutedEventArgs e)
768 789
         {
769
-            if(BtnPenBlue.Visibility!= Visibility.Visible)
790
+            if (BtnPenBlue.Visibility != Visibility.Visible)
770 791
             {
771 792
                 return;
772 793
             }
794
+
773 795
             #region 防止连击
796
+
774 797
             if (IsPressButton)
775 798
             {
776 799
                 return;
@@ -784,7 +807,9 @@ namespace XHWK.WKTool
784 807
                     IsPressButton = false;
785 808
                 }))).Start();
786 809
             }
787
-            #endregion
810
+
811
+            #endregion 防止连击
812
+
788 813
             BtnPenBlue.Visibility = Visibility.Collapsed;
789 814
             BtnPenRed.Visibility = Visibility.Visible;
790 815
             BtnPenBlue_CL.Visibility = Visibility.Visible;
@@ -797,9 +822,11 @@ namespace XHWK.WKTool
797 822
             }
798 823
 
799 824
             #region 录屏批注取消画笔
825
+
800 826
             //string imagePath = Path.Combine(tempPath, time + ".jpg");
801 827
             //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
802
-            #endregion
828
+
829
+            #endregion 录屏批注取消画笔
803 830
 
804 831
             try
805 832
             {
@@ -870,16 +897,18 @@ namespace XHWK.WKTool
870 897
             }
871 898
 
872 899
             //imgCanvas.Source = new BitmapImage(new Uri(imagePath));
873
-
874 900
         }
901
+
875 902
         /// <summary>
876 903
         /// 屏幕宽
877 904
         /// </summary>
878 905
         internal double pwidth = SystemParameters.PrimaryScreenWidth;
906
+
879 907
         /// <summary>
880 908
         /// 屏幕高
881 909
         /// </summary>
882 910
         internal double pHeight = SystemParameters.PrimaryScreenHeight;
911
+
883 912
         /// <summary>
884 913
         /// 获取时间戳
885 914
         /// </summary>
@@ -889,6 +918,7 @@ namespace XHWK.WKTool
889 918
             TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
890 919
             return Convert.ToInt64(ts.TotalMilliseconds).ToString();
891 920
         }
921
+
892 922
         /// <summary>
893 923
         /// 画笔粗细事件
894 924
         /// </summary>
@@ -899,6 +929,7 @@ namespace XHWK.WKTool
899 929
             gridThickness.Visibility = Visibility.Visible;
900 930
             gridColour.Visibility = Visibility.Collapsed;
901 931
         }
932
+
902 933
         /// <summary>
903 934
         /// 画笔颜色事件
904 935
         /// </summary>
@@ -909,6 +940,7 @@ namespace XHWK.WKTool
909 940
             gridColour.Visibility = Visibility.Visible;
910 941
             gridThickness.Visibility = Visibility.Collapsed;
911 942
         }
943
+
912 944
         /// <summary>
913 945
         /// 白色
914 946
         /// </summary>
@@ -921,6 +953,7 @@ namespace XHWK.WKTool
921 953
             gridColour.Visibility = Visibility.Collapsed;
922 954
             gridThickness.Visibility = Visibility.Collapsed;
923 955
         }
956
+
924 957
         /// <summary>
925 958
         /// 红色
926 959
         /// </summary>
@@ -933,6 +966,7 @@ namespace XHWK.WKTool
933 966
             gridColour.Visibility = Visibility.Collapsed;
934 967
             gridThickness.Visibility = Visibility.Collapsed;
935 968
         }
969
+
936 970
         /// <summary>
937 971
         /// 黄色
938 972
         /// </summary>
@@ -945,6 +979,7 @@ namespace XHWK.WKTool
945 979
             gridColour.Visibility = Visibility.Collapsed;
946 980
             gridThickness.Visibility = Visibility.Collapsed;
947 981
         }
982
+
948 983
         /// <summary>
949 984
         /// 青色
950 985
         /// </summary>
@@ -957,6 +992,7 @@ namespace XHWK.WKTool
957 992
             gridColour.Visibility = Visibility.Collapsed;
958 993
             gridThickness.Visibility = Visibility.Collapsed;
959 994
         }
995
+
960 996
         /// <summary>
961 997
         /// 灰色
962 998
         /// </summary>
@@ -969,6 +1005,7 @@ namespace XHWK.WKTool
969 1005
             gridColour.Visibility = Visibility.Collapsed;
970 1006
             gridThickness.Visibility = Visibility.Collapsed;
971 1007
         }
1008
+
972 1009
         /// <summary>
973 1010
         /// 蓝色
974 1011
         /// </summary>
@@ -981,6 +1018,7 @@ namespace XHWK.WKTool
981 1018
             gridColour.Visibility = Visibility.Collapsed;
982 1019
             gridThickness.Visibility = Visibility.Collapsed;
983 1020
         }
1021
+
984 1022
         /// <summary>
985 1023
         /// 画笔 细
986 1024
         /// </summary>
@@ -992,6 +1030,7 @@ namespace XHWK.WKTool
992 1030
             gridColour.Visibility = Visibility.Collapsed;
993 1031
             gridThickness.Visibility = Visibility.Collapsed;
994 1032
         }
1033
+
995 1034
         /// <summary>
996 1035
         /// 画笔 中
997 1036
         /// </summary>
@@ -1003,6 +1042,7 @@ namespace XHWK.WKTool
1003 1042
             gridColour.Visibility = Visibility.Collapsed;
1004 1043
             gridThickness.Visibility = Visibility.Collapsed;
1005 1044
         }
1045
+
1006 1046
         /// <summary>
1007 1047
         /// 画笔粗
1008 1048
         /// </summary>
@@ -1014,6 +1054,7 @@ namespace XHWK.WKTool
1014 1054
             gridColour.Visibility = Visibility.Collapsed;
1015 1055
             gridThickness.Visibility = Visibility.Collapsed;
1016 1056
         }
1057
+
1017 1058
         /// <summary>
1018 1059
         /// 橡皮
1019 1060
         /// </summary>
@@ -1023,6 +1064,7 @@ namespace XHWK.WKTool
1023 1064
         {
1024 1065
             APP.W_PracticeWindow.Eraser();
1025 1066
         }
1067
+
1026 1068
         /// <summary>
1027 1069
         /// 🖊
1028 1070
         /// </summary>
@@ -1032,6 +1074,7 @@ namespace XHWK.WKTool
1032 1074
         {
1033 1075
             APP.W_PracticeWindow.Pen();
1034 1076
         }
1077
+
1035 1078
         /// <summary>
1036 1079
         /// ⚪
1037 1080
         /// </summary>
@@ -1041,6 +1084,7 @@ namespace XHWK.WKTool
1041 1084
         {
1042 1085
             APP.W_PracticeWindow.Round();
1043 1086
         }
1087
+
1044 1088
         /// <summary>
1045 1089
         /// 矩形
1046 1090
         /// </summary>
@@ -1050,17 +1094,21 @@ namespace XHWK.WKTool
1050 1094
         {
1051 1095
             APP.W_PracticeWindow.Rectangle();
1052 1096
         }
1053
-        #endregion
1054
-        #endregion
1097
+
1098
+        #endregion 画笔相关
1099
+
1100
+        #endregion 事件
1055 1101
 
1056 1102
         /// <summary>
1057 1103
         /// 停止录屏
1058 1104
         /// </summary>
1059 1105
         public delegate void StopRecordingScreen();
1106
+
1060 1107
         /// <summary>
1061 1108
         /// 停止录屏
1062 1109
         /// </summary>
1063 1110
         public event StopRecordingScreen Click_stopRecordingScreen;
1111
+
1064 1112
         /// <summary>
1065 1113
         /// 黑笔
1066 1114
         /// </summary>
@@ -1068,8 +1116,8 @@ namespace XHWK.WKTool
1068 1116
         /// <param name="e"></param>
1069 1117
         private void BtnBlackPen_Click(object sender, RoutedEventArgs e)
1070 1118
         {
1071
-
1072 1119
         }
1120
+
1073 1121
         /// <summary>
1074 1122
         /// 移动工具栏
1075 1123
         /// </summary>
@@ -1079,10 +1127,11 @@ namespace XHWK.WKTool
1079 1127
         {
1080 1128
             DragMove();
1081 1129
         }
1130
+
1082 1131
         /// <summary>
1083 1132
         /// 红笔
1084 1133
         /// </summary>
1085
-        /// <param name="sender"></param> 
1134
+        /// <param name="sender"></param>
1086 1135
         /// <param name="e"></param>
1087 1136
         private void BtnBlackPenTwo_Click(object sender, RoutedEventArgs e)
1088 1137
         {
@@ -1090,7 +1139,9 @@ namespace XHWK.WKTool
1090 1139
             {
1091 1140
                 return;
1092 1141
             }
1142
+
1093 1143
             #region 防止连击
1144
+
1094 1145
             if (IsPressButton)
1095 1146
             {
1096 1147
                 return;
@@ -1104,7 +1155,9 @@ namespace XHWK.WKTool
1104 1155
                     IsPressButton = false;
1105 1156
                 }))).Start();
1106 1157
             }
1107
-            #endregion
1158
+
1159
+            #endregion 防止连击
1160
+
1108 1161
             BtnPenBlue.Visibility = Visibility.Visible;
1109 1162
             BtnPenRed.Visibility = Visibility.Collapsed;
1110 1163
             BtnPenBlue_CL.Visibility = Visibility.Collapsed;
@@ -1115,10 +1168,14 @@ namespace XHWK.WKTool
1115 1168
             {
1116 1169
                 Directory.CreateDirectory(tempPath);
1117 1170
             }
1171
+
1118 1172
             #region 录屏批注取消画笔
1173
+
1119 1174
             string imagePath = Path.Combine(tempPath, time + ".jpg");
1120 1175
             ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
1121
-            #endregion
1176
+
1177
+            #endregion 录屏批注取消画笔
1178
+
1122 1179
             try
1123 1180
             {
1124 1181
                 if (flg == 10)
@@ -1168,7 +1225,6 @@ namespace XHWK.WKTool
1168 1225
                     APP.W_PracticeWindow.Red();
1169 1226
                     APP.W_PracticeWindow.Show();
1170 1227
 
1171
-
1172 1228
                     new Thread(new ThreadStart(new Action(() =>
1173 1229
                     {
1174 1230
                         Thread.Sleep(100);
@@ -1178,8 +1234,6 @@ namespace XHWK.WKTool
1178 1234
                             Topmost = true;
1179 1235
                         });
1180 1236
                     }))).Start();
1181
-
1182
-
1183 1237
                 }
1184 1238
             }
1185 1239
             catch (Exception ex)
@@ -1187,68 +1241,7 @@ namespace XHWK.WKTool
1187 1241
                 LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
1188 1242
             }
1189 1243
         }
1190
-        /// <summary>
1191
-        /// 鼠标右键按下事件 废弃
1192
-        /// </summary>
1193
-        /// <param name="sender"></param>
1194
-        /// <param name="e"></param>
1195
-        private void RightButtonDown()
1196
-        {
1197
-            if (flg > 9)
1198
-            {
1199
-                Owner = null;
1200
-                APP.W_PracticeWindow.Hide();
1201
-            }
1202
-            else
1203
-            {
1204
-                //string time = GetTimeStamp();
1205
-                string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
1206
-                if (!Directory.Exists(tempPath))
1207
-                {
1208
-                    Directory.CreateDirectory(tempPath);
1209
-                }
1210
-
1211
-                #region 录屏批注取消画笔
1212
-                //string imagePath = Path.Combine(tempPath, time + ".jpg");
1213
-                //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
1214
-                #endregion
1215 1244
 
1216
-                try
1217
-                {
1218
-                    if (APP.W_PracticeWindow == null)
1219
-                    {
1220
-                        APP.W_PracticeWindow = new PracticeWindow
1221
-                        {
1222
-                            //APP.W_PracticeWindow.Topmost = true;
1223
-                            Width = pwidth,
1224
-                            Height = pHeight,
1225
-                            Left = 0,
1226
-                            Top = 0
1227
-                        };
1228
-                        //practiceWin.Owner = this;
1229
-                    }
1230
-                    APP.W_PracticeWindow.InitPen();
1231
-                    APP.W_PracticeWindow.InitTQLPPen();
1232
-                    APP.W_PracticeWindow.Initialize();//imagePath);
1233
-
1234
-                    if (flg == 0)
1235
-                    {
1236
-                        flg = 10;
1237
-                        APP.W_PracticeWindow.Red();
1238
-                    }
1239
-                    else
1240
-                    {
1241
-                        flg = 11;
1242
-                        APP.W_PracticeWindow.Blue();
1243
-                    }
1244
-                    APP.W_PracticeWindow.Show();
1245
-                }
1246
-                catch (Exception ex)
1247
-                {
1248
-                    LogHelper.WriteErrLog("【批注(PracticeWindow)" + ex.Message, ex);
1249
-                }
1250
-            }
1251
-        }
1252 1245
         /// <summary>
1253 1246
         /// 返回主界面
1254 1247
         /// </summary>
@@ -1301,7 +1294,6 @@ namespace XHWK.WKTool
1301 1294
                     {
1302 1295
                         VideoInfo = null;
1303 1296
                         FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/");
1304
-
1305 1297
                     }))).Start();
1306 1298
                 }
1307 1299
                 catch (Exception ex)
@@ -1327,6 +1319,7 @@ namespace XHWK.WKTool
1327 1319
             }))).Start();
1328 1320
             Hide();
1329 1321
         }
1322
+
1330 1323
         /// <summary>
1331 1324
         /// 批注退出 废弃
1332 1325
         /// </summary>
@@ -1334,11 +1327,6 @@ namespace XHWK.WKTool
1334 1327
         {
1335 1328
             new Thread(new ThreadStart(new Action(() =>
1336 1329
             {
1337
-                //Dispatcher.Invoke(() =>
1338
-                //{
1339
-                //    borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
1340
-                //    borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
1341
-                //});
1342 1330
                 flg = 0;
1343 1331
                 Thread.Sleep(500);
1344 1332
                 Dispatcher.Invoke(() =>
@@ -1348,6 +1336,7 @@ namespace XHWK.WKTool
1348 1336
                 });
1349 1337
             }))).Start();
1350 1338
         }
1339
+
1351 1340
         /// <summary>
1352 1341
         /// 修改笔状态
1353 1342
         /// </summary>
@@ -1357,40 +1346,18 @@ namespace XHWK.WKTool
1357 1346
             BtnPenRed.Visibility = Visibility.Visible;
1358 1347
             BtnPenBlue_CL.Visibility = Visibility.Collapsed;
1359 1348
             BtnPenRed_CL.Visibility = Visibility.Collapsed;
1360
-            //borOne.Background = new SolidColorBrush(Colors.DodgerBlue);
1361
-            //borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
1362
-        }
1363
-
1364
-        /// <summary>
1365
-        /// 切换页面
1366
-        /// </summary>
1367
-        void SwitchPages()
1368
-        {
1369
-            //SendKeys.SendWait("%{TAB}");
1370
-            MouseEventCommon.MouseMiddleClickEvent(0);
1371
-        }
1372
-        //bool isToobar = false;
1373
-        /// <summary>
1374
-        /// 在工具条区域内
1375
-        /// </summary>
1376
-        /// <param name="sender"></param>
1377
-        /// <param name="e"></param>
1378
-        private void gridToobarTwo_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
1379
-        {
1380
-            //isToobar = true;
1381 1349
         }
1382 1350
 
1383 1351
         private void gridToobarTwo_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
1384 1352
         {
1385 1353
             //if (BtnRecordingScreen.ToolTip.ToString().Equals("暂停") && (gridToobar.Visibility == Visibility.Visible || BorderBlack.Visibility == Visibility.Visible))
1386
-            if(BtnRecordingScreenPause.Visibility == Visibility.Visible)
1354
+            if (BtnRecordingScreenPause.Visibility == Visibility.Visible)
1387 1355
             {
1388 1356
                 if (APP.IsHideSRTool)
1389 1357
                 {
1390 1358
                     if (APP.W_MinToolbar == null)
1391 1359
                     {
1392 1360
                         APP.W_MinToolbar = new MinToolbar();
1393
-
1394 1361
                     }
1395 1362
                     APP.W_MinToolbar.Topmost = true;
1396 1363
                     double MinToolTop = Top;
@@ -1419,7 +1386,7 @@ namespace XHWK.WKTool
1419 1386
                             {
1420 1387
                                 //LblMessage.Content = "不在区域内:(" + pointRecord.X + "," + pointRecord.Y + ") (" + Left + "," + Top + ")";
1421 1388
                                 APP.W_MinToolbar.Initialize(MinToolTop, ActualHeight);
1422
-                                GridSrToobar.Visibility =  Visibility.Hidden;
1389
+                                GridSrToobar.Visibility = Visibility.Hidden;
1423 1390
                                 APP.W_MinToolbar.Show();
1424 1391
                             }
1425 1392
                         });
@@ -1428,4 +1395,4 @@ namespace XHWK.WKTool
1428 1395
             }
1429 1396
         }
1430 1397
     }
1431
-}
1398
+}

+ 131
- 59
XHWK.WKTool/UControl/Uc_VideoItem.xaml Прегледај датотеку

@@ -1,119 +1,191 @@
1
-<UserControl x:Class="XHWK.WKTool.UControl.Uc_VideoItem"
2
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
5
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
6
-             xmlns:local="clr-namespace:XHWK.WKTool.UControl"
7
-             mc:Ignorable="d" 
8
-             d:DesignHeight="260" d:DesignWidth="250">
1
+<UserControl
2
+    x:Class="XHWK.WKTool.UControl.Uc_VideoItem"
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:local="clr-namespace:XHWK.WKTool.UControl"
7
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8
+    d:DesignHeight="260"
9
+    d:DesignWidth="250"
10
+    mc:Ignorable="d">
9 11
     <Grid>
10 12
         <Grid>
11 13
             <Grid.RowDefinitions>
12
-                <RowDefinition Height="10*"/>
13
-                <RowDefinition Height="130*"/>
14
-                <RowDefinition Height="110*"/>
15
-                <RowDefinition Height="10*"/>
14
+                <RowDefinition Height="10*" />
15
+                <RowDefinition Height="130*" />
16
+                <RowDefinition Height="110*" />
17
+                <RowDefinition Height="10*" />
16 18
             </Grid.RowDefinitions>
17
-            <!--视频缩略图-->
19
+            <!--  视频缩略图  -->
18 20
             <Grid Grid.Row="1">
19 21
                 <Grid.ColumnDefinitions>
20
-                    <ColumnDefinition Width="20*"/>
21
-                    <ColumnDefinition Width="210*"/>
22
-                    <ColumnDefinition Width="20*"/>
22
+                    <ColumnDefinition Width="20*" />
23
+                    <ColumnDefinition Width="210*" />
24
+                    <ColumnDefinition Width="20*" />
23 25
                 </Grid.ColumnDefinitions>
24 26
                 <Grid Grid.Column="1">
25
-                    <Border Background="#dddddd">
26
-                        <Button  x:Name="BtnVideoPlay" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Stretch"  Cursor="Hand" Click="BtnVideoPlay_Click" VerticalAlignment="Stretch">
27
-                            <Image x:Name="ImgVideo" Cursor="Hand" Stretch="Fill"/>
27
+                    <Border Background="#eeeeee">
28
+                        <Button
29
+                            x:Name="BtnVideoPlay"
30
+                            HorizontalAlignment="Stretch"
31
+                            VerticalAlignment="Stretch"
32
+                            Click="BtnVideoPlay_Click"
33
+                            Cursor="Hand"
34
+                            Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
35
+                            <Image
36
+                                x:Name="ImgVideo"
37
+                                Cursor="Hand"
38
+                                Stretch="Fill" />
28 39
                         </Button>
29 40
                     </Border>
30 41
                     <Grid>
31 42
                         <Grid.ColumnDefinitions>
32
-                            <ColumnDefinition Width="75*"/>
33
-                            <ColumnDefinition Width="60*"/>
34
-                            <ColumnDefinition Width="75*"/>
43
+                            <ColumnDefinition Width="75*" />
44
+                            <ColumnDefinition Width="60*" />
45
+                            <ColumnDefinition Width="75*" />
35 46
                         </Grid.ColumnDefinitions>
36 47
                         <Grid.RowDefinitions>
37
-                            <RowDefinition Height="35*"/>
38
-                            <RowDefinition Height="60*"/>
39
-                            <RowDefinition Height="35*"/>
48
+                            <RowDefinition Height="40*" />
49
+                            <RowDefinition Height="60*" />
50
+                            <RowDefinition Height="40*" />
40 51
                         </Grid.RowDefinitions>
41 52
                         <Grid Grid.Row="0" Grid.Column="2">
42
-                            <Button Cursor="Hand" x:Name="btnSetUp" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Right" VerticalAlignment="Top" Click="Button_Click">
43
-                                <Image x:Name="ImgSetUp" Source="/Images/Clip_Clip.png" Visibility="Visible"/>
53
+                            <Button
54
+                                x:Name="btnSetUp"
55
+                                Margin="0,0,4,0"
56
+                                HorizontalAlignment="Right"
57
+                                VerticalAlignment="Center"
58
+                                Click="Button_Click"
59
+                                Cursor="Hand"
60
+                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
61
+                                <Image
62
+                                    x:Name="ImgSetUp"
63
+                                    Source="/Images/Clip_Clip.png"
64
+                                    Visibility="Visible" />
44 65
                             </Button>
45 66
                         </Grid>
46 67
                         <Grid Grid.Row="1" Grid.Column="1">
47 68
                             <Border Background="#7FDDDDDD" CornerRadius="30">
48
-                                <Image x:Name="ImgVideoPlay" Source="/星火微课;component/Images/VideoList_Play.png" Cursor="Hand" MouseLeftButtonDown="Image_MouseLeftButtonDown" />
69
+                                <Image
70
+                                    x:Name="ImgVideoPlay"
71
+                                    Cursor="Hand"
72
+                                    MouseLeftButtonDown="Image_MouseLeftButtonDown"
73
+                                    Source="/星火微课;component/Images/VideoList_Play.png" />
49 74
                             </Border>
50 75
                         </Grid>
51 76
                     </Grid>
52 77
                 </Grid>
53 78
             </Grid>
54
-            <!--信息-->
79
+            <!--  信息  -->
55 80
             <Grid Grid.Row="2">
56 81
                 <Grid.RowDefinitions>
57
-                    <RowDefinition Height="5*"></RowDefinition>
58
-                    <RowDefinition Height="30*"></RowDefinition>
59
-                    <RowDefinition Height="5*"></RowDefinition>
60
-                    <RowDefinition Height="30*"></RowDefinition>
61
-                    <RowDefinition Height="40*"></RowDefinition>
82
+                    <RowDefinition Height="5*" />
83
+                    <RowDefinition Height="30*" />
84
+                    <RowDefinition Height="5*" />
85
+                    <RowDefinition Height="30*" />
86
+                    <RowDefinition Height="40*" />
62 87
                 </Grid.RowDefinitions>
63
-                <!--名-->
88
+                <!--    -->
64 89
                 <Grid Grid.Row="1">
65
-                    <TextBlock x:Name="TbName" Text="一二三四五六七八九十一..." TextWrapping="Wrap" Foreground="#FF3492F4" FontSize="{Binding WordSize18}" TextAlignment="Center" ToolTip="" Visibility="Visible" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>
90
+                    <TextBlock
91
+                        x:Name="TbName"
92
+                        FontSize="{Binding WordSize18}"
93
+                        Foreground="#FF3492F4"
94
+                        MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"
95
+                        Text="一二三四五六七八九十一..."
96
+                        TextAlignment="Center"
97
+                        TextWrapping="Wrap"
98
+                        ToolTip=""
99
+                        Visibility="Visible" />
66 100
                     <Grid x:Name="GridModify" Visibility="Hidden">
67 101
                         <Grid.ColumnDefinitions>
68
-                            <ColumnDefinition Width="15*"/>
69
-                            <ColumnDefinition Width="190*"/>
70
-                            <ColumnDefinition Width="30*"/>
71
-                            <ColumnDefinition Width="15*"/>
102
+                            <ColumnDefinition Width="15*" />
103
+                            <ColumnDefinition Width="190*" />
104
+                            <ColumnDefinition Width="30*" />
105
+                            <ColumnDefinition Width="15*" />
72 106
                         </Grid.ColumnDefinitions>
73 107
                         <Grid Grid.Column="1">
74
-                            <TextBox x:Name="TxtModify"  TextWrapping="Wrap" Text="TextBox" FontSize="{Binding WordSize16}" LostFocus="TxtModify_LostFocus" KeyUp="TxtModify_KeyUp">
108
+                            <TextBox
109
+                                x:Name="TxtModify"
110
+                                FontSize="{Binding WordSize16}"
111
+                                KeyUp="TxtModify_KeyUp"
112
+                                LostFocus="TxtModify_LostFocus"
113
+                                Text="TextBox"
114
+                                TextWrapping="Wrap">
75 115
                                 <TextBox.Resources>
76 116
                                     <Style TargetType="{x:Type Border}">
77
-                                        <Setter Property="CornerRadius" Value="3"/>
78
-                                        <Setter Property="BorderBrush" Value="#3492F4"/>
117
+                                        <Setter Property="CornerRadius" Value="3" />
118
+                                        <Setter Property="BorderBrush" Value="#3492F4" />
79 119
                                     </Style>
80 120
                                 </TextBox.Resources>
81 121
                             </TextBox>
82 122
                         </Grid>
83 123
                         <Grid Grid.Column="2">
84
-                            <Button Cursor="Hand" x:Name="BtnNameModifyOK" Background="White" BorderBrush="#FFABADB3" Click="BtnNameModifyOK_Click">
124
+                            <Button
125
+                                x:Name="BtnNameModifyOK"
126
+                                Background="White"
127
+                                BorderBrush="#FFABADB3"
128
+                                Click="BtnNameModifyOK_Click"
129
+                                Cursor="Hand">
85 130
                                 <Button.Resources>
86 131
                                     <Style TargetType="{x:Type Border}">
87
-                                        <Setter Property="CornerRadius" Value="3"/>
88
-                                        <Setter Property="BorderBrush" Value="#3492F4"/>
132
+                                        <Setter Property="CornerRadius" Value="3" />
133
+                                        <Setter Property="BorderBrush" Value="#3492F4" />
89 134
                                     </Style>
90 135
                                 </Button.Resources>
91
-                                <Image Source="/星火微课;component/Images/VideoList_OK.png"></Image>
136
+                                <Image Source="/星火微课;component/Images/VideoList_OK.png" />
92 137
                             </Button>
93 138
                         </Grid>
94 139
                     </Grid>
95 140
                 </Grid>
96
-                <!--信息-->
141
+                <!--  信息  -->
97 142
                 <Grid Grid.Row="3">
98
-                    <Label x:Name="lblDateSize" Content="2020-10-10 10:10:00|1000.00MB" Foreground="#FF9A9A9A" FontSize="{Binding WordSize12}" HorizontalContentAlignment="Center"/>
143
+                    <Label
144
+                        x:Name="lblDateSize"
145
+                        HorizontalContentAlignment="Center"
146
+                        Content="2020-10-10 10:10:00|1000.00MB"
147
+                        FontSize="{Binding WordSize12}"
148
+                        Foreground="#FF9A9A9A" />
99 149
                 </Grid>
100
-                <!--按钮-->
150
+                <!--  按钮  -->
101 151
                 <Grid Grid.Row="4">
102 152
                     <Grid.ColumnDefinitions>
103
-                        <ColumnDefinition Width="20*"></ColumnDefinition>
104
-                        <ColumnDefinition Width="100*"></ColumnDefinition>
105
-                        <ColumnDefinition Width="10*"></ColumnDefinition>
106
-                        <ColumnDefinition Width="100*"></ColumnDefinition>
107
-                        <ColumnDefinition Width="20*"></ColumnDefinition>
153
+                        <ColumnDefinition Width="20*" />
154
+                        <ColumnDefinition Width="100*" />
155
+                        <ColumnDefinition Width="10*" />
156
+                        <ColumnDefinition Width="100*" />
157
+                        <ColumnDefinition Width="20*" />
108 158
                     </Grid.ColumnDefinitions>
109 159
                     <Grid Grid.Column="1">
110
-                        <Border x:Name="BorUploadBtn" CornerRadius="6" Background="#FF3492F4">
111
-                            <Button Cursor="Hand" x:Name="BtnUpload" Content="上传" Foreground="White" FontSize="{Binding WordSize18}" Click="BtnUpload_Click"  Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
160
+                        <Border
161
+                            x:Name="BorUploadBtn"
162
+                            Background="#FF3492F4"
163
+                            CornerRadius="6">
164
+                            <Button
165
+                                x:Name="BtnUpload"
166
+                                HorizontalAlignment="Stretch"
167
+                                VerticalAlignment="Stretch"
168
+                                Click="BtnUpload_Click"
169
+                                Content="上传"
170
+                                Cursor="Hand"
171
+                                FontSize="{Binding WordSize18}"
172
+                                Foreground="White"
173
+                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
112 174
                         </Border>
113 175
                     </Grid>
114 176
                     <Grid Grid.Column="3">
115
-                        <Border CornerRadius="6" Background="#FFC3C3C3">
116
-                            <Button Cursor="Hand" x:Name="BtnDelVideo" Content="删除"  Foreground="White" FontSize="{Binding WordSize18}" Background="Transparent" Click="BtnDelVideo_Click"  Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
177
+                        <Border Background="#FFC3C3C3" CornerRadius="6">
178
+                            <Button
179
+                                x:Name="BtnDelVideo"
180
+                                HorizontalAlignment="Stretch"
181
+                                VerticalAlignment="Stretch"
182
+                                Background="Transparent"
183
+                                Click="BtnDelVideo_Click"
184
+                                Content="删除"
185
+                                Cursor="Hand"
186
+                                FontSize="{Binding WordSize18}"
187
+                                Foreground="White"
188
+                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
117 189
                         </Border>
118 190
                     </Grid>
119 191
                 </Grid>

+ 2172
- 949
XHWK.WKTool/XHMicroLessonSystemWindow.xaml
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 211
- 389
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs Прегледај датотеку

@@ -8,6 +8,7 @@ using Common.system;
8 8
 using RobotpenGateway;
9 9
 
10 10
 using Spire.Pdf;
11
+using Spire.Pdf.Print;
11 12
 
12 13
 using System;
13 14
 using System.Collections.Generic;
@@ -38,6 +39,7 @@ using TStudyDigitalPen.HID;
38 39
 
39 40
 using XHWK.Model;
40 41
 using XHWK.WKTool.DAL;
42
+using XHWK.WKTool.Models;
41 43
 using XHWK.WKTool.Skin;
42 44
 using XHWK.WKTool.UControl;
43 45
 
@@ -100,15 +102,6 @@ namespace XHWK.WKTool
100 102
             End
101 103
         }
102 104
 
103
-        ///// <summary>
104
-        ///// 状态
105
-        ///// </summary>
106
-        //private State _state = State.End;
107
-        ///// <summary>
108
-        ///// 计时用
109
-        ///// </summary>
110
-        //private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
111
-
112 105
         #region 上传
113 106
 
114 107
         /// <summary>
@@ -154,60 +147,16 @@ namespace XHWK.WKTool
154 147
             new Aspose.Slides.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
155 148
             InitializeComponent();
156 149
 
157
-            float WorkW = PrimaryScreen.ScaleWorkingAreaSize.Width;
158
-            float WorkH = PrimaryScreen.ScaleWorkingAreaSize.Height;
159
-            double proportion = 1036.0 / 1290.0;
160
-            //限制大小 确保大屏幕下录制不会卡死  暂时
161
-            if (WorkW > 1920.0)
162
-            {
163
-                Width = 1290;
164
-                Height = 1036;
165
-            }
166
-            else
167
-            {
168
-                Width = (PrimaryScreen.ScaleWorkingAreaSize.Height) / proportion - (BorderThickness.Left + BorderThickness.Right);
169
-                Height = PrimaryScreen.ScaleWorkingAreaSize.Height - (BorderThickness.Top + BorderThickness.Bottom);
170
-            }
171
-            GridContent.Width = Width - 14;
172
-            GridContent.Height = Height;
173
-
174 150
             #region 调整文字大小
175 151
 
176 152
             APP.PageContextData.WordSize20 = 20.00;
177 153
             APP.PageContextData.WordSize18 = 18.00;
178 154
             APP.PageContextData.WordSize16 = 16.00;
179
-            double WordFontPro = GridContent.Height / 1030.00;
180
-            //txbNotConnected.FontSize = 16.00 * WordFontPro;//连接状态文字
181
-            //TxbTime.FontSize = 20.00 * WordFontPro;//录屏时间
182
-            //TxbType.FontSize = 20.00 * WordFontPro;//录屏消息
183
-            APP.PageContextData.WordSize20 = 20.00 * WordFontPro;
184
-            APP.PageContextData.WordSize18 = 18.00 * WordFontPro;
185
-            APP.PageContextData.WordSize16 = 16.00 * WordFontPro;
186
-            APP.PageContextData.WordSize14 = 14.00 * WordFontPro;
187
-            APP.PageContextData.WordSize12 = 12.00 * WordFontPro;
155
+            APP.PageContextData.WordSize14 = 14.00;
156
+            APP.PageContextData.WordSize12 = 12.00;
188 157
 
189 158
             #endregion 调整文字大小
190 159
 
191
-            #region 读取本地配置 废弃   2021年7月9日赵耀
192
-
193
-            //if (File.Exists(APP.DataPath + "interfaceAddress.txt")) //若不为空
194
-            //{
195
-            //    APP.apiUrl = System.IO.File.ReadAllText(APP.DataPath + "interfaceAddress.txt", Encoding.Default);
196
-            //}
197
-            //if (File.Exists(APP.DataPath + "imageUploadAddress.txt")) //若不为空
198
-            //{
199
-            //    APP.uploadUrl = System.IO.File.ReadAllText(APP.DataPath + "imageUploadAddress.txt", Encoding.Default);
200
-            //}
201
-            //if (File.Exists(APP.DataPath + "pictureShowsAddress.txt")) //若不为空
202
-            //{
203
-            //    APP.showImageUrl = System.IO.File.ReadAllText(APP.DataPath + "pictureShowsAddress.txt", Encoding.Default);
204
-            //}
205
-
206
-            #endregion 读取本地配置 废弃   2021年7月9日赵耀
207
-
208
-            //GridMain.Height= PrimaryScreen.ScaleScreenSize().Height - 40;
209
-            //this.Top = (screeHeight - this.Height) / 2;
210
-            //this.Left = (screeWidth - this.Width) / 2;
211 160
             ResizeMode = System.Windows.ResizeMode.CanMinimize;
212 161
             BtnPrint.IsEnabled = false;
213 162
 
@@ -225,14 +174,7 @@ namespace XHWK.WKTool
225 174
             APP.PageDrawList.Add(model_DrawData);
226 175
             txbv.Text = "v" + FileToolsCommon.GetConfigValue("VersionName");
227 176
             txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
228
-            //if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
229
-            //{
230
-            //    rbnY.IsChecked = true;
231
-            //}
232
-            //else
233
-            //{
234
-            //    rbnN.IsChecked = true;
235
-            //}
177
+
236 178
             txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
237 179
             Initialize();
238 180
             InitPen();
@@ -285,8 +227,6 @@ namespace XHWK.WKTool
285 227
             //wfhCamera.Visibility = Visibility.Hidden;
286 228
             ImgPDFPath = null;
287 229
             ImgPDFPath = new string[300];
288
-            //GridM.Height = GridM.ActualWidth / proportion;
289
-            //GridM.Height = GridM.Width / proportion;
290 230
         }
291 231
 
292 232
         /// <summary>
@@ -1287,8 +1227,6 @@ namespace XHWK.WKTool
1287 1227
                 APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
1288 1228
                 APP.W_JieTuWindow.Show();
1289 1229
             }
1290
-
1291
-            //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
1292 1230
         }
1293 1231
 
1294 1232
         /// <summary>
@@ -3859,31 +3797,6 @@ namespace XHWK.WKTool
3859 3797
                         num++;
3860 3798
                     }
3861 3799
 
3862
-                    #region 设置录屏唯一  废弃
3863
-
3864
-                    //if (FileToolsCommon.IsExistFile(VideoSavePathName))
3865
-                    //{
3866
-                    //    MessageBoxResult dr = MessageWindow.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
3867
-                    //    if (dr == MessageBoxResult.OK)
3868
-                    //    {
3869
-                    //        try
3870
-                    //        {
3871
-                    //            FileToolsCommon.DeleteFile(VideoSavePathName);
3872
-                    //            APP.VideoList.RemoveAll(x => x.VideoPath == VideoSavePathName);
3873
-                    //        }
3874
-                    //        catch (Exception ex)
3875
-                    //        {
3876
-                    //            LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
3877
-                    //        }
3878
-                    //    }
3879
-                    //    else
3880
-                    //    {
3881
-                    //        return;
3882
-                    //    }
3883
-                    //}
3884
-
3885
-                    #endregion 设置录屏唯一  废弃
3886
-
3887 3800
                     #region 禁用按钮
3888 3801
 
3889 3802
                     BtnPrint.IsEnabled = false;
@@ -4113,36 +4026,20 @@ namespace XHWK.WKTool
4113 4026
 
4114 4027
                     #endregion 设置大小
4115 4028
 
4116
-                    //System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, new ThreadStart(delegate
4117
-                    //{
4118
-                    //}));
4119 4029
                     Dispatcher.Invoke(() =>
4120 4030
                     {
4121 4031
                         //保存图片
4122
-                        ImageHelper.SaveUI(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
4123
-                        //ImageHelper.SaveUIToImage(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
4124
-                        //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(GridMain.ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(GridMain.ActualHeight * (PrimaryScreen.DpiY / 96f)), 0, 0);
4125
-                        //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)), (int)RsW, (int)RsH);
4126
-                        //ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)(ActualWidth * (PrimaryScreen.DpiX / 96f)), (int)(ActualHeight * (PrimaryScreen.DpiY / 96f)), 1281, 1026);
4032
+                        ImageHelper.SaveUI2(GridMain, FilePathName, gridActWidth, gridActHeight, (int)RsW, (int)RsH);
4033
+
4127 4034
                         SRTime = SRTime.AddMilliseconds(200);
4128
-                        //if (TxbTime.Visibility == Visibility.Hidden)
4129
-                        //{
4130
-                        //    TxbTime.Visibility = Visibility.Visible;
4131
-                        //    ImgLZImg.Visibility = Visibility.Visible;
4132
-                        //}
4035
+
4133 4036
                         if (SRTime.Hour > 0)
4134 4037
                         {
4135
-                            //Dispatcher.Invoke(() =>
4136
-                            //{
4137 4038
                             TxbTime.Text = SRTime.ToString("HH:mm:ss");
4138
-                            //});
4139 4039
                         }
4140 4040
                         else
4141 4041
                         {
4142
-                            //Dispatcher.Invoke(() =>
4143
-                            //{
4144 4042
                             TxbTime.Text = SRTime.ToString("mm:ss");
4145
-                            //});
4146 4043
                         }
4147 4044
                     });
4148 4045
                 }
@@ -4466,15 +4363,6 @@ namespace XHWK.WKTool
4466 4363
                 mouseDown = false;
4467 4364
                 HideAngleBorder();
4468 4365
 
4469
-                //隐藏跳转
4470
-                //txbCurrpage.Visibility = Visibility.Visible;
4471
-                //txtJump.Visibility = Visibility.Hidden;
4472
-                //BtnJumpPage.Visibility = Visibility.Hidden;
4473
-
4474
-                //if(!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
4475
-                //{
4476
-                //    ImgWG();
4477
-                //}
4478 4366
                 APP.PageContextData.currpage -= 1;
4479 4367
                 JumpPageClick();
4480 4368
             }
@@ -4492,15 +4380,6 @@ namespace XHWK.WKTool
4492 4380
                 mouseDown = false;
4493 4381
                 HideAngleBorder();
4494 4382
 
4495
-                //隐藏跳转
4496
-                //txbCurrpage.Visibility = Visibility.Visible;
4497
-                //txtJump.Visibility = Visibility.Hidden;
4498
-                //BtnJumpPage.Visibility = Visibility.Hidden;
4499
-
4500
-                //if (!APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
4501
-                //{
4502
-                //    ImgWG();
4503
-                //}
4504 4383
                 APP.PageContextData.currpage += 1;
4505 4384
                 JumpPageClick();
4506 4385
             }
@@ -4556,22 +4435,6 @@ namespace XHWK.WKTool
4556 4435
                         APP.PageDrawList[APP.PageContextData.currpage - 1].IsImageLocation = false;
4557 4436
                         if (APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.X > 0)
4558 4437
                         {
4559
-                            //var group = IMG.FindResource("Imageview") as TransformGroup;
4560
-                            //#region 高低 缩放比例
4561
-                            //if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
4562
-                            //{
4563
-                            //    var transform1 = group.Children[0] as ScaleTransform;
4564
-                            //    transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
4565
-                            //    transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
4566
-                            //    imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
4567
-                            //    imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
4568
-                            //}
4569
-                            //#endregion
4570
-                            //#region 坐标XY轴
4571
-                            //var transform = group.Children[1] as TranslateTransform;
4572
-                            //transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
4573
-                            //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
4574
-                            //#endregion
4575 4438
                             mouseDown = false;
4576 4439
                             ImgXY();
4577 4440
                         }
@@ -4598,23 +4461,6 @@ namespace XHWK.WKTool
4598 4461
             imgCanvas.Height = APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes.CenterY;
4599 4462
 
4600 4463
             imgCanvas.Margin = new Thickness(APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.X, APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation.Y, 0, 0);
4601
-            //imgCanvas.Margin.Left= APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
4602
-            //transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
4603
-        }
4604
-
4605
-        private void ImgWG()
4606
-        {
4607
-            mouseDown = false;
4608
-            APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
4609
-            {
4610
-                X = imgCanvas.Margin.Left,
4611
-                Y = imgCanvas.Margin.Top
4612
-            };
4613
-            APP.PageDrawList[APP.PageContextData.currpage - 1].ImageSizes = new ScaleTransform
4614
-            {
4615
-                CenterX = imgCanvas.ActualWidth,
4616
-                CenterY = imgCanvas.ActualHeight
4617
-            };
4618 4464
         }
4619 4465
 
4620 4466
         #endregion 分页
@@ -6357,13 +6203,6 @@ namespace XHWK.WKTool
6357 6203
             DataContext = APP.PageContextData;
6358 6204
         }
6359 6205
 
6360
-        /// <summary>
6361
-        /// 设置页面显示
6362
-        /// </summary>
6363
-        private void SetUp()
6364
-        {
6365
-        }
6366
-
6367 6206
         #endregion 方法
6368 6207
 
6369 6208
         #region 跳转
@@ -6419,33 +6258,6 @@ namespace XHWK.WKTool
6419 6258
 
6420 6259
         #region 原跳转
6421 6260
 
6422
-        /// <summary>
6423
-        /// 跳转页
6424
-        /// </summary>
6425
-        /// <param name="sender"></param>
6426
-        /// <param name="e"></param>
6427
-        private void txbCurrpage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
6428
-        {
6429
-            if (e.ClickCount == 2)
6430
-            {
6431
-                try
6432
-                {
6433
-                    if (int.Parse(txbCurrpage.Text) > 0)
6434
-                    {
6435
-                        //txtJump.Text = txbCurrpage.Text;
6436
-                        //txbCurrpage.Visibility = Visibility.Hidden;
6437
-                        //txtJump.Visibility = Visibility.Visible;
6438
-                        //BtnJumpPage.Visibility = Visibility.Visible;
6439
-                        //txtJump.Focus();
6440
-                        //txtJump.SelectAll();
6441
-                    }
6442
-                }
6443
-                catch (Exception)
6444
-                {
6445
-                }
6446
-            }
6447
-        }
6448
-
6449 6261
         /// <summary>
6450 6262
         /// 确定跳转
6451 6263
         /// </summary>
@@ -6505,94 +6317,6 @@ namespace XHWK.WKTool
6505 6317
 
6506 6318
         #endregion 原跳转
6507 6319
 
6508
-        #region 打印
6509
-
6510
-        /// <summary>
6511
-        /// 下拉框数据源
6512
-        /// </summary>
6513
-        public DataTable data = new DataTable();
6514
-
6515
-        private DataTable dtComponentsUniqueNo;
6516
-
6517
-        /// <summary>
6518
-        /// 打印进度
6519
-        /// </summary>
6520
-        private System.Timers.Timer timesPrint;
6521
-
6522
-        /// <summary>
6523
-        /// 打印消息
6524
-        /// </summary>
6525
-        private System.Timers.Timer timesPrintMsg;
6526
-
6527
-        private double wit = 0;
6528
-        private double hei = 0;
6529
-
6530
-        /// <summary>
6531
-        /// 打印状态消息
6532
-        /// </summary>
6533
-        private string PrintMsg = "打印中";
6534
-
6535
-        /// <summary>
6536
-        /// 打印初始化
6537
-        /// </summary>
6538
-        public void InitPrint()
6539
-        {
6540
-            ResizeMode = ResizeMode.NoResize;
6541
-            List<string> defaList = LatticeFileHelper.GetPrinterList(out string defa);
6542
-            if (defaList.Count > 0)
6543
-            {
6544
-                data.Columns.Add("Value");
6545
-                data.Columns.Add("Key");
6546
-                for (int i = 0; i < defaList.Count; i++)
6547
-                {
6548
-                    //创建一行
6549
-                    DataRow row = data.NewRow();
6550
-                    //将此行添加到table中
6551
-                    data.Rows.Add(row);
6552
-                    data.Rows[i]["Value"] = defaList[i];
6553
-                    data.Rows[i]["Key"] = i.ToString();
6554
-                }
6555
-                dtComponentsUniqueNo = data.DefaultView.ToTable();
6556
-                cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
6557
-                cmbClass.SelectedIndex = 0;
6558
-            }
6559
-
6560
-            Dictionary<int, int> dicItem = new Dictionary<int, int>();
6561
-            dicItem.Add(0, 600);
6562
-            dicItem.Add(1, 1200);
6563
-            CbxDpi.ItemsSource = dicItem;
6564
-            CbxDpi.SelectedIndex = 0;
6565
-
6566
-            Dictionary<int, string> dictypeItem = new Dictionary<int, string>();
6567
-            dictypeItem.Add(0, "2x2");
6568
-            dictypeItem.Add(1, "3x3");
6569
-            dictypeItem.Add(2, "4x4");
6570
-            CbxType.ItemsSource = dictypeItem;
6571
-            CbxType.SelectedIndex = 0;
6572
-            TQLInit();
6573
-        }
6574
-
6575
-        /// <summary>
6576
-        /// 初始化页面
6577
-        /// </summary>
6578
-        /// <param name="_imgPath"></param>
6579
-        /// <param name="_wit"></param>
6580
-        /// <param name="_hei"></param>
6581
-        public void InitializePrint(string _imgPath, double _wit, double _hei)
6582
-        {
6583
-            wit = _wit;
6584
-            hei = _hei;
6585
-            if (!string.IsNullOrWhiteSpace(_imgPath))
6586
-            {
6587
-                imgPri.Source = new BitmapImage(new Uri(_imgPath));
6588
-            }
6589
-            else
6590
-            {
6591
-                imgPri.Source = null;
6592
-            }
6593
-            GridPrintMask.Visibility = Visibility.Collapsed;
6594
-        }
6595
-
6596 6320
         #region TQL打印
6597 6321
 
6598 6322
         /// <summary>
@@ -6608,28 +6332,10 @@ namespace XHWK.WKTool
6608 6332
         private TmatrixClass TMC = new TmatrixClass();
6609 6333
         public static string gPrintFileName;
6610 6334
 
6611
-        //string gDirectory = Application.StartupPath;
6612
-        //string gFileName = "";
6613 6335
         private bool gbInitDone = false;
6614 6336
 
6615
-        //string gUserName = "";
6616
-        //string gPassword = "";
6617
-        //private string gEKeyStr;
6618
-
6619 6337
         private iTextSharp.text.Document document;
6620 6338
 
6621
-        private enum TMATRIX_POINT_TYPE
6622
-        {
6623
-            TmatrixPointType_2x2 = 0,	// 2x2 Point Type
6624
-            TmatrixPointType_3x3 = 1,	// 3x3 Point Type
6625
-        };
6626
-
6627
-        private enum TMATRIX_OBJECT_TYPE
6628
-        {
6629
-            TMATRIX_OT_ElementCode = 0,	// 此类型对象的Index范围是:75497472~83886079(十六进制为:0x04800000~0x04ffffff)
6630
-            TMATRIX_OT_PositionCode,		// 此类型对象没有Index
6631
-        };
6632
-
6633 6339
         /// <summary>
6634 6340
         /// TQL初始化打印
6635 6341
         /// </summary>
@@ -6696,38 +6402,27 @@ namespace XHWK.WKTool
6696 6402
                 catch (Exception)
6697 6403
                 {
6698 6404
                 }
6699
-                int i;
6700
-                for (i = 0; i < 4; i++)
6701
-                {
6702
-                    int DPIValue = 0;
6703
-                    int TypeValue = 0;
6704
-                    try
6705
-                    {
6706
-                        DPIValue = CbxDpi.SelectedIndex;
6707
-                        //TypeValue = CbxType.SelectedIndex;
6708
-                    }
6709
-                    catch (Exception)
6710
-                    {
6711
-                    }
6712
-                    APP.gPointType[i] = TypeValue;
6713
-                    APP.gPointDPI[i] = DPIValue;
6714
-                }
6715 6405
 
6716
-                APP.gbGenerateBGWithVImage = false;
6717
-                APP.gbGenerateVImage = false;
6718
-                APP.gbGenerateBGWithoutVImage = false;
6719
-                APP.gbGenerateBGWithImage = true;
6406
+                PDFPath = PDFPath.Replace("/", "\\");
6720 6407
 
6721 6408
                 //初始页
6722
-                int SPID = 0;
6723
-
6724 6409
                 bool[] bPublishImageType = new bool[4];
6725
-                bPublishImageType[0] = APP.gbGenerateBGWithVImage;
6726
-                bPublishImageType[1] = APP.gbGenerateVImage;
6727
-                bPublishImageType[2] = APP.gbGenerateBGWithoutVImage;
6728
-                bPublishImageType[3] = APP.gbGenerateBGWithImage;
6729
-                PDFPath = PDFPath.Replace("/", "\\");
6730
-                string sGenerateResult = TMC.GenerateTmatrixCode_OID4(gKeyStr, PDFPath, SPID, APP.gPointType, bPublishImageType, APP.gPointDPI);
6410
+                bPublishImageType[0] = false;
6411
+                bPublishImageType[1] = false;
6412
+                bPublishImageType[2] = false;
6413
+                bPublishImageType[3] = true;
6414
+
6415
+                int[] gPointType = { 0, 0, 0, 0, 1 };
6416
+                int[] gPointDPI = { 0, 0, 0, 0, 1 };
6417
+
6418
+                string sGenerateResult = TMC.GenerateTmatrixCode_OID4(
6419
+                        gKeyStr,
6420
+                        PDFPath,
6421
+                        0,
6422
+                        gPointType,
6423
+                        bPublishImageType,
6424
+                        gPointDPI
6425
+                    );
6731 6426
                 if (sGenerateResult.Substring(0, 1) == "1")
6732 6427
                 {
6733 6428
                     Dispatcher.Invoke(() =>
@@ -6752,6 +6447,8 @@ namespace XHWK.WKTool
6752 6447
 
6753 6448
         #endregion TQL打印
6754 6449
 
6450
+        #region 事件
6451
+
6755 6452
         /// <summary>
6756 6453
         /// 打印
6757 6454
         /// </summary>
@@ -6766,7 +6463,7 @@ namespace XHWK.WKTool
6766 6463
             }
6767 6464
             BtnPrint.IsEnabled = false;
6768 6465
             Thread myThread = new Thread(StartPrint);
6769
-            List<string> StrList = new List<string>();
6466
+            PrintModel printmodel = new PrintModel();
6770 6467
 
6771 6468
             int ipdf = 102;
6772 6469
             string imgPath = FileToolsCommon.GetFileAbsolutePath("temp/");
@@ -6777,18 +6474,18 @@ namespace XHWK.WKTool
6777 6474
                 imgPath = tempImgPath + ipdf.ToString() + ".pdf";
6778 6475
                 ipdf++;
6779 6476
             }
6780
-            StrList.Add(imgPath);
6477
+            printmodel.filepath = imgPath;
6781 6478
             //打印数量
6782 6479
             int PrinterNum = Convert.ToInt32(txbNumberOfCopies.Content);
6783
-            StrList.Add(PrinterNum.ToString());
6480
+            printmodel.num = PrinterNum;
6784 6481
             //打印机名称
6785 6482
             string PrinterName = cmbClass.Text;
6786
-            StrList.Add(PrinterName);
6483
+            printmodel.printname = PrinterName;
6787 6484
             PrintMsg = "准备中";
6788 6485
             msgnum = 0;
6789 6486
             num = 0;
6790 6487
             GridPrintMask.Visibility = Visibility.Visible;
6791
-            myThread.Start(StrList);
6488
+            myThread.Start(printmodel);
6792 6489
             timesPrint = new System.Timers.Timer(100);
6793 6490
             timesPrint.Elapsed += Times_ElapsedClick;
6794 6491
             timesPrint.Start();
@@ -6798,6 +6495,136 @@ namespace XHWK.WKTool
6798 6495
             timesPrintMsg.Start();
6799 6496
         }
6800 6497
 
6498
+        /// <summary>
6499
+        /// 减
6500
+        /// </summary>
6501
+        /// <param name="sender"></param>
6502
+        /// <param name="e"></param>
6503
+        private void BtnPrintLess_Click(object sender, RoutedEventArgs e)
6504
+        {
6505
+            int num = Convert.ToInt32(txbNumberOfCopies.Content);
6506
+            if (num > 1)
6507
+            {
6508
+                num--;
6509
+                txbNumberOfCopies.Content = num.ToString();
6510
+            }
6511
+        }
6512
+
6513
+        /// <summary>
6514
+        /// 新增
6515
+        /// </summary>
6516
+        /// <param name="sender"></param>
6517
+        /// <param name="e"></param>
6518
+        private void BtnPrintAdd_Click(object sender, RoutedEventArgs e)
6519
+        {
6520
+            int num = Convert.ToInt32(txbNumberOfCopies.Content);
6521
+            if (num > 0)
6522
+            {
6523
+                num++;
6524
+                txbNumberOfCopies.Content = num.ToString();
6525
+            }
6526
+        }
6527
+
6528
+        /// <summary>
6529
+        /// 打印说明
6530
+        /// </summary>
6531
+        /// <param name="sender"></param>
6532
+        /// <param name="e"></param>
6533
+        private void btnPrintExplain_Click(object sender, RoutedEventArgs e)
6534
+        {
6535
+            System.Diagnostics.Process.Start(FileToolsCommon.GetFileAbsolutePath("/星火微课点阵码打印及印刷指导手册.docx"));
6536
+        }
6537
+
6538
+        #endregion 事件
6539
+
6540
+        #region 打印界面
6541
+
6542
+        /// <summary>
6543
+        /// 下拉框数据源
6544
+        /// </summary>
6545
+        public DataTable data = new DataTable();
6546
+
6547
+        private DataTable dtComponentsUniqueNo;
6548
+
6549
+        /// <summary>
6550
+        /// 打印进度
6551
+        /// </summary>
6552
+        private System.Timers.Timer timesPrint;
6553
+
6554
+        /// <summary>
6555
+        /// 打印消息
6556
+        /// </summary>
6557
+        private System.Timers.Timer timesPrintMsg;
6558
+
6559
+        private double wit = 0;
6560
+        private double hei = 0;
6561
+
6562
+        /// <summary>
6563
+        /// 打印状态消息
6564
+        /// </summary>
6565
+        private string PrintMsg = "打印中";
6566
+
6567
+        /// <summary>
6568
+        /// 打印初始化
6569
+        /// </summary>
6570
+        public void InitPrint()
6571
+        {
6572
+            ResizeMode = ResizeMode.NoResize;
6573
+            List<string> defaList = LatticeFileHelper.GetPrinterList(out string defa);
6574
+            if (defaList.Count > 0)
6575
+            {
6576
+                data.Columns.Add("Value");
6577
+                data.Columns.Add("Key");
6578
+                for (int i = 0; i < defaList.Count; i++)
6579
+                {
6580
+                    //创建一行
6581
+                    DataRow row = data.NewRow();
6582
+                    //将此行添加到table中
6583
+                    data.Rows.Add(row);
6584
+                    data.Rows[i]["Value"] = defaList[i];
6585
+                    data.Rows[i]["Key"] = i.ToString();
6586
+                }
6587
+                dtComponentsUniqueNo = data.DefaultView.ToTable();
6588
+                cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
6589
+                cmbClass.SelectedIndex = 0;
6590
+            }
6591
+
6592
+            Dictionary<int, int> dicItem = new Dictionary<int, int>();
6593
+            dicItem.Add(0, 600);
6594
+            dicItem.Add(1, 1200);
6595
+            CbxDpi.ItemsSource = dicItem;
6596
+            CbxDpi.SelectedIndex = 0;
6597
+
6598
+            Dictionary<int, string> dictypeItem = new Dictionary<int, string>();
6599
+            dictypeItem.Add(0, "2x2");
6600
+            dictypeItem.Add(1, "3x3");
6601
+            dictypeItem.Add(2, "4x4");
6602
+            CbxType.ItemsSource = dictypeItem;
6603
+            CbxType.SelectedIndex = 0;
6604
+            TQLInit();
6605
+        }
6606
+
6607
+        /// <summary>
6608
+        /// 初始化页面
6609
+        /// </summary>
6610
+        /// <param name="_imgPath"></param>
6611
+        /// <param name="_wit"></param>
6612
+        /// <param name="_hei"></param>
6613
+        public void InitializePrint(string _imgPath, double _wit, double _hei)
6614
+        {
6615
+            wit = _wit;
6616
+            hei = _hei;
6617
+            if (!string.IsNullOrWhiteSpace(_imgPath))
6618
+            {
6619
+                imgPri.Source = new BitmapImage(new Uri(_imgPath));
6620
+            }
6621
+            else
6622
+            {
6623
+                imgPri.Source = null;
6624
+            }
6625
+            GridPrintMask.Visibility = Visibility.Collapsed;
6626
+        }
6627
+
6801 6628
         private int msgnum = 0;
6802 6629
 
6803 6630
         /// <summary>
@@ -6849,13 +6676,14 @@ namespace XHWK.WKTool
6849 6676
         /// </summary>
6850 6677
         private void StartPrint(object obj)
6851 6678
         {
6679
+            PrintModel printModel = (PrintModel)obj;
6852 6680
             try
6853 6681
             {
6854 6682
                 document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 0f, 0f, 0f, 0f);
6855 6683
                 PrintMsg = "生成文件";
6856 6684
                 msgnum = 0;
6857
-                List<string> objStr1 = (List<string>)obj;
6858
-                string SourcePath1 = objStr1[0];
6685
+
6686
+                string SourcePath1 = printModel.filepath;
6859 6687
                 try
6860 6688
                 {
6861 6689
                     SourcePath1 = SourcePath1.Replace("/", "\\");
@@ -6868,7 +6696,6 @@ namespace XHWK.WKTool
6868 6696
                     document.AddKeywords("Print");
6869 6697
 
6870 6698
                     document.AddHeader("TmatrixCode", "0");
6871
-                    Thread.Sleep(300);
6872 6699
 
6873 6700
                     iTextSharp.text.pdf.PdfWriter.GetInstance(document, fs);
6874 6701
                 }
@@ -6928,12 +6755,8 @@ namespace XHWK.WKTool
6928 6755
                     image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
6929 6756
                     document.NewPage();
6930 6757
                     document.Add(image);
6931
-                    //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
6932
-                    //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
6933
-                    //p1.Leading = 150;      //行间距
6934
-                    //document.Add(p1);
6935 6758
                 }
6936
-                //Console.WriteLine("转换成功!");
6759
+
6937 6760
                 document.Close();
6938 6761
             }
6939 6762
             catch (Exception ex)
@@ -6950,11 +6773,10 @@ namespace XHWK.WKTool
6950 6773
                 LogHelper.WriteErrLog("打印转换PDF失败,原因:" + ex.Message, ex);
6951 6774
             }
6952 6775
 
6953
-            List<string> objStr = (List<string>)obj;
6954 6776
             //PDF位置
6955
-            string SourcePath = objStr[0];
6956
-            int PrinterNum = int.Parse(objStr[1]);
6957
-            string PrinterName = objStr[2];
6777
+            string SourcePath = printModel.filepath;
6778
+            int PrinterNum = printModel.num;
6779
+            string PrinterName = printModel.printname;
6958 6780
             PrintMsg = "铺码中";
6959 6781
             msgnum = 0;
6960 6782
             Thread.Sleep(500);
@@ -6967,6 +6789,7 @@ namespace XHWK.WKTool
6967 6789
 
6968 6790
                 try
6969 6791
                 {
6792
+                    // 腾千里会根据原PDF的页数生成多个PDF文件
6970 6793
                     for (int i = 0; i < strs.Count(); i++)
6971 6794
                     {
6972 6795
                         timesPrint.Stop();
@@ -6976,7 +6799,8 @@ namespace XHWK.WKTool
6976 6799
                         timesPrint.Interval = 100;
6977 6800
                         timesPrint.Start();
6978 6801
                         string fileName = strs[i];
6979
-                        Print(fileName, PrinterName, (short)PrinterNum);
6802
+                        //打印文件
6803
+                        Print2(fileName, PrinterName, (short)PrinterNum);
6980 6804
                     }
6981 6805
                 }
6982 6806
                 catch (Exception ex)
@@ -7073,6 +6897,8 @@ namespace XHWK.WKTool
7073 6897
         /// <param name="PrinterName">打印机名称</param>
7074 6898
         private void Print(string PDFPath, string PrinterName, short PrinterNum = 1)
7075 6899
         {
6900
+            Console.WriteLine("PDFPath:" + PDFPath);
6901
+            //PDFPath = "D:/123.pdf";
7076 6902
             //加载PDF文档
7077 6903
             PdfDocument doc = new PdfDocument();
7078 6904
             doc.LoadFromFile(PDFPath);
@@ -7091,10 +6917,46 @@ namespace XHWK.WKTool
7091 6917
 
7092 6918
             //设置打印份数为2份
7093 6919
             doc.PrintSettings.Copies = PrinterNum;
6920
+
6921
+            doc.PrintSettings.PrinterResolutionKind = PdfPrinterResolutionKind.High;
6922
+            //获取原文档第一页的纸张大小,这里的单位是Point
6923
+
6924
+            doc.PrintSettings.SelectSinglePageLayout(PdfSinglePageScalingMode.ActualSize, true);
7094 6925
             //打印PDF文档
6926
+
7095 6927
             doc.Print();
7096 6928
         }
7097 6929
 
6930
+        private void Print2(string PDFPath, string PrinterName, short PrinterNum = 1)
6931
+        {
6932
+            PrintDocument pd = new PrintDocument();
6933
+
6934
+            Process p = new Process();
6935
+
6936
+            ProcessStartInfo startInfo = new ProcessStartInfo();
6937
+
6938
+            startInfo.CreateNoWindow = true;
6939
+
6940
+            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
6941
+
6942
+            startInfo.UseShellExecute = true;
6943
+
6944
+            startInfo.FileName = PDFPath;
6945
+
6946
+            startInfo.Verb = "print";
6947
+
6948
+            Console.WriteLine("PrinterName:"+ PrinterName);
6949
+            Console.WriteLine("pd.PrinterSettings.PrinterName", pd.PrinterSettings.PrinterName);
6950
+
6951
+            startInfo.Arguments = @"/p /h \" + PDFPath + "\"\"" + PrinterName + "\"";
6952
+
6953
+            p.StartInfo = startInfo;
6954
+
6955
+            p.Start();
6956
+
6957
+            p.WaitForExit();
6958
+        }
6959
+
7098 6960
         /// <summary>
7099 6961
         /// 生成图片
7100 6962
         /// </summary>
@@ -7151,47 +7013,7 @@ namespace XHWK.WKTool
7151 7013
             }
7152 7014
         }
7153 7015
 
7154
-        /// <summary>
7155
-        /// 减
7156
-        /// </summary>
7157
-        /// <param name="sender"></param>
7158
-        /// <param name="e"></param>
7159
-        private void BtnPrintLess_Click(object sender, RoutedEventArgs e)
7160
-        {
7161
-            int num = Convert.ToInt32(txbNumberOfCopies.Content);
7162
-            if (num > 1)
7163
-            {
7164
-                num--;
7165
-                txbNumberOfCopies.Content = num.ToString();
7166
-            }
7167
-        }
7168
-
7169
-        /// <summary>
7170
-        /// 新增
7171
-        /// </summary>
7172
-        /// <param name="sender"></param>
7173
-        /// <param name="e"></param>
7174
-        private void BtnPrintAdd_Click(object sender, RoutedEventArgs e)
7175
-        {
7176
-            int num = Convert.ToInt32(txbNumberOfCopies.Content);
7177
-            if (num > 0)
7178
-            {
7179
-                num++;
7180
-                txbNumberOfCopies.Content = num.ToString();
7181
-            }
7182
-        }
7183
-
7184
-        /// <summary>
7185
-        /// 打印说明
7186
-        /// </summary>
7187
-        /// <param name="sender"></param>
7188
-        /// <param name="e"></param>
7189
-        private void btnPrintExplain_Click(object sender, RoutedEventArgs e)
7190
-        {
7191
-            System.Diagnostics.Process.Start(FileToolsCommon.GetFileAbsolutePath("/星火微课点阵码打印及印刷指导手册.docx"));
7192
-        }
7193
-
7194
-        #endregion 打印
7016
+        #endregion 打印界面
7195 7017
 
7196 7018
         #region 设备检测
7197 7019
 

+ 3
- 14
XHWK.WKTool/XHWK.WKTool.csproj Прегледај датотеку

@@ -229,9 +229,6 @@
229 229
     <Compile Include="DeviceWindow.xaml.cs">
230 230
       <DependentUpon>DeviceWindow.xaml</DependentUpon>
231 231
     </Compile>
232
-    <Compile Include="FileDirectoryWindow.xaml.cs">
233
-      <DependentUpon>FileDirectoryWindow.xaml</DependentUpon>
234
-    </Compile>
235 232
     <Compile Include="Helpers\BackgroundWorkerHelper.cs" />
236 233
     <Compile Include="Helpers\ScreenHelper.cs" />
237 234
     <Compile Include="Helpers\WpfHelper.cs" />
@@ -258,16 +255,16 @@
258 255
     <Compile Include="Models\AppModel.cs" />
259 256
     <Compile Include="Models\Direction.cs" />
260 257
     <Compile Include="Models\EntityBase.cs" />
258
+    <Compile Include="Models\FileDirectoryData.cs" />
259
+    <Compile Include="Models\FileDirectoryModel.cs" />
261 260
     <Compile Include="Models\Limit.cs" />
261
+    <Compile Include="Models\PrintModel.cs" />
262 262
     <Compile Include="Models\Tool.cs" />
263 263
     <Compile Include="license\MyLicense.cs" />
264 264
     <Compile Include="Models\DownloadInfoModel.cs" />
265 265
     <Compile Include="PracticeWindow.xaml.cs">
266 266
       <DependentUpon>PracticeWindow.xaml</DependentUpon>
267 267
     </Compile>
268
-    <Compile Include="PrintWindow.xaml.cs">
269
-      <DependentUpon>PrintWindow.xaml</DependentUpon>
270
-    </Compile>
271 268
     <Compile Include="ProductVerification.xaml.cs">
272 269
       <DependentUpon>ProductVerification.xaml</DependentUpon>
273 270
     </Compile>
@@ -368,10 +365,6 @@
368 365
       <SubType>Designer</SubType>
369 366
       <Generator>MSBuild:Compile</Generator>
370 367
     </Page>
371
-    <Page Include="PrintWindow.xaml">
372
-      <SubType>Designer</SubType>
373
-      <Generator>MSBuild:Compile</Generator>
374
-    </Page>
375 368
     <Page Include="ProductVerification.xaml">
376 369
       <SubType>Designer</SubType>
377 370
       <Generator>MSBuild:Compile</Generator>
@@ -416,10 +409,6 @@
416 409
       <Generator>MSBuild:Compile</Generator>
417 410
       <SubType>Designer</SubType>
418 411
     </Page>
419
-    <Page Include="FileDirectoryWindow.xaml">
420
-      <SubType>Designer</SubType>
421
-      <Generator>MSBuild:Compile</Generator>
422
-    </Page>
423 412
     <Page Include="LoginWindow.xaml">
424 413
       <SubType>Designer</SubType>
425 414
       <Generator>MSBuild:Compile</Generator>

+ 1
- 1
XHWK.WKTool/XHWK.WKTool.csproj.user Прегледај датотеку

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="utf-8"?>
2 2
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 3
   <PropertyGroup>
4
-    <ProjectView>ShowAllFiles</ProjectView>
4
+    <ProjectView>ProjectFiles</ProjectView>
5 5
   </PropertyGroup>
6 6
 </Project>

+ 102
- 64
XHWK.WKTool/system/FFMpeg.cs Прегледај датотеку

@@ -14,23 +14,22 @@ using VisioForge.Shared.NAudio.Wave;
14 14
 namespace Common.system
15 15
 {
16 16
     /// <summary>
17
-    /// ffmpeg帮助类
18
-    /// 创建人:赵耀
19
-    /// 创建时间::2020年8月22日
20
-    /// 需要安装\SSCR\Setup Screen Capturer Recorder v0.12.10.exe
17
+    /// ffmpeg帮助类 创建人:赵耀 创建时间::2020年8月22日 需要安装\SSCR\Setup Screen Capturer Recorder v0.12.10.exe
21 18
     /// 本地调试需要配置环境变量 将ffmpeg.exe位置配置到环境变量的path中
22 19
     /// </summary>
23 20
     public class FFMpeg
24 21
     {
25 22
         #region 变量
23
+
26 24
         public Process myProcess = null;
27 25
 
28 26
         /// <summary>
29 27
         /// 是否输出录课录屏日志
30 28
         /// </summary>
31 29
         public bool OutputVideoLog = FileToolsCommon.GetConfigValue("OutputVideoLog") != "0";
30
+
32 31
         /// <summary>
33
-        /// ffmpeg输出日志文件地址  每个文件2MB左右
32
+        /// ffmpeg输出日志文件地址 每个文件2MB左右
34 33
         /// </summary>
35 34
         private string LogPath = "";
36 35
 
@@ -43,7 +42,9 @@ namespace Common.system
43 42
         /// 是否可以录制麦克风
44 43
         /// </summary>
45 44
         private bool IsRecordMicrophone = true;
46
-        #endregion
45
+
46
+        #endregion 变量
47
+
47 48
         /// <summary>
48 49
         /// 录制屏幕
49 50
         /// </summary>
@@ -78,7 +79,9 @@ namespace Common.system
78 79
             {
79 80
                 MicrophoneName = GetMicrophoneName();
80 81
             }
82
+
81 83
             #region 检测麦克风扬声器
84
+
82 85
             string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
83 86
             FileToolsCommon.CreateDirectory(AudioPath);
84 87
             string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";//FileToolsCommon.GetFileAbsolutePath("adoS.m");
@@ -90,7 +93,6 @@ namespace Common.system
90 93
             }
91 94
             catch (Exception)
92 95
             {
93
-
94 96
             }
95 97
             //是否录制音频
96 98
             if (RecordingSound)
@@ -121,7 +123,9 @@ namespace Common.system
121 123
                 }
122 124
                 StopRecordAudio(1);
123 125
             }
124
-            #endregion
126
+
127
+            #endregion 检测麦克风扬声器
128
+
125 129
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
126 130
             string SpeakerStr = "";
127 131
             string MicrophoneStr = "";
@@ -140,30 +144,15 @@ namespace Common.system
140 144
             {
141 145
                 case ".MP4":
142 146
                     myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -framerate 6 -offset_x 0 -offset_y 0 -video_size " + size.Width + "x" + size.Height + " -i desktop -pix_fmt yuv420p -vf scale=trunc(iw/2)*2:trunc(ih/2)*2 -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
143
-                    //myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f dshow -i video=\"screen-capture-recorder\" -pix_fmt yuv420p -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
144
-                    //if (string.IsNullOrWhiteSpace(MicrophoneName))
145
-                    //{
146
-                    //    myProcess.StartInfo.Arguments = "-f dshow -i video=\"screen-capture-recorder\" -f dshow -i audio=\"virtual-audio-capturer\" -vcodec libx264 -acodec libmp3lame -r 15 -crf 22 " + PathName;  //ffmpeg的参数
147
-                    //}
148
-                    //else
149
-                    //{
150
-                    //    myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" -f dshow -i audio=\"" +
151
-                    //        MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -i video=\"screen-capture-recorder\" -pix_fmt yuv420p -vcodec h264 -preset:v ultrafast -tune:v zerolatency -acodec aac -ar 44100 -ac 2 " + PathName;  //ffmpeg的参数
152
-                    //}
147
+
153 148
                     break;
149
+
154 150
                 case ".AVI":
155 151
                 case ".FLV":
156 152
                     myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -framerate 6 -offset_x 0 -offset_y 0 -video_size " + size.Width + "x" + size.Height + " -i desktop -pix_fmt yuv420p -vf scale=trunc(iw/2)*2:trunc(ih/2)*2 -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac -f " + Extension.ToLower().Replace(".", "") + " " + PathName;
157
-                    //if (string.IsNullOrWhiteSpace(MicrophoneName))
158
-                    //{
159
-                    //    myProcess.StartInfo.Arguments = "-f dshow -i video=\"screen-capture-recorder\" -f dshow -i audio=\"virtual-audio-capturer\" -vcodec libx264 -acodec libmp3lame -r 15 -crf 22 -f " + Extension.ToLower() + " " + PathName;  //ffmpeg的参数
160
-                    //}
161
-                    //else
162
-                    //{
163
-                    //    myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" -f dshow -i audio=\"" +
164
-                    //        MicrophoneName + "\" -filter_complex amix=inputs=2:duration=first:dropout_transition=2 -f dshow -i video=\"screen-capture-recorder\" -pix_fmt yuv420p -vcodec h264 -preset:v ultrafast -tune:v zerolatency -acodec aac -ar 44100 -ac 2 -f " + Extension.ToLower() + " " + PathName;  //ffmpeg的参数
165
-                    //}
153
+
166 154
                     break;
155
+
167 156
                 default:
168 157
                     myProcess.StartInfo.Arguments = SpeakerStr + MicrophoneStr + " -f gdigrab -framerate 6 -offset_x 0 -offset_y 0 -video_size " + size.Width + "x" + size.Height + " -i desktop -pix_fmt yuv420p -vf scale=trunc(iw/2)*2:trunc(ih/2)*2 -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -acodec aac " + PathName;
169 158
                     break;
@@ -229,7 +218,9 @@ namespace Common.system
229 218
             {
230 219
                 MicrophoneName = GetMicrophoneName();
231 220
             }
221
+
232 222
             #region 检测麦克风扬声器
223
+
233 224
             string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
234 225
             FileToolsCommon.CreateDirectory(AudioPath);
235 226
             string audioSpeakerPath = AudioPath + "adoS" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".m";
@@ -241,7 +232,6 @@ namespace Common.system
241 232
             }
242 233
             catch (Exception)
243 234
             {
244
-
245 235
             }
246 236
             if (RecordingSound)
247 237
             {
@@ -278,10 +268,11 @@ namespace Common.system
278 268
                 {
279 269
                     ErrMessage = "无法录制麦克风,请关闭杀毒软件,确保麦克风处于可用状态!";
280 270
                     //return false;
281
-
282 271
                 }
283 272
             }
284
-            #endregion
273
+
274
+            #endregion 检测麦克风扬声器
275
+
285 276
             myProcess = new Process();
286 277
             LogPath = CreateffmpegLog();
287 278
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
@@ -349,7 +340,9 @@ namespace Common.system
349 340
                 myProcess.Close();//关闭进程
350 341
                 myProcess.Dispose();//释放资源
351 342
             }
343
+
352 344
             #region 进程是否已经释放
345
+
353 346
             bool IsRunning = true;
354 347
             while (IsRunning)
355 348
             {
@@ -361,7 +354,9 @@ namespace Common.system
361 354
                     Thread.Sleep(100);
362 355
                 }
363 356
             }
364
-            #endregion
357
+
358
+            #endregion 进程是否已经释放
359
+
365 360
             myProcess = null;
366 361
             return true;
367 362
             //myProcess.Kill();
@@ -387,7 +382,9 @@ namespace Common.system
387 382
             {
388 383
                 myProcess = null;
389 384
             }
385
+
390 386
             #region 进程是否已经释放
387
+
391 388
             bool IsRunning = true;
392 389
             while (IsRunning)
393 390
             {
@@ -399,7 +396,9 @@ namespace Common.system
399 396
                     Thread.Sleep(100);
400 397
                 }
401 398
             }
402
-            #endregion
399
+
400
+            #endregion 进程是否已经释放
401
+
403 402
             try
404 403
             {
405 404
                 myProcess = null;
@@ -426,10 +425,6 @@ namespace Common.system
426 425
         /// <param name="VideoHeight">视频高度</param>
427 426
         public bool SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight, out string ErrMessage)
428 427
         {
429
-            //new Thread(new ThreadStart(new Action(() =>
430
-            //{
431
-
432
-            //}))).Start();
433 428
             while (myProcess != null)
434 429
             {
435 430
                 Thread.Sleep(100);
@@ -437,7 +432,7 @@ namespace Common.system
437 432
             ErrMessage = null;
438 433
             string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
439 434
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
440
-            //Debug.WriteLine(KillProcessArray.Length.ToString());
435
+       
441 436
             foreach (Process KillProcess in KillProcessArray)
442 437
             {
443 438
                 KillProcess.Kill();
@@ -445,10 +440,11 @@ namespace Common.system
445 440
             myProcess = new Process();
446 441
             try
447 442
             {
448
-
449 443
                 LogPath = CreateffmpegLog();
450 444
                 string mp3Str = "";
445
+
451 446
                 #region 判断音频是否存在
447
+
452 448
                 if (!string.IsNullOrWhiteSpace(Mp3Path))
453 449
                 {
454 450
                     if (FileToolsCommon.IsExistFile(Mp3Path))
@@ -456,7 +452,9 @@ namespace Common.system
456 452
                         mp3Str = "-i " + Mp3Path;
457 453
                     }
458 454
                 }
459
-                #endregion
455
+
456
+                #endregion 判断音频是否存在
457
+
460 458
                 myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
461 459
                 switch (Extension.ToUpper())
462 460
                 {
@@ -466,18 +464,21 @@ namespace Common.system
466 464
                             mp3Str + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
467 465
                             VideoSavePath;
468 466
                         break;
467
+
469 468
                     case ".AVI":
470 469
                         myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
471 470
                             ImageListPath + @"%d.png " +
472 471
                             mp3Str + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
473 472
                             VideoSavePath;
474 473
                         break;
474
+
475 475
                     case ".FLV":
476 476
                         myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
477 477
                             ImageListPath + @"%d.png " +
478 478
                             mp3Str + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
479 479
                             VideoSavePath;
480 480
                         break;
481
+
481 482
                     default:
482 483
                         myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
483 484
                             ImageListPath + @"%d.png " +
@@ -520,7 +521,9 @@ namespace Common.system
520 521
                     return false;
521 522
                 }
522 523
                 myProcess.Dispose();               //释放资源
524
+
523 525
                 #region 进程是否已经释放
526
+
524 527
                 bool IsRunning = true;
525 528
                 while (IsRunning)
526 529
                 {
@@ -532,7 +535,9 @@ namespace Common.system
532 535
                         Thread.Sleep(100);
533 536
                     }
534 537
                 }
535
-                #endregion
538
+
539
+                #endregion 进程是否已经释放
540
+
536 541
                 myProcess = null;
537 542
                 //生成视频后删除图片和音频保存列表
538 543
                 //FileToolsCommon.DeleteDirectory(ImageListPath);
@@ -582,7 +587,9 @@ namespace Common.system
582 587
             //{
583 588
             //    KillProcess.Kill();
584 589
             //}
590
+
585 591
             #region 判断文件是否存在
592
+
586 593
             if (Extension.ToUpper() == ".MP3")
587 594
             {
588 595
                 if (!FileToolsCommon.IsExistFile(Path + "temp/filelist.d"))
@@ -597,7 +604,9 @@ namespace Common.system
597 604
                     return;
598 605
                 }
599 606
             }
600
-            #endregion
607
+
608
+            #endregion 判断文件是否存在
609
+
601 610
             myProcess = new Process();
602 611
             LogPath = CreateffmpegLog();
603 612
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
@@ -607,7 +616,6 @@ namespace Common.system
607 616
             }
608 617
             else
609 618
             {
610
-
611 619
                 myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temprs/filelist.d -c copy " + FilePath;
612 620
             }
613 621
             if (OutputVideoLog)
@@ -627,7 +635,9 @@ namespace Common.system
627 635
             myProcess.WaitForExit();           //阻塞等待进程结束
628 636
             myProcess.Close();                 //关闭进程
629 637
             myProcess.Dispose();               //释放资源
638
+
630 639
             #region 进程是否已经释放
640
+
631 641
             bool IsRunning = true;
632 642
             while (IsRunning)
633 643
             {
@@ -639,7 +649,9 @@ namespace Common.system
639 649
                     Thread.Sleep(100);
640 650
                 }
641 651
             }
642
-            #endregion
652
+
653
+            #endregion 进程是否已经释放
654
+
643 655
             myProcess = null;
644 656
             if (Extension.ToUpper() == ".MP3")
645 657
             {
@@ -693,7 +705,9 @@ namespace Common.system
693 705
             myProcess.WaitForExit();           //阻塞等待进程结束
694 706
             myProcess.Close();                 //关闭进程
695 707
             myProcess.Dispose();               //释放资源
708
+
696 709
             #region 进程是否已经释放
710
+
697 711
             bool IsRunning = true;
698 712
             while (IsRunning)
699 713
             {
@@ -705,7 +719,9 @@ namespace Common.system
705 719
                     Thread.Sleep(100);
706 720
                 }
707 721
             }
708
-            #endregion
722
+
723
+            #endregion 进程是否已经释放
724
+
709 725
             myProcess = null;
710 726
         }
711 727
 
@@ -768,6 +784,7 @@ namespace Common.system
768 784
             FileToolsCommon.AppendText(tempFilePath + "filelist.d", "file ./" + num + Extension + "\r\n");
769 785
             return CompleteFilePath;
770 786
         }
787
+
771 788
         /// <summary>
772 789
         /// 生成缩略图
773 790
         /// </summary>
@@ -816,7 +833,9 @@ namespace Common.system
816 833
                 myProcess.WaitForExit();           //阻塞等待进程结束
817 834
                 myProcess.Close();                 //关闭进程
818 835
                 myProcess.Dispose();               //释放资源
836
+
819 837
                 #region 进程是否已经释放
838
+
820 839
                 bool IsRunning = true;
821 840
                 while (IsRunning)
822 841
                 {
@@ -828,7 +847,9 @@ namespace Common.system
828 847
                         Thread.Sleep(100);
829 848
                     }
830 849
                 }
831
-                #endregion
850
+
851
+                #endregion 进程是否已经释放
852
+
832 853
                 myProcess = null;
833 854
                 return true;
834 855
             }
@@ -838,6 +859,7 @@ namespace Common.system
838 859
                 return false;
839 860
             }
840 861
         }
862
+
841 863
         /// <summary>
842 864
         /// 视频转码
843 865
         /// </summary>
@@ -881,7 +903,9 @@ namespace Common.system
881 903
                 myProcess.WaitForExit();           //阻塞等待进程结束
882 904
                 myProcess.Close();                 //关闭进程
883 905
                 myProcess.Dispose();               //释放资源
906
+
884 907
                 #region 进程是否已经释放
908
+
885 909
                 bool IsRunning = true;
886 910
                 while (IsRunning)
887 911
                 {
@@ -893,7 +917,9 @@ namespace Common.system
893 917
                         Thread.Sleep(100);
894 918
                     }
895 919
                 }
896
-                #endregion
920
+
921
+                #endregion 进程是否已经释放
922
+
897 923
                 myProcess = null;
898 924
                 Thread.Sleep(200);
899 925
                 FileToolsCommon.DeleteFile(VideoPathName);
@@ -959,15 +985,17 @@ namespace Common.system
959 985
             }
960 986
         }
961 987
 
962
-
963 988
         #region 麦克风声卡检测
989
+
964 990
         #region 获取麦克风
991
+
965 992
         private bool IsMicrophone = false;
966 993
 
967 994
         /// <summary>
968 995
         /// 使用FFmpeg获取的麦克风名
969 996
         /// </summary>
970 997
         private string MicrophoneNameInfo = "";
998
+
971 999
         /// <summary>
972 1000
         /// 获取麦克风名称
973 1001
         /// </summary>
@@ -1011,6 +1039,7 @@ namespace Common.system
1011 1039
             //    return FullName;
1012 1040
             //}
1013 1041
         }
1042
+
1014 1043
         /// <summary>
1015 1044
         /// 获取麦克风列表
1016 1045
         /// </summary>
@@ -1019,6 +1048,7 @@ namespace Common.system
1019 1048
         {
1020 1049
             return GetAudioInDevicesList();
1021 1050
         }
1051
+
1022 1052
         /// <summary>
1023 1053
         /// 使用FFmpeg获取设备名称--待定
1024 1054
         /// </summary>
@@ -1029,7 +1059,6 @@ namespace Common.system
1029 1059
             {
1030 1060
                 try
1031 1061
                 {
1032
-
1033 1062
                     while (myProcess != null)
1034 1063
                     {
1035 1064
                         Thread.Sleep(100);
@@ -1061,9 +1090,9 @@ namespace Common.system
1061 1090
                 {
1062 1091
                     LogHelper.WriteErrLog("【获取设备信息】(GetMToFFmpeg)信息获取失败:" + ex.Message, ex);
1063 1092
                 }
1064
-
1065 1093
             }))).Start();
1066 1094
         }
1095
+
1067 1096
         /// <summary>
1068 1097
         /// 使用FFmpeg获取设备名称--待定
1069 1098
         /// </summary>
@@ -1081,13 +1110,17 @@ namespace Common.system
1081 1110
                         MicrophoneNameInfo = MicrophoneNameInfo.Substring(MicrophoneNameInfo.IndexOf("]") + 1);
1082 1111
                         MicrophoneNameInfo = MicrophoneNameInfo.Replace("\"", "");
1083 1112
                         MicrophoneNameInfo = MicrophoneNameInfo.Trim();
1113
+
1084 1114
                         #region 测试
1115
+
1085 1116
                         //byte[] bufferASCII = Encoding.Default.GetBytes(MicrophoneNameInfo);
1086 1117
                         //MicrophoneNameInfo = Encoding.UTF8.GetString(bufferASCII); // 统一使用UTF-8
1087 1118
                         ////System.Text.Encoding GB2312 = System.Text.Encoding.GetEncoding("GB2312");
1088 1119
                         ////byte[] gb = GB2312.GetBytes(MicrophoneNameInfo);
1089 1120
                         ////MicrophoneNameInfo = Encoding.UTF8.GetString(gb);
1090
-                        #endregion
1121
+
1122
+                        #endregion 测试
1123
+
1091 1124
                         IsMicrophone = false;
1092 1125
                         FileToolsCommon.AppendText(LogPath, e.Data);
1093 1126
                         //FileToolsCommon.AppendText(LogPath, "\r\n***************************************************\r\n");
@@ -1139,6 +1172,7 @@ namespace Common.system
1139 1172
                 return "";
1140 1173
             }
1141 1174
         }
1175
+
1142 1176
         /// <summary>
1143 1177
         /// AForge获取麦克风列表
1144 1178
         /// </summary>
@@ -1164,8 +1198,9 @@ namespace Common.system
1164 1198
             }
1165 1199
             return devicesList;
1166 1200
         }
1201
+
1167 1202
         /// <summary>
1168
-        /// 获取声音输入设备名称   不完整
1203
+        /// 获取声音输入设备名称 不完整
1169 1204
         /// </summary>
1170 1205
         /// <returns></returns>
1171 1206
         public static string GetInDeviceName()
@@ -1190,6 +1225,7 @@ namespace Common.system
1190 1225
                 return "";
1191 1226
             }
1192 1227
         }
1228
+
1193 1229
         /// <summary>
1194 1230
         /// 获取声音输入设备完整名称
1195 1231
         /// </summary>
@@ -1229,6 +1265,7 @@ namespace Common.system
1229 1265
                 return "";
1230 1266
             }
1231 1267
         }
1268
+
1232 1269
         /// <summary>
1233 1270
         /// 获取声音输入设备完整名称列表
1234 1271
         /// </summary>
@@ -1259,6 +1296,7 @@ namespace Common.system
1259 1296
             }
1260 1297
             return devices;
1261 1298
         }
1299
+
1262 1300
         /// <summary>
1263 1301
         /// 获取麦克风---废弃
1264 1302
         /// </summary>
@@ -1275,7 +1313,6 @@ namespace Common.system
1275 1313
                 {
1276 1314
                     try
1277 1315
                     {
1278
-
1279 1316
                         if (device.FriendlyName.StartsWith(deviceInfo.ProductName))
1280 1317
                         {
1281 1318
                             devs.Add(device.FriendlyName);
@@ -1284,7 +1321,6 @@ namespace Common.system
1284 1321
                     }
1285 1322
                     catch (Exception)
1286 1323
                     {
1287
-
1288 1324
                     }
1289 1325
                 }
1290 1326
             }
@@ -1297,7 +1333,8 @@ namespace Common.system
1297 1333
                 return "";
1298 1334
             }
1299 1335
         }
1300
-        #endregion
1336
+
1337
+        #endregion 获取麦克风
1301 1338
 
1302 1339
         #region 录音
1303 1340
 
@@ -1351,27 +1388,29 @@ namespace Common.system
1351 1388
         //            }
1352 1389
         //            catch (Exception)
1353 1390
         //            {
1354
-
1355 1391
         //            }
1356 1392
         //        };
1357 1393
         //        waveIn.StartRecording();
1358 1394
         //    }
1359 1395
         //    catch (Exception ex)
1360 1396
         //    {
1361
-
1362 1397
         //        throw;
1363 1398
         //    }
1364 1399
         //}
1365
-        #endregion
1400
+
1401
+        #endregion 录音
1402
+
1366 1403
         #region 检测是否可用
1404
+
1367 1405
         /// <summary>
1368 1406
         /// 录制麦克风的声音
1369 1407
         /// </summary>
1370 1408
         private WaveInEvent waveIn = null; //new WaveInEvent();
1409
+
1371 1410
         /// <summary>
1372 1411
         /// 开始录制麦克风
1373 1412
         /// </summary>
1374
-        public bool StartRecordAudio(string audioFile, string DeviceName = "", bool IsStopDelFile=true)
1413
+        public bool StartRecordAudio(string audioFile, string DeviceName = "", bool IsStopDelFile = true)
1375 1414
         {
1376 1415
             try
1377 1416
             {
@@ -1408,7 +1447,6 @@ namespace Common.system
1408 1447
                     }
1409 1448
                     catch (Exception)
1410 1449
                     {
1411
-
1412 1450
                     }
1413 1451
                 };
1414 1452
                 waveIn.StartRecording();
@@ -1464,7 +1502,6 @@ namespace Common.system
1464 1502
             }
1465 1503
         }
1466 1504
 
1467
-
1468 1505
         /// <summary>
1469 1506
         /// 录制扬声器的声音
1470 1507
         /// </summary>
@@ -1497,7 +1534,6 @@ namespace Common.system
1497 1534
                     }
1498 1535
                     catch (Exception)
1499 1536
                     {
1500
-
1501 1537
                     }
1502 1538
                 };
1503 1539
                 capture.StartRecording();
@@ -1509,7 +1545,9 @@ namespace Common.system
1509 1545
                 return false;
1510 1546
             }
1511 1547
         }
1512
-        #endregion
1513
-        #endregion
1548
+
1549
+        #endregion 检测是否可用
1550
+
1551
+        #endregion 麦克风声卡检测
1514 1552
     }
1515
-}
1553
+}

+ 37
- 95
XHWK.WKTool/system/ImageHelper.cs Прегледај датотеку

@@ -11,9 +11,7 @@ using System.Windows.Media.Imaging;
11 11
 namespace Common.system
12 12
 {
13 13
     /// <summary>
14
-    /// 图片帮助类
15
-    /// 创建人:赵耀
16
-    /// 创建时间:2018年11月1日
14
+    /// 图片帮助类 创建人:赵耀 创建时间:2018年11月1日
17 15
     /// </summary>
18 16
     public class ImageHelper
19 17
     {
@@ -30,9 +28,9 @@ namespace Common.system
30 28
                 {
31 29
                     FileStream fs = File.OpenRead(path); //OpenRead
32 30
                     int filelength = 0;
33
-                    filelength = (int)fs.Length; //获得文件长度 
34
-                    byte[] image = new byte[filelength]; //建立一个字节数组 
35
-                    fs.Read(image, 0, filelength); //按字节流读取 
31
+                    filelength = (int)fs.Length; //获得文件长度
32
+                    byte[] image = new byte[filelength]; //建立一个字节数组
33
+                    fs.Read(image, 0, filelength); //按字节流读取
36 34
                     System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
37 35
                     fs.Close();
38 36
                     Bitmap bit = new Bitmap(result);
@@ -48,6 +46,7 @@ namespace Common.system
48 46
                 return null;
49 47
             }
50 48
         }
49
+
51 50
         /// <summary>
52 51
         /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
53 52
         /// </summary>
@@ -61,9 +60,9 @@ namespace Common.system
61 60
                 {
62 61
                     FileStream fs = File.OpenRead(path); //OpenRead
63 62
                     int filelength = 0;
64
-                    filelength = (int)fs.Length; //获得文件长度 
65
-                    byte[] image = new byte[filelength]; //建立一个字节数组 
66
-                    fs.Read(image, 0, filelength); //按字节流读取 
63
+                    filelength = (int)fs.Length; //获得文件长度
64
+                    byte[] image = new byte[filelength]; //建立一个字节数组
65
+                    fs.Read(image, 0, filelength); //按字节流读取
67 66
                     System.Drawing.Image result = System.Drawing.Image.FromStream(fs);
68 67
                     fs.Close();
69 68
                     return result;
@@ -78,6 +77,7 @@ namespace Common.system
78 77
                 return null;
79 78
             }
80 79
         }
80
+
81 81
         /// <summary>
82 82
         /// 通过FileStream 来打开文件,这样就可以实现不锁定Image文件,到时可以让多用户同时访问Image文件
83 83
         /// </summary>
@@ -107,6 +107,7 @@ namespace Common.system
107 107
                 return null;
108 108
             }
109 109
         }
110
+
110 111
         #region 获取RGB
111 112
 
112 113
         private static Bitmap _Bitmap = null;
@@ -138,6 +139,7 @@ namespace Common.system
138 139
         #endregion 获取RGB
139 140
 
140 141
         #region 截图统一方法
142
+
141 143
         /// <summary>
142 144
         /// 截图通用方法 创建人:赵耀 创建时间:2020年8月11日
143 145
         /// </summary>
@@ -180,7 +182,6 @@ namespace Common.system
180 182
                 }
181 183
                 if (IsRetImg)
182 184
                 {
183
-
184 185
                     Uri uri = new Uri(ImageSavePath, UriKind.Absolute);
185 186
                     bitmapimg = new BitmapImage(uri);
186 187
                 }
@@ -193,6 +194,7 @@ namespace Common.system
193 194
                 return false;
194 195
             }
195 196
         }
197
+
196 198
         /// <summary>
197 199
         /// 获取临时图片保存位置
198 200
         /// </summary>
@@ -206,6 +208,7 @@ namespace Common.system
206 208
             TempPath += Convert.ToInt64(ts.TotalMilliseconds).ToString() + ".jpg";
207 209
             return TempPath;
208 210
         }
211
+
209 212
         #endregion 截图统一方法
210 213
 
211 214
         #region 图片压缩
@@ -389,9 +392,11 @@ namespace Common.system
389 392
                 ob.Dispose();
390 393
             }
391 394
         }
395
+
392 396
         #endregion 图片压缩
393 397
 
394 398
         #region 截屏指定UI控件
399
+
395 400
         /// <summary>
396 401
         /// 保存图片
397 402
         /// </summary>
@@ -403,6 +408,7 @@ namespace Common.system
403 408
         /// <param name="ImgHeight">转换后高</param>
404 409
         public static void SaveUI(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
405 410
         {
411
+            Console.WriteLine("截图的路径为:" + filePathName);
406 412
             try
407 413
             {
408 414
                 //在位图中呈现UI元素
@@ -429,9 +435,6 @@ namespace Common.system
429 435
                         Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
430 436
                         try
431 437
                         {
432
-                            //MemoryStream memoryStream = new MemoryStream(data);
433
-                            //Bitmap bit = (Bitmap)Image.FromStream(memoryStream);
434
-
435 438
                             MemoryStream memoryStream = new MemoryStream();
436 439
                             encoder.Save(memoryStream);
437 440
                             Bitmap bit = new Bitmap(memoryStream, true);
@@ -476,10 +479,20 @@ namespace Common.system
476 479
             }
477 480
             catch (Exception)
478 481
             {
479
-
480 482
             }
481 483
         }
482 484
 
485
+        public static void SaveUI2(FrameworkElement frameworkElement, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
486
+        {
487
+            System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
488
+            RenderTargetBitmap bmp = new RenderTargetBitmap((int)frameworkElement.ActualWidth, (int)frameworkElement.ActualHeight, 1 / 96, 1 / 96, PixelFormats.Default);
489
+            bmp.Render(frameworkElement);
490
+            BitmapEncoder encoder = new PngBitmapEncoder();
491
+            encoder.Frames.Add(BitmapFrame.Create(bmp));
492
+            encoder.Save(fs);
493
+            fs.Close();
494
+        }
495
+
483 496
         /// <summary>
484 497
         /// 保存图片
485 498
         /// </summary>
@@ -528,10 +541,7 @@ namespace Common.system
528 541
                                 Img = bit;
529 542
                             }
530 543
                             Img.Save(filePathName);
531
-                            //Bitmap bitmap = CutImageWhitePart(Img);
532
-                            //FileToolsCommon.DeleteFile(filePathName);
533
-                            //bitmap.Save(filePathName);
534
-                            //bitmap.Dispose();
544
+
535 545
                             memoryStream.Dispose();
536 546
                             Img.Dispose();
537 547
                             bit.Dispose();
@@ -539,25 +549,10 @@ namespace Common.system
539 549
                     }
540 550
                     catch (Exception)
541 551
                     {
542
-
543 552
                     }
544 553
                 }
545 554
                 else
546 555
                 {
547
-                    //SaveImageModel sim = new SaveImageModel();
548
-                    //sim.encoder = new PngBitmapEncoder();
549
-                    //sim.encoder = new PngBitmapEncoder();
550
-                    //BitmapFrame test= encoder.Frames[0];
551
-                    //sim.encoder.Frames.Add(BitmapFrame.Create(test));
552
-                    ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
553
-                    ////sim.encoder.CopyTo(encoder);
554
-                    ////encoder.CopyTo(sim.encoder);
555
-                    //sim.FilePath = filePathName;
556
-                    ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
557
-                    ////bmp.CopyTo(sim.bmp);
558
-                    //Thread t1 = new Thread(SaveImage);
559
-                    //t1.Start(sim);
560
-
561 556
                     System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
562 557
                     encoder.Save(fs);
563 558
                     fs.Close();
@@ -569,63 +564,7 @@ namespace Common.system
569 564
                 //Console.WriteLine(ex.Message);
570 565
             }
571 566
         }
572
-        public static void SaveUI1(FrameworkElement ui, string filePathName, int width, int height, int ImgWidth, int ImgHeight)
573
-        {
574
-            try
575
-            {
576
-                //在位图中呈现UI元素
577
-                RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
578
-                bmp.Render(ui);
579
-
580
-                //BitmapEncoder encoder = new PngBitmapEncoder();
581
-                //encoder.Frames.Add(BitmapFrame.Create(bmp));
582
-
583
-                //BitmapSource bitmapSource= bmp.Clone();
584
-
585
-
586 567
 
587
-                //定义切割矩形
588
-                var cut = new Int32Rect(0, 0, width, height);
589
-                //计算Stride
590
-                var stride = bmp.Format.BitsPerPixel * cut.Width / 8;
591
-                //声明字节数组
592
-                byte[] data = new byte[cut.Height * stride];
593
-
594
-                //调用CopyPixels
595
-                bmp.CopyPixels(cut, data, stride, 0);
596
-                new Thread(new ThreadStart(new Action(() =>
597
-                {
598
-                    BitmapSource bitmapSource = BitmapSource.Create(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Bgr32, null, data, stride);
599
-
600
-                    BitmapEncoder encoder = new PngBitmapEncoder();
601
-                    encoder.Frames.Add(BitmapFrame.Create(bitmapSource));
602
-
603
-                    using (var stream = new FileStream(filePathName, FileMode.Create))
604
-                    {
605
-                        encoder.Save(stream);
606
-                    }
607
-                }))).Start();
608
-                //SaveModel saveModel = new SaveModel();
609
-                //saveModel.ImgWidth = ImgWidth;
610
-                //saveModel.ImgHeight = ImgHeight;
611
-                //saveModel.filePathName = filePathName;
612
-                //saveModel.bmp = bmp;
613
-                //saveModel.encoder =new PngBitmapEncoder();
614
-                //foreach (BitmapFrame eitem in encoder.Frames)
615
-                //{
616
-                //    saveModel.encoder = new PngBitmapEncoder();
617
-                //    saveModel.encoder.Frames.Add( eitem );
618
-                //}
619
-
620
-                //Thread myThread = new Thread(SaveImage);
621
-                //myThread.Start(saveModel);
622
-            }
623
-            catch (Exception)
624
-            {
625
-
626
-            }
627
-
628
-        }
629 568
         public static void SaveImage(object model)
630 569
         {
631 570
             try
@@ -679,7 +618,6 @@ namespace Common.system
679 618
                     }
680 619
                     catch (Exception)
681 620
                     {
682
-
683 621
                     }
684 622
                 }
685 623
                 else
@@ -705,9 +643,9 @@ namespace Common.system
705 643
             }
706 644
             catch (Exception)
707 645
             {
708
-
709 646
             }
710 647
         }
648
+
711 649
         /// <summary>
712 650
         /// 截图转换成bitmap
713 651
         /// </summary>
@@ -782,6 +720,7 @@ namespace Common.system
782 720
 
783 721
             return bmp;
784 722
         }
723
+
785 724
         private static void SaveImage1(object obj)
786 725
         {
787 726
             SaveImageModel sim = (SaveImageModel)obj;
@@ -795,9 +734,10 @@ namespace Common.system
795 734
             fs.Close();
796 735
         }
797 736
 
798
-        #endregion
737
+        #endregion 截屏指定UI控件
799 738
 
800 739
         #region 去掉白边
740
+
801 741
         /// <summary>
802 742
         /// 裁剪图片(去掉白边)
803 743
         /// </summary>
@@ -903,7 +843,6 @@ namespace Common.system
903 843
                 //cloneBitmap.Save(@"d:\123.png", ImageFormat.Png);
904 844
                 return cloneBitmap;
905 845
             }
906
-
907 846
         }
908 847
 
909 848
         /// <summary>
@@ -919,14 +858,17 @@ namespace Common.system
919 858
 
920 859
             return false;
921 860
         }
922
-        #endregion
861
+
862
+        #endregion 去掉白边
923 863
     }
864
+
924 865
     public class SaveImageModel
925 866
     {
926 867
         public string FilePath { get; set; }
927 868
         public BitmapEncoder encoder { get; set; }
928 869
         //public RenderTargetBitmap bmp { get; set; }
929 870
     }
871
+
930 872
     public class SaveModel
931 873
     {
932 874
         public int ImgWidth { get; set; }
@@ -935,4 +877,4 @@ namespace Common.system
935 877
         public string filePathName { get; set; }
936 878
         public RenderTargetBitmap bmp { get; set; }
937 879
     }
938
-}
880
+}

Loading…
Откажи
Сачувај