Browse Source

添加全局错误日志 合并前终止ffmpeg

tags/对接微服务前
张剑 3 years ago
parent
commit
5572e8ce71

+ 2
- 2
XHWK.WKTool/App.config View File

9
     <!--参数是否加密 0不加密 1加密-->
9
     <!--参数是否加密 0不加密 1加密-->
10
     <add key="IsParameterEncryption" value="0" />
10
     <add key="IsParameterEncryption" value="0" />
11
     <!--版本号-->
11
     <!--版本号-->
12
-    <add key="VersionCode" value="101" />
13
-    <add key="VersionName" value="3.1.7" />
12
+    <add key="VersionCode" value="102" />
13
+    <add key="VersionName" value="3.1.8" />
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15
     <add key="SkinStyle" value="0" />
15
     <add key="SkinStyle" value="0" />
16
     <!--是否输出视频记录日志:0否-->
16
     <!--是否输出视频记录日志:0否-->

+ 78
- 12
XHWK.WKTool/App.xaml.cs View File

10
 using System.Reflection;
10
 using System.Reflection;
11
 using System.Security.Principal;
11
 using System.Security.Principal;
12
 using System.Threading;
12
 using System.Threading;
13
+using System.Threading.Tasks;
13
 using System.Windows;
14
 using System.Windows;
14
 using System.Windows.Threading;
15
 using System.Windows.Threading;
15
 
16
 
264
         /// <summary>
265
         /// <summary>
265
         /// 主页面
266
         /// 主页面
266
         /// </summary>
267
         /// </summary>
267
-        public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
268
+        public static MainWindow W_XHMicroLessonSystemWindow = null;
268
 
269
 
269
         /// <summary>
270
         /// <summary>
270
         /// 创建微课页面
271
         /// 创建微课页面
329
         {
330
         {
330
             Console.WriteLine("初始化APP");
331
             Console.WriteLine("初始化APP");
331
             LogHelper.InitLog4Net();
332
             LogHelper.InitLog4Net();
333
+
332
             myloading = new LoadDialog();
334
             myloading = new LoadDialog();
333
             StopSameProcess();
335
             StopSameProcess();
334
             Killffmpeg();
336
             Killffmpeg();
433
 
435
 
434
         #endregion 杀死已存在的进程
436
         #endregion 杀死已存在的进程
435
 
437
 
436
-        /// <summary>
437
-        /// 错误处理
438
-        /// </summary>
439
-        /// <param name="sender">
440
-        /// </param>
441
-        /// <param name="e">
442
-        /// </param>
443
-        private void MyApp_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
438
+        private void RegisterEvents()
439
+        {
440
+            //Task线程内未捕获异常处理事件
441
+            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;//Task异常
442
+
443
+            //UI线程未捕获异常处理事件(UI主线程)
444
+            DispatcherUnhandledException += App_DispatcherUnhandledException;
445
+
446
+            //非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
447
+            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
448
+        }
449
+
450
+        private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
451
+        {
452
+            try
453
+            {
454
+                var exception = e.Exception as Exception;
455
+                if (exception != null)
456
+                {
457
+                    HandleException(exception);
458
+                }
459
+            }
460
+            catch (Exception ex)
461
+            {
462
+                HandleException(ex);
463
+            }
464
+            finally
465
+            {
466
+                e.SetObserved();
467
+            }
468
+        }
469
+
470
+        //非UI线程未捕获异常处理事件(例如自己创建的一个子线程)
471
+        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
472
+        {
473
+            try
474
+            {
475
+                var exception = e.ExceptionObject as Exception;
476
+                if (exception != null)
477
+                {
478
+                    HandleException(exception);
479
+                }
480
+            }
481
+            catch (Exception ex)
482
+            {
483
+                HandleException(ex);
484
+            }
485
+            finally
486
+            {
487
+                //ignore
488
+            }
489
+        }
490
+
491
+        //UI线程未捕获异常处理事件(UI主线程)
492
+        private static void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
493
+        {
494
+            try
495
+            {
496
+                HandleException(e.Exception);
497
+            }
498
+            catch (Exception ex)
499
+            {
500
+                HandleException(ex);
501
+            }
502
+            finally
503
+            {
504
+                e.Handled = true;
505
+            }
506
+        }
507
+
508
+        private static void HandleException(Exception ex)
444
         {
509
         {
445
-            LogHelper.WriteErrLog("未标示错误:" + e.Exception.Message, e.Exception);
446
-            MessageWindow.Show("程序异常." + Environment.NewLine + e.Exception.Message);
447
-            e.Handled = true;
510
+            MessageBox.Show("出错了,请与开发人员联系:" + ex.Message);
511
+            //记录日志
512
+            LogHelper.WriteErrLog("未捕获异常:" + ex.Message, ex);
448
         }
513
         }
449
 
514
 
450
         #region 数据保存和读取
515
         #region 数据保存和读取
651
         /// </param>
716
         /// </param>
652
         protected override void OnStartup(StartupEventArgs e)
717
         protected override void OnStartup(StartupEventArgs e)
653
         {
718
         {
719
+            RegisterEvents();
654
             new Thread(o =>
720
             new Thread(o =>
655
             {
721
             {
656
                 while (true)
722
                 while (true)

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

301
 
301
 
302
             if (APP.W_XHMicroLessonSystemWindow == null)
302
             if (APP.W_XHMicroLessonSystemWindow == null)
303
             {
303
             {
304
-                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
304
+                APP.W_XHMicroLessonSystemWindow = new MainWindow();
305
             }
305
             }
306
             APP.W_XHMicroLessonSystemWindow.Show();
306
             APP.W_XHMicroLessonSystemWindow.Show();
307
             LblCreate.Visibility = Visibility.Hidden;
307
             LblCreate.Visibility = Visibility.Hidden;

+ 1
- 1
XHWK.WKTool/JieTuWindow.xaml.cs View File

19
 
19
 
20
 using XHWK.WKTool;
20
 using XHWK.WKTool;
21
 
21
 
22
-using static XHWK.WKTool.XHMicroLessonSystemWindow;
22
+using static XHWK.WKTool.MainWindow;
23
 
23
 
24
 namespace ComeCapture
24
 namespace ComeCapture
25
 {
25
 {

XHWK.WKTool/XHMicroLessonSystemWindow.xaml → XHWK.WKTool/MainWindow.xaml View File

1
 <Window
1
 <Window
2
-    x:Class="XHWK.WKTool.XHMicroLessonSystemWindow"
2
+    x:Class="XHWK.WKTool.MainWindow"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8
     Width="950"
8
     Width="950"
9
     Height="700"
9
     Height="700"
10
     AllowsTransparency="False"
10
     AllowsTransparency="False"
11
-  
12
     BorderBrush="#eee"
11
     BorderBrush="#eee"
13
     BorderThickness="1"
12
     BorderThickness="1"
14
     Loaded="Window_Loaded"
13
     Loaded="Window_Loaded"
220
         </Style>
219
         </Style>
221
     </Window.Resources>
220
     </Window.Resources>
222
 
221
 
223
-
224
     <Grid>
222
     <Grid>
225
         <!--  内容区 上:标题栏  下:工具栏和录制区域  -->
223
         <!--  内容区 上:标题栏  下:工具栏和录制区域  -->
226
         <Grid
224
         <Grid
398
                             Cursor="Hand"
396
                             Cursor="Hand"
399
                             FontSize="14"
397
                             FontSize="14"
400
                             Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
398
                             Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
401
-
402
                     </Grid>
399
                     </Grid>
403
                     <!--  测试  -->
400
                     <!--  测试  -->
404
                     <Grid Grid.Column="2" Visibility="Collapsed">
401
                     <Grid Grid.Column="2" Visibility="Collapsed">
879
                                             <ScaleTransform ScaleX="-1" />
876
                                             <ScaleTransform ScaleX="-1" />
880
                                         </Image.RenderTransform>
877
                                         </Image.RenderTransform>
881
                                     </Image>
878
                                     </Image>
882
-                                   
883
                                 </Grid>
879
                                 </Grid>
884
                             </Border>
880
                             </Border>
885
                         </Grid>
881
                         </Grid>
891
                             Background="#FFFFFFFF"
887
                             Background="#FFFFFFFF"
892
                             Visibility="Visible">
888
                             Visibility="Visible">
893
                             <Grid.ColumnDefinitions>
889
                             <Grid.ColumnDefinitions>
894
-                                <ColumnDefinition Width="200"></ColumnDefinition>
895
-                                <ColumnDefinition Width="*"></ColumnDefinition>
896
-                                <ColumnDefinition Width="200"></ColumnDefinition>
897
-                        
890
+                                <ColumnDefinition Width="200" />
891
+                                <ColumnDefinition Width="*" />
892
+                                <ColumnDefinition Width="200" />
898
                             </Grid.ColumnDefinitions>
893
                             </Grid.ColumnDefinitions>
899
                             <!--  页码  -->
894
                             <!--  页码  -->
900
                             <Grid
895
                             <Grid
901
-                                    x:Name="GridPage"
902
-                                    Grid.Column="0"
903
-                                    Grid.Row="0"
904
-                                    HorizontalAlignment="Left"
905
-                                    VerticalAlignment="Center"
906
-                                    MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
907
-                                    Visibility="Collapsed">
896
+                                x:Name="GridPage"
897
+                                Grid.Row="0"
898
+                                Grid.Column="0"
899
+                                HorizontalAlignment="Left"
900
+                                VerticalAlignment="Center"
901
+                                MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
902
+                                Visibility="Collapsed">
908
                                 <StackPanel
903
                                 <StackPanel
909
-                                        Grid.Row="0"
910
-                                        Grid.Column="1"
911
-                                        Height="30"
912
-                                        Margin="0,0,0,0"
913
-                                        HorizontalAlignment="Center"
914
-                                        VerticalAlignment="Bottom"
915
-                                        Background="Transparent"
916
-                                        Orientation="Horizontal">
904
+                                    Grid.Row="0"
905
+                                    Grid.Column="1"
906
+                                    Height="30"
907
+                                    Margin="0,0,0,0"
908
+                                    HorizontalAlignment="Center"
909
+                                    VerticalAlignment="Bottom"
910
+                                    Background="Transparent"
911
+                                    Orientation="Horizontal">
917
 
912
 
918
-                                    <Label Margin="5,0,0,0" Content="页码:" VerticalAlignment="Center" ></Label>
913
+                                    <Label
914
+                                        Margin="5,0,0,0"
915
+                                        VerticalAlignment="Center"
916
+                                        Content="页码:" />
919
 
917
 
920
                                     <Button
918
                                     <Button
921
-                                            x:Name="last_button"
922
-                                            Width="28"
923
-                                            Height="20"
924
-                                            Click="last_button_Click"
925
-                                            Cursor="Hand"
926
-                                            Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
919
+                                        x:Name="last_button"
920
+                                        Width="28"
921
+                                        Height="20"
922
+                                        Click="last_button_Click"
923
+                                        Cursor="Hand"
924
+                                        Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
927
                                         <StackPanel>
925
                                         <StackPanel>
928
                                             <Image
926
                                             <Image
929
-                                                    Width="16"
930
-                                                    Height="12"
931
-                                                    Source=".\Images\class_p1.png" />
927
+                                                Width="16"
928
+                                                Height="12"
929
+                                                Source=".\Images\class_p1.png" />
932
                                         </StackPanel>
930
                                         </StackPanel>
933
                                     </Button>
931
                                     </Button>
934
                                     <Grid
932
                                     <Grid
935
-                                            Width="60"
936
-                                            Background="Transparent"
937
-                                            MouseLeftButtonDown="Window_MouseLeftButtonDown_1">
933
+                                        Width="60"
934
+                                        Background="Transparent"
935
+                                        MouseLeftButtonDown="Window_MouseLeftButtonDown_1">
938
                                         <StackPanel
936
                                         <StackPanel
939
-                                                HorizontalAlignment="Center"
940
-                                                Background="Transparent"
941
-                                                Orientation="Horizontal">
937
+                                            HorizontalAlignment="Center"
938
+                                            Background="Transparent"
939
+                                            Orientation="Horizontal">
942
                                             <TextBlock
940
                                             <TextBlock
943
-                                                    x:Name="txbCurrpage"
944
-                                                    Margin="0"
945
-                                                    HorizontalAlignment="Center"
946
-                                                    VerticalAlignment="Center"
947
-                                                    FontSize="14"
948
-                                                    Text="{Binding currpage}"
949
-                                                    TextAlignment="Center" />
941
+                                                x:Name="txbCurrpage"
942
+                                                Margin="0"
943
+                                                HorizontalAlignment="Center"
944
+                                                VerticalAlignment="Center"
945
+                                                FontSize="14"
946
+                                                Text="{Binding currpage}"
947
+                                                TextAlignment="Center" />
950
                                             <TextBlock
948
                                             <TextBlock
951
-                                                    HorizontalAlignment="Center"
952
-                                                    VerticalAlignment="Center"
953
-                                                    FontSize="14"
954
-                                                    Text="/"
955
-                                                    TextAlignment="Center" />
949
+                                                HorizontalAlignment="Center"
950
+                                                VerticalAlignment="Center"
951
+                                                FontSize="14"
952
+                                                Text="/"
953
+                                                TextAlignment="Center" />
956
                                             <TextBlock
954
                                             <TextBlock
957
-                                                    x:Name="txbTotalpage"
958
-                                                    HorizontalAlignment="Center"
959
-                                                    VerticalAlignment="Center"
960
-                                                    FontSize="14"
961
-                                                    Text="{Binding pagenum}"
962
-                                                    TextAlignment="Center" />
955
+                                                x:Name="txbTotalpage"
956
+                                                HorizontalAlignment="Center"
957
+                                                VerticalAlignment="Center"
958
+                                                FontSize="14"
959
+                                                Text="{Binding pagenum}"
960
+                                                TextAlignment="Center" />
963
                                         </StackPanel>
961
                                         </StackPanel>
964
                                     </Grid>
962
                                     </Grid>
965
                                     <Button
963
                                     <Button
966
-                                            x:Name="next_btn"
967
-                                            Width="28"
968
-                                            Height="20"
969
-                                            Background="Transparent"
970
-                                            Click="next_btn_Click"
971
-                                            Cursor="Hand"
972
-                                            Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
964
+                                        x:Name="next_btn"
965
+                                        Width="28"
966
+                                        Height="20"
967
+                                        Background="Transparent"
968
+                                        Click="next_btn_Click"
969
+                                        Cursor="Hand"
970
+                                        Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
973
                                         <StackPanel>
971
                                         <StackPanel>
974
                                             <Image
972
                                             <Image
975
-                                                    Width="16"
976
-                                                    Height="12"
977
-                                                    Source=".\Images\class_p2.png" />
973
+                                                Width="16"
974
+                                                Height="12"
975
+                                                Source=".\Images\class_p2.png" />
978
                                         </StackPanel>
976
                                         </StackPanel>
979
                                     </Button>
977
                                     </Button>
980
-
981
                                 </StackPanel>
978
                                 </StackPanel>
982
                             </Grid>
979
                             </Grid>
983
                             <StackPanel
980
                             <StackPanel
984
-                                    Margin="5"
985
-                                    Grid.Column="1"
986
-                                    HorizontalAlignment="Right"
987
-                                    VerticalAlignment="Center"
988
-                                    Orientation="Horizontal">
981
+                                Grid.Column="1"
982
+                                Margin="5"
983
+                                HorizontalAlignment="Right"
984
+                                VerticalAlignment="Center"
985
+                                Orientation="Horizontal">
989
                                 <TextBlock
986
                                 <TextBlock
990
-                                        Margin="5,0,0,0"
991
-                                        Padding="0,0,0,0"
992
-                                        VerticalAlignment="Center"
993
-                                        FontSize="12"
994
-                                        Text="颜色: " />
987
+                                    Margin="5,0,0,0"
988
+                                    Padding="0,0,0,0"
989
+                                    VerticalAlignment="Center"
990
+                                    FontSize="12"
991
+                                    Text="颜色: " />
995
                                 <Button
992
                                 <Button
996
-                                        x:Name="btnWhite"
997
-                                        Width="20"
998
-                                        Height="20"
999
-                                        Margin="0,2,0,0"
1000
-                                        Background="#FFFFFF"
1001
-                                        Click="BtnWhite_Click"
1002
-                                        Cursor="Hand"
1003
-                                        Visibility="Collapsed" />
993
+                                    x:Name="btnWhite"
994
+                                    Width="20"
995
+                                    Height="20"
996
+                                    Margin="0,2,0,0"
997
+                                    Background="#FFFFFF"
998
+                                    Click="BtnWhite_Click"
999
+                                    Cursor="Hand"
1000
+                                    Visibility="Collapsed" />
1004
                                 <Border
1001
                                 <Border
1002
+                                    Width="20"
1003
+                                    Height="20"
1004
+                                    Margin="5,2,0,0"
1005
+                                    Background="#666666">
1006
+                                    <Button
1007
+                                        x:Name="btnRed"
1005
                                         Width="20"
1008
                                         Width="20"
1006
                                         Height="20"
1009
                                         Height="20"
1007
-                                        Margin="5,2,0,0"
1008
-                                        Background="#666666">
1009
-                                    <Button
1010
-                                            x:Name="btnRed"
1011
-                                            Width="20"
1012
-                                            Height="20"
1013
-                                            Margin="1,1,1,1"
1014
-                                            HorizontalAlignment="Center"
1015
-                                            Background="#FF0000"
1016
-                                            Click="BtnRed_Click"
1017
-                                            Cursor="Hand"
1018
-                                            Style="{StaticResource NoMouseOverButtonStyle}">
1010
+                                        Margin="1,1,1,1"
1011
+                                        HorizontalAlignment="Center"
1012
+                                        Background="#FF0000"
1013
+                                        Click="BtnRed_Click"
1014
+                                        Cursor="Hand"
1015
+                                        Style="{StaticResource NoMouseOverButtonStyle}">
1019
                                         <Image
1016
                                         <Image
1020
-                                                x:Name="imgRed"
1021
-                                                Width="12"
1022
-                                                Source=".\Images\microLessonSystem_999.png"
1023
-                                                Visibility="Visible" />
1017
+                                            x:Name="imgRed"
1018
+                                            Width="12"
1019
+                                            Source=".\Images\microLessonSystem_999.png"
1020
+                                            Visibility="Visible" />
1024
                                     </Button>
1021
                                     </Button>
1025
                                 </Border>
1022
                                 </Border>
1026
                                 <Border
1023
                                 <Border
1024
+                                    Width="20"
1025
+                                    Height="20"
1026
+                                    Margin="5,2,0,0"
1027
+                                    Background="#666666">
1028
+                                    <Button
1029
+                                        x:Name="btnGray"
1027
                                         Width="20"
1030
                                         Width="20"
1028
                                         Height="20"
1031
                                         Height="20"
1029
-                                        Margin="5,2,0,0"
1030
-                                        Background="#666666">
1031
-                                    <Button
1032
-                                            x:Name="btnGray"
1033
-                                            Width="20"
1034
-                                            Height="20"
1035
-                                            Margin="1,1,1,1"
1036
-                                            Background="#333333"
1037
-                                            Click="BtnGray_Click"
1038
-                                            Cursor="Hand"
1039
-                                            Style="{StaticResource NoMouseOverButtonStyle}">
1032
+                                        Margin="1,1,1,1"
1033
+                                        Background="#333333"
1034
+                                        Click="BtnGray_Click"
1035
+                                        Cursor="Hand"
1036
+                                        Style="{StaticResource NoMouseOverButtonStyle}">
1040
                                         <Image
1037
                                         <Image
1041
-                                                x:Name="imgGray"
1042
-                                                Width="12"
1043
-                                                Source=".\Images\microLessonSystem_999.png"
1044
-                                                Visibility="Collapsed" />
1038
+                                            x:Name="imgGray"
1039
+                                            Width="12"
1040
+                                            Source=".\Images\microLessonSystem_999.png"
1041
+                                            Visibility="Collapsed" />
1045
                                     </Button>
1042
                                     </Button>
1046
                                 </Border>
1043
                                 </Border>
1047
                                 <Border
1044
                                 <Border
1045
+                                    Width="20"
1046
+                                    Height="20"
1047
+                                    Margin="5,2,0,0"
1048
+                                    Background="#666666">
1049
+                                    <Button
1050
+                                        x:Name="btnCyanBlue"
1048
                                         Width="20"
1051
                                         Width="20"
1049
                                         Height="20"
1052
                                         Height="20"
1050
-                                        Margin="5,2,0,0"
1051
-                                        Background="#666666">
1052
-                                    <Button
1053
-                                            x:Name="btnCyanBlue"
1054
-                                            Width="20"
1055
-                                            Height="20"
1056
-                                            Margin="1,1,1,1"
1057
-                                            Background="#63D600"
1058
-                                            Click="BtnCyanBlue_Click"
1059
-                                            Cursor="Hand"
1060
-                                            Style="{StaticResource NoMouseOverButtonStyle}">
1053
+                                        Margin="1,1,1,1"
1054
+                                        Background="#63D600"
1055
+                                        Click="BtnCyanBlue_Click"
1056
+                                        Cursor="Hand"
1057
+                                        Style="{StaticResource NoMouseOverButtonStyle}">
1061
                                         <Image
1058
                                         <Image
1062
-                                                x:Name="imgCyanBlue"
1063
-                                                Width="12"
1064
-                                                Source=".\Images\microLessonSystem_999.png"
1065
-                                                Visibility="Collapsed" />
1059
+                                            x:Name="imgCyanBlue"
1060
+                                            Width="12"
1061
+                                            Source=".\Images\microLessonSystem_999.png"
1062
+                                            Visibility="Collapsed" />
1066
                                     </Button>
1063
                                     </Button>
1067
                                 </Border>
1064
                                 </Border>
1068
                                 <Border
1065
                                 <Border
1069
-                                        Width="20"
1070
-                                        Height="20"
1071
-                                        Margin="5,2,0,0"
1072
-                                        Background="#666666">
1066
+                                    Width="20"
1067
+                                    Height="20"
1068
+                                    Margin="5,2,0,0"
1069
+                                    Background="#666666">
1073
 
1070
 
1074
                                     <Button
1071
                                     <Button
1075
-                                            x:Name="btnYellow"
1076
-                                            Width="20"
1077
-                                            Height="20"
1078
-                                            Margin="1,1,1,1"
1079
-                                            Background="#FFBC00"
1080
-                                            Click="BtnYellow_Click"
1081
-                                            Cursor="Hand"
1082
-                                            Style="{StaticResource NoMouseOverButtonStyle}">
1072
+                                        x:Name="btnYellow"
1073
+                                        Width="20"
1074
+                                        Height="20"
1075
+                                        Margin="1,1,1,1"
1076
+                                        Background="#FFBC00"
1077
+                                        Click="BtnYellow_Click"
1078
+                                        Cursor="Hand"
1079
+                                        Style="{StaticResource NoMouseOverButtonStyle}">
1083
 
1080
 
1084
                                         <Image
1081
                                         <Image
1085
-                                                x:Name="imgYellow"
1086
-                                                Width="12"
1087
-                                                Source=".\Images\microLessonSystem_999.png"
1088
-                                                Visibility="Collapsed" />
1082
+                                            x:Name="imgYellow"
1083
+                                            Width="12"
1084
+                                            Source=".\Images\microLessonSystem_999.png"
1085
+                                            Visibility="Collapsed" />
1089
                                     </Button>
1086
                                     </Button>
1090
                                 </Border>
1087
                                 </Border>
1091
                                 <Border
1088
                                 <Border
1092
-                                        Width="20"
1093
-                                        Height="20"
1094
-                                        Margin="5,2,0,0"
1095
-                                        Background="#666666">
1089
+                                    Width="20"
1090
+                                    Height="20"
1091
+                                    Margin="5,2,0,0"
1092
+                                    Background="#666666">
1096
 
1093
 
1097
                                     <Button
1094
                                     <Button
1098
-                                            x:Name="btnBlue"
1099
-                                            Width="20"
1100
-                                            Height="20"
1101
-                                            Margin="1,1,1,1"
1102
-                                            Background="#00B4FC"
1103
-                                            Click="BtnBlue_Click"
1104
-                                            Cursor="Hand"
1105
-                                            Style="{StaticResource NoMouseOverButtonStyle}">
1095
+                                        x:Name="btnBlue"
1096
+                                        Width="20"
1097
+                                        Height="20"
1098
+                                        Margin="1,1,1,1"
1099
+                                        Background="#00B4FC"
1100
+                                        Click="BtnBlue_Click"
1101
+                                        Cursor="Hand"
1102
+                                        Style="{StaticResource NoMouseOverButtonStyle}">
1106
                                         <Image
1103
                                         <Image
1107
-                                                x:Name="imgBlue"
1108
-                                                Width="12"
1109
-                                                Source=".\Images\microLessonSystem_999.png"
1110
-                                                Visibility="Collapsed" />
1104
+                                            x:Name="imgBlue"
1105
+                                            Width="12"
1106
+                                            Source=".\Images\microLessonSystem_999.png"
1107
+                                            Visibility="Collapsed" />
1111
                                     </Button>
1108
                                     </Button>
1112
                                 </Border>
1109
                                 </Border>
1113
                                 <TextBlock
1110
                                 <TextBlock
1114
-                                        Margin="5,0,0,0"
1115
-                                        Padding="0,0,0,0"
1116
-                                        VerticalAlignment="Center"
1117
-                                        FontSize="12"
1118
-                                        Text="粗细: " />
1111
+                                    Margin="5,0,0,0"
1112
+                                    Padding="0,0,0,0"
1113
+                                    VerticalAlignment="Center"
1114
+                                    FontSize="12"
1115
+                                    Text="粗细: " />
1119
                                 <RadioButton
1116
                                 <RadioButton
1120
-                                        x:Name="rbnFine"
1121
-                                        Margin="0"
1122
-                                        VerticalAlignment="Center"
1123
-                                        Click="RbnFine_Click"
1124
-                                        Content=" 细"
1125
-                                        Cursor="Hand"
1126
-                                        FontSize="12"
1127
-                                        IsChecked="True"
1128
-                                        Style="{StaticResource radBase}" />
1117
+                                    x:Name="rbnFine"
1118
+                                    Margin="0"
1119
+                                    VerticalAlignment="Center"
1120
+                                    Click="RbnFine_Click"
1121
+                                    Content=" 细"
1122
+                                    Cursor="Hand"
1123
+                                    FontSize="12"
1124
+                                    IsChecked="True"
1125
+                                    Style="{StaticResource radBase}" />
1129
                                 <RadioButton
1126
                                 <RadioButton
1130
-                                        x:Name="rbnIn"
1131
-                                        Margin="5,0,0,0"
1132
-                                        VerticalAlignment="Center"
1133
-                                        Click="RbnIn_Click"
1134
-                                        Content=" 中"
1135
-                                        Cursor="Hand"
1136
-                                        FontSize="12"
1137
-                                        Style="{StaticResource radBase}" />
1127
+                                    x:Name="rbnIn"
1128
+                                    Margin="5,0,0,0"
1129
+                                    VerticalAlignment="Center"
1130
+                                    Click="RbnIn_Click"
1131
+                                    Content=" 中"
1132
+                                    Cursor="Hand"
1133
+                                    FontSize="12"
1134
+                                    Style="{StaticResource radBase}" />
1138
                                 <RadioButton
1135
                                 <RadioButton
1139
-                                        x:Name="rbnCrude"
1140
-                                        Margin="5,0,0,0"
1141
-                                        VerticalAlignment="Center"
1142
-                                        Click="RbnCrude_Click"
1143
-                                        Content=" 粗"
1144
-                                        Cursor="Hand"
1145
-                                        FontSize="12"
1146
-                                        Style="{StaticResource radBase}" />
1136
+                                    x:Name="rbnCrude"
1137
+                                    Margin="5,0,0,0"
1138
+                                    VerticalAlignment="Center"
1139
+                                    Click="RbnCrude_Click"
1140
+                                    Content=" 粗"
1141
+                                    Cursor="Hand"
1142
+                                    FontSize="12"
1143
+                                    Style="{StaticResource radBase}" />
1147
                             </StackPanel>
1144
                             </StackPanel>
1148
                             <StackPanel
1145
                             <StackPanel
1149
-                                    Margin="5"
1150
-                                    Grid.Column="2"
1151
-                                    HorizontalAlignment="Right"
1152
-                                    VerticalAlignment="Center"
1153
-                                    Orientation="Horizontal">
1146
+                                Grid.Column="2"
1147
+                                Margin="5"
1148
+                                HorizontalAlignment="Right"
1149
+                                VerticalAlignment="Center"
1150
+                                Orientation="Horizontal">
1154
                                 <TextBlock
1151
                                 <TextBlock
1155
-                                        Padding="5,0,0,0"
1156
-                                        VerticalAlignment="Center"
1157
-                                        FontSize="12"
1158
-                                        Text="摄像头: " />
1152
+                                    Padding="5,0,0,0"
1153
+                                    VerticalAlignment="Center"
1154
+                                    FontSize="12"
1155
+                                    Text="摄像头: " />
1159
                                 <RadioButton
1156
                                 <RadioButton
1160
-                                        x:Name="rbnOpen"
1161
-                                        Margin="0,0,0,0"
1162
-                                        VerticalAlignment="Center"
1163
-                                        Click="RbnOpen_Click"
1164
-                                        Content=" 开"
1165
-                                        Cursor="Hand"
1166
-                                        FontSize="12"
1167
-                                        Style="{StaticResource radBase}" />
1157
+                                    x:Name="rbnOpen"
1158
+                                    Margin="0,0,0,0"
1159
+                                    VerticalAlignment="Center"
1160
+                                    Click="RbnOpen_Click"
1161
+                                    Content=" 开"
1162
+                                    Cursor="Hand"
1163
+                                    FontSize="12"
1164
+                                    Style="{StaticResource radBase}" />
1168
                                 <RadioButton
1165
                                 <RadioButton
1169
-                                        x:Name="rbnTurnOff"
1170
-                                        Margin="5,0,10,0"
1171
-                                        VerticalAlignment="Center"
1172
-                                        Click="RbnTurnOff_Click"
1173
-                                        Content=" 关"
1174
-                                        Cursor="Hand"
1175
-                                        FontSize="12"
1176
-                                        IsChecked="True"
1177
-                                        Style="{StaticResource radBase}" />
1166
+                                    x:Name="rbnTurnOff"
1167
+                                    Margin="5,0,10,0"
1168
+                                    VerticalAlignment="Center"
1169
+                                    Click="RbnTurnOff_Click"
1170
+                                    Content=" 关"
1171
+                                    Cursor="Hand"
1172
+                                    FontSize="12"
1173
+                                    IsChecked="True"
1174
+                                    Style="{StaticResource radBase}" />
1178
                             </StackPanel>
1175
                             </StackPanel>
1179
                         </Grid>
1176
                         </Grid>
1180
                     </Grid>
1177
                     </Grid>
1306
                                                 Foreground="#333333"
1303
                                                 Foreground="#333333"
1307
                                                 Text="科技蓝" />
1304
                                                 Text="科技蓝" />
1308
                                         </Grid>
1305
                                         </Grid>
1309
-
1310
                                     </Grid>
1306
                                     </Grid>
1311
 
1307
 
1312
                                     <Label
1308
                                     <Label
1545
                                             <Grid.ColumnDefinitions>
1541
                                             <Grid.ColumnDefinitions>
1546
                                                 <ColumnDefinition Width="76" />
1542
                                                 <ColumnDefinition Width="76" />
1547
                                                 <ColumnDefinition Width="76" />
1543
                                                 <ColumnDefinition Width="76" />
1548
-
1549
                                             </Grid.ColumnDefinitions>
1544
                                             </Grid.ColumnDefinitions>
1550
                                             <!--  浏览按钮  -->
1545
                                             <!--  浏览按钮  -->
1551
                                             <Button
1546
                                             <Button
1665
                                     </Grid.ColumnDefinitions>
1660
                                     </Grid.ColumnDefinitions>
1666
                                     <Grid.RowDefinitions>
1661
                                     <Grid.RowDefinitions>
1667
                                         <RowDefinition Height="50*" />
1662
                                         <RowDefinition Height="50*" />
1668
-
1669
                                     </Grid.RowDefinitions>
1663
                                     </Grid.RowDefinitions>
1670
                                     <Grid Grid.Column="2">
1664
                                     <Grid Grid.Column="2">
1671
                                         <!--  保存  -->
1665
                                         <!--  保存  -->
1701
                                             Foreground="#333333"
1695
                                             Foreground="#333333"
1702
                                             Text="未连接"
1696
                                             Text="未连接"
1703
                                             Visibility="Hidden" />
1697
                                             Visibility="Hidden" />
1704
-
1705
                                     </Grid>
1698
                                     </Grid>
1706
                                 </Grid>
1699
                                 </Grid>
1707
                             </Grid>
1700
                             </Grid>
1898
                         FontSize="12"
1891
                         FontSize="12"
1899
                         Foreground="White"
1892
                         Foreground="White"
1900
                         IsDefault="True" />
1893
                         IsDefault="True" />
1901
-                    
1894
+
1902
                     <Button
1895
                     <Button
1903
                         x:Name="btnPrint_Print"
1896
                         x:Name="btnPrint_Print"
1904
                         Grid.Column="4"
1897
                         Grid.Column="4"
1915
                         Foreground="White"
1908
                         Foreground="White"
1916
                         IsDefault="True" />
1909
                         IsDefault="True" />
1917
                 </Grid>
1910
                 </Grid>
1918
-
1919
             </Grid>
1911
             </Grid>
1920
-
1921
         </Border>
1912
         </Border>
1922
 
1913
 
1923
         <Grid
1914
         <Grid

XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs → XHWK.WKTool/MainWindow.xaml.cs View File

13
 using System;
13
 using System;
14
 using System.Collections.Generic;
14
 using System.Collections.Generic;
15
 using System.Data;
15
 using System.Data;
16
+using System.Diagnostics;
16
 using System.Drawing;
17
 using System.Drawing;
17
 using System.IO;
18
 using System.IO;
18
 using System.Linq;
19
 using System.Linq;
44
     /// <summary>
45
     /// <summary>
45
     /// 主页面
46
     /// 主页面
46
     /// </summary>
47
     /// </summary>
47
-    public partial class XHMicroLessonSystemWindow : Window, PenEventI
48
+    public partial class MainWindow : Window, PenEventI
48
     {
49
     {
49
         #region 字段
50
         #region 字段
50
 
51
 
128
         /// <summary>
129
         /// <summary>
129
         /// 主页面
130
         /// 主页面
130
         /// </summary>
131
         /// </summary>
131
-        public XHMicroLessonSystemWindow()
132
+        public MainWindow()
132
         {
133
         {
133
             InitializeComponent();
134
             InitializeComponent();
134
 
135
 
3200
                     BtnScreenRecording.IsEnabled = false;
3201
                     BtnScreenRecording.IsEnabled = false;
3201
                 });
3202
                 });
3202
 
3203
 
3203
-                //缩略图
3204
-                string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
3205
-                FileToolsCommon.CreateDirectory(ThumbnailPath);
3206
-                //缩略图存储位置
3207
-                string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
3208
-
3204
+       
3205
+               
3209
                 videoWriter.Close();
3206
                 videoWriter.Close();
3210
                 waveIn.StopRecording();
3207
                 waveIn.StopRecording();
3211
                 //停止截图
3208
                 //停止截图
3212
-
3213
                 Dispatcher.Invoke(() =>
3209
                 Dispatcher.Invoke(() =>
3214
                 {
3210
                 {
3215
                     timer.Change(-1, 0);
3211
                     timer.Change(-1, 0);
3219
                     TxbType.Text = "保存中";
3215
                     TxbType.Text = "保存中";
3220
                 });
3216
                 });
3221
 
3217
 
3222
-                FileToolsCommon.DeleteFile(ThumbnailPathName);
3223
-                VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
3224
-                VideoInfo.VideoPath = VideoSavePathName;
3225
-                VideoInfo.ThumbnailPath = ThumbnailPathName;
3226
-                Console.WriteLine("生成缩略图");
3227
-
3218
+          
3219
+              
3220
+                Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
3221
+                foreach (Process KillProcess in KillProcessArray)
3222
+                {
3223
+                    KillProcess.Kill();
3224
+                }
3228
                 Console.WriteLine("合并音视频 gridActWidth:" + gridActWidth + " gridActHeight:" + gridActHeight);
3225
                 Console.WriteLine("合并音视频 gridActWidth:" + gridActWidth + " gridActHeight:" + gridActHeight);
3229
-
3230
-                //APP.FFmpeg.VideoAudioMerge(VideoSynthesisPathName, AudioPathName, VideoSavePathName, gridActWidth, gridActHeight);
3231
                 FFMpegConverter ffMpeg = new FFMpegConverter();
3226
                 FFMpegConverter ffMpeg = new FFMpegConverter();
3232
                 //ffMpeg.ConvertProgress += FfMpeg_ConvertProgress;
3227
                 //ffMpeg.ConvertProgress += FfMpeg_ConvertProgress;
3233
                 FFMpegInput[] input = new FFMpegInput[] {
3228
                 FFMpegInput[] input = new FFMpegInput[] {
3243
                     new OutputSettings() { }
3238
                     new OutputSettings() { }
3244
                 );
3239
                 );
3245
 
3240
 
3241
+
3246
                 //生成缩略图
3242
                 //生成缩略图
3247
-                bool ThuRes = APP.FFmpeg.GenerateThumbnails(TempVideoPathName, ThumbnailPathName, 200, 130);
3243
+                string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
3244
+                FileToolsCommon.CreateDirectory(ThumbnailPath);
3245
+                //缩略图存储位置
3246
+                string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileName(VideoSavePathName).Replace(".", "") + ".JPG";
3248
 
3247
 
3248
+                FileToolsCommon.DeleteFile(ThumbnailPathName);
3249
+                VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
3250
+                VideoInfo.VideoPath = VideoSavePathName;
3251
+                VideoInfo.ThumbnailPath = ThumbnailPathName;
3249
                 VideoInfo.FileGuid = Guid.NewGuid().ToString();
3252
                 VideoInfo.FileGuid = Guid.NewGuid().ToString();
3250
                 VideoInfo.IsUpload = false;
3253
                 VideoInfo.IsUpload = false;
3251
                 VideoInfo.Uploaded = 0;
3254
                 VideoInfo.Uploaded = 0;
3255
+                try
3256
+                {
3257
+                    bool ThuRes = APP.FFmpeg.GenerateThumbnails(TempVideoPathName, ThumbnailPathName, 200, 130);
3252
 
3258
 
3259
+                }
3260
+                catch (Exception ex) {
3261
+                    LogHelper.WriteErrLog("录制生成缩略图", ex);
3262
+                }
3263
+                
3253
                 if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
3264
                 if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
3254
                 {
3265
                 {
3255
                     APP.VideoList.Add(VideoInfo);
3266
                     APP.VideoList.Add(VideoInfo);
3257
                     APP.SaveWkData();
3268
                     APP.SaveWkData();
3258
                 }
3269
                 }
3259
 
3270
 
3260
-                FileToolsCommon.DeleteFile(TempVideoPathName);
3261
-                FileToolsCommon.DeleteFile(TempAudioPathName);
3271
+                try
3272
+                {
3273
+                    FileToolsCommon.DeleteFile(TempVideoPathName);
3274
+                    FileToolsCommon.DeleteFile(TempAudioPathName);
3275
+                }
3276
+                catch (Exception ex) {
3277
+                    LogHelper.WriteErrLog("删除录制临时文件",ex);
3278
+                }
3279
+             
3262
 
3280
 
3263
                 Dispatcher.Invoke(() =>
3281
                 Dispatcher.Invoke(() =>
3264
                 {
3282
                 {
3470
                 return;
3488
                 return;
3471
             }
3489
             }
3472
             System.Windows.Point point = e.GetPosition(img);
3490
             System.Windows.Point point = e.GetPosition(img);
3473
-          
3491
+
3474
             System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
3492
             System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
3475
-           
3493
+
3476
             TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
3494
             TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
3477
             double delta = e.Delta * 0.001;
3495
             double delta = e.Delta * 0.001;
3478
             DowheelZoom(group, point, delta);
3496
             DowheelZoom(group, point, delta);
3492
             TranslateTransform transform1 = group.Children[1] as TranslateTransform;
3510
             TranslateTransform transform1 = group.Children[1] as TranslateTransform;
3493
             transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
3511
             transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
3494
             transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
3512
             transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
3495
-   
3513
+
3496
             APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
3514
             APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
3497
             {
3515
             {
3498
                 X = transform1.X,
3516
                 X = transform1.X,
3712
             imageOperationUtil.HideAngleBorder();
3730
             imageOperationUtil.HideAngleBorder();
3713
         }
3731
         }
3714
 
3732
 
3715
-   
3716
         private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
3733
         private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
3717
         {
3734
         {
3718
             imageOperationUtil.PicEMap_MouseDown(sender, e);
3735
             imageOperationUtil.PicEMap_MouseDown(sender, e);
3720
 
3737
 
3721
         private void imgCanvas_MouseMove(object sender, MouseEventArgs e)
3738
         private void imgCanvas_MouseMove(object sender, MouseEventArgs e)
3722
         {
3739
         {
3723
-            imageOperationUtil.imgCanvas_MouseMove(sender,e);
3740
+            imageOperationUtil.imgCanvas_MouseMove(sender, e);
3724
         }
3741
         }
3725
 
3742
 
3726
         private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)
3743
         private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)

+ 1
- 1
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

415
 
415
 
416
             if (APP.W_XHMicroLessonSystemWindow == null)
416
             if (APP.W_XHMicroLessonSystemWindow == null)
417
             {
417
             {
418
-                APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
418
+                APP.W_XHMicroLessonSystemWindow = new MainWindow();
419
             }
419
             }
420
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
420
             APP.W_XHMicroLessonSystemWindow.InitializeKeyDownEvent();
421
             //APP.W_XHMicroLessonSystemWindow.InitPen();
421
             //APP.W_XHMicroLessonSystemWindow.InitPen();

+ 1
- 1
XHWK.WKTool/UploadWindow.xaml.cs View File

10
 using XHWK.Model;
10
 using XHWK.Model;
11
 using XHWK.WKTool.DAL;
11
 using XHWK.WKTool.DAL;
12
 
12
 
13
-using static XHWK.WKTool.XHMicroLessonSystemWindow;
13
+using static XHWK.WKTool.MainWindow;
14
 
14
 
15
 namespace XHWK.WKTool
15
 namespace XHWK.WKTool
16
 {
16
 {

+ 3
- 3
XHWK.WKTool/XHWK.WKTool.csproj View File

341
     <Compile Include="Welcome.xaml.cs">
341
     <Compile Include="Welcome.xaml.cs">
342
       <DependentUpon>Welcome.xaml</DependentUpon>
342
       <DependentUpon>Welcome.xaml</DependentUpon>
343
     </Compile>
343
     </Compile>
344
-    <Compile Include="XHMicroLessonSystemWindow.xaml.cs">
345
-      <DependentUpon>XHMicroLessonSystemWindow.xaml</DependentUpon>
344
+    <Compile Include="MainWindow.xaml.cs">
345
+      <DependentUpon>MainWindow.xaml</DependentUpon>
346
     </Compile>
346
     </Compile>
347
     <Compile Include="CreateAMicroLessonWindow.xaml.cs">
347
     <Compile Include="CreateAMicroLessonWindow.xaml.cs">
348
       <DependentUpon>CreateAMicroLessonWindow.xaml</DependentUpon>
348
       <DependentUpon>CreateAMicroLessonWindow.xaml</DependentUpon>
448
       <SubType>Designer</SubType>
448
       <SubType>Designer</SubType>
449
       <Generator>MSBuild:Compile</Generator>
449
       <Generator>MSBuild:Compile</Generator>
450
     </Page>
450
     </Page>
451
-    <Page Include="XHMicroLessonSystemWindow.xaml">
451
+    <Page Include="MainWindow.xaml">
452
       <Generator>MSBuild:Compile</Generator>
452
       <Generator>MSBuild:Compile</Generator>
453
       <SubType>Designer</SubType>
453
       <SubType>Designer</SubType>
454
     </Page>
454
     </Page>

Loading…
Cancel
Save