Browse Source

Merge remote-tracking branch 'origin/zyy' into zhangxueyang

tags/录制修改前
zhangxueyang 4 years ago
parent
commit
ded62c0555

+ 0
- 1
Common/system/BlackboardNew.cs View File

439
                         //}
439
                         //}
440
                         stroke = null;
440
                         stroke = null;
441
                     }
441
                     }
442
-
443
                     stylusPoints = new StylusPointCollection();
442
                     stylusPoints = new StylusPointCollection();
444
                     stylusPoint = new StylusPoint();
443
                     stylusPoint = new StylusPoint();
445
                     //stroke = new Stroke(stylusPoints);
444
                     //stroke = new Stroke(stylusPoints);

+ 243
- 122
Common/system/FFMpeg.cs View File

36
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
36
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
37
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
37
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
38
             //文件保存路径
38
             //文件保存路径
39
-            string PathName = GetFilePathName(FilePath);
39
+            string PathName = GetRSFilePathName(FilePath);
40
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
40
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
41
             foreach (var KillProcess in KillProcessArray)
41
             foreach (var KillProcess in KillProcessArray)
42
             {
42
             {
44
             }
44
             }
45
             myProcess = new Process();
45
             myProcess = new Process();
46
             LogPath = CreateffmpegLog();
46
             LogPath = CreateffmpegLog();
47
-            string MicrophoneName = GetMicrophone();
47
+            string MicrophoneName = null;
48
+            string audioTestPath = FileToolsCommon.GetFileAbsolutePath("ado.m");
49
+            try
50
+            {
51
+                FileToolsCommon.DeleteFile(audioTestPath);
52
+            }
53
+            catch (Exception)
54
+            {
55
+
56
+            }
57
+            if (StartRecordAudio(audioTestPath))
58
+            {
59
+                MicrophoneName = GetMicrophone();
60
+            }
61
+            StopRecordAudio();
48
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
62
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
49
             switch (Extension.ToUpper())
63
             switch (Extension.ToUpper())
50
             {
64
             {
102
             {
116
             {
103
                 Thread.Sleep(100);
117
                 Thread.Sleep(100);
104
             }
118
             }
119
+            //路径
120
+            string Path = FileToolsCommon.GetDirectoryName(Mp3Path);
105
             //文件保存路径
121
             //文件保存路径
106
             string PathName = GetFilePathName(Mp3Path);
122
             string PathName = GetFilePathName(Mp3Path);
107
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
123
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
112
             myProcess = new Process();
128
             myProcess = new Process();
113
             LogPath = CreateffmpegLog();
129
             LogPath = CreateffmpegLog();
114
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
130
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
115
-            string MicrophoneName = GetMicrophone();
131
+            string MicrophoneName = null;
132
+            string audioTestPath = FileToolsCommon.GetFileAbsolutePath("ado.m");
133
+            try
134
+            {
135
+                FileToolsCommon.DeleteFile(audioTestPath);
136
+            }
137
+            catch (Exception)
138
+            {
139
+
140
+            }
141
+            if (StartRecordAudio(audioTestPath))
142
+            {
143
+                MicrophoneName = GetMicrophone();
144
+            }
145
+            StopRecordAudio();
116
             if (string.IsNullOrWhiteSpace(MicrophoneName))
146
             if (string.IsNullOrWhiteSpace(MicrophoneName))
117
             {
147
             {
118
                 myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" " + PathName;
148
                 myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" " + PathName;
205
         /// <param name="VideoHeight">视频高度</param>
235
         /// <param name="VideoHeight">视频高度</param>
206
         public void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
236
         public void SynthesisVideo(string ImageListPath, string Mp3Path, string VideoSavePath, int Frequency, int VideoWidth, int VideoHeight)
207
         {
237
         {
208
-            new Thread(new ThreadStart(new Action(() =>
238
+            //new Thread(new ThreadStart(new Action(() =>
239
+            //{
240
+
241
+            //}))).Start();
242
+            while (myProcess != null)
243
+            {
244
+                Thread.Sleep(100);
245
+            }
246
+            string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
247
+            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
248
+            //Debug.WriteLine(KillProcessArray.Length.ToString());
249
+            foreach (var KillProcess in KillProcessArray)
250
+            {
251
+                KillProcess.Kill();
252
+            }
253
+            myProcess = new Process();
254
+            LogPath = CreateffmpegLog();
255
+            this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
256
+            switch (Extension.ToUpper())
209
             {
257
             {
210
-                Thread.Sleep(500);
211
-                while (myProcess != null)
258
+                case "MP4":
259
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
260
+                        ImageListPath + @"%d.png -i " +
261
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
262
+                        VideoSavePath;
263
+                    break;
264
+                case "AVI":
265
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
266
+                        ImageListPath + @"%d.png -i " +
267
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
268
+                        VideoSavePath;
269
+                    break;
270
+                case "FLV":
271
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
272
+                        ImageListPath + @"%d.png -i " +
273
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
274
+                        VideoSavePath;
275
+                    break;
276
+                default:
277
+                    myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
278
+                        ImageListPath + @"%d.png -i " +
279
+                        Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
280
+                        VideoSavePath;
281
+                    break;
282
+            }
283
+            myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
284
+            myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
285
+            myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
286
+            myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
287
+                                                                   //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
288
+            myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
289
+            myProcess.Start();                 //启动线程
290
+            myProcess.BeginErrorReadLine();    //开始异步读取
291
+            myProcess.WaitForExit();           //阻塞等待进程结束
292
+            myProcess.Close();                 //关闭进程
293
+            myProcess.Dispose();               //释放资源
294
+            #region 进程是否已经释放
295
+            bool IsRunning = true;
296
+            while (IsRunning)
297
+            {
298
+                IsRunning = false;
299
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
300
+                foreach (var KillProcess in ProcessArray)
212
                 {
301
                 {
302
+                    IsRunning = true;
213
                     Thread.Sleep(100);
303
                     Thread.Sleep(100);
214
                 }
304
                 }
215
-                string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
216
-                Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
217
-                //Debug.WriteLine(KillProcessArray.Length.ToString());
218
-                foreach (var KillProcess in KillProcessArray)
219
-                {
220
-                    KillProcess.Kill();
221
-                }
222
-                myProcess = new Process();
223
-                LogPath = CreateffmpegLog();
224
-                this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
225
-                switch (Extension.ToUpper())
226
-                {
227
-                    case "MP4":
228
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
229
-                            ImageListPath + @"%d.png -i " +
230
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
231
-                            VideoSavePath;
232
-                        break;
233
-                    case "AVI":
234
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
235
-                            ImageListPath + @"%d.png -i " +
236
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f AVI " +
237
-                            VideoSavePath;
238
-                        break;
239
-                    case "FLV":
240
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
241
-                            ImageListPath + @"%d.png -i " +
242
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -f FLV " +
243
-                            VideoSavePath;
244
-                        break;
245
-                    default:
246
-                        myProcess.StartInfo.Arguments = @"-y -r " + Frequency + " -i " +
247
-                            ImageListPath + @"%d.png -i " +
248
-                            Mp3Path + @" -s " + VideoWidth + "x" + VideoHeight + " -vcodec mpeg4 " +
249
-                            VideoSavePath;
250
-                        break;
251
-                }
252
-                myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
253
-                myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
254
-                myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
255
-                myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
256
-                                                                       //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
257
-                myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
258
-                myProcess.Start();                 //启动线程
259
-                myProcess.BeginErrorReadLine();    //开始异步读取
260
-                myProcess.WaitForExit();           //阻塞等待进程结束
261
-                myProcess.Close();                 //关闭进程
262
-                myProcess.Dispose();               //释放资源
263
-                #region 进程是否已经释放
264
-                bool IsRunning = true;
265
-                while (IsRunning)
266
-                {
267
-                    IsRunning = false;
268
-                    Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
269
-                    foreach (var KillProcess in ProcessArray)
270
-                    {
271
-                        IsRunning = true;
272
-                        Thread.Sleep(100);
273
-                    }
274
-                }
275
-                #endregion
276
-                myProcess = null;
277
-                //生成视频后删除图片和音频保存列表
278
-                //FileToolsCommon.DeleteDirectory(ImageListPath);
279
-                //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
280
-                FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp/");
305
+            }
306
+            #endregion
307
+            myProcess = null;
308
+            //生成视频后删除图片和音频保存列表
309
+            //FileToolsCommon.DeleteDirectory(ImageListPath);
310
+            //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
311
+
312
+            Thread.Sleep(100);
313
+            FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp");
281
 
314
 
282
-                //Dispatcher.Invoke(() =>
283
-                //{
284
-                //});
285
-                //// 允许不同线程间的调用
286
-                //Control.CheckForIllegalCrossThreadCalls = false;
287
-            }))).Start();
315
+            //Dispatcher.Invoke(() =>
316
+            //{
317
+            //});
318
+            //// 允许不同线程间的调用
319
+            //Control.CheckForIllegalCrossThreadCalls = false;
288
         }
320
         }
289
 
321
 
290
         /// <summary>
322
         /// <summary>
307
             //路径
339
             //路径
308
             string FilePath = (string)FilePathobj;
340
             string FilePath = (string)FilePathobj;
309
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
341
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
310
-            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
311
-            foreach (var KillProcess in KillProcessArray)
312
-            {
313
-                KillProcess.Kill();
314
-            }
342
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
343
+            //Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
344
+            //foreach (var KillProcess in KillProcessArray)
345
+            //{
346
+            //    KillProcess.Kill();
347
+            //}
315
             myProcess = new Process();
348
             myProcess = new Process();
316
             LogPath = CreateffmpegLog();
349
             LogPath = CreateffmpegLog();
317
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
350
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
318
-            myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temp/filelist.d -c copy " + FilePath;
351
+            if (Extension.ToUpper() == ".MP3")
352
+            {
353
+                myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temp/filelist.d -c copy " + FilePath;
354
+            }
355
+            else
356
+            {
357
+
358
+                myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temprs/filelist.d -c copy " + FilePath;
359
+            }
319
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
360
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
320
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
361
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
321
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
362
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
341
             }
382
             }
342
             #endregion
383
             #endregion
343
             myProcess = null;
384
             myProcess = null;
344
-            FileToolsCommon.DeleteDirectory(Path + "temp/");
385
+            if (Extension.ToUpper() == ".MP3")
386
+            {
387
+                FileToolsCommon.DeleteDirectory(Path + "temp/");
388
+            }
389
+            else
390
+                FileToolsCommon.DeleteDirectory(Path + "temprs/");
345
         }
391
         }
346
 
392
 
347
         /// <summary>
393
         /// <summary>
348
-        /// 获取文件完整路径
394
+        /// 获取文件完整路径 音频
349
         /// </summary>
395
         /// </summary>
350
         /// <param name="FilePath">文件路径</param>
396
         /// <param name="FilePath">文件路径</param>
351
         /// <returns></returns>
397
         /// <returns></returns>
374
             return CompleteFilePath;
420
             return CompleteFilePath;
375
         }
421
         }
376
 
422
 
423
+        /// <summary>
424
+        /// 获取文件完整路径 录屏
425
+        /// </summary>
426
+        /// <param name="FilePath">文件路径</param>
427
+        /// <returns></returns>
428
+        string GetRSFilePathName(string FilePath)
429
+        {
430
+            //路径
431
+            string Path = FileToolsCommon.GetDirectoryName(FilePath);
432
+            //Path.GetFileName(FilePath);//获取文件名
433
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
434
+            string tempFilePath = Path + "temprs/";
435
+            //创建临时目录
436
+            FileToolsCommon.CreateDirectory(tempFilePath);
437
+            //创建记录文件
438
+            if (!FileToolsCommon.IsExistFile(tempFilePath + "filelist.d"))
439
+            {
440
+                FileToolsCommon.CreateFile(tempFilePath + "filelist.d");
441
+            }
442
+            int num = 1;
443
+            string CompleteFilePath = tempFilePath + num + Extension;
444
+            while (FileToolsCommon.IsExistFile(CompleteFilePath))
445
+            {
446
+                num++;
447
+                CompleteFilePath = tempFilePath + num + Extension;
448
+            }
449
+            FileToolsCommon.AppendText(tempFilePath + "filelist.d", "file ./" + num + Extension + "\r\n");
450
+            return CompleteFilePath;
451
+        }
377
         /// <summary>
452
         /// <summary>
378
         /// 生成缩略图
453
         /// 生成缩略图
379
         /// </summary>
454
         /// </summary>
381
         /// <param name="ImagePath">图片地址</param>
456
         /// <param name="ImagePath">图片地址</param>
382
         public void GenerateThumbnails(string VideoPath, string ImagePath)
457
         public void GenerateThumbnails(string VideoPath, string ImagePath)
383
         {
458
         {
384
-                while (myProcess != null)
459
+            while (myProcess != null)
460
+            {
461
+                Thread.Sleep(100);
462
+            }
463
+            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
464
+            foreach (var KillProcess in KillProcessArray)
465
+            {
466
+                KillProcess.Kill();
467
+            }
468
+            myProcess = new Process();
469
+            LogPath = CreateffmpegLog();
470
+            this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
471
+                                                                                                                  //myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -s " + thubWidth + "*" + thubHeight + " -f image2 \"" + ImagePath + "\"";
472
+            myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -f image2 \"" + ImagePath + "\"";
473
+            myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
474
+            myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
475
+            myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
476
+            myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
477
+                                                                   //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
478
+            myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
479
+            myProcess.Start();                 //启动线程
480
+            myProcess.BeginErrorReadLine();    //开始异步读取
481
+            myProcess.WaitForExit();           //阻塞等待进程结束
482
+            myProcess.Close();                 //关闭进程
483
+            myProcess.Dispose();               //释放资源
484
+            #region 进程是否已经释放
485
+            bool IsRunning = true;
486
+            while (IsRunning)
487
+            {
488
+                IsRunning = false;
489
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
490
+                foreach (var KillProcess in ProcessArray)
385
                 {
491
                 {
492
+                    IsRunning = true;
386
                     Thread.Sleep(100);
493
                     Thread.Sleep(100);
387
                 }
494
                 }
388
-                Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
389
-                foreach (var KillProcess in KillProcessArray)
390
-                {
391
-                    KillProcess.Kill();
392
-                }
393
-                myProcess = new Process();
394
-                LogPath = CreateffmpegLog();
395
-                this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
396
-                                                                                                                      //myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -s " + thubWidth + "*" + thubHeight + " -f image2 \"" + ImagePath + "\"";
397
-                myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -f image2 \"" + ImagePath + "\"";
398
-                myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
399
-                myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
400
-                myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
401
-                myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
402
-                                                                       //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
403
-                myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
404
-                myProcess.Start();                 //启动线程
405
-                myProcess.BeginErrorReadLine();    //开始异步读取
406
-                myProcess.WaitForExit();           //阻塞等待进程结束
407
-                myProcess.Close();                 //关闭进程
408
-                myProcess.Dispose();               //释放资源
409
-                #region 进程是否已经释放
410
-                bool IsRunning = true;
411
-                while (IsRunning)
412
-                {
413
-                    IsRunning = false;
414
-                    Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
415
-                    foreach (var KillProcess in ProcessArray)
416
-                    {
417
-                        IsRunning = true;
418
-                        Thread.Sleep(100);
419
-                    }
420
-                }
421
-                #endregion
422
-                myProcess = null;
495
+            }
496
+            #endregion
497
+            myProcess = null;
423
         }
498
         }
424
 
499
 
425
         /// <summary>
500
         /// <summary>
555
             return devs;
630
             return devs;
556
         }
631
         }
557
 
632
 
633
+        //录制麦克风的声音
634
+        WaveInEvent waveIn = null; //new WaveInEvent();
635
+        /// <summary>
636
+        /// 开始录制
637
+        /// </summary>
638
+        public bool StartRecordAudio(string audioFile)
639
+        {
640
+            try
641
+            {
642
+                waveIn = new WaveInEvent();
643
+                //生成音频文件的对象
644
+                WaveFileWriter writer = new WaveFileWriter(audioFile, waveIn.WaveFormat);
645
+                //开始录音,写数据
646
+                waveIn.DataAvailable += (s, a) =>
647
+                {
648
+                    writer.Write(a.Buffer, 0, a.BytesRecorded);
649
+                };
650
+
651
+                //结束录音
652
+                waveIn.RecordingStopped += (s, a) =>
653
+                {
654
+                    writer.Dispose();
655
+                    writer = null;
656
+                    waveIn.Dispose();
657
+                };
658
+                waveIn.StartRecording();
659
+                return true;
660
+            }
661
+            catch (Exception ex)
662
+            {
663
+                LogHelper.WriteErrLog("【麦克风】麦克风不可用:" + ex.Message, ex);
664
+                return false;
665
+            }
666
+        }
558
 
667
 
668
+        //结束录制
669
+        public void StopRecordAudio()
670
+        {
671
+            try
672
+            {
673
+                waveIn.StopRecording();
674
+            }
675
+            catch (Exception ex)
676
+            {
677
+                LogHelper.WriteErrLog("【麦克风】麦克风不可用:" + ex.Message, ex);
678
+            }
679
+        }
559
     }
680
     }
560
 }
681
 }

+ 12
- 3
Common/system/FileToolsCommon.cs View File

788
         /// 删除指定目录及其所有子目录  
788
         /// 删除指定目录及其所有子目录  
789
         /// </summary>  
789
         /// </summary>  
790
         /// <param name="directoryPath">指定目录的绝对路径</param>  
790
         /// <param name="directoryPath">指定目录的绝对路径</param>  
791
-        public static void DeleteDirectory(string directoryPath)
791
+        public static bool DeleteDirectory(string directoryPath)
792
         {
792
         {
793
-            if (IsExistDirectory(directoryPath))
793
+            try
794
             {
794
             {
795
-                Directory.Delete(directoryPath, true);
795
+                if (IsExistDirectory(directoryPath))
796
+                {
797
+                    Directory.Delete(directoryPath, true);
798
+                }
799
+                return true;
800
+            }
801
+            catch (Exception)
802
+            {
803
+                //目录中有文件占用
804
+                return false;
796
             }
805
             }
797
         }
806
         }
798
         #endregion
807
         #endregion

+ 29
- 39
XHWK.WKTool/App.cs View File

137
         [STAThread]
137
         [STAThread]
138
         private static void Main()
138
         private static void Main()
139
         {
139
         {
140
+            StopSameProcess();
141
+            Killffmpeg();
142
+            LatticeFileHelper.RunPrintConfig();
140
             try
143
             try
141
             {
144
             {
142
                 UserInfo = new Model_UserInfo();
145
                 UserInfo = new Model_UserInfo();
143
                 WKDataList = new List<Model_WKData>();
146
                 WKDataList = new List<Model_WKData>();
144
-                WKData = new Model_WKData();
145
                 VideoList = new List<Model_Video>();
147
                 VideoList = new List<Model_Video>();
146
                 #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
148
                 #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
147
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
149
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
186
                 string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
188
                 string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
187
                 LogHelper.WriteErrLog(ErrMessage, ex);
189
                 LogHelper.WriteErrLog(ErrMessage, ex);
188
             }
190
             }
189
-            StopSameProcess();
190
-            Killffmpeg();
191
-            LatticeFileHelper.RunPrintConfig();
192
         }
191
         }
193
 
192
 
194
         #region 杀死已存在的进程
193
         #region 杀死已存在的进程
201
             Process[] processList = Process.GetProcesses();
200
             Process[] processList = Process.GetProcesses();
202
             foreach (Process process in processList)
201
             foreach (Process process in processList)
203
             {
202
             {
204
-                if (process.ProcessName.ToUpper() == "XHSCHOOL")
203
+                if (process.ProcessName.ToUpper() == "星火微课")
205
                 {
204
                 {
206
                     if (process.Id != current.Id) //忽略当前进程
205
                     if (process.Id != current.Id) //忽略当前进程
207
                     {
206
                     {
249
         {
248
         {
250
             try
249
             try
251
             {
250
             {
252
-                if (UserInfo == null)
251
+                WKData.VideoList = VideoList;
252
+                if (WKDataList != null)
253
                 {
253
                 {
254
-                    return;
254
+                    WKDataList.RemoveAll(x => x.WkPath == WKData.WkPath);
255
                 }
255
                 }
256
-                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
256
+                else
257
                 {
257
                 {
258
-                    WKData.VideoList = VideoList;
259
-                    if (WKDataList != null)
260
-                    {
261
-                        WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
262
-                    }
263
-                    else
264
-                    {
265
-                        WKDataList = new List<Model_WKData>();
266
-                    }
267
-                    WKDataList.Add(WKData);
268
-                    //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
269
-                    string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
270
-                    string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
271
-                    FileToolsCommon.CreateDirectory(SavePath);
272
-                    string SaveName = SavePath + "UserWkDate.d";
273
-                    FileToolsCommon.DeleteFile(SaveName);
274
-                    FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
258
+                    WKDataList = new List<Model_WKData>();
275
                 }
259
                 }
260
+                WKDataList.Add(WKData);
261
+                //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
262
+                string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
263
+                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
264
+                FileToolsCommon.CreateDirectory(SavePath);
265
+                string SaveName = SavePath + "WkDate.d";
266
+                FileToolsCommon.DeleteFile(SaveName);
267
+                FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
276
             }
268
             }
277
             catch (Exception ex)
269
             catch (Exception ex)
278
             {
270
             {
282
         /// <summary>
274
         /// <summary>
283
         /// 读取微课信息 
275
         /// 读取微课信息 
284
         /// </summary>
276
         /// </summary>
285
-        public static void ReadWkData()
277
+        public static void ReadWkData(string WkPath)
286
         {
278
         {
287
             try
279
             try
288
             {
280
             {
289
-                if (UserInfo == null)
281
+                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
282
+                FileToolsCommon.CreateDirectory(SavePath);
283
+                string SaveName = SavePath + "WkDate.d";
284
+                //文件若存在则读取
285
+                if (FileToolsCommon.IsExistFile(SaveName))
290
                 {
286
                 {
291
-                    return;
292
-                }
293
-                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
294
-                {
295
-                    string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
296
-                    FileToolsCommon.CreateDirectory(SavePath);
297
-                    string SaveName = SavePath + "UserWkDate.d";
298
-                    //文件若存在则读取
299
-                    if (FileToolsCommon.IsExistFile(SaveName))
287
+                    string WkDateXmlStr = FileToolsCommon.FileToString(SaveName);
288
+                    WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
289
+                    if (WKDataList.Exists(x => x.WkPath == WkPath))
300
                     {
290
                     {
301
-                        string WkDateXmlStr = FileToolsCommon.FileToString(SaveName);
302
-                        WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
291
+                        WKData = WKDataList.Find(x => x.WkPath == WkPath);
292
+                        VideoList = new List<Model_Video>();
293
+                        VideoList = WKData.VideoList;
303
                     }
294
                     }
304
                 }
295
                 }
305
             }
296
             }
342
             try
333
             try
343
             {
334
             {
344
                 PageDrawList = new List<Model_DrawData>();
335
                 PageDrawList = new List<Model_DrawData>();
345
-                FileToolsCommon.CreateDirectory(WKData.WkPath);
346
                 string SavePath = WKData.WkPath + "PageData.d";
336
                 string SavePath = WKData.WkPath + "PageData.d";
347
                 if (FileToolsCommon.IsExistFile(SavePath))
337
                 if (FileToolsCommon.IsExistFile(SavePath))
348
                 {
338
                 {

+ 1
- 1
XHWK.WKTool/CountdownWindow.xaml View File

11
     WindowStartupLocation="CenterOwner" WindowState="Maximized"
11
     WindowStartupLocation="CenterOwner" WindowState="Maximized"
12
     WindowStyle="None">
12
     WindowStyle="None">
13
     <Window.Background>
13
     <Window.Background>
14
-        <SolidColorBrush Opacity="0.96" Color="#292C2E" />
14
+        <SolidColorBrush Opacity="0.10" Color="#292C2E" />
15
     </Window.Background>
15
     </Window.Background>
16
     <Grid>
16
     <Grid>
17
         <!--<Image x:Name="ImgGif"
17
         <!--<Image x:Name="ImgGif"

+ 1
- 2
XHWK.WKTool/CreateAMicroLessonWindow.xaml View File

5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
         xmlns:local="clr-namespace:XHWK.WKTool"
6
         xmlns:local="clr-namespace:XHWK.WKTool"
7
         mc:Ignorable="d"
7
         mc:Ignorable="d"
8
-        Title="MainWindow" Height="341" Width="454"   AllowsTransparency="True"
9
-    ShowInTaskbar="False"
8
+        Title="星火微课" Height="341" Width="454"   AllowsTransparency="True"
10
     WindowStartupLocation="CenterScreen"
9
     WindowStartupLocation="CenterScreen"
11
     WindowStyle="None">
10
     WindowStyle="None">
12
     <Viewbox>
11
     <Viewbox>

+ 11
- 3
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

84
                 System.Windows.MessageBox.Show("路径不可为空!");
84
                 System.Windows.MessageBox.Show("路径不可为空!");
85
                 return;
85
                 return;
86
             }
86
             }
87
-            APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/"+APP.UserInfo.Username + "/";
88
             #endregion
87
             #endregion
88
+            string wkpath=FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim()+"/";
89
+            //读取微课数据
90
+            APP.ReadWkData(wkpath);
91
+            if(APP.WKData==null)
92
+            {
93
+                APP.WKData = new Model.Model_WKData();
94
+                APP.WKData.WkPath = wkpath;
95
+                APP.WKData.WkName = txbExplainName.Text;
96
+                APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
97
+            }
89
             //创建文件夹
98
             //创建文件夹
90
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
99
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
91
             //存储文件
100
             //存储文件
92
             FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
101
             FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
93
-            APP.WKData.WkName = txbExplainName.Text;
94
-            APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
102
+            APP.ReadDrawData();
95
             #region 微课不允许有多个视频 废弃
103
             #region 微课不允许有多个视频 废弃
96
             ////判断微课是否存在,存在则询问
104
             ////判断微课是否存在,存在则询问
97
             //if (APP.WKDataList != null&& APP.WKDataList.Count>0)
105
             //if (APP.WKDataList != null&& APP.WKDataList.Count>0)

+ 0
- 2
XHWK.WKTool/FileDirectoryWindow.xaml.cs View File

274
             }
274
             }
275
         }
275
         }
276
 
276
 
277
-
278
-
279
         public static List<T> FindChilds<T>(DependencyObject parent, string childName)
277
         public static List<T> FindChilds<T>(DependencyObject parent, string childName)
280
   where T : DependencyObject
278
   where T : DependencyObject
281
         {
279
         {

+ 0
- 3
XHWK.WKTool/LoginWindow.xaml.cs View File

104
                 APP.IsLoginType = true;
104
                 APP.IsLoginType = true;
105
                 txbAccountNumber.Text = string.Empty;
105
                 txbAccountNumber.Text = string.Empty;
106
                 pobPassword.Password = string.Empty;
106
                 pobPassword.Password = string.Empty;
107
-                //读取微课数据
108
-                APP.ReadWkData();
109
-                APP.ReadDrawData();
110
                 #region 登陆后 根据用户名设置微课路径 废弃
107
                 #region 登陆后 根据用户名设置微课路径 废弃
111
                 //APP.WKData.WkPath += APP.UserInfo.Username + "/";
108
                 //APP.WKData.WkPath += APP.UserInfo.Username + "/";
112
                 ////判断微课是否存在,存在则询问
109
                 ////判断微课是否存在,存在则询问

+ 26
- 2
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

162
         {
162
         {
163
             //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
163
             //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
164
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
164
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
165
-            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
165
+            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "tempsr/");
166
             VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
166
             VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
167
             int num = 1;
167
             int num = 1;
168
             while(FileToolsCommon.IsExistFile(VideoSavePathName))
168
             while(FileToolsCommon.IsExistFile(VideoSavePathName))
220
                 TimeOut();
220
                 TimeOut();
221
                 IsSuspend = true;
221
                 IsSuspend = true;
222
                 ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
222
                 ImgRecordingScreen.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
223
+                #region 2秒内不可点击
224
+                new Thread(new ThreadStart(new Action(() =>
225
+                {
226
+                    Dispatcher.Invoke(() =>
227
+                    {
228
+                        BtnRecordingScreen.IsEnabled = false;
229
+                        BtnStopRecordingScreen.IsEnabled = false;
230
+                    });
231
+                    Thread.Sleep(2000);
232
+                    Dispatcher.Invoke(() =>
233
+                    {
234
+                        BtnRecordingScreen.IsEnabled = true;
235
+                        BtnStopRecordingScreen.IsEnabled = true;
236
+                    });
237
+                }))).Start();
238
+                #endregion
223
                 try
239
                 try
224
                 {
240
                 {
225
                     APP.FFmpeg.SuspendFFmpeg();
241
                     APP.FFmpeg.SuspendFFmpeg();
291
                         //保存数据
307
                         //保存数据
292
                         APP.SaveWkData();
308
                         APP.SaveWkData();
293
                     }))).Start();
309
                     }))).Start();
310
+                    Click_stopRecordingScreen();
294
                 }
311
                 }
295
                 catch (Exception ex)
312
                 catch (Exception ex)
296
                 {
313
                 {
539
         }
556
         }
540
         #endregion
557
         #endregion
541
         #endregion
558
         #endregion
542
-
559
+        /// <summary>
560
+        /// 停止录屏
561
+        /// </summary>
562
+        public delegate void StopRecordingScreen();
563
+        /// <summary>
564
+        /// 停止录屏
565
+        /// </summary>
566
+        public event StopRecordingScreen Click_stopRecordingScreen;
543
 
567
 
544
     }
568
     }
545
 }
569
 }

+ 107
- 20
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

306
             {
306
             {
307
                 APP.W_ScreenRecordingToolbarWindow.Initialize();
307
                 APP.W_ScreenRecordingToolbarWindow.Initialize();
308
             }
308
             }
309
+            APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
309
             //显示在右下角
310
             //显示在右下角
310
             APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
311
             APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
311
             APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
312
             APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
313
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
314
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
314
             APP.W_ScreenRecordingToolbarWindow.Show();
315
             APP.W_ScreenRecordingToolbarWindow.Show();
315
             Hide();
316
             Hide();
316
-            TxbRecordScreenWord.Text = "录屏";
317
         }
317
         }
318
+        /// <summary>
319
+        /// 保存录屏中
320
+        /// </summary>
321
+        private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
322
+        {
323
+            TxbRecordScreenWord.Text = "保存中";//
324
+            btnScreenRecording.IsEnabled = false;
325
+
326
+            new Thread(new ThreadStart(new Action(() =>
327
+            {
328
+                while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
329
+                {
330
+                    Thread.Sleep(100);
331
+                }
332
+                Dispatcher.Invoke(() =>
333
+                {
334
+                    btnScreenRecording.IsEnabled = true;
335
+                    TxbRecordScreenWord.Text = "录屏";
336
+                });
337
+            }))).Start();
338
+
339
+        }
340
+
318
         /// <summary>
341
         /// <summary>
319
         /// 上传事件
342
         /// 上传事件
320
         /// </summary>
343
         /// </summary>
1140
                 else
1163
                 else
1141
                 {
1164
                 {
1142
                     APP.W_CountdownWindow.Initialize();
1165
                     APP.W_CountdownWindow.Initialize();
1143
-                    APP.W_CountdownWindow.Topmost = true;
1166
+                    //APP.W_CountdownWindow.Topmost = true;
1144
                 }
1167
                 }
1145
                 APP.W_CountdownWindow.Show();
1168
                 APP.W_CountdownWindow.Show();
1146
                 #endregion
1169
                 #endregion
1151
                 ImgStop.Visibility = Visibility.Collapsed;
1174
                 ImgStop.Visibility = Visibility.Collapsed;
1152
                 ImgStopTwo.Visibility = Visibility.Visible;
1175
                 ImgStopTwo.Visibility = Visibility.Visible;
1153
                 TxbRecordingWord.Text = "暂停";
1176
                 TxbRecordingWord.Text = "暂停";
1177
+                #region 2秒内不可点击
1178
+                new Thread(new ThreadStart(new Action(() =>
1179
+                {
1180
+                    Dispatcher.Invoke(() =>
1181
+                    {
1182
+                        BtnRecord.IsEnabled = false;
1183
+                        btnStop.IsEnabled = false;
1184
+                    });
1185
+                    Thread.Sleep(2000);
1186
+                    Dispatcher.Invoke(() =>
1187
+                    {
1188
+                        BtnRecord.IsEnabled = true;
1189
+                        btnStop.IsEnabled = true;
1190
+                    });
1191
+                }))).Start();
1192
+                #endregion
1154
                 try
1193
                 try
1155
                 {
1194
                 {
1156
                     APP.FFmpeg.StartRecordingAudio(AudioPathName);
1195
                     APP.FFmpeg.StartRecordingAudio(AudioPathName);
1177
                 ImgStop.Visibility = Visibility.Visible;
1216
                 ImgStop.Visibility = Visibility.Visible;
1178
                 ImgStopTwo.Visibility = Visibility.Collapsed;
1217
                 ImgStopTwo.Visibility = Visibility.Collapsed;
1179
                 TxbRecordingWord.Text = "继续";
1218
                 TxbRecordingWord.Text = "继续";
1219
+                #region 2秒内不可点击
1220
+                new Thread(new ThreadStart(new Action(() =>
1221
+                {
1222
+                    Dispatcher.Invoke(() =>
1223
+                    {
1224
+                        BtnRecord.IsEnabled = false;
1225
+                        btnStop.IsEnabled = false;
1226
+                    });
1227
+                    Thread.Sleep(2000);
1228
+                    Dispatcher.Invoke(() =>
1229
+                    {
1230
+                        BtnRecord.IsEnabled = true;
1231
+                        btnStop.IsEnabled = true;
1232
+                    });
1233
+                }))).Start();
1234
+                #endregion
1180
                 try
1235
                 try
1181
                 {
1236
                 {
1182
                     APP.FFmpeg.SuspendFFmpeg();
1237
                     APP.FFmpeg.SuspendFFmpeg();
1258
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1313
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1259
                 ImgStop.Visibility = Visibility.Visible;
1314
                 ImgStop.Visibility = Visibility.Visible;
1260
                 ImgStopTwo.Visibility = Visibility.Collapsed;
1315
                 ImgStopTwo.Visibility = Visibility.Collapsed;
1261
-                TxbRecordingWord.Text = "已录制";
1316
+                TxbRecordingWord.Text = "保存中";
1317
+                #region 2秒内不可点击
1318
+                new Thread(new ThreadStart(new Action(() =>
1319
+                {
1320
+                    Dispatcher.Invoke(() =>
1321
+                    {
1322
+                        BtnRecord.IsEnabled = false;
1323
+                        btnStop.IsEnabled = false;
1324
+                    });
1325
+                }))).Start();
1326
+                #endregion
1262
                 try
1327
                 try
1263
                 {
1328
                 {
1329
+                    //缩略图
1330
+                    string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
1331
+                    FileToolsCommon.CreateDirectory(ThumbnailPath);
1332
+                    //缩略图存储位置
1333
+                    string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
1334
+                    int gridActWidth = (int)GridMain.ActualWidth;
1335
+                    int gridActHeight = (int)GridMain.ActualHeight;
1264
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1336
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1265
                     new Thread(new ThreadStart(new Action(() =>
1337
                     new Thread(new ThreadStart(new Action(() =>
1266
                     {
1338
                     {
1339
+                        //停止截图
1267
                         while (APP.FFmpeg.myProcess != null)
1340
                         while (APP.FFmpeg.myProcess != null)
1268
                         {
1341
                         {
1269
                             Thread.Sleep(100);
1342
                             Thread.Sleep(100);
1273
                             IsStartCount = false;
1346
                             IsStartCount = false;
1274
                             timer.Stop();
1347
                             timer.Stop();
1275
                         });
1348
                         });
1276
-                    }))).Start();
1277
-
1278
-                    new Thread(new ThreadStart(new Action(() =>
1279
-                    {
1280
-                        while (APP.FFmpeg.myProcess != null)
1349
+                    //}))).Start();
1350
+                    //new Thread(new ThreadStart(new Action(() =>
1351
+                    //{
1352
+                        //判断音频是否存在 判断音频临时文件夹是否存在
1353
+                        if (!FileToolsCommon.IsExistFile(AudioPathName))
1281
                         {
1354
                         {
1282
                             Thread.Sleep(100);
1355
                             Thread.Sleep(100);
1283
                         }
1356
                         }
1284
-                    }))).Start();
1285
-                    APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, (int)GridMain.Width, (int)GridMain.Height);
1286
-                    //生成缩略图
1287
-                    string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
1288
-                    FileToolsCommon.CreateDirectory(ThumbnailPath);
1289
-                    //缩略图存储位置
1290
-                    string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
1291
-                    new Thread(new ThreadStart(new Action(() =>
1292
-                    {
1357
+                        if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
1358
+                        {
1359
+                            Thread.Sleep(100);
1360
+                        }
1361
+                        APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, gridActWidth, gridActHeight);
1362
+                    //}))).Start();
1363
+                    //new Thread(new ThreadStart(new Action(() =>
1364
+                    //{
1293
                         while (!FileToolsCommon.IsExistFile(VideoSavePathName))
1365
                         while (!FileToolsCommon.IsExistFile(VideoSavePathName))
1294
                         {
1366
                         {
1295
                             Thread.Sleep(100);
1367
                             Thread.Sleep(100);
1296
                         }
1368
                         }
1369
+                        while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSavePathName) + "temp/"))
1370
+                        {
1371
+                            Thread.Sleep(100);
1372
+                        }
1373
+                        Dispatcher.Invoke(() =>
1374
+                        {
1375
+                            BtnRecord.IsEnabled = true;
1376
+                            btnStop.IsEnabled = true;
1377
+                            TxbRecordingWord.Text = "录制";
1378
+                        });
1297
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
1379
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
1298
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
1380
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
1299
                         Thread.Sleep(500);
1381
                         Thread.Sleep(500);
2283
         /// <param name="e"></param>
2365
         /// <param name="e"></param>
2284
         private void BtnShrink_Click(object sender, RoutedEventArgs e)
2366
         private void BtnShrink_Click(object sender, RoutedEventArgs e)
2285
         {
2367
         {
2286
-            if (Visibility == Visibility.Hidden)
2287
-                Visibility = Visibility.Visible;
2368
+            if (this.WindowState == WindowState.Minimized)
2369
+            {
2370
+                this.WindowState = WindowState.Normal;
2371
+            }
2288
             else
2372
             else
2289
-                Visibility = Visibility.Hidden;
2373
+            {
2374
+                this.WindowState = WindowState.Minimized;
2375
+            }
2290
         }
2376
         }
2291
         /// <summary>
2377
         /// <summary>
2292
         /// 位置确定
2378
         /// 位置确定
2299
             //btnOk.Visibility = Visibility.Collapsed;
2385
             //btnOk.Visibility = Visibility.Collapsed;
2300
             //blackboard_canvas.Visibility = Visibility.Visible;
2386
             //blackboard_canvas.Visibility = Visibility.Visible;
2301
         }
2387
         }
2388
+
2302
     }
2389
     }
2303
 }
2390
 }

+ 8
- 1
XHWK.WKTool/XHWK.WKTool.csproj View File

7
     <ProjectGuid>{57591E23-644E-416D-B1CA-BB04C550130F}</ProjectGuid>
7
     <ProjectGuid>{57591E23-644E-416D-B1CA-BB04C550130F}</ProjectGuid>
8
     <OutputType>WinExe</OutputType>
8
     <OutputType>WinExe</OutputType>
9
     <RootNamespace>XHWK.WKTool</RootNamespace>
9
     <RootNamespace>XHWK.WKTool</RootNamespace>
10
-    <AssemblyName>XHWK.WKTool</AssemblyName>
10
+    <AssemblyName>星火微课</AssemblyName>
11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12
     <FileAlignment>512</FileAlignment>
12
     <FileAlignment>512</FileAlignment>
13
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
13
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
146
     <Compile Include="PrintWindow.xaml.cs">
146
     <Compile Include="PrintWindow.xaml.cs">
147
       <DependentUpon>PrintWindow.xaml</DependentUpon>
147
       <DependentUpon>PrintWindow.xaml</DependentUpon>
148
     </Compile>
148
     </Compile>
149
+    <Compile Include="PromptWindow.xaml.cs">
150
+      <DependentUpon>PromptWindow.xaml</DependentUpon>
151
+    </Compile>
149
     <Compile Include="ScreenRecordingToolbarWindow.xaml.cs">
152
     <Compile Include="ScreenRecordingToolbarWindow.xaml.cs">
150
       <DependentUpon>ScreenRecordingToolbarWindow.xaml</DependentUpon>
153
       <DependentUpon>ScreenRecordingToolbarWindow.xaml</DependentUpon>
151
     </Compile>
154
     </Compile>
177
       <SubType>Designer</SubType>
180
       <SubType>Designer</SubType>
178
       <Generator>MSBuild:Compile</Generator>
181
       <Generator>MSBuild:Compile</Generator>
179
     </Page>
182
     </Page>
183
+    <Page Include="PromptWindow.xaml">
184
+      <Generator>MSBuild:Compile</Generator>
185
+      <SubType>Designer</SubType>
186
+    </Page>
180
     <Page Include="Themes\Generic.xaml">
187
     <Page Include="Themes\Generic.xaml">
181
       <Generator>MSBuild:Compile</Generator>
188
       <Generator>MSBuild:Compile</Generator>
182
       <SubType>Designer</SubType>
189
       <SubType>Designer</SubType>

Loading…
Cancel
Save