Bläddra i källkod

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

tags/录制修改前
耀 4 år sedan
förälder
incheckning
baf2711315

+ 18
- 11
Common/system/BlackboardNew.cs Visa fil

@@ -403,17 +403,24 @@ namespace Common.system
403 403
             {
404 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 426
                 stylusPoints = new StylusPointCollection();

+ 160
- 43
Common/system/FFMpeg.cs Visa fil

@@ -36,7 +36,7 @@ namespace Common.system
36 36
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
37 37
             string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
38 38
             //文件保存路径
39
-            string PathName = GetFilePathName(FilePath);
39
+            string PathName = GetRSFilePathName(FilePath);
40 40
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
41 41
             foreach (var KillProcess in KillProcessArray)
42 42
             {
@@ -44,7 +44,21 @@ namespace Common.system
44 44
             }
45 45
             myProcess = new Process();
46 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 62
             myProcess.StartInfo.FileName = FileToolsCommon.GetFileAbsolutePath(@"/ffmpeg/bin/ffmpeg.exe");   //ffmpeg.exe的绝对路径
49 63
             switch (Extension.ToUpper())
50 64
             {
@@ -102,6 +116,8 @@ namespace Common.system
102 116
             {
103 117
                 Thread.Sleep(100);
104 118
             }
119
+            //路径
120
+            string Path = FileToolsCommon.GetDirectoryName(Mp3Path);
105 121
             //文件保存路径
106 122
             string PathName = GetFilePathName(Mp3Path);
107 123
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
@@ -112,7 +128,21 @@ namespace Common.system
112 128
             myProcess = new Process();
113 129
             LogPath = CreateffmpegLog();
114 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 146
             if (string.IsNullOrWhiteSpace(MicrophoneName))
117 147
             {
118 148
                 myProcess.StartInfo.Arguments = "-f dshow -i audio=\"virtual-audio-capturer\" " + PathName;
@@ -277,7 +307,7 @@ namespace Common.system
277 307
                 //生成视频后删除图片和音频保存列表
278 308
                 //FileToolsCommon.DeleteDirectory(ImageListPath);
279 309
                 //FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(Mp3Path));
280
-                FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp/");
310
+                FileToolsCommon.DeleteDirectory(FileToolsCommon.GetDirectoryName(VideoSavePath) + "temp");
281 311
 
282 312
                 //Dispatcher.Invoke(() =>
283 313
                 //{
@@ -307,6 +337,7 @@ namespace Common.system
307 337
             //路径
308 338
             string FilePath = (string)FilePathobj;
309 339
             string Path = FileToolsCommon.GetDirectoryName(FilePath);
340
+            string Extension = FileToolsCommon.GetIOExtension(FilePath);//扩展名
310 341
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
311 342
             foreach (var KillProcess in KillProcessArray)
312 343
             {
@@ -315,7 +346,15 @@ namespace Common.system
315 346
             myProcess = new Process();
316 347
             LogPath = CreateffmpegLog();
317 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 358
             myProcess.StartInfo.UseShellExecute = false;           //不使用操作系统外壳程序启动
320 359
             myProcess.StartInfo.RedirectStandardError = true;      //重定向标准错误输出
321 360
             myProcess.StartInfo.CreateNoWindow = true;             //不显示程序窗口
@@ -341,11 +380,14 @@ namespace Common.system
341 380
             }
342 381
             #endregion
343 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 389
         /// <summary>
348
-        /// 获取文件完整路径
390
+        /// 获取文件完整路径 音频
349 391
         /// </summary>
350 392
         /// <param name="FilePath">文件路径</param>
351 393
         /// <returns></returns>
@@ -374,6 +416,35 @@ namespace Common.system
374 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 448
         /// <summary>
378 449
         /// 生成缩略图
379 450
         /// </summary>
@@ -381,45 +452,45 @@ namespace Common.system
381 452
         /// <param name="ImagePath">图片地址</param>
382 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 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 496
         /// <summary>
@@ -555,6 +626,52 @@ namespace Common.system
555 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 Visa fil

@@ -788,11 +788,20 @@ namespace Common.system
788 788
         /// 删除指定目录及其所有子目录  
789 789
         /// </summary>  
790 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 807
         #endregion

+ 27
- 39
XHWK.WKTool/App.cs Visa fil

@@ -130,11 +130,13 @@ namespace XHWK.WKTool
130 130
         [STAThread]
131 131
         private static void Main()
132 132
         {
133
+            StopSameProcess();
134
+            Killffmpeg();
135
+            LatticeFileHelper.RunPrintConfig();
133 136
             try
134 137
             {
135 138
                 UserInfo = new Model_UserInfo();
136 139
                 WKDataList = new List<Model_WKData>();
137
-                WKData = new Model_WKData();
138 140
                 VideoList = new List<Model_Video>();
139 141
                 #region 强制以管理员方式运行 修改人:赵耀 修改时间:2020年9月7日
140 142
                 WindowsIdentity identity = WindowsIdentity.GetCurrent();
@@ -179,9 +181,6 @@ namespace XHWK.WKTool
179 181
                 string ErrMessage = "【进程】(Main):进程意外关闭。 " + ex.Message;
180 182
                 LogHelper.WriteErrLog(ErrMessage, ex);
181 183
             }
182
-            StopSameProcess();
183
-            Killffmpeg();
184
-            LatticeFileHelper.RunPrintConfig();
185 184
         }
186 185
 
187 186
         #region 杀死已存在的进程
@@ -194,7 +193,7 @@ namespace XHWK.WKTool
194 193
             Process[] processList = Process.GetProcesses();
195 194
             foreach (Process process in processList)
196 195
             {
197
-                if (process.ProcessName.ToUpper() == "XHSCHOOL")
196
+                if (process.ProcessName.ToUpper() == "星火微课")
198 197
                 {
199 198
                     if (process.Id != current.Id) //忽略当前进程
200 199
                     {
@@ -242,30 +241,23 @@ namespace XHWK.WKTool
242 241
         {
243 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 262
             catch (Exception ex)
271 263
             {
@@ -275,24 +267,21 @@ namespace XHWK.WKTool
275 267
         /// <summary>
276 268
         /// 读取微课信息 
277 269
         /// </summary>
278
-        public static void ReadWkData()
270
+        public static void ReadWkData(string WkPath)
279 271
         {
280 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,7 +324,6 @@ namespace XHWK.WKTool
335 324
             try
336 325
             {
337 326
                 PageDrawList = new List<Model_DrawData>();
338
-                FileToolsCommon.CreateDirectory(WKData.WkPath);
339 327
                 string SavePath = WKData.WkPath + "PageData.d";
340 328
                 if (FileToolsCommon.IsExistFile(SavePath))
341 329
                 {

+ 1
- 1
XHWK.WKTool/CountdownWindow.xaml Visa fil

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

+ 1
- 2
XHWK.WKTool/CreateAMicroLessonWindow.xaml Visa fil

@@ -5,8 +5,7 @@
5 5
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6 6
         xmlns:local="clr-namespace:XHWK.WKTool"
7 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 9
     WindowStartupLocation="CenterScreen"
11 10
     WindowStyle="None">
12 11
     <Viewbox>

+ 11
- 3
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs Visa fil

@@ -84,14 +84,22 @@ namespace XHWK.WKTool
84 84
                 System.Windows.MessageBox.Show("路径不可为空!");
85 85
                 return;
86 86
             }
87
-            APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/"+APP.UserInfo.Username + "/";
88 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 99
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
91 100
             //存储文件
92 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 103
             #region 微课不允许有多个视频 废弃
96 104
             ////判断微课是否存在,存在则询问
97 105
             //if (APP.WKDataList != null&& APP.WKDataList.Count>0)

+ 0
- 2
XHWK.WKTool/FileDirectoryWindow.xaml.cs Visa fil

@@ -264,8 +264,6 @@ namespace XHWK.WKTool
264 264
             }
265 265
         }
266 266
 
267
-
268
-
269 267
         public static List<T> FindChilds<T>(DependencyObject parent, string childName)
270 268
   where T : DependencyObject
271 269
         {

+ 0
- 3
XHWK.WKTool/LoginWindow.xaml.cs Visa fil

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

+ 26
- 2
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs Visa fil

@@ -162,7 +162,7 @@ namespace XHWK.WKTool
162 162
         {
163 163
             //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
164 164
             FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
165
-            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
165
+            FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "tempsr/");
166 166
             VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
167 167
             int num = 1;
168 168
             while(FileToolsCommon.IsExistFile(VideoSavePathName))
@@ -220,6 +220,22 @@ namespace XHWK.WKTool
220 220
                 TimeOut();
221 221
                 IsSuspend = true;
222 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 239
                 try
224 240
                 {
225 241
                     APP.FFmpeg.SuspendFFmpeg();
@@ -291,6 +307,7 @@ namespace XHWK.WKTool
291 307
                         //保存数据
292 308
                         APP.SaveWkData();
293 309
                     }))).Start();
310
+                    Click_stopRecordingScreen();
294 311
                 }
295 312
                 catch (Exception ex)
296 313
                 {
@@ -539,7 +556,14 @@ namespace XHWK.WKTool
539 556
         }
540 557
         #endregion
541 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 Visa fil

@@ -299,6 +299,7 @@ namespace XHWK.WKTool
299 299
             {
300 300
                 APP.W_ScreenRecordingToolbarWindow.Initialize();
301 301
             }
302
+            APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
302 303
             //显示在右下角
303 304
             APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
304 305
             APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
@@ -306,8 +307,30 @@ namespace XHWK.WKTool
306 307
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
307 308
             APP.W_ScreenRecordingToolbarWindow.Show();
308 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 334
         /// <summary>
312 335
         /// 上传事件
313 336
         /// </summary>
@@ -1136,7 +1159,7 @@ namespace XHWK.WKTool
1136 1159
                 else
1137 1160
                 {
1138 1161
                     APP.W_CountdownWindow.Initialize();
1139
-                    APP.W_CountdownWindow.Topmost = true;
1162
+                    //APP.W_CountdownWindow.Topmost = true;
1140 1163
                 }
1141 1164
                 APP.W_CountdownWindow.Show();
1142 1165
                 #endregion
@@ -1145,6 +1168,22 @@ namespace XHWK.WKTool
1145 1168
                 //BtnRecording.Content = "暂停录制";
1146 1169
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
1147 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 1187
                 try
1149 1188
                 {
1150 1189
                     APP.FFmpeg.StartRecordingAudio(AudioPathName);
@@ -1169,6 +1208,22 @@ namespace XHWK.WKTool
1169 1208
                 IsSuspendR = true;
1170 1209
                 ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
1171 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 1227
                 try
1173 1228
                 {
1174 1229
                     APP.FFmpeg.SuspendFFmpeg();
@@ -1245,7 +1300,17 @@ namespace XHWK.WKTool
1245 1300
                 btnLoginType.IsEnabled = true;
1246 1301
                 IsSuspendR = true;
1247 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 1314
                 try
1250 1315
                 {
1251 1316
                     APP.FFmpeg.StopFFmpeg(AudioPathName);
@@ -1281,6 +1346,16 @@ namespace XHWK.WKTool
1281 1346
                         {
1282 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 1359
                         FileToolsCommon.DeleteFile(ThumbnailPathName);
1285 1360
                         VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
1286 1361
                         Thread.Sleep(500);
@@ -2180,10 +2255,14 @@ namespace XHWK.WKTool
2180 2255
         /// <param name="e"></param>
2181 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 2262
             else
2186
-                Visibility = Visibility.Hidden;
2263
+            {
2264
+                this.WindowState = WindowState.Minimized;
2265
+            }
2187 2266
         }
2188 2267
         /// <summary>
2189 2268
         /// 位置确定
@@ -2196,5 +2275,6 @@ namespace XHWK.WKTool
2196 2275
             //btnOk.Visibility = Visibility.Collapsed;
2197 2276
             //blackboard_canvas.Visibility = Visibility.Visible;
2198 2277
         }
2278
+
2199 2279
     }
2200 2280
 }

+ 1
- 1
XHWK.WKTool/XHWK.WKTool.csproj Visa fil

@@ -7,7 +7,7 @@
7 7
     <ProjectGuid>{57591E23-644E-416D-B1CA-BB04C550130F}</ProjectGuid>
8 8
     <OutputType>WinExe</OutputType>
9 9
     <RootNamespace>XHWK.WKTool</RootNamespace>
10
-    <AssemblyName>XHWK.WKTool</AssemblyName>
10
+    <AssemblyName>星火微课</AssemblyName>
11 11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
12 12
     <FileAlignment>512</FileAlignment>
13 13
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Laddar…
Avbryt
Spara