Browse Source

zhao:修改录课保存和读取,录制和录屏增加保存时间

tags/录制修改前
耀 4 years ago
parent
commit
baf2711315

+ 18
- 11
Common/system/BlackboardNew.cs View File

403
             {
403
             {
404
                 if (stroke != null && stroke.StylusPoints.Count > 1)
404
                 if (stroke != null && stroke.StylusPoints.Count > 1)
405
                 {
405
                 {
406
-                    drawingAttributes = new DrawingAttributes();
407
-                    //m_canvas.DefaultDrawingAttributes = drawingAttributes;
408
-                    drawingAttributes.Color = _color;
409
-                    drawingAttributes.Width = _size * 5;
410
-                    drawingAttributes.Height = _size * 5;
411
-                    drawingAttributes.FitToCurve = true;
412
-                    drawingAttributes.IgnorePressure = false;
413
-
414
-                    stroke.DrawingAttributes = drawingAttributes;
415
-                    //m_canvas.DefaultDrawingAttributes= drawingAttributes;
416
-                    m_canvas.Strokes.Add(stroke);
406
+                    try
407
+                    {
408
+                        drawingAttributes = new DrawingAttributes();
409
+                        //m_canvas.DefaultDrawingAttributes = drawingAttributes;
410
+                        drawingAttributes.Color = _color;
411
+                        drawingAttributes.Width = _size * 5;
412
+                        drawingAttributes.Height = _size * 5;
413
+                        drawingAttributes.FitToCurve = true;
414
+                        drawingAttributes.IgnorePressure = false;
415
+
416
+                        stroke.DrawingAttributes = drawingAttributes;
417
+                        //m_canvas.DefaultDrawingAttributes= drawingAttributes;
418
+                        m_canvas.Strokes.Add(stroke);
419
+                    }
420
+                    catch (Exception ex)
421
+                    {
422
+                        LogHelper.WriteErrLog("【点阵笔】(changepages):" + ex.Message, ex);
423
+                    }
417
                 }
424
                 }
418
 
425
 
419
                 stylusPoints = new StylusPointCollection();
426
                 stylusPoints = new StylusPointCollection();

+ 160
- 43
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;
277
                 //生成视频后删除图片和音频保存列表
307
                 //生成视频后删除图片和音频保存列表
278
                 //FileToolsCommon.DeleteDirectory(ImageListPath);
308
                 //FileToolsCommon.DeleteDirectory(ImageListPath);
279
                 //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
309
                 //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
280
-                FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp/");
310
+                FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp");
281
 
311
 
282
                 //Dispatcher.Invoke(() =>
312
                 //Dispatcher.Invoke(() =>
283
                 //{
313
                 //{
307
             //路径
337
             //路径
308
             string FilePath = (string)FilePathobj;
338
             string FilePath = (string)FilePathobj;
309
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
339
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
340
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
310
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
341
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
311
             foreach (var KillProcess in KillProcessArray)
342
             foreach (var KillProcess in KillProcessArray)
312
             {
343
             {
315
             myProcess = new Process();
346
             myProcess = new Process();
316
             LogPath = CreateffmpegLog();
347
             LogPath = CreateffmpegLog();
317
             this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
348
             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;
349
+            if (Extension.ToUpper() == ".MP3")
350
+            {
351
+                myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temp/filelist.d -c copy " + FilePath;
352
+            }
353
+            else
354
+            {
355
+
356
+                myProcess.StartInfo.Arguments = "-f concat  -safe 0 -i " + Path + "temprs/filelist.d -c copy " + FilePath;
357
+            }
319
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
358
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
320
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
359
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
321
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
360
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
341
             }
380
             }
342
             #endregion
381
             #endregion
343
             myProcess = null;
382
             myProcess = null;
344
-            FileToolsCommon.DeleteDirectory(Path + "temp/");
383
+            if (Extension.ToUpper() == ".MP3")
384
+                FileToolsCommon.DeleteDirectory(Path + "temp/");
385
+            else
386
+                FileToolsCommon.DeleteDirectory(Path + "temprs/");
345
         }
387
         }
346
 
388
 
347
         /// <summary>
389
         /// <summary>
348
-        /// 获取文件完整路径
390
+        /// 获取文件完整路径 音频
349
         /// </summary>
391
         /// </summary>
350
         /// <param name="FilePath">文件路径</param>
392
         /// <param name="FilePath">文件路径</param>
351
         /// <returns></returns>
393
         /// <returns></returns>
374
             return CompleteFilePath;
416
             return CompleteFilePath;
375
         }
417
         }
376
 
418
 
419
+        /// <summary>
420
+        /// 获取文件完整路径 录屏
421
+        /// </summary>
422
+        /// <param name="FilePath">文件路径</param>
423
+        /// <returns></returns>
424
+        string GetRSFilePathName(string FilePath)
425
+        {
426
+            //路径
427
+            string Path = FileToolsCommon.GetDirectoryName(FilePath);
428
+            //Path.GetFileName(FilePath);//获取文件名
429
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
430
+            string tempFilePath = Path + "temprs/";
431
+            //创建临时目录
432
+            FileToolsCommon.CreateDirectory(tempFilePath);
433
+            //创建记录文件
434
+            if (!FileToolsCommon.IsExistFile(tempFilePath + "filelist.d"))
435
+            {
436
+                FileToolsCommon.CreateFile(tempFilePath + "filelist.d");
437
+            }
438
+            int num = 1;
439
+            string CompleteFilePath = tempFilePath + num + Extension;
440
+            while (FileToolsCommon.IsExistFile(CompleteFilePath))
441
+            {
442
+                num++;
443
+                CompleteFilePath = tempFilePath + num + Extension;
444
+            }
445
+            FileToolsCommon.AppendText(tempFilePath + "filelist.d", "file ./" + num + Extension + "\r\n");
446
+            return CompleteFilePath;
447
+        }
377
         /// <summary>
448
         /// <summary>
378
         /// 生成缩略图
449
         /// 生成缩略图
379
         /// </summary>
450
         /// </summary>
381
         /// <param name="ImagePath">图片地址</param>
452
         /// <param name="ImagePath">图片地址</param>
382
         public void GenerateThumbnails(string VideoPath, string ImagePath)
453
         public void GenerateThumbnails(string VideoPath, string ImagePath)
383
         {
454
         {
384
-                while (myProcess != null)
455
+            while (myProcess != null)
456
+            {
457
+                Thread.Sleep(100);
458
+            }
459
+            Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
460
+            foreach (var KillProcess in KillProcessArray)
461
+            {
462
+                KillProcess.Kill();
463
+            }
464
+            myProcess = new Process();
465
+            LogPath = CreateffmpegLog();
466
+            this.myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
467
+                                                                                                                  //myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -s " + thubWidth + "*" + thubHeight + " -f image2 \"" + ImagePath + "\"";
468
+            myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -f image2 \"" + ImagePath + "\"";
469
+            myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
470
+            myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
471
+            myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
472
+            myProcess.StartInfo.RedirectStandardInput = true;      //用于模拟该进程控制台的输入
473
+                                                                   //外部程序(这里是FFMPEG)输出流时候产生的事件,这里是把流的处理过程转移到下面的方法中,详细请查阅MSDN
474
+            myProcess.ErrorDataReceived += new DataReceivedEventHandler(Output);
475
+            myProcess.Start();                 //启动线程
476
+            myProcess.BeginErrorReadLine();    //开始异步读取
477
+            myProcess.WaitForExit();           //阻塞等待进程结束
478
+            myProcess.Close();                 //关闭进程
479
+            myProcess.Dispose();               //释放资源
480
+            #region 进程是否已经释放
481
+            bool IsRunning = true;
482
+            while (IsRunning)
483
+            {
484
+                IsRunning = false;
485
+                Process[] ProcessArray = Process.GetProcessesByName("ffmpeg");
486
+                foreach (var KillProcess in ProcessArray)
385
                 {
487
                 {
488
+                    IsRunning = true;
386
                     Thread.Sleep(100);
489
                     Thread.Sleep(100);
387
                 }
490
                 }
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;
491
+            }
492
+            #endregion
493
+            myProcess = null;
423
         }
494
         }
424
 
495
 
425
         /// <summary>
496
         /// <summary>
555
             return devs;
626
             return devs;
556
         }
627
         }
557
 
628
 
629
+        //录制麦克风的声音
630
+        WaveInEvent waveIn = null; //new WaveInEvent();
631
+        /// <summary>
632
+        /// 开始录制
633
+        /// </summary>
634
+        public bool StartRecordAudio(string audioFile)
635
+        {
636
+            try
637
+            {
638
+                waveIn = new WaveInEvent();
639
+                //生成音频文件的对象
640
+                WaveFileWriter writer = new WaveFileWriter(audioFile, waveIn.WaveFormat);
641
+                //开始录音,写数据
642
+                waveIn.DataAvailable += (s, a) =>
643
+                {
644
+                    writer.Write(a.Buffer, 0, a.BytesRecorded);
645
+                };
646
+
647
+                //结束录音
648
+                waveIn.RecordingStopped += (s, a) =>
649
+                {
650
+                    writer.Dispose();
651
+                    writer = null;
652
+                    waveIn.Dispose();
653
+                };
654
+                waveIn.StartRecording();
655
+                return true;
656
+            }
657
+            catch (Exception ex)
658
+            {
659
+                LogHelper.WriteErrLog("【麦克风】麦克风不可用:" + ex.Message, ex);
660
+                return false;
661
+            }
662
+        }
558
 
663
 
664
+        //结束录制
665
+        public void StopRecordAudio()
666
+        {
667
+            try
668
+            {
669
+                waveIn.StopRecording();
670
+            }
671
+            catch (Exception ex)
672
+            {
673
+                LogHelper.WriteErrLog("【麦克风】麦克风不可用:" + ex.Message, ex);
674
+            }
675
+        }
559
     }
676
     }
560
 }
677
 }

+ 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

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

130
         [STAThread]
130
         [STAThread]
131
         private static void Main()
131
         private static void Main()
132
         {
132
         {
133
+            StopSameProcess();
134
+            Killffmpeg();
135
+            LatticeFileHelper.RunPrintConfig();
133
             try
136
             try
134
             {
137
             {
135
                 UserInfo = new Model_UserInfo();
138
                 UserInfo = new Model_UserInfo();
136
                 WKDataList = new List<Model_WKData>();
139
                 WKDataList = new List<Model_WKData>();
137
-                WKData = new Model_WKData();
138
                 VideoList = new List<Model_Video>();
140
                 VideoList = new List<Model_Video>();
139
                 #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
141
                 #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
140
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
142
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
179
                 string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
181
                 string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
180
                 LogHelper.WriteErrLog(ErrMessage, ex);
182
                 LogHelper.WriteErrLog(ErrMessage, ex);
181
             }
183
             }
182
-            StopSameProcess();
183
-            Killffmpeg();
184
-            LatticeFileHelper.RunPrintConfig();
185
         }
184
         }
186
 
185
 
187
         #region 杀死已存在的进程
186
         #region 杀死已存在的进程
194
             Process[] processList = Process.GetProcesses();
193
             Process[] processList = Process.GetProcesses();
195
             foreach (Process process in processList)
194
             foreach (Process process in processList)
196
             {
195
             {
197
-                if (process.ProcessName.ToUpper() == "XHSCHOOL")
196
+                if (process.ProcessName.ToUpper() == "星火微课")
198
                 {
197
                 {
199
                     if (process.Id != current.Id) //忽略当前进程
198
                     if (process.Id != current.Id) //忽略当前进程
200
                     {
199
                     {
242
         {
241
         {
243
             try
242
             try
244
             {
243
             {
245
-                if (UserInfo == null)
244
+                WKData.VideoList = VideoList;
245
+                if (WKDataList != null)
246
                 {
246
                 {
247
-                    return;
247
+                    WKDataList.RemoveAll(x => x.WkPath == WKData.WkPath);
248
                 }
248
                 }
249
-                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
249
+                else
250
                 {
250
                 {
251
-                    WKData.VideoList = VideoList;
252
-                    if (WKDataList != null)
253
-                    {
254
-                        WKDataList.RemoveAll(x => x.WkName == WKData.WkName);
255
-                    }
256
-                    else
257
-                    {
258
-                        WKDataList = new List<Model_WKData>();
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/" + APP.UserInfo.Username + "/");
264
-                    FileToolsCommon.CreateDirectory(SavePath);
265
-                    string SaveName = SavePath + "UserWkDate.d";
266
-                    FileToolsCommon.DeleteFile(SaveName);
267
-                    FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
251
+                    WKDataList = new List<Model_WKData>();
268
                 }
252
                 }
253
+                WKDataList.Add(WKData);
254
+                //string WkDateXmlStr = XmlUtilHelper.Serializer(typeof(Model_WKData), WKData);
255
+                string WkDateXmlStr = XmlUtilHelper.XmlSerialize(WKDataList);
256
+                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
257
+                FileToolsCommon.CreateDirectory(SavePath);
258
+                string SaveName = SavePath + "WkDate.d";
259
+                FileToolsCommon.DeleteFile(SaveName);
260
+                FileToolsCommon.WriteText(SaveName, WkDateXmlStr);
269
             }
261
             }
270
             catch (Exception ex)
262
             catch (Exception ex)
271
             {
263
             {
275
         /// <summary>
267
         /// <summary>
276
         /// 读取微课信息 
268
         /// 读取微课信息 
277
         /// </summary>
269
         /// </summary>
278
-        public static void ReadWkData()
270
+        public static void ReadWkData(string WkPath)
279
         {
271
         {
280
             try
272
             try
281
             {
273
             {
282
-                if (UserInfo == null)
274
+                string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/");
275
+                FileToolsCommon.CreateDirectory(SavePath);
276
+                string SaveName = SavePath + "WkDate.d";
277
+                //文件若存在则读取
278
+                if (FileToolsCommon.IsExistFile(SaveName))
283
                 {
279
                 {
284
-                    return;
285
-                }
286
-                if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
287
-                {
288
-                    string SavePath = FileToolsCommon.GetFileAbsolutePath("/Data/" + APP.UserInfo.Username + "/");
289
-                    FileToolsCommon.CreateDirectory(SavePath);
290
-                    string SaveName = SavePath + "UserWkDate.d";
291
-                    //文件若存在则读取
292
-                    if (FileToolsCommon.IsExistFile(SaveName))
280
+                    string WkDateXmlStr = FileToolsCommon.FileToString(SaveName);
281
+                    WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
282
+                    if (WKDataList.Exists(x => x.WkPath == WkPath))
293
                     {
283
                     {
294
-                        string WkDateXmlStr = FileToolsCommon.FileToString(SaveName);
295
-                        WKDataList = XmlUtilHelper.DESerializer<List<Model_WKData>>(WkDateXmlStr);
284
+                        WKData = WKDataList.Find(x => x.WkPath == WkPath);
296
                     }
285
                     }
297
                 }
286
                 }
298
             }
287
             }
335
             try
324
             try
336
             {
325
             {
337
                 PageDrawList = new List<Model_DrawData>();
326
                 PageDrawList = new List<Model_DrawData>();
338
-                FileToolsCommon.CreateDirectory(WKData.WkPath);
339
                 string SavePath = WKData.WkPath + "PageData.d";
327
                 string SavePath = WKData.WkPath + "PageData.d";
340
                 if (FileToolsCommon.IsExistFile(SavePath))
328
                 if (FileToolsCommon.IsExistFile(SavePath))
341
                 {
329
                 {

+ 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

264
             }
264
             }
265
         }
265
         }
266
 
266
 
267
-
268
-
269
         public static List<T> FindChilds<T>(DependencyObject parent, string childName)
267
         public static List<T> FindChilds<T>(DependencyObject parent, string childName)
270
   where T : DependencyObject
268
   where T : DependencyObject
271
         {
269
         {

+ 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
 }

+ 86
- 6
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

299
             {
299
             {
300
                 APP.W_ScreenRecordingToolbarWindow.Initialize();
300
                 APP.W_ScreenRecordingToolbarWindow.Initialize();
301
             }
301
             }
302
+            APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
302
             //显示在右下角
303
             //显示在右下角
303
             APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
304
             APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
304
             APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
305
             APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
306
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
307
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
307
             APP.W_ScreenRecordingToolbarWindow.Show();
308
             APP.W_ScreenRecordingToolbarWindow.Show();
308
             Hide();
309
             Hide();
309
-            TxbRecordScreenWord.Text = "录屏";
310
         }
310
         }
311
+        /// <summary>
312
+        /// 保存录屏中
313
+        /// </summary>
314
+        private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
315
+        {
316
+            TxbRecordScreenWord.Text = "保存中";//
317
+            btnScreenRecording.IsEnabled = false;
318
+
319
+            new Thread(new ThreadStart(new Action(() =>
320
+            {
321
+                while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
322
+                {
323
+                    Thread.Sleep(100);
324
+                }
325
+                Dispatcher.Invoke(() =>
326
+                {
327
+                    btnScreenRecording.IsEnabled = true;
328
+                    TxbRecordScreenWord.Text = "录屏";
329
+                });
330
+            }))).Start();
331
+           
332
+        }
333
+
311
         /// <summary>
334
         /// <summary>
312
         /// 上传事件
335
         /// 上传事件
313
         /// </summary>
336
         /// </summary>
1136
                 else
1159
                 else
1137
                 {
1160
                 {
1138
                     APP.W_CountdownWindow.Initialize();
1161
                     APP.W_CountdownWindow.Initialize();
1139
-                    APP.W_CountdownWindow.Topmost = true;
1162
+                    //APP.W_CountdownWindow.Topmost = true;
1140
                 }
1163
                 }
1141
                 APP.W_CountdownWindow.Show();
1164
                 APP.W_CountdownWindow.Show();
1142
                 #endregion
1165
                 #endregion
1145
                 //BtnRecording.Content = "暂停录制";
1168
                 //BtnRecording.Content = "暂停录制";
1146
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
1169
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
1147
                 TxbRecordingWord.Text = "暂停";
1170
                 TxbRecordingWord.Text = "暂停";
1171
+                #region 2秒内不可点击
1172
+                new Thread(new ThreadStart(new Action(() =>
1173
+                {
1174
+                    Dispatcher.Invoke(() =>
1175
+                    {
1176
+                        BtnRecord.IsEnabled = false;
1177
+                        btnStop.IsEnabled = false;
1178
+                    });
1179
+                    Thread.Sleep(2000);
1180
+                    Dispatcher.Invoke(() =>
1181
+                    {
1182
+                        BtnRecord.IsEnabled = true;
1183
+                        btnStop.IsEnabled = true;
1184
+                    });
1185
+                }))).Start();
1186
+                #endregion
1148
                 try
1187
                 try
1149
                 {
1188
                 {
1150
                     APP.FFmpeg.StartRecordingAudio(AudioPathName);
1189
                     APP.FFmpeg.StartRecordingAudio(AudioPathName);
1169
                 IsSuspendR = true;
1208
                 IsSuspendR = true;
1170
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1209
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1171
                 TxbRecordingWord.Text = "继续";
1210
                 TxbRecordingWord.Text = "继续";
1211
+                #region 2秒内不可点击
1212
+                new Thread(new ThreadStart(new Action(() =>
1213
+                {
1214
+                    Dispatcher.Invoke(() =>
1215
+                    {
1216
+                        BtnRecord.IsEnabled = false;
1217
+                        btnStop.IsEnabled = false;
1218
+                    });
1219
+                    Thread.Sleep(2000);
1220
+                    Dispatcher.Invoke(() =>
1221
+                    {
1222
+                        BtnRecord.IsEnabled = true;
1223
+                        btnStop.IsEnabled = true;
1224
+                    });
1225
+                }))).Start();
1226
+                #endregion
1172
                 try
1227
                 try
1173
                 {
1228
                 {
1174
                     APP.FFmpeg.SuspendFFmpeg();
1229
                     APP.FFmpeg.SuspendFFmpeg();
1245
                 btnLoginType.IsEnabled = true;
1300
                 btnLoginType.IsEnabled = true;
1246
                 IsSuspendR = true;
1301
                 IsSuspendR = true;
1247
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1302
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1248
-                TxbRecordingWord.Text = "已录制";
1303
+                TxbRecordingWord.Text = "保存中";
1304
+                #region 2秒内不可点击
1305
+                new Thread(new ThreadStart(new Action(() =>
1306
+                {
1307
+                    Dispatcher.Invoke(() =>
1308
+                    {
1309
+                        BtnRecord.IsEnabled = false;
1310
+                        btnStop.IsEnabled = false;
1311
+                    });
1312
+                }))).Start();
1313
+                #endregion
1249
                 try
1314
                 try
1250
                 {
1315
                 {
1251
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1316
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
1281
                         {
1346
                         {
1282
                             Thread.Sleep(100);
1347
                             Thread.Sleep(100);
1283
                         }
1348
                         }
1349
+                        while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSavePathName) + "temp/"))
1350
+                        {
1351
+                            Thread.Sleep(100);
1352
+                        }
1353
+                        Dispatcher.Invoke(() =>
1354
+                        {
1355
+                            BtnRecord.IsEnabled = true;
1356
+                            btnStop.IsEnabled = true;
1357
+                            TxbRecordingWord.Text = "录制";
1358
+                        });
1284
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
1359
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
1285
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
1360
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
1286
                         Thread.Sleep(500);
1361
                         Thread.Sleep(500);
2180
         /// <param name="e"></param>
2255
         /// <param name="e"></param>
2181
         private void BtnShrink_Click(object sender, RoutedEventArgs e)
2256
         private void BtnShrink_Click(object sender, RoutedEventArgs e)
2182
         {
2257
         {
2183
-            if (Visibility == Visibility.Hidden)
2184
-                Visibility = Visibility.Visible;
2258
+            if(this.WindowState == WindowState.Minimized)
2259
+            {
2260
+                this.WindowState = WindowState.Normal;
2261
+            }
2185
             else
2262
             else
2186
-                Visibility = Visibility.Hidden;
2263
+            {
2264
+                this.WindowState = WindowState.Minimized;
2265
+            }
2187
         }
2266
         }
2188
         /// <summary>
2267
         /// <summary>
2189
         /// 位置确定
2268
         /// 位置确定
2196
             //btnOk.Visibility = Visibility.Collapsed;
2275
             //btnOk.Visibility = Visibility.Collapsed;
2197
             //blackboard_canvas.Visibility = Visibility.Visible;
2276
             //blackboard_canvas.Visibility = Visibility.Visible;
2198
         }
2277
         }
2278
+
2199
     }
2279
     }
2200
 }
2280
 }

+ 1
- 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>

Loading…
Cancel
Save