|
@@ -6,6 +6,7 @@ using System;
|
6
|
6
|
using System.Drawing;
|
7
|
7
|
using System.IO;
|
8
|
8
|
using System.Threading;
|
|
9
|
+using System.Threading.Tasks;
|
9
|
10
|
using System.Windows;
|
10
|
11
|
using System.Windows.Forms;
|
11
|
12
|
using System.Windows.Ink;
|
|
@@ -45,6 +46,8 @@ namespace XHWK.WKTool
|
45
|
46
|
/// </summary>
|
46
|
47
|
private string TempAudioPathName2;
|
47
|
48
|
|
|
49
|
+ private string temppath = APP.WKData.WkPath + "_temppath/";
|
|
50
|
+
|
48
|
51
|
/// <summary>
|
49
|
52
|
/// 视频信息
|
50
|
53
|
/// </summary>
|
|
@@ -196,11 +199,12 @@ namespace XHWK.WKTool
|
196
|
199
|
/// <summary>
|
197
|
200
|
/// 设置录屏文件地址
|
198
|
201
|
/// </summary>
|
199
|
|
- private void SetUpVideoPathName()
|
|
202
|
+ private void SetSavePath()
|
200
|
203
|
{
|
201
|
204
|
string fileType = ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
|
202
|
205
|
FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
|
203
|
|
- FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temprs/");
|
|
206
|
+ FileToolsCommon.DeleteDirectory(temppath);
|
|
207
|
+ FileToolsCommon.CreateDirectory(temppath);
|
204
|
208
|
VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + fileType;
|
205
|
209
|
int num = 1;
|
206
|
210
|
while (FileToolsCommon.IsExistFile(VideoSavePathName))
|
|
@@ -209,9 +213,9 @@ namespace XHWK.WKTool
|
209
|
213
|
VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "." + fileType;
|
210
|
214
|
}
|
211
|
215
|
|
212
|
|
- TempVideoPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + ".avi";
|
213
|
|
- TempAudioPathName1 = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "_1.mp3";
|
214
|
|
- TempAudioPathName2 = APP.WKData.WkPath + APP.WKData.WkName + "_录屏_" + num + "_2.mp3";
|
|
216
|
+ TempVideoPathName = temppath + "_录屏_" + num + ".avi";
|
|
217
|
+ TempAudioPathName1 = temppath + "_麦克风_" + num + "_1.mp3";
|
|
218
|
+ TempAudioPathName2 = temppath + "_扬声器_" + num + "_2.mp3";
|
215
|
219
|
}
|
216
|
220
|
|
217
|
221
|
/// <summary>
|
|
@@ -226,7 +230,7 @@ namespace XHWK.WKTool
|
226
|
230
|
private ZAudioRecordHelper helper2 = null;
|
227
|
231
|
|
228
|
232
|
//桌面录制
|
229
|
|
- private ZVideoRecordHelper helper3 = null;
|
|
233
|
+ private ZVideoRecordHelper helper0 = null;
|
230
|
234
|
|
231
|
235
|
public IntPtr winHandle;// 当前窗体指针
|
232
|
236
|
|
|
@@ -235,7 +239,7 @@ namespace XHWK.WKTool
|
235
|
239
|
/// </summary>
|
236
|
240
|
/// <param name="sender"></param>
|
237
|
241
|
/// <param name="e"></param>
|
238
|
|
- private void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
|
|
242
|
+ private async void BtnRecordingScreen_Click(object sender, RoutedEventArgs e)
|
239
|
243
|
{
|
240
|
244
|
#region 防止连击
|
241
|
245
|
|
|
@@ -280,7 +284,7 @@ namespace XHWK.WKTool
|
280
|
284
|
VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType")),
|
281
|
285
|
WkType = Enum_WKVidetype.RecordingScreen
|
282
|
286
|
};
|
283
|
|
- SetUpVideoPathName();
|
|
287
|
+ SetSavePath();
|
284
|
288
|
|
285
|
289
|
if (APP.W_CountdownWindow == null)
|
286
|
290
|
{
|
|
@@ -322,45 +326,44 @@ namespace XHWK.WKTool
|
322
|
326
|
|
323
|
327
|
#endregion 隐藏工具栏
|
324
|
328
|
|
325
|
|
- helper1 = new ZAudioRecordHelper(TempAudioPathName1, ZAudioRecordHelper.RecordType.microphone);
|
326
|
|
- helper2 = new ZAudioRecordHelper(TempAudioPathName2, ZAudioRecordHelper.RecordType.loudspeaker);
|
327
|
|
-
|
328
|
|
- winHandle = new WindowInteropHelper(this).Handle;
|
329
|
|
- var curScreen = Screen.FromHandle(winHandle);
|
330
|
|
- int RecordWidth = curScreen.Bounds.Width;
|
331
|
|
- int RecordHeight = curScreen.Bounds.Height;
|
332
|
|
- helper3 = new ZVideoRecordHelper(TempVideoPathName, RecordWidth, RecordHeight);
|
333
|
|
-
|
334
|
|
- new Thread(o =>
|
|
329
|
+ try
|
335
|
330
|
{
|
336
|
|
- Thread.Sleep(3000);
|
337
|
|
- Dispatcher.Invoke(() =>
|
338
|
|
- {
|
339
|
|
- _state = State.Start;
|
340
|
|
- helper1.StartRecordAudio();
|
341
|
|
- helper2.StartRecordAudio();
|
342
|
|
- helper3.StartRecordVideo();
|
343
|
|
- });
|
344
|
|
-
|
345
|
|
- Thread.Sleep(1000);
|
346
|
|
-
|
347
|
|
- Dispatcher.Invoke(() =>
|
348
|
|
- {
|
349
|
|
- k_hook.Start();//安装键盘钩子
|
350
|
|
- });
|
351
|
|
- })
|
352
|
|
- { IsBackground = true }.Start();
|
|
331
|
+ // 视频
|
|
332
|
+ winHandle = new WindowInteropHelper(this).Handle;
|
|
333
|
+ var curScreen = Screen.FromHandle(winHandle);
|
|
334
|
+ int RecordWidth = curScreen.Bounds.Width;
|
|
335
|
+ int RecordHeight = curScreen.Bounds.Height;
|
|
336
|
+ helper0 = new ZVideoRecordHelper(TempVideoPathName, RecordWidth, RecordHeight);
|
|
337
|
+
|
|
338
|
+ // 麦克风
|
|
339
|
+ helper1 = new ZAudioRecordHelper(TempAudioPathName1, ZAudioRecordHelper.RecordType.microphone);
|
|
340
|
+ // 扬声器
|
|
341
|
+ helper2 = new ZAudioRecordHelper(TempAudioPathName2, ZAudioRecordHelper.RecordType.loudspeaker);
|
|
342
|
+
|
|
343
|
+ await Task.Delay(3000);
|
|
344
|
+ APP.W_CountdownWindow.Hide();
|
|
345
|
+ await Task.Delay(100);
|
|
346
|
+ _state = State.Start;
|
|
347
|
+ helper1.StartRecordAudio();
|
|
348
|
+ helper2.StartRecordAudio();
|
|
349
|
+ helper0.StartRecordVideo();
|
|
350
|
+ k_hook.Start();//安装键盘钩子
|
|
351
|
+ }
|
|
352
|
+ catch (Exception)
|
|
353
|
+ {
|
|
354
|
+ ExitByErr();
|
|
355
|
+ }
|
353
|
356
|
|
|
357
|
+ Console.WriteLine("TempVideoPathName:" + TempVideoPathName);
|
354
|
358
|
Console.WriteLine("TempAudioPathName1:" + TempAudioPathName1);
|
355
|
359
|
Console.WriteLine("TempAudioPathName2:" + TempAudioPathName2);
|
356
|
|
- Console.WriteLine("TempVideoPathName:" + TempVideoPathName);
|
357
|
360
|
}
|
358
|
361
|
else if (_state == State.Start)
|
359
|
362
|
{
|
360
|
363
|
_state = State.Pause;
|
361
|
364
|
helper1.PauseRecordAudio();
|
362
|
365
|
helper2.PauseRecordAudio();
|
363
|
|
- helper3.PauseRecordVideo();
|
|
366
|
+ helper0.PauseRecordVideo();
|
364
|
367
|
BtnRecordingScreen.Visibility = Visibility.Visible;
|
365
|
368
|
BtnRecordingScreenPause.Visibility = Visibility.Collapsed;
|
366
|
369
|
}
|
|
@@ -369,12 +372,49 @@ namespace XHWK.WKTool
|
369
|
372
|
_state = State.Start;
|
370
|
373
|
helper1.ResumeRecordAudio();
|
371
|
374
|
helper2.ResumeRecordAudio();
|
372
|
|
- helper3.ResumeRecordVideo();
|
|
375
|
+ helper0.ResumeRecordVideo();
|
373
|
376
|
BtnRecordingScreen.Visibility = Visibility.Collapsed;
|
374
|
377
|
BtnRecordingScreenPause.Visibility = Visibility.Visible;
|
375
|
378
|
}
|
376
|
379
|
}
|
377
|
380
|
|
|
381
|
+ private void ExitByErr()
|
|
382
|
+ {
|
|
383
|
+ BtnRecordingScreen.ToolTip = "开始";
|
|
384
|
+ k_hook.Stop();
|
|
385
|
+ TxbTime.Content = "00:00";
|
|
386
|
+
|
|
387
|
+ if (APP.W_PracticeWindow != null)
|
|
388
|
+ {
|
|
389
|
+ if (APP.W_PracticeWindow.Visibility == Visibility.Visible)
|
|
390
|
+ {
|
|
391
|
+ Owner = null;
|
|
392
|
+ APP.W_PracticeWindow.ReturnPractice();
|
|
393
|
+ }
|
|
394
|
+ }
|
|
395
|
+
|
|
396
|
+ if (APP.W_XHMicroLessonSystemWindow == null)
|
|
397
|
+ {
|
|
398
|
+ APP.W_XHMicroLessonSystemWindow = new MainWindow();
|
|
399
|
+ }
|
|
400
|
+ APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
|
|
401
|
+
|
|
402
|
+ APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
|
|
403
|
+ APP.W_XHMicroLessonSystemWindow.Show();
|
|
404
|
+ End();
|
|
405
|
+ if (t != null)
|
|
406
|
+ {
|
|
407
|
+ t.Stop();
|
|
408
|
+ t = null;
|
|
409
|
+ }
|
|
410
|
+ helper0.StopRecordVideo();
|
|
411
|
+ helper1.StopRecordAudio();
|
|
412
|
+ helper2.StopRecordAudio();
|
|
413
|
+ FileToolsCommon.DeleteDirectory(temppath);
|
|
414
|
+ Click_stopRecordingScreen();
|
|
415
|
+ Hide();
|
|
416
|
+ }
|
|
417
|
+
|
378
|
418
|
/// <summary>
|
379
|
419
|
/// 停止录像
|
380
|
420
|
/// </summary>
|
|
@@ -418,7 +458,7 @@ namespace XHWK.WKTool
|
418
|
458
|
APP.W_XHMicroLessonSystemWindow = new MainWindow();
|
419
|
459
|
}
|
420
|
460
|
APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
|
421
|
|
- //APP.W_XHMicroLessonSystemWindow.InitPen();
|
|
461
|
+
|
422
|
462
|
APP.W_XHMicroLessonSystemWindow.InitTQLPPen();
|
423
|
463
|
APP.W_XHMicroLessonSystemWindow.Show();
|
424
|
464
|
|
|
@@ -428,57 +468,61 @@ namespace XHWK.WKTool
|
428
|
468
|
t.Stop();
|
429
|
469
|
t = null;
|
430
|
470
|
Console.WriteLine("停止录制");
|
|
471
|
+ helper0.StopRecordVideo();
|
431
|
472
|
helper1.StopRecordAudio();
|
432
|
473
|
helper2.StopRecordAudio();
|
433
|
|
- helper3.StopRecordVideo();
|
434
|
474
|
|
435
|
475
|
new Thread(new ThreadStart(new Action(() =>
|
436
|
476
|
{
|
437
|
477
|
FFMpegConverter ffMpeg = new FFMpegConverter();
|
438
|
478
|
|
439
|
479
|
FFMpegInput[] input = new FFMpegInput[] {
|
440
|
|
- new FFMpegInput(TempVideoPathName),
|
441
|
|
- new FFMpegInput(TempAudioPathName1),
|
442
|
|
- new FFMpegInput(TempAudioPathName1),
|
443
|
|
- };
|
|
480
|
+ new FFMpegInput(TempVideoPathName),
|
|
481
|
+ new FFMpegInput(TempAudioPathName1),
|
|
482
|
+ new FFMpegInput(TempAudioPathName2),
|
|
483
|
+ };
|
444
|
484
|
|
445
|
|
- // 多路音频混音
|
446
|
|
- ffMpeg.ConvertMedia(
|
447
|
|
- input,
|
448
|
|
- VideoSavePathName,
|
449
|
|
- "mp4",
|
450
|
|
- new OutputSettings()
|
|
485
|
+ try
|
|
486
|
+ {
|
|
487
|
+ // 多路音频混音
|
|
488
|
+ ffMpeg.ConvertMedia(
|
|
489
|
+ input,
|
|
490
|
+ VideoSavePathName,
|
|
491
|
+ "mp4",
|
|
492
|
+ new OutputSettings()
|
|
493
|
+ {
|
|
494
|
+ CustomOutputArgs = "-filter_complex amix=inputs=2:duration=first:dropout_transition=2"
|
|
495
|
+ }
|
|
496
|
+ );
|
|
497
|
+ //生成缩略图
|
|
498
|
+ string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
|
|
499
|
+ FileToolsCommon.CreateDirectory(ThumbnailPath);
|
|
500
|
+ //缩略图存储位置
|
|
501
|
+ string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
|
|
502
|
+
|
|
503
|
+ VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
504
|
+ VideoInfo.VideoPath = VideoSavePathName;
|
|
505
|
+ VideoInfo.ThumbnailPath = ThumbnailPathName;
|
|
506
|
+ APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName, 200, 130);
|
|
507
|
+ VideoInfo.FileGuid = Guid.NewGuid().ToString();
|
|
508
|
+ VideoInfo.IsUpload = false;
|
|
509
|
+ VideoInfo.Uploaded = 0;
|
|
510
|
+ if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
|
451
|
511
|
{
|
452
|
|
- CustomOutputArgs = "-filter_complex amix=inputs=2:duration=first:dropout_transition=2"
|
|
512
|
+ APP.VideoList.Add(VideoInfo);
|
|
513
|
+ //保存数据
|
|
514
|
+ APP.SaveWkData();
|
453
|
515
|
}
|
454
|
|
- );
|
455
|
|
- //生成缩略图
|
456
|
|
- string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
|
457
|
|
- FileToolsCommon.CreateDirectory(ThumbnailPath);
|
458
|
|
- //缩略图存储位置
|
459
|
|
- string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
|
460
|
|
-
|
461
|
|
- FileToolsCommon.DeleteFile(ThumbnailPathName);
|
462
|
|
- VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
463
|
|
- VideoInfo.VideoPath = VideoSavePathName;
|
464
|
|
- VideoInfo.ThumbnailPath = ThumbnailPathName;
|
465
|
|
- APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName, 200, 130);
|
466
|
|
- VideoInfo.FileGuid = Guid.NewGuid().ToString();
|
467
|
|
- VideoInfo.IsUpload = false;
|
468
|
|
- VideoInfo.Uploaded = 0;
|
469
|
|
- if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
|
|
516
|
+ }
|
|
517
|
+ catch (Exception ex)
|
470
|
518
|
{
|
471
|
|
- APP.VideoList.Add(VideoInfo);
|
472
|
|
- //保存数据
|
473
|
|
- APP.SaveWkData();
|
|
519
|
+ LogHelper.WriteErrLog("录屏保存" + ex.Message, ex);
|
474
|
520
|
}
|
475
|
521
|
|
476
|
|
- FileToolsCommon.DeleteFile(TempAudioPathName1);
|
477
|
|
- FileToolsCommon.DeleteFile(TempAudioPathName2);
|
478
|
|
- FileToolsCommon.DeleteFile(TempVideoPathName);
|
|
522
|
+ FileToolsCommon.DeleteDirectory(temppath);
|
479
|
523
|
}))).Start();
|
480
|
|
- Click_stopRecordingScreen();
|
481
|
524
|
}
|
|
525
|
+ Click_stopRecordingScreen();
|
482
|
526
|
Hide();
|
483
|
527
|
|
484
|
528
|
SRTime = Convert.ToDateTime("2020-01-01 00:00:00");
|
|
@@ -525,17 +569,11 @@ namespace XHWK.WKTool
|
525
|
569
|
#endregion 防止连击
|
526
|
570
|
|
527
|
571
|
string time = GetTimeStamp();
|
528
|
|
- string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
|
529
|
|
- if (!Directory.Exists(tempPath))
|
530
|
|
- {
|
531
|
|
- Directory.CreateDirectory(tempPath);
|
532
|
|
- }
|
|
572
|
+
|
533
|
573
|
try
|
534
|
574
|
{
|
535
|
575
|
Dispatcher.Invoke(() =>
|
536
|
576
|
{
|
537
|
|
- //borOne.Background = new SolidColorBrush(Colors.LightSkyBlue);
|
538
|
|
- //borTwo.Background = new SolidColorBrush(Colors.DodgerBlue);
|
539
|
577
|
if (APP.W_PracticeWindow == null)
|
540
|
578
|
{
|
541
|
579
|
APP.W_PracticeWindow = new PracticeWindow
|
|
@@ -545,10 +583,8 @@ namespace XHWK.WKTool
|
545
|
583
|
Left = 0,
|
546
|
584
|
Top = 0
|
547
|
585
|
};
|
548
|
|
- //practiceWin.Owner = this;
|
549
|
586
|
}
|
550
|
|
- //APP.W_PracticeWindow.InitPen();
|
551
|
|
- //APP.W_PracticeWindow.InitTQLPPen();
|
|
587
|
+
|
552
|
588
|
APP.W_PracticeWindow.Initialize();// imagePath);
|
553
|
589
|
flg = 11;
|
554
|
590
|
APP.W_PracticeWindow.Blue();
|
|
@@ -566,7 +602,6 @@ namespace XHWK.WKTool
|
566
|
602
|
Thread.Sleep(500);
|
567
|
603
|
Dispatcher.Invoke(() =>
|
568
|
604
|
{
|
569
|
|
- //Owner = APP.W_PracticeWindow;
|
570
|
605
|
Topmost = true;
|
571
|
606
|
});
|
572
|
607
|
}))).Start();
|
|
@@ -613,18 +648,6 @@ namespace XHWK.WKTool
|
613
|
648
|
BtnPenBlue_CL.Visibility = Visibility.Visible;
|
614
|
649
|
BtnPenRed_CL.Visibility = Visibility.Collapsed;
|
615
|
650
|
string time = GetTimeStamp();
|
616
|
|
- string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
|
617
|
|
- if (!Directory.Exists(tempPath))
|
618
|
|
- {
|
619
|
|
- Directory.CreateDirectory(tempPath);
|
620
|
|
- }
|
621
|
|
-
|
622
|
|
- #region 录屏批注取消画笔
|
623
|
|
-
|
624
|
|
- //string imagePath = Path.Combine(tempPath, time + ".jpg");
|
625
|
|
- //ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
|
626
|
|
-
|
627
|
|
- #endregion 录屏批注取消画笔
|
628
|
651
|
|
629
|
652
|
try
|
630
|
653
|
{
|
|
@@ -816,15 +839,10 @@ namespace XHWK.WKTool
|
816
|
839
|
BtnPenBlue_CL.Visibility = Visibility.Collapsed;
|
817
|
840
|
BtnPenRed_CL.Visibility = Visibility.Visible;
|
818
|
841
|
string time = GetTimeStamp();
|
819
|
|
- string tempPath = AppDomain.CurrentDomain.BaseDirectory + "temp\\";
|
820
|
|
- if (!Directory.Exists(tempPath))
|
821
|
|
- {
|
822
|
|
- Directory.CreateDirectory(tempPath);
|
823
|
|
- }
|
824
|
842
|
|
825
|
843
|
#region 录屏批注取消画笔
|
826
|
844
|
|
827
|
|
- string imagePath = Path.Combine(tempPath, time + ".jpg");
|
|
845
|
+ string imagePath = Path.Combine(temppath, time + ".jpg");
|
828
|
846
|
ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), imagePath, true, out BitmapImage bitmap);
|
829
|
847
|
|
830
|
848
|
#endregion 录屏批注取消画笔
|