ソースを参照

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

tags/对接微服务前
张剑 3年前
コミット
5572e8ce71

+ 2
- 2
XHWK.WKTool/App.config ファイルの表示

@@ -9,8 +9,8 @@
9 9
     <!--参数是否加密 0不加密 1加密-->
10 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 14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 15
     <add key="SkinStyle" value="0" />
16 16
     <!--是否输出视频记录日志:0否-->

+ 78
- 12
XHWK.WKTool/App.xaml.cs ファイルの表示

@@ -10,6 +10,7 @@ using System.Linq;
10 10
 using System.Reflection;
11 11
 using System.Security.Principal;
12 12
 using System.Threading;
13
+using System.Threading.Tasks;
13 14
 using System.Windows;
14 15
 using System.Windows.Threading;
15 16
 
@@ -264,7 +265,7 @@ namespace XHWK.WKTool
264 265
         /// <summary>
265 266
         /// 主页面
266 267
         /// </summary>
267
-        public static XHMicroLessonSystemWindow W_XHMicroLessonSystemWindow = null;
268
+        public static MainWindow W_XHMicroLessonSystemWindow = null;
268 269
 
269 270
         /// <summary>
270 271
         /// 创建微课页面
@@ -329,6 +330,7 @@ namespace XHWK.WKTool
329 330
         {
330 331
             Console.WriteLine("初始化APP");
331 332
             LogHelper.InitLog4Net();
333
+
332 334
             myloading = new LoadDialog();
333 335
             StopSameProcess();
334 336
             Killffmpeg();
@@ -433,18 +435,81 @@ namespace XHWK.WKTool
433 435
 
434 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 515
         #region 数据保存和读取
@@ -651,6 +716,7 @@ namespace XHWK.WKTool
651 716
         /// </param>
652 717
         protected override void OnStartup(StartupEventArgs e)
653 718
         {
719
+            RegisterEvents();
654 720
             new Thread(o =>
655 721
             {
656 722
                 while (true)

+ 1
- 1
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs ファイルの表示

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

+ 1
- 1
XHWK.WKTool/JieTuWindow.xaml.cs ファイルの表示

@@ -19,7 +19,7 @@ using System.Windows.Media.Imaging;
19 19
 
20 20
 using XHWK.WKTool;
21 21
 
22
-using static XHWK.WKTool.XHMicroLessonSystemWindow;
22
+using static XHWK.WKTool.MainWindow;
23 23
 
24 24
 namespace ComeCapture
25 25
 {

XHWK.WKTool/XHMicroLessonSystemWindow.xaml → XHWK.WKTool/MainWindow.xaml ファイルの表示

@@ -1,5 +1,5 @@
1 1
 <Window
2
-    x:Class="XHWK.WKTool.XHMicroLessonSystemWindow"
2
+    x:Class="XHWK.WKTool.MainWindow"
3 3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5 5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -8,7 +8,6 @@
8 8
     Width="950"
9 9
     Height="700"
10 10
     AllowsTransparency="False"
11
-  
12 11
     BorderBrush="#eee"
13 12
     BorderThickness="1"
14 13
     Loaded="Window_Loaded"
@@ -220,7 +219,6 @@
220 219
         </Style>
221 220
     </Window.Resources>
222 221
 
223
-
224 222
     <Grid>
225 223
         <!--  内容区 上:标题栏  下:工具栏和录制区域  -->
226 224
         <Grid
@@ -398,7 +396,6 @@
398 396
                             Cursor="Hand"
399 397
                             FontSize="14"
400 398
                             Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
401
-
402 399
                     </Grid>
403 400
                     <!--  测试  -->
404 401
                     <Grid Grid.Column="2" Visibility="Collapsed">
@@ -879,7 +876,6 @@
879 876
                                             <ScaleTransform ScaleX="-1" />
880 877
                                         </Image.RenderTransform>
881 878
                                     </Image>
882
-                                   
883 879
                                 </Grid>
884 880
                             </Border>
885 881
                         </Grid>
@@ -891,290 +887,291 @@
891 887
                             Background="#FFFFFFFF"
892 888
                             Visibility="Visible">
893 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 893
                             </Grid.ColumnDefinitions>
899 894
                             <!--  页码  -->
900 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 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 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 925
                                         <StackPanel>
928 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 930
                                         </StackPanel>
933 931
                                     </Button>
934 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 936
                                         <StackPanel
939
-                                                HorizontalAlignment="Center"
940
-                                                Background="Transparent"
941
-                                                Orientation="Horizontal">
937
+                                            HorizontalAlignment="Center"
938
+                                            Background="Transparent"
939
+                                            Orientation="Horizontal">
942 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 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 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 961
                                         </StackPanel>
964 962
                                     </Grid>
965 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 971
                                         <StackPanel>
974 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 976
                                         </StackPanel>
979 977
                                     </Button>
980
-
981 978
                                 </StackPanel>
982 979
                             </Grid>
983 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 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 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 1001
                                 <Border
1002
+                                    Width="20"
1003
+                                    Height="20"
1004
+                                    Margin="5,2,0,0"
1005
+                                    Background="#666666">
1006
+                                    <Button
1007
+                                        x:Name="btnRed"
1005 1008
                                         Width="20"
1006 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 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 1021
                                     </Button>
1025 1022
                                 </Border>
1026 1023
                                 <Border
1024
+                                    Width="20"
1025
+                                    Height="20"
1026
+                                    Margin="5,2,0,0"
1027
+                                    Background="#666666">
1028
+                                    <Button
1029
+                                        x:Name="btnGray"
1027 1030
                                         Width="20"
1028 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 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 1042
                                     </Button>
1046 1043
                                 </Border>
1047 1044
                                 <Border
1045
+                                    Width="20"
1046
+                                    Height="20"
1047
+                                    Margin="5,2,0,0"
1048
+                                    Background="#666666">
1049
+                                    <Button
1050
+                                        x:Name="btnCyanBlue"
1048 1051
                                         Width="20"
1049 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 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 1063
                                     </Button>
1067 1064
                                 </Border>
1068 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 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 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 1086
                                     </Button>
1090 1087
                                 </Border>
1091 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 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 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 1108
                                     </Button>
1112 1109
                                 </Border>
1113 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 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 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 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 1144
                             </StackPanel>
1148 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 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 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 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 1175
                             </StackPanel>
1179 1176
                         </Grid>
1180 1177
                     </Grid>
@@ -1306,7 +1303,6 @@
1306 1303
                                                 Foreground="#333333"
1307 1304
                                                 Text="科技蓝" />
1308 1305
                                         </Grid>
1309
-
1310 1306
                                     </Grid>
1311 1307
 
1312 1308
                                     <Label
@@ -1545,7 +1541,6 @@
1545 1541
                                             <Grid.ColumnDefinitions>
1546 1542
                                                 <ColumnDefinition Width="76" />
1547 1543
                                                 <ColumnDefinition Width="76" />
1548
-
1549 1544
                                             </Grid.ColumnDefinitions>
1550 1545
                                             <!--  浏览按钮  -->
1551 1546
                                             <Button
@@ -1665,7 +1660,6 @@
1665 1660
                                     </Grid.ColumnDefinitions>
1666 1661
                                     <Grid.RowDefinitions>
1667 1662
                                         <RowDefinition Height="50*" />
1668
-
1669 1663
                                     </Grid.RowDefinitions>
1670 1664
                                     <Grid Grid.Column="2">
1671 1665
                                         <!--  保存  -->
@@ -1701,7 +1695,6 @@
1701 1695
                                             Foreground="#333333"
1702 1696
                                             Text="未连接"
1703 1697
                                             Visibility="Hidden" />
1704
-
1705 1698
                                     </Grid>
1706 1699
                                 </Grid>
1707 1700
                             </Grid>
@@ -1898,7 +1891,7 @@
1898 1891
                         FontSize="12"
1899 1892
                         Foreground="White"
1900 1893
                         IsDefault="True" />
1901
-                    
1894
+
1902 1895
                     <Button
1903 1896
                         x:Name="btnPrint_Print"
1904 1897
                         Grid.Column="4"
@@ -1915,9 +1908,7 @@
1915 1908
                         Foreground="White"
1916 1909
                         IsDefault="True" />
1917 1910
                 </Grid>
1918
-
1919 1911
             </Grid>
1920
-
1921 1912
         </Border>
1922 1913
 
1923 1914
         <Grid

XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs → XHWK.WKTool/MainWindow.xaml.cs ファイルの表示

@@ -13,6 +13,7 @@ using NReco.VideoConverter;
13 13
 using System;
14 14
 using System.Collections.Generic;
15 15
 using System.Data;
16
+using System.Diagnostics;
16 17
 using System.Drawing;
17 18
 using System.IO;
18 19
 using System.Linq;
@@ -44,7 +45,7 @@ namespace XHWK.WKTool
44 45
     /// <summary>
45 46
     /// 主页面
46 47
     /// </summary>
47
-    public partial class XHMicroLessonSystemWindow : Window, PenEventI
48
+    public partial class MainWindow : Window, PenEventI
48 49
     {
49 50
         #region 字段
50 51
 
@@ -128,7 +129,7 @@ namespace XHWK.WKTool
128 129
         /// <summary>
129 130
         /// 主页面
130 131
         /// </summary>
131
-        public XHMicroLessonSystemWindow()
132
+        public MainWindow()
132 133
         {
133 134
             InitializeComponent();
134 135
 
@@ -3200,16 +3201,11 @@ namespace XHWK.WKTool
3200 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 3206
                 videoWriter.Close();
3210 3207
                 waveIn.StopRecording();
3211 3208
                 //停止截图
3212
-
3213 3209
                 Dispatcher.Invoke(() =>
3214 3210
                 {
3215 3211
                     timer.Change(-1, 0);
@@ -3219,15 +3215,14 @@ namespace XHWK.WKTool
3219 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 3225
                 Console.WriteLine("合并音视频 gridActWidth:" + gridActWidth + " gridActHeight:" + gridActHeight);
3229
-
3230
-                //APP.FFmpeg.VideoAudioMerge(VideoSynthesisPathName, AudioPathName, VideoSavePathName, gridActWidth, gridActHeight);
3231 3226
                 FFMpegConverter ffMpeg = new FFMpegConverter();
3232 3227
                 //ffMpeg.ConvertProgress += FfMpeg_ConvertProgress;
3233 3228
                 FFMpegInput[] input = new FFMpegInput[] {
@@ -3243,13 +3238,29 @@ namespace XHWK.WKTool
3243 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 3252
                 VideoInfo.FileGuid = Guid.NewGuid().ToString();
3250 3253
                 VideoInfo.IsUpload = false;
3251 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 3264
                 if (!APP.VideoList.Exists(x => x.FileGuid == VideoInfo.FileGuid) || !APP.VideoList.Exists(x => x.VideoPath == VideoInfo.VideoPath))
3254 3265
                 {
3255 3266
                     APP.VideoList.Add(VideoInfo);
@@ -3257,8 +3268,15 @@ namespace XHWK.WKTool
3257 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 3281
                 Dispatcher.Invoke(() =>
3264 3282
                 {
@@ -3470,9 +3488,9 @@ namespace XHWK.WKTool
3470 3488
                 return;
3471 3489
             }
3472 3490
             System.Windows.Point point = e.GetPosition(img);
3473
-          
3491
+
3474 3492
             System.Windows.Point PicLocate = e.GetPosition(imgCanvas);
3475
-           
3493
+
3476 3494
             TransformGroup group = IMG.FindResource("Imageview") as TransformGroup;
3477 3495
             double delta = e.Delta * 0.001;
3478 3496
             DowheelZoom(group, point, delta);
@@ -3492,7 +3510,7 @@ namespace XHWK.WKTool
3492 3510
             TranslateTransform transform1 = group.Children[1] as TranslateTransform;
3493 3511
             transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
3494 3512
             transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
3495
-   
3513
+
3496 3514
             APP.PageDrawList[APP.PageContextData.currpage - 1].ImageLocation = new TranslateTransform
3497 3515
             {
3498 3516
                 X = transform1.X,
@@ -3712,7 +3730,6 @@ namespace XHWK.WKTool
3712 3730
             imageOperationUtil.HideAngleBorder();
3713 3731
         }
3714 3732
 
3715
-   
3716 3733
         private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
3717 3734
         {
3718 3735
             imageOperationUtil.PicEMap_MouseDown(sender, e);
@@ -3720,7 +3737,7 @@ namespace XHWK.WKTool
3720 3737
 
3721 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 3743
         private void imgCanvas_MouseUp(object sender, MouseButtonEventArgs e)

+ 1
- 1
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs ファイルの表示

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

+ 1
- 1
XHWK.WKTool/UploadWindow.xaml.cs ファイルの表示

@@ -10,7 +10,7 @@ using System.Windows.Input;
10 10
 using XHWK.Model;
11 11
 using XHWK.WKTool.DAL;
12 12
 
13
-using static XHWK.WKTool.XHMicroLessonSystemWindow;
13
+using static XHWK.WKTool.MainWindow;
14 14
 
15 15
 namespace XHWK.WKTool
16 16
 {

+ 3
- 3
XHWK.WKTool/XHWK.WKTool.csproj ファイルの表示

@@ -341,8 +341,8 @@
341 341
     <Compile Include="Welcome.xaml.cs">
342 342
       <DependentUpon>Welcome.xaml</DependentUpon>
343 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 346
     </Compile>
347 347
     <Compile Include="CreateAMicroLessonWindow.xaml.cs">
348 348
       <DependentUpon>CreateAMicroLessonWindow.xaml</DependentUpon>
@@ -448,7 +448,7 @@
448 448
       <SubType>Designer</SubType>
449 449
       <Generator>MSBuild:Compile</Generator>
450 450
     </Page>
451
-    <Page Include="XHMicroLessonSystemWindow.xaml">
451
+    <Page Include="MainWindow.xaml">
452 452
       <Generator>MSBuild:Compile</Generator>
453 453
       <SubType>Designer</SubType>
454 454
     </Page>

読み込み中…
キャンセル
保存