Przeglądaj źródła

多摄像头处理

摄像头渲染
窗口阴影
master
张剑 1 rok temu
rodzic
commit
3bbab01e05

+ 119
- 0
.editorconfig Wyświetl plik

@@ -0,0 +1,119 @@
1
+[*]
2
+end_of_line = crlf
3
+charset = utf-8-bom
4
+indent_size = 4
5
+insert_final_newline = true
6
+tab_width = 4
7
+trim_trailing_whitespace = true
8
+
9
+resharper_xaml_binding_without_context_not_resolved_highlighting = none
10
+resharper_xaml_binding_with_context_not_resolved_highlighting = none
11
+
12
+# ReSharper properties
13
+resharper_csharp_max_line_length = 100
14
+resharper_csharp_wrap_arguments_style = chop_if_long
15
+resharper_csharp_wrap_before_binary_opsign = true
16
+resharper_csharp_wrap_before_declaration_lpar = true
17
+resharper_csharp_wrap_before_invocation_lpar = true
18
+resharper_csharp_wrap_extends_list_style = chop_if_long
19
+resharper_csharp_wrap_parameters_style = chop_if_long
20
+resharper_indent_preprocessor_if = usual_indent
21
+resharper_indent_preprocessor_other = usual_indent
22
+resharper_keep_existing_declaration_block_arrangement = false
23
+resharper_keep_existing_linebreaks = false
24
+resharper_max_array_initializer_elements_on_line = 1
25
+resharper_max_attribute_length_for_same_line = 2
26
+resharper_max_enum_members_on_line = 1
27
+resharper_max_formal_parameters_on_line = 2
28
+resharper_max_initializer_elements_on_line = 1
29
+resharper_max_invocation_arguments_on_line = 2
30
+resharper_place_field_attribute_on_same_line = if_owner_is_single_line
31
+resharper_wrap_after_declaration_lpar = true
32
+resharper_wrap_after_invocation_lpar = true
33
+resharper_wrap_array_initializer_style = chop_if_long
34
+resharper_wrap_before_declaration_rpar = true
35
+resharper_wrap_before_first_type_parameter_constraint = true
36
+resharper_wrap_before_invocation_rpar = true
37
+resharper_wrap_before_linq_expression = true
38
+resharper_wrap_chained_binary_expressions = chop_if_long
39
+resharper_wrap_chained_binary_patterns = chop_if_long
40
+resharper_wrap_chained_method_calls = chop_if_long
41
+resharper_wrap_enum_declaration = chop_if_long
42
+resharper_wrap_for_stmt_header_style = chop_if_long
43
+resharper_wrap_list_pattern = chop_if_long
44
+resharper_wrap_multiple_declaration_style = chop_if_long
45
+resharper_wrap_switch_expression = chop_if_long
46
+
47
+# Microsoft .NET properties
48
+csharp_preserve_single_line_blocks = true
49
+
50
+[*.xml]
51
+indent_style = space
52
+
53
+[*.cs]
54
+dotnet_sort_system_directives_first = true
55
+dotnet_style_coalesce_expression = true:suggestion
56
+dotnet_style_collection_initializer = true:suggestion
57
+dotnet_style_explicit_tuple_names = true:suggestion
58
+dotnet_style_null_propagation = true:suggestion
59
+dotnet_style_object_initializer = true:suggestion
60
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
61
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
62
+dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
63
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
64
+dotnet_style_predefined_type_for_locals_parameters_members = true:silent
65
+dotnet_style_predefined_type_for_member_access = true:silent
66
+dotnet_style_prefer_auto_properties = true:silent
67
+dotnet_style_prefer_conditional_expression_over_assignment = true
68
+dotnet_style_prefer_conditional_expression_over_return = true
69
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
70
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
71
+dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
72
+dotnet_style_qualification_for_event = false:silent
73
+dotnet_style_qualification_for_field = false:silent
74
+dotnet_style_qualification_for_method = false:silent
75
+dotnet_style_qualification_for_property = false:silent
76
+dotnet_style_readonly_field = true:suggestion
77
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
78
+csharp_indent_case_contents = true
79
+csharp_indent_labels = flush_left
80
+csharp_indent_switch_labels = true
81
+csharp_new_line_before_catch = true
82
+csharp_new_line_before_else = true
83
+csharp_new_line_before_finally = true
84
+csharp_new_line_before_members_in_anonymous_types = true
85
+csharp_new_line_before_members_in_object_initializers = true
86
+csharp_new_line_before_open_brace = all
87
+csharp_new_line_between_query_expression_clauses = true
88
+csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
89
+csharp_prefer_braces = true:silent
90
+csharp_prefer_simple_default_expression = true:suggestion
91
+csharp_preserve_single_line_blocks = true
92
+csharp_preserve_single_line_statements = true
93
+csharp_space_after_cast = false
94
+csharp_space_after_colon_in_inheritance_clause = true
95
+csharp_space_after_keywords_in_control_flow_statements = true
96
+csharp_space_around_binary_operators = before_and_after
97
+csharp_space_before_colon_in_inheritance_clause = true
98
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
99
+csharp_space_between_method_call_name_and_opening_parenthesis = false
100
+csharp_space_between_method_call_parameter_list_parentheses = false
101
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
102
+csharp_space_between_method_declaration_parameter_list_parentheses = false
103
+csharp_space_between_parentheses = false
104
+csharp_style_conditional_delegate_call = true:suggestion
105
+csharp_style_deconstructed_variable_declaration = true:suggestion
106
+csharp_style_expression_bodied_accessors = true:silent
107
+csharp_style_expression_bodied_constructors = false:silent
108
+csharp_style_expression_bodied_indexers = true:silent
109
+csharp_style_expression_bodied_methods = false:silent
110
+csharp_style_expression_bodied_operators = false:silent
111
+csharp_style_expression_bodied_properties = true:silent
112
+csharp_style_inlined_variable_declaration = true:suggestion
113
+csharp_style_pattern_local_over_anonymous_function = true:suggestion
114
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
115
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
116
+csharp_style_throw_expression = true:suggestion
117
+csharp_style_var_elsewhere = true:silent
118
+csharp_style_var_for_built_in_types = true:silent
119
+csharp_style_var_when_type_is_apparent = true:silent

+ 3
- 3
XHWK.WKTool/App.config Wyświetl plik

@@ -5,12 +5,12 @@
5 5
   </startup>
6 6
   <appSettings>
7 7
     <!--0正式 1测试-->
8
-    <add key="IsDebug" value="1" />
8
+    <add key="IsDebug" value="0" />
9 9
     <!--参数是否加密 0不加密 1加密-->
10 10
     <add key="IsParameterEncryption" value="0" />
11 11
     <!--版本号-->
12
-    <add key="VersionCode" value="116" />
13
-    <add key="VersionName" value="3.2.7" />
12
+    <add key="VersionCode" value="117" />
13
+    <add key="VersionName" value="3.9.0" />
14 14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15 15
     <add key="SkinStyle" value="0" />
16 16
     <!--是否输出视频记录日志:0否-->

+ 12
- 18
XHWK.WKTool/AppUpdateWin.xaml Wyświetl plik

@@ -2,10 +2,9 @@
2 2
     x:Class="XHWK.WKTool.AppUpdateWin"
3 3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
-    xmlns:Views="clr-namespace:Common.system"
6 5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7
-    xmlns:local="clr-namespace:XHWK.WKTool"
8 6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    xmlns:views="clr-namespace:Common.system"
9 8
     Title="AppUpdateWin"
10 9
     Width="480"
11 10
     Height="330"
@@ -19,7 +18,7 @@
19 18
     mc:Ignorable="d">
20 19
 
21 20
     <Grid>
22
-        <Views:ZJClippingBorder
21
+        <views:ZJClippingBorder
23 22
             Margin="0"
24 23
             Background="#fafafa"
25 24
             BorderBrush="#3f6fff"
@@ -40,7 +39,6 @@
40 39
                         Source="/Images/APP.png" />
41 40
 
42 41
                     <TextBlock
43
-                        Grid.Row="0"
44 42
                         Margin="10,0,0,0"
45 43
                         VerticalAlignment="Center"
46 44
                         FontSize="24"
@@ -48,13 +46,13 @@
48 46
                         Text="应用更新" />
49 47
                 </StackPanel>
50 48
                 <ScrollViewer
51
-                    Name="content_sv"
49
+                    Name="ContentSv"
52 50
                     Grid.Row="1"
53 51
                     Margin="10,10,10,10"
54 52
                     HorizontalScrollBarVisibility="Disabled"
55 53
                     VerticalScrollBarVisibility="Auto">
56 54
                     <TextBlock
57
-                        x:Name="appmsg_tb"
55
+                        x:Name="AppmsgTb"
58 56
                         Margin="10,10,10,10"
59 57
                         FontSize="14"
60 58
                         Foreground="#333333"
@@ -63,13 +61,11 @@
63 61
                 </ScrollViewer>
64 62
 
65 63
                 <UniformGrid
66
-                    x:Name="button_bottom"
64
+                    x:Name="ButtonBottom"
67 65
                     Grid.Row="2"
68 66
                     Columns="2"
69 67
                     Rows="1">
70 68
                     <Button
71
-                        Grid.Row="7"
72
-                        Grid.ColumnSpan="2"
73 69
                         Width="190"
74 70
                         Height="42"
75 71
                         Click="Button_Click"
@@ -93,8 +89,6 @@
93 89
                         </Button.Template>
94 90
                     </Button>
95 91
                     <Button
96
-                        Grid.Row="7"
97
-                        Grid.ColumnSpan="2"
98 92
                         Width="190"
99 93
                         Height="42"
100 94
                         Click="gengxinClick"
@@ -120,7 +114,7 @@
120 114
                 </UniformGrid>
121 115
 
122 116
                 <Grid
123
-                    x:Name="progress_sp"
117
+                    x:Name="ProgressSp"
124 118
                     Grid.Row="1"
125 119
                     Grid.RowSpan="2"
126 120
                     Visibility="Collapsed">
@@ -129,7 +123,7 @@
129 123
                         VerticalAlignment="Center"
130 124
                         Orientation="Vertical">
131 125
                         <TextBlock
132
-                            x:Name="parogress_tb"
126
+                            x:Name="ParogressTb"
133 127
                             Margin="10,10,10,10"
134 128
                             HorizontalAlignment="Center"
135 129
                             FontSize="23"
@@ -137,21 +131,21 @@
137 131
                             LineHeight="30"
138 132
                             Text="正在更新,已下载0%" />
139 133
 
140
-                        <Views:ZJClippingBorder
134
+                        <views:ZJClippingBorder
141 135
                             Height="12"
142 136
                             Margin="20,20,20,20"
143 137
                             CornerRadius="6"
144 138
                             SnapsToDevicePixels="True">
145 139
                             <ProgressBar
146
-                                x:Name="mprogress"
140
+                                x:Name="Mprogress"
147 141
                                 BorderThickness="0"
148 142
                                 Foreground="#3f6fff"
149 143
                                 Maximum="100"
150
-                                Minimum="0" />
151
-                        </Views:ZJClippingBorder>
144
+                                Minimum="0" Cursor="" />
145
+                        </views:ZJClippingBorder>
152 146
                     </StackPanel>
153 147
                 </Grid>
154 148
             </Grid>
155
-        </Views:ZJClippingBorder>
149
+        </views:ZJClippingBorder>
156 150
     </Grid>
157 151
 </Window>

+ 8
- 9
XHWK.WKTool/AppUpdateWin.xaml.cs Wyświetl plik

@@ -67,23 +67,22 @@ namespace XHWK.WKTool
67 67
 
68 68
         public void downloadBegin(int position)
69 69
         {
70
-            progress_sp.Visibility = Visibility.Visible;
71
-            content_sv.Visibility = Visibility.Collapsed;
72
-            button_bottom.Visibility = Visibility.Collapsed;
70
+            ProgressSp.Visibility = Visibility.Visible;
71
+            ContentSv.Visibility = Visibility.Collapsed;
72
+            ButtonBottom.Visibility = Visibility.Collapsed;
73 73
         }
74 74
 
75 75
         public void downloadProgress(int position, int progress)
76 76
         {
77
-            mprogress.Value = progress;
78
-            parogress_tb.Text = $"正在更新,已下载{progress}%";
77
+            Mprogress.Value = progress;
78
+            ParogressTb.Text = $"正在更新,已下载{progress}%";
79 79
         }
80 80
 
81 81
         public void downloadEnd(int position, string filepath)
82 82
         {
83
-            progress_sp.Visibility = Visibility.Collapsed;
84
-            content_sv.Visibility = Visibility.Visible;
85
-            button_bottom.Visibility = Visibility.Visible;
86
-
83
+            ProgressSp.Visibility = Visibility.Collapsed;
84
+            ContentSv.Visibility = Visibility.Visible;
85
+            ButtonBottom.Visibility = Visibility.Visible;
87 86
             try
88 87
             {
89 88
                 using (var managementClass = new ManagementClass("Win32_Process"))

+ 3
- 36
XHWK.WKTool/CreateAMicroLessonWindow.xaml Wyświetl plik

@@ -3,51 +3,18 @@
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"
6
-    xmlns:local="clr-namespace:XHWK.WKTool"
7 6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8 7
     Title="星火微课"
9 8
     Width="800"
10 9
     Height="450"
11
-    Margin="0"
12
-    AllowsTransparency="True"
13 10
     Closed="Window_Closed"
14 11
     Loaded="Window_Loaded"
12
+    Style="{StaticResource ZWinStyle}"
15 13
     WindowStartupLocation="CenterScreen"
16
-    WindowStyle="None"
14
+    WindowStyle="SingleBorderWindow"
17 15
     mc:Ignorable="d">
18 16
 
19
-    <Window.Resources>
20
-        <Style x:Key="Button_Menu" TargetType="{x:Type Button}">
21
-            <Setter Property="Width" Value="auto" />
22
-            <Setter Property="Height" Value="auto" />
23
-            <Setter Property="BorderThickness" Value="0" />
24
-            <Setter Property="Foreground" Value="Black" />
25
-            <Setter Property="Template">
26
-                <Setter.Value>
27
-                    <ControlTemplate TargetType="{x:Type Button}">
28
-                        <Border Background="#c3c3c3">
29
-                            <Border
30
-                                x:Name="MyBackgroundElement"
31
-                                Background="#F7F7F7"
32
-                                BorderBrush="{DynamicResource ForgroundBrush}"
33
-                                BorderThickness="1">
34
-                                <ContentPresenter
35
-                                    x:Name="ButtonContentPresenter"
36
-                                    HorizontalAlignment="Center"
37
-                                    VerticalAlignment="Center" />
38
-                            </Border>
39
-                        </Border>
40
-                        <ControlTemplate.Triggers>
41
-                            <Trigger Property="IsMouseOver" Value="True">
42
-                                <Setter TargetName="MyBackgroundElement" Property="Background" Value="#EDF5FF" />
43
-                                <Setter TargetName="MyBackgroundElement" Property="Opacity" Value="1" />
44
-                            </Trigger>
45
-                        </ControlTemplate.Triggers>
46
-                    </ControlTemplate>
47
-                </Setter.Value>
48
-            </Setter>
49
-        </Style>
50
-    </Window.Resources>
17
+    <Window.Resources />
51 18
     <Grid>
52 19
         <Grid Background="#FF4B95FF" MouseLeftButtonDown="Window_MouseLeftButtonDown">
53 20
             <Grid.ColumnDefinitions>

+ 7
- 5
XHWK.WKTool/DeviceWindow.xaml Wyświetl plik

@@ -10,12 +10,13 @@
10 10
     Title="设备检测"
11 11
     Width="569"
12 12
     Height="367"
13
-    AllowsTransparency="True"
13
+    AllowsTransparency="False"
14 14
     BorderBrush="#FFE9E9E9"
15 15
     BorderThickness="1"
16 16
     ShowInTaskbar="True"
17
+    Style="{StaticResource ZWinStyle}"
17 18
     WindowStartupLocation="CenterScreen"
18
-    WindowStyle="None"
19
+    WindowStyle="SingleBorderWindow"
19 20
     mc:Ignorable="d">
20 21
 
21 22
     <Window.Resources>
@@ -139,9 +140,9 @@
139 140
             </Setter>
140 141
         </Style>
141 142
     </Window.Resources>
142
-    <Grid>
143
+    <Grid Background="White">
143 144
         <Grid.RowDefinitions>
144
-            <RowDefinition Height="42" />
145
+            <RowDefinition Height="40" />
145 146
             <RowDefinition Height="*" />
146 147
         </Grid.RowDefinitions>
147 148
         <Grid
@@ -152,7 +153,8 @@
152 153
             MouseLeftButtonDown="Window_MouseLeftButtonDown">
153 154
             <TextBlock
154 155
                 Grid.RowSpan="2"
155
-                Padding="10,13,0,0"
156
+                Margin="16,0,0,0"
157
+                VerticalAlignment="Center"
156 158
                 FontSize="16"
157 159
                 Foreground="White"
158 160
                 Text="设备检测" />

+ 127
- 131
XHWK.WKTool/DeviceWindow.xaml.cs Wyświetl plik

@@ -1,12 +1,8 @@
1 1
 using Accord.Video;
2 2
 using Accord.Video.DirectShow;
3
-
4 3
 using Common.system;
5
-
6 4
 using NAudio.Wave;
7
-
8 5
 using System;
9
-using System.Collections.Generic;
10 6
 using System.Data;
11 7
 using System.Diagnostics;
12 8
 using System.Drawing.Imaging;
@@ -17,26 +13,25 @@ using System.Windows;
17 13
 using System.Windows.Input;
18 14
 using System.Windows.Media.Imaging;
19 15
 
20
-using System.Windows.Threading;
21
-
22 16
 namespace XHWK.WKTool
23 17
 {
18
+    using System.Linq;
19
+    using system;
20
+
24 21
     /// <summary>
25 22
     /// DeviceWindow.xaml 的交互逻辑
26 23
     /// </summary>
27
-    public partial class DeviceWindow : Window
24
+    public partial class DeviceWindow
28 25
     {
29
-        private bool cameraGood = false;
30
-        private bool microphoneGood = false;
31
-        private bool loudspeakerGood = false;
26
+        private bool _cameraGood;
27
+        private bool _microphoneGood;
28
+        private bool _loudspeakerGood;
32 29
 
33 30
         public DeviceWindow()
34 31
         {
35 32
             InitializeComponent();
36
-
37 33
             MicrophoneSetting.Click += MicrophoneSetting_Click;
38
-
39
-            cameraCheck();
34
+            CameraCheck();
40 35
         }
41 36
 
42 37
         private void MicrophoneSetting_Click(object sender, RoutedEventArgs e)
@@ -76,60 +71,60 @@ namespace XHWK.WKTool
76 71
         private void BtnDown_Click(object sender, RoutedEventArgs e)
77 72
         {
78 73
             imgPlayer.Visibility = Visibility.Hidden;
79
-            closeCamera();
80
-            if (waveIn != null)
74
+            CloseCamera();
75
+            if (_waveIn != null)
81 76
             {
82
-                waveIn.StopRecording();
77
+                _waveIn.StopRecording();
83 78
             }
84
-
85 79
             Close();
86 80
         }
87 81
 
88 82
         #region 摄像头
89 83
 
90
-        private void cameraCheck()
84
+        private void CameraCheck()
91 85
         {
92 86
             HidePage();
93 87
             GridCamera.Visibility = Visibility.Visible;
94
-
95
-            var devs = new FilterInfoCollection(FilterCategory.VideoInputDevice);//获取摄像头列表
96
-            CmbCameraList.ItemsSource = devs;
97
-            if (devs.Count > 0)
88
+            var devs = new FilterInfoCollection(FilterCategory.VideoInputDevice); //获取摄像头列表
89
+            var allCamera = devs.Where
90
+                    (x => x.Name != "screen-capture-recorder" && x.Name != "OBS Virtual Camera")
91
+                .ToList();
92
+            CmbCameraList.ItemsSource = allCamera;
93
+            if (allCamera.Count > 0)
98 94
             {
99 95
                 CmbCameraList.SelectedIndex = 0;
96
+                APP.CameraName = allCamera[0].MonikerString;
100 97
             }
101 98
         }
102 99
 
103
-        private void CmbCameraList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
100
+        private void CmbCameraList_SelectionChanged
101
+            (object sender, System.Windows.Controls.SelectionChangedEventArgs e)
104 102
         {
105
-            Console.WriteLine("选择变化");
106
-            checkCamera();
103
+            Console.WriteLine(@"选择变化");
104
+            CheckCamera();
107 105
         }
108 106
 
109
-        private VideoCaptureDevice Camera;//用来操作摄像头
107
+        private VideoCaptureDevice _camera; //用来操作摄像头
110 108
 
111 109
         /// <summary>
112 110
         /// 检测
113 111
         /// </summary>
114
-        /// <param name="sender">
115
-        /// </param>
116
-        /// <param name="e">
117
-        /// </param>
118
-        private void checkCamera()
112
+        private void CheckCamera()
119 113
         {
120 114
             try
121 115
             {
122
-                closeCamera();
123
-
116
+                CloseCamera();
124 117
                 imgPlayer.Visibility = Visibility.Visible;
125 118
                 if (CmbCameraList.SelectedIndex >= 0)
126 119
                 {
127 120
                     var info = CmbCameraList.SelectedItem as FilterInfo;
128
-                    Camera = new VideoCaptureDevice(info.MonikerString);
121
+                    APP.CameraName = info.MonikerString;
122
+                    _camera = new VideoCaptureDevice(info.MonikerString);
129 123
                     //配置录像参数(宽,高,帧率,比特率等参数)VideoCapabilities这个属性会返回摄像头支持哪些配置
130
-                    Camera.VideoResolution = Camera.VideoCapabilities[0];
131
-                    Camera.NewFrame += Camera_NewFrame;//设置回调,aforge会不断从这个回调推出图像数据,SnapshotFrame也是有待比较
132
-                    Camera.Start();//打开摄像头
124
+                    _camera.VideoResolution = _camera.VideoCapabilities[0];
125
+                    _camera.NewFrame +=
126
+                        Camera_NewFrame; //设置回调,aforge会不断从这个回调推出图像数据,SnapshotFrame也是有待比较
127
+                    _camera.Start(); //打开摄像头
133 128
                 }
134 129
             }
135 130
             catch (Exception ex)
@@ -138,17 +133,18 @@ namespace XHWK.WKTool
138 133
             }
139 134
         }
140 135
 
141
-        private void closeCamera()
136
+        private void CloseCamera()
142 137
         {
143 138
             try
144 139
             {
145
-                if (Camera != null)
140
+                if (_camera != null)
146 141
                 {
147
-                    Camera.SignalToStop();
142
+                    _camera.SignalToStop();
148 143
                 }
149 144
             }
150 145
             catch (Exception)
151 146
             {
147
+                // ignored
152 148
             }
153 149
         }
154 150
 
@@ -157,18 +153,20 @@ namespace XHWK.WKTool
157 153
         /// </summary>
158 154
         private void Camera_NewFrame(object sender, NewFrameEventArgs eventArgs)
159 155
         {
160
-            Dispatcher.Invoke(new Action(
161
-                    () =>
162
-                    {
163
-                        MemoryStream ms = new MemoryStream();
164
-                        eventArgs.Frame.Save(ms, ImageFormat.Bmp);
165
-                        BitmapImage image = new BitmapImage();
166
-                        image.BeginInit();
167
-                        image.StreamSource = new MemoryStream(ms.GetBuffer());
168
-                        ms.Close();
169
-                        image.EndInit();
170
-                        imgPlayer.Source = image;
171
-                    }));//同步显示
156
+            Dispatcher.Invoke
157
+            (
158
+                () =>
159
+                {
160
+                    MemoryStream ms = new MemoryStream();
161
+                    eventArgs.Frame.Save(ms, ImageFormat.Bmp);
162
+                    BitmapImage image = new BitmapImage();
163
+                    image.BeginInit();
164
+                    image.StreamSource = new MemoryStream(ms.GetBuffer());
165
+                    ms.Close();
166
+                    image.EndInit();
167
+                    imgPlayer.Source = image;
168
+                }
169
+            ); //同步显示
172 170
         }
173 171
 
174 172
         /// <summary>
@@ -180,9 +178,9 @@ namespace XHWK.WKTool
180 178
         /// </param>
181 179
         private void BtnCameraStop_Click(object sender, RoutedEventArgs e)
182 180
         {
183
-            if (Camera != null)
181
+            if (_camera != null)
184 182
             {
185
-                Camera.SignalToStop();
183
+                _camera.SignalToStop();
186 184
             }
187 185
         }
188 186
 
@@ -193,13 +191,9 @@ namespace XHWK.WKTool
193 191
         /// <summary>
194 192
         /// 扬声器
195 193
         /// </summary>
196
-        /// <param name="sender">
197
-        /// </param>
198
-        /// <param name="e">
199
-        /// </param>
200 194
         private void Speaker_Check()
201 195
         {
202
-            closeCamera();
196
+            CloseCamera();
203 197
             CmbCameraList.SelectedIndex = -1;
204 198
             HidePage();
205 199
             GridSpeaker.Visibility = Visibility.Visible;
@@ -214,8 +208,9 @@ namespace XHWK.WKTool
214 208
         /// </param>
215 209
         private void BtnSpeakerDetection_Click(object sender, RoutedEventArgs e)
216 210
         {
217
-            Console.WriteLine("播放");
218
-            MediaAudio.Source = new Uri(FileToolsCommon.GetFileAbsolutePath("/Resources/audiotest.mp3"));
211
+            Console.WriteLine(@"播放");
212
+            MediaAudio.Source = new Uri
213
+                (FileToolsCommon.GetFileAbsolutePath("/Resources/audiotest.mp3"));
219 214
             MediaAudio.Position = TimeSpan.Zero;
220 215
             MediaAudio.Play();
221 216
             ImgAcousticWave.Visibility = Visibility.Visible;
@@ -232,7 +227,7 @@ namespace XHWK.WKTool
232 227
         /// </param>
233 228
         private void MediaAudio_MediaOpened(object sender, RoutedEventArgs e)
234 229
         {
235
-            Console.WriteLine("播放中。。。");
230
+            Console.WriteLine(@"播放中。。。");
236 231
         }
237 232
 
238 233
         private void MediaAudio_MediaEnded(object sender, RoutedEventArgs e)
@@ -250,8 +245,6 @@ namespace XHWK.WKTool
250 245
         /// <summary>
251 246
         /// 麦克风
252 247
         /// </summary>
253
-        /// <param name="sender">
254
-        /// </param>
255 248
         /// <param name="e">
256 249
         /// </param>
257 250
         private async void Microphone_Check()
@@ -263,21 +256,23 @@ namespace XHWK.WKTool
263 256
             DataTable data = new DataTable();
264 257
             data.Columns.Add("Value");
265 258
             data.Columns.Add("Key");
266
-            await Task.Run(() =>
267
-            {
268
-                for (int n = 0; n < WaveIn.DeviceCount; n++)
259
+            await Task.Run
260
+            (
261
+                () =>
269 262
                 {
270
-                    var caps = WaveIn.GetCapabilities(n);
271
-
272
-                    //创建一行
273
-                    DataRow row = data.NewRow();
274
-                    //将此行添加到table中
275
-                    data.Rows.Add(row);
276
-                    data.Rows[n]["Value"] = caps.ProductName;
277
-                    data.Rows[n]["Key"] = n + "";
263
+                    for (int n = 0; n < WaveIn.DeviceCount; n++)
264
+                    {
265
+                        var caps = WaveIn.GetCapabilities(n);
266
+
267
+                        //创建一行
268
+                        DataRow row = data.NewRow();
269
+                        //将此行添加到table中
270
+                        data.Rows.Add(row);
271
+                        data.Rows[n]["Value"] = caps.ProductName;
272
+                        data.Rows[n]["Key"] = n + "";
273
+                    }
278 274
                 }
279
-            });
280
-
275
+            );
281 276
             CmbMicrophoneList.ItemsSource = data.DefaultView;
282 277
             if (WaveIn.DeviceCount > 0)
283 278
             {
@@ -285,55 +280,58 @@ namespace XHWK.WKTool
285 280
             }
286 281
         }
287 282
 
288
-        private WaveInEvent waveIn = null;
283
+        private WaveInEvent _waveIn;
289 284
 
290
-        private void CmbMicrophoneList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
285
+        private void CmbMicrophoneList_SelectionChanged
286
+            (object sender, System.Windows.Controls.SelectionChangedEventArgs e)
291 287
         {
292
-            if (waveIn != null)
288
+            if (_waveIn != null)
293 289
             {
294
-                waveIn.StopRecording();
290
+                _waveIn.StopRecording();
295 291
             }
296 292
             volumeProgressBar.Value = 0;
297
-
298 293
             if (CmbMicrophoneList.SelectedIndex >= 0)
299 294
             {
300
-                var select_index = CmbMicrophoneList.SelectedIndex;
301
-                ThreadPool.QueueUserWorkItem((item) =>
302
-                {
303
-                    waveIn = new WaveInEvent();
304
-                    waveIn.DeviceNumber = select_index;
305
-
306
-                    //开始录音,写数据
307
-                    waveIn.DataAvailable += (o, e1) =>
295
+                var selectIndex = CmbMicrophoneList.SelectedIndex;
296
+                ThreadPool.QueueUserWorkItem
297
+                (
298
+                    (item) =>
308 299
                     {
309
-                        byte[] buf = e1.Buffer;
310
-                        float maxNumber = 0;
311
-                        for (int index = 0; index < buf.Length; index += 2)
312
-                        {
313
-                            short sample = (short)((buf[index + 1] << 8) | buf[index + 0]);
314
-                            float sample32 = sample / 32768f;
315
-                            sample32 = Math.Abs(sample32);
300
+                        _waveIn = new WaveInEvent();
301
+                        _waveIn.DeviceNumber = selectIndex;
316 302
 
317
-                            if (sample32 > maxNumber)
303
+                        //开始录音,写数据
304
+                        _waveIn.DataAvailable += (o, e1) =>
305
+                        {
306
+                            byte[] buf = e1.Buffer;
307
+                            float maxNumber = 0;
308
+                            for (int index = 0; index < buf.Length; index += 2)
318 309
                             {
319
-                                maxNumber = sample32;
310
+                                short sample = (short)((buf[index + 1] << 8) | buf[index + 0]);
311
+                                float sample32 = sample / 32768f;
312
+                                sample32 = Math.Abs(sample32);
313
+                                if (sample32 > maxNumber)
314
+                                {
315
+                                    maxNumber = sample32;
316
+                                }
320 317
                             }
321
-                        }
322
-
323
-                        Dispatcher.Invoke(() =>
318
+                            Dispatcher.Invoke
319
+                            (
320
+                                () =>
321
+                                {
322
+                                    volumeProgressBar.Value = maxNumber * 100;
323
+                                }
324
+                            );
325
+                        };
326
+
327
+                        //结束录音
328
+                        _waveIn.RecordingStopped += (s, a) =>
324 329
                         {
325
-                            volumeProgressBar.Value = maxNumber * 100;
326
-                        });
327
-                    };
328
-
329
-                    //结束录音
330
-                    waveIn.RecordingStopped += (s, a) =>
331
-                    {
332
-                        waveIn.Dispose();
333
-                    };
334
-
335
-                    waveIn.StartRecording();
336
-                });
330
+                            _waveIn.Dispose();
331
+                        };
332
+                        _waveIn.StartRecording();
333
+                    }
334
+                );
337 335
             }
338 336
         }
339 337
 
@@ -348,7 +346,7 @@ namespace XHWK.WKTool
348 346
         {
349 347
             HidePage();
350 348
             GridDetection.Visibility = Visibility.Visible;
351
-            if (cameraGood)
349
+            if (_cameraGood)
352 350
             {
353 351
                 TxbCamera.Text = "可用";
354 352
             }
@@ -356,8 +354,7 @@ namespace XHWK.WKTool
356 354
             {
357 355
                 TxbCamera.Text = "不可用";
358 356
             }
359
-
360
-            if (loudspeakerGood)
357
+            if (_loudspeakerGood)
361 358
             {
362 359
                 TxbSpeaker.Text = "可用";
363 360
             }
@@ -365,8 +362,7 @@ namespace XHWK.WKTool
365 362
             {
366 363
                 TxbSpeaker.Text = "不可用";
367 364
             }
368
-
369
-            if (microphoneGood)
365
+            if (_microphoneGood)
370 366
             {
371 367
                 TxbMicrophone.Text = "可用";
372 368
             }
@@ -391,6 +387,7 @@ namespace XHWK.WKTool
391 387
             }
392 388
             catch (Exception)
393 389
             {
390
+                // ignored
394 391
             }
395 392
         }
396 393
 
@@ -400,47 +397,46 @@ namespace XHWK.WKTool
400 397
 
401 398
         private void btn_camera_good_Click(object sender, RoutedEventArgs e)
402 399
         {
403
-            cameraGood = true;
400
+            _cameraGood = true;
404 401
             Speaker_Check();
405 402
         }
406 403
 
407 404
         private void btn_camera_bad_Click(object sender, RoutedEventArgs e)
408 405
         {
409
-            cameraGood = false;
406
+            _cameraGood = false;
410 407
             Speaker_Check();
411 408
         }
412 409
 
413 410
         private void btn_speaker_good_Click(object sender, RoutedEventArgs e)
414 411
         {
415
-            loudspeakerGood = true;
412
+            _loudspeakerGood = true;
416 413
             Microphone_Check();
417 414
         }
418 415
 
419 416
         private void btn_speaker_bad_Click(object sender, RoutedEventArgs e)
420 417
         {
421
-            loudspeakerGood = false;
418
+            _loudspeakerGood = false;
422 419
             Microphone_Check();
423 420
         }
424 421
 
425 422
         private void btn_microphone_good_Click(object sender, RoutedEventArgs e)
426 423
         {
427
-            if (waveIn != null)
424
+            if (_waveIn != null)
428 425
             {
429
-                waveIn.StopRecording();
426
+                _waveIn.StopRecording();
430 427
             }
431
-
432
-            microphoneGood = true;
428
+            _microphoneGood = true;
433 429
             result_show();
434 430
             CmbMicrophoneList.SelectedIndex = -1;
435 431
         }
436 432
 
437 433
         private void btn_microphone_bad_Click(object sender, RoutedEventArgs e)
438 434
         {
439
-            if (waveIn != null)
435
+            if (_waveIn != null)
440 436
             {
441
-                waveIn.StopRecording();
437
+                _waveIn.StopRecording();
442 438
             }
443
-            microphoneGood = false;
439
+            _microphoneGood = false;
444 440
             result_show();
445 441
             CmbMicrophoneList.SelectedIndex = -1;
446 442
         }
@@ -454,7 +450,7 @@ namespace XHWK.WKTool
454 450
         /// </param>
455 451
         private void BtnDetection_Click(object sender, RoutedEventArgs e)
456 452
         {
457
-            cameraCheck();
453
+            CameraCheck();
458 454
         }
459 455
 
460 456
         #endregion 事件

+ 8
- 38
XHWK.WKTool/LoginWindow.xaml Wyświetl plik

@@ -67,31 +67,6 @@
67 67
                 </Setter.Value>
68 68
             </Setter>
69 69
         </Style>
70
-        <Style x:Key="NoMouseOverButtonStyle" TargetType="{x:Type Button}">
71
-            <Setter Property="BorderThickness" Value="1" />
72
-            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
73
-            <Setter Property="HorizontalContentAlignment" Value="Center" />
74
-            <Setter Property="VerticalContentAlignment" Value="Center" />
75
-            <Setter Property="Padding" Value="1" />
76
-            <Setter Property="Template">
77
-                <Setter.Value>
78
-                    <ControlTemplate TargetType="{x:Type Button}">
79
-                        <Border
80
-                            x:Name="Chrome"
81
-                            Background="{TemplateBinding Background}"
82
-                            BorderBrush="{TemplateBinding BorderBrush}"
83
-                            SnapsToDevicePixels="true">
84
-                            <ContentPresenter
85
-                                Margin="{TemplateBinding Padding}"
86
-                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
87
-                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
88
-                                RecognizesAccessKey="True"
89
-                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
90
-                        </Border>
91
-                    </ControlTemplate>
92
-                </Setter.Value>
93
-            </Setter>
94
-        </Style>
95 70
     </Window.Resources>
96 71
     <Grid>
97 72
         <Border
@@ -140,7 +115,7 @@
140 115
                                 FontSize="12"
141 116
                                 Foreground="#FF666666" />
142 117
                             <TextBox
143
-                                x:Name="txbAccountNumber"
118
+                                x:Name="TxbAccountNumber"
144 119
                                 Margin="5,5"
145 120
                                 BorderBrush="{x:Null}"
146 121
                                 BorderThickness="0"
@@ -190,7 +165,7 @@
190 165
                         <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
191 166
                             <Viewbox Margin="0,0,5,0" VerticalAlignment="Center">
192 167
                                 <CheckBox
193
-                                    x:Name="ckSaveName"
168
+                                    x:Name="CkSaveName"
194 169
                                     Click="CkSaveName_Click"
195 170
                                     Cursor="Hand"
196 171
                                     Style="{DynamicResource CheckBoxStyle1}" />
@@ -223,7 +198,7 @@
223 198
                             <RowDefinition Height="5*" />
224 199
                         </Grid.RowDefinitions>
225 200
                         <Button
226
-                            x:Name="btnStart"
201
+                            x:Name="BtnStart"
227 202
                             Grid.Row="1"
228 203
                             Grid.ColumnSpan="2"
229 204
                             HorizontalAlignment="Stretch"
@@ -235,8 +210,7 @@
235 210
                             Cursor="Hand"
236 211
                             FontSize="18"
237 212
                             Foreground="#FFFFFF"
238
-                            IsDefault="True"
239
-                            >
213
+                            IsDefault="True">
240 214
                             <Button.Template>
241 215
                                 <ControlTemplate TargetType="{x:Type Button}">
242 216
                                     <Border
@@ -268,8 +242,7 @@
268 242
                             Cursor="Hand"
269 243
                             FontSize="18"
270 244
                             Foreground="#FFFFFF"
271
-                            IsDefault="True"
272
-                            >
245
+                            IsDefault="True">
273 246
                             <Button.Template>
274 247
                                 <ControlTemplate TargetType="{x:Type Button}">
275 248
                                     <Border
@@ -295,8 +268,7 @@
295 268
                             VerticalAlignment="Stretch"
296 269
                             Click="BtnServiceAddress_Click"
297 270
                             Cursor="Hand"
298
-                            FontSize="{Binding WordSize12}"
299
-                            >
271
+                            FontSize="{Binding WordSize12}">
300 272
                             <Button.Template>
301 273
                                 <ControlTemplate TargetType="{x:Type Button}">
302 274
                                     <Grid>
@@ -426,8 +398,7 @@
426 398
                             FontSize="18"
427 399
                             FontWeight="Bold"
428 400
                             Foreground="#FFFFFF"
429
-                            IsDefault="True"
430
-                            >
401
+                            IsDefault="True">
431 402
                             <Button.Template>
432 403
                                 <ControlTemplate TargetType="{x:Type Button}">
433 404
                                     <Border
@@ -460,8 +431,7 @@
460 431
                             FontSize="18"
461 432
                             FontWeight="Bold"
462 433
                             Foreground="#FFFFFF"
463
-                            IsDefault="True"
464
-                            >
434
+                            IsDefault="True">
465 435
                             <Button.Template>
466 436
                                 <ControlTemplate TargetType="{x:Type Button}">
467 437
                                     <Border

+ 21
- 11
XHWK.WKTool/LoginWindow.xaml.cs Wyświetl plik

@@ -37,8 +37,8 @@ namespace XHWK.WKTool
37 37
                 string accountNumber = System.IO.File.ReadAllText(APP.DataPath + "accountNumber.txt", Encoding.Default);
38 38
                 if (!string.IsNullOrWhiteSpace(accountNumber))
39 39
                 {
40
-                    txbAccountNumber.Text = accountNumber;
41
-                    ckSaveName.IsChecked = true;
40
+                    TxbAccountNumber.Text = accountNumber;
41
+                    CkSaveName.IsChecked = true;
42 42
                 }
43 43
             }
44 44
             DataContext = APP.PageContextData;
@@ -53,7 +53,7 @@ namespace XHWK.WKTool
53 53
         /// </param>
54 54
         private void BtnDown_Click(object sender, RoutedEventArgs e)
55 55
         {
56
-            txbAccountNumber.Text = string.Empty;
56
+            TxbAccountNumber.Text = string.Empty;
57 57
             pobPassword.Password = string.Empty;
58 58
             Hide();
59 59
         }
@@ -78,12 +78,12 @@ namespace XHWK.WKTool
78 78
 
79 79
             #endregion 获取服务接口地址 --2021年7月9日赵耀
80 80
 
81
-            if (string.IsNullOrEmpty(txbAccountNumber.Text))
81
+            if (string.IsNullOrEmpty(TxbAccountNumber.Text))
82 82
             {
83 83
                 MessageWindow.Show("账号未输入");
84 84
                 return;
85 85
             }
86
-            if (txbAccountNumber.Text.Length > 18)
86
+            if (TxbAccountNumber.Text.Length > 18)
87 87
             {
88 88
                 MessageWindow.Show("账号长度不能高于18位");
89 89
                 return;
@@ -109,7 +109,7 @@ namespace XHWK.WKTool
109 109
         {
110 110
             string accountNumber = string.Empty;
111 111
             string password = string.Empty;
112
-            accountNumber = txbAccountNumber.Text.Replace(" ", "").Trim();
112
+            accountNumber = TxbAccountNumber.Text.Replace(" ", "").Trim();
113 113
             password = pobPassword.Password.Replace(" ", "").Trim();
114 114
 
115 115
             int code = xhapi.Login(accountNumber, password);
@@ -117,21 +117,31 @@ namespace XHWK.WKTool
117 117
             {
118 118
                 FileToolsCommon.CreateDirectory(APP.DataPath);
119 119
                 string applicationData = APP.DataPath + "accountNumber.txt";
120
-                if (ckSaveName.IsChecked == true)
120
+                if (CkSaveName.IsChecked == true)
121 121
                 {
122
-                    string accountNumbers = txbAccountNumber.Text;
123
-                    System.IO.File.WriteAllText(applicationData, accountNumbers, Encoding.Default);//存放账号
122
+                    string accountNumbers = TxbAccountNumber.Text;
123
+                    System.IO.File.WriteAllText
124
+                    (
125
+                        applicationData,
126
+                        accountNumbers,
127
+                        Encoding.Default
128
+                    ); //存放账号
124 129
                 }
125 130
                 else
126 131
                 {
127 132
                     string accountNumbers = "";
128
-                    System.IO.File.WriteAllText(applicationData, accountNumbers, Encoding.Default);//存放账号
133
+                    System.IO.File.WriteAllText
134
+                    (
135
+                        applicationData,
136
+                        accountNumbers,
137
+                        Encoding.Default
138
+                    ); //存放账号
129 139
                 }
130 140
 
131 141
                 APP.myloading.Hide();
132 142
                 //UpdateSettingString("userName", txbAccountNumber.Text);
133 143
                 APP.IsLoginType = true;
134
-                txbAccountNumber.Text = string.Empty;
144
+                TxbAccountNumber.Text = string.Empty;
135 145
                 pobPassword.Password = string.Empty;
136 146
 
137 147
                 #region 下载头像

+ 20
- 28
XHWK.WKTool/MainWindow.xaml Wyświetl plik

@@ -2,21 +2,20 @@
2 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
+    xmlns:controls="clr-namespace:AForge.Controls;assembly=AForge.Controls"
5 6
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6 7
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7 8
     Title="星火微课系统"
8 9
     Width="950"
9 10
     Height="700"
10
-    AllowsTransparency="False"
11
-    BorderBrush="#eee"
12
-    BorderThickness="1"
13 11
     Closed="Window_Closed"
14 12
     Loaded="Window_Loaded"
15 13
     MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
16 14
     ResizeMode="CanMinimize"
17 15
     ShowInTaskbar="True"
16
+    Style="{StaticResource ZWinStyle}"
18 17
     WindowStartupLocation="CenterScreen"
19
-    WindowStyle="None"
18
+    WindowStyle="SingleBorderWindow"
20 19
     mc:Ignorable="d">
21 20
 
22 21
     <Window.Resources>
@@ -820,8 +819,10 @@
820 819
                                             <ScaleTransform ScaleX="-1" />
821 820
                                         </Image.RenderTransform>
822 821
                                     </Image>
822
+
823
+
823 824
                                     <Image
824
-                                        x:Name="imgPlayerRight"
825
+                                        x:Name="ImgPlayerRight"
825 826
                                         Width="172"
826 827
                                         Height="124"
827 828
                                         Margin="10,7,26,10"
@@ -1363,45 +1364,35 @@
1363 1364
                                                 Text="摄像头位置" />
1364 1365
                                         </Grid>
1365 1366
                                         <Grid Grid.Row="1" Grid.Column="3">
1366
-                                            <!--<Grid.ColumnDefinitions>
1367
-                                                    <ColumnDefinition Width="15*" />
1368
-                                                    <ColumnDefinition Width="80*" />
1369
-                                                    <ColumnDefinition Width="80*" />
1370
-                                                    <ColumnDefinition Width="41*" />
1371
-                                                </Grid.ColumnDefinitions>
1372
-                                                <Grid.RowDefinitions>
1373
-                                                    <RowDefinition Height="60*" />
1374
-                                                    <RowDefinition Height="60*" />
1375
-                                                </Grid.RowDefinitions>-->
1376
-
1377 1367
                                             <StackPanel
1378 1368
                                                 Margin="15,0,0,0"
1379 1369
                                                 HorizontalAlignment="Left"
1380 1370
                                                 VerticalAlignment="Center"
1381 1371
                                                 Orientation="Horizontal">
1382 1372
                                                 <RadioButton
1383
-                                                    x:Name="rbnRight"
1373
+                                                    x:Name="rbnLeft"
1384 1374
                                                     Margin="0"
1385 1375
                                                     HorizontalAlignment="Left"
1386 1376
                                                     VerticalAlignment="Center"
1387
-                                                    Content=" 上"
1377
+                                                    Content=" 左上"
1388 1378
                                                     Cursor="Hand"
1389 1379
                                                     FontSize="16"
1390 1380
                                                     Foreground="#333333"
1391 1381
                                                     GroupName="RbtnCamera"
1392
-                                                    IsChecked="True"
1393 1382
                                                     Style="{StaticResource RadBase}" />
1394 1383
                                                 <RadioButton
1395
-                                                    x:Name="rbnRightUnder"
1396
-                                                    Margin="15,0"
1397
-                                                    HorizontalAlignment="Left"
1384
+                                                    x:Name="rbnRight"
1385
+                                                    Margin="15,0,0,0"
1386
+                                                    HorizontalAlignment="Right"
1398 1387
                                                     VerticalAlignment="Center"
1399
-                                                    Content=" 右"
1388
+                                                    Content=" 右"
1400 1389
                                                     Cursor="Hand"
1401 1390
                                                     FontSize="16"
1402 1391
                                                     Foreground="#333333"
1403 1392
                                                     GroupName="RbtnCamera"
1393
+                                                    IsChecked="True"
1404 1394
                                                     Style="{StaticResource RadBase}" />
1395
+
1405 1396
                                             </StackPanel>
1406 1397
                                         </Grid>
1407 1398
                                         <Grid Grid.Row="2" Grid.Column="3">
@@ -1410,23 +1401,24 @@
1410 1401
                                                 HorizontalAlignment="Left"
1411 1402
                                                 VerticalAlignment="Center"
1412 1403
                                                 Orientation="Horizontal">
1404
+
1413 1405
                                                 <RadioButton
1414
-                                                    x:Name="rbnLeft"
1415
-                                                    Margin="0"
1406
+                                                    x:Name="rbnLeftUnder"
1416 1407
                                                     HorizontalAlignment="Left"
1417 1408
                                                     VerticalAlignment="Center"
1418
-                                                    Content=" 左"
1409
+                                                    Content=" 左"
1419 1410
                                                     Cursor="Hand"
1420 1411
                                                     FontSize="16"
1421 1412
                                                     Foreground="#333333"
1422 1413
                                                     GroupName="RbtnCamera"
1423 1414
                                                     Style="{StaticResource RadBase}" />
1415
+
1424 1416
                                                 <RadioButton
1425
-                                                    x:Name="rbnLeftUnder"
1417
+                                                    x:Name="rbnRightUnder"
1426 1418
                                                     Margin="15,0"
1427 1419
                                                     HorizontalAlignment="Left"
1428 1420
                                                     VerticalAlignment="Center"
1429
-                                                    Content=" 下"
1421
+                                                    Content=" 下"
1430 1422
                                                     Cursor="Hand"
1431 1423
                                                     FontSize="16"
1432 1424
                                                     Foreground="#333333"

+ 2084
- 1396
XHWK.WKTool/MainWindow.xaml.cs
Plik diff jest za duży
Wyświetl plik


+ 11
- 9
XHWK.WKTool/MessageWindow.xaml Wyświetl plik

@@ -3,7 +3,6 @@
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"
6
-    xmlns:local="clr-namespace:XHWK.WKTool"
7 6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8 7
     Title="星火微课"
9 8
     Width="446"
@@ -13,22 +12,26 @@
13 12
     MouseMove="Window_MouseMove"
14 13
     ResizeMode="NoResize"
15 14
     ShowInTaskbar="False"
15
+    Style="{StaticResource ZWinStyle}"
16 16
     Topmost="True"
17 17
     WindowStartupLocation="CenterScreen"
18 18
     WindowState="Normal"
19 19
     WindowStyle="None"
20 20
     mc:Ignorable="d">
21 21
 
22
-    <Border BorderBrush="#3f6fff" BorderThickness="1">
22
+    <Border
23
+        Background="White"
24
+        BorderBrush="#3f6fff"
25
+        BorderThickness="0">
23 26
         <Grid>
24 27
             <Grid.RowDefinitions>
25
-                <RowDefinition Height="42" />
28
+                <RowDefinition Height="40" />
26 29
                 <RowDefinition Height="*" />
27 30
                 <RowDefinition Height="60" />
28 31
             </Grid.RowDefinitions>
29 32
             <Grid Grid.Row="0" Background="#3f6fff">
30 33
                 <Label
31
-                    x:Name="lblTitle"
34
+                    x:Name="LblTitle"
32 35
                     Margin="14,0,0,0"
33 36
                     HorizontalAlignment="Left"
34 37
                     VerticalAlignment="Center"
@@ -39,7 +42,7 @@
39 42
                     Foreground="White" />
40 43
 
41 44
                 <Button
42
-                    x:Name="borCancel"
45
+                    x:Name="BorCancel"
43 46
                     Grid.Row="0"
44 47
                     Width="46"
45 48
                     HorizontalAlignment="Right"
@@ -52,8 +55,7 @@
52 55
             </Grid>
53 56
             <Grid Grid.Row="1">
54 57
                 <TextBlock
55
-                    x:Name="tbkContent"
56
-                    Grid.Row="1"
58
+                    x:Name="TbkContent"
57 59
                     Margin="20,0,20,0"
58 60
                     HorizontalAlignment="Center"
59 61
                     VerticalAlignment="Center"
@@ -65,14 +67,14 @@
65 67
             <Grid Grid.Row="2" Margin="0,0,0,0">
66 68
 
67 69
                 <Border
68
-                    x:Name="borOk"
70
+                    x:Name="BorOk"
69 71
                     Margin="0,0,10,0"
70 72
                     HorizontalAlignment="Right"
71 73
                     VerticalAlignment="Center"
72 74
                     Background="#3f6fff"
73 75
                     CornerRadius="6">
74 76
                     <Button
75
-                        x:Name="BtnOK"
77
+                        x:Name="BtnOk"
76 78
                         Width="76"
77 79
                         Height="30"
78 80
                         Background="#00000000"

+ 5
- 5
XHWK.WKTool/MessageWindow.xaml.cs Wyświetl plik

@@ -20,26 +20,26 @@ namespace XHWK.WKTool
20 20
             switch (MessageType)
21 21
             {
22 22
                 case 1:
23
-                    borCancel.Visibility = Visibility.Hidden;
23
+                    BorCancel.Visibility = Visibility.Hidden;
24 24
                     break;
25 25
                 case 2:
26
-                    borCancel.Visibility = Visibility.Visible;
26
+                    BorCancel.Visibility = Visibility.Visible;
27 27
                     break;
28 28
                 default:
29 29
                     break;
30 30
             }
31
-            lblTitle.Content = Title;
31
+            LblTitle.Content = Title;
32 32
             if (!string.IsNullOrWhiteSpace(Content))
33 33
             {
34 34
                 if (Content.Length > 143)
35 35
                 {
36 36
                     Content = Content.Substring(0, 140) + "...";
37 37
                 }
38
-                tbkContent.Text = Content;
38
+                TbkContent.Text = Content;
39 39
             }
40 40
             else
41 41
             {
42
-                tbkContent.Text = "错误!";
42
+                TbkContent.Text = "错误!";
43 43
             }
44 44
         }
45 45
         /// <summary>

+ 70
- 25
XHWK.WKTool/PromptWindow.xaml Wyświetl plik

@@ -1,35 +1,80 @@
1
-<Window x:Class="XHWK.WKTool.PromptWindow"
2
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
-        xmlns:local="clr-namespace:XHWK.WKTool"
7
-        mc:Ignorable="d"
8
-        Title="PromptWindow" Height="210" Width="553" WindowStartupLocation="CenterOwner"
9
-    WindowStyle="None" AllowsTransparency="True"    WindowState="Normal"
10
-    ShowInTaskbar="True"   ResizeMode="NoResize"
11
-    BorderThickness="7">
1
+<Window
2
+    x:Class="XHWK.WKTool.PromptWindow"
3
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
+    Title="PromptWindow"
8
+    Width="553"
9
+    Height="210"
10
+    AllowsTransparency="True"
11
+    BorderThickness="7"
12
+    ResizeMode="NoResize"
13
+    ShowInTaskbar="True"
14
+    WindowStartupLocation="CenterOwner"
15
+    WindowState="Normal"
16
+    WindowStyle="None"
17
+    mc:Ignorable="d">
12 18
     <Window.Effect>
13
-        <DropShadowEffect BlurRadius="10" Color="#bababa" Direction="80" ShadowDepth="0"/>
19
+        <DropShadowEffect
20
+            BlurRadius="10"
21
+            Direction="80"
22
+            ShadowDepth="0"
23
+            Color="#bababa" />
14 24
     </Window.Effect>
15 25
     <Grid Background="#FFFFFF">
16 26
         <Grid.RowDefinitions>
17
-            <RowDefinition Height="auto"/>
18
-            <RowDefinition Height="auto"/>
19
-            <RowDefinition Height="auto"/>
27
+            <RowDefinition Height="auto" />
28
+            <RowDefinition Height="auto" />
29
+            <RowDefinition Height="auto" />
20 30
         </Grid.RowDefinitions>
21
-        <TextBlock Grid.Row="0" Text="确定删除" FontSize="24" Margin="25,26,0,0"/>
22
-        <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="25,36,0,0">
23
-            <TextBlock Text="删除" FontSize="18" Foreground="#919191" />
24
-            <TextBlock x:Name="txbName" Text="微课01" FontSize="18" Foreground="#919191"/>
31
+        <TextBlock
32
+            Grid.Row="0"
33
+            Margin="25,26,0,0"
34
+            FontSize="24"
35
+            Text="确定删除" />
36
+        <StackPanel
37
+            Grid.Row="1"
38
+            Margin="25,36,0,0"
39
+            Orientation="Horizontal">
40
+            <TextBlock
41
+                FontSize="18"
42
+                Foreground="#919191"
43
+                Text="删除" />
44
+            <TextBlock
45
+                x:Name="txbName"
46
+                FontSize="18"
47
+                Foreground="#919191"
48
+                Text="微课01" />
25 49
         </StackPanel>
26
-       
27
-        <StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,30,0,0">
28
-            <Border x:Name="borCancel" Background="#E5E5E5" CornerRadius="6" >
29
-                <Button x:Name="btnCancel" Width="104" Height="42" Content="取消" FontSize="18"  Background="Transparent"/>
50
+
51
+        <StackPanel
52
+            Grid.Row="2"
53
+            Margin="0,30,0,0"
54
+            HorizontalAlignment="Right"
55
+            Orientation="Horizontal">
56
+            <Border
57
+                x:Name="borCancel"
58
+                Background="#E5E5E5"
59
+                CornerRadius="6">
60
+                <Button
61
+                    x:Name="btnCancel"
62
+                    Width="104"
63
+                    Height="42"
64
+                    Background="Transparent"
65
+                    Content="取消"
66
+                    FontSize="18" />
30 67
             </Border>
31
-            <Border Background="#E5E5E5" CornerRadius="6" Margin="30,0,20,0">
32
-                <Button Width="104" Height="42" Content="确定" FontSize="18"  Background="Transparent"/>
68
+            <Border
69
+                Margin="30,0,20,0"
70
+                Background="#E5E5E5"
71
+                CornerRadius="6">
72
+                <Button
73
+                    Width="104"
74
+                    Height="42"
75
+                    Background="Transparent"
76
+                    Content="确定"
77
+                    FontSize="18" />
33 78
             </Border>
34 79
         </StackPanel>
35 80
     </Grid>

+ 24
- 0
XHWK.WKTool/Resources/OverwrideDefaultControlStyles.xaml Wyświetl plik

@@ -9,4 +9,28 @@
9 9
     <Style BasedOn="{StaticResource for_scrollviewer}" TargetType="ScrollViewer" />
10 10
 
11 11
     <Style BasedOn="{StaticResource MyButton}" TargetType="Button" />
12
+
13
+    <Style x:Key="ZWinStyle" TargetType="Window">
14
+        <Setter Property="AllowsTransparency" Value="False" />
15
+        <Setter Property="Background" Value="Transparent" />
16
+        <Setter Property="BorderBrush" Value="Transparent" />
17
+        <Setter Property="BorderThickness" Value="0" />
18
+        <Setter Property="WindowChrome.WindowChrome">
19
+            <Setter.Value>
20
+                <WindowChrome
21
+                    CaptionHeight="0"
22
+                    CornerRadius="0"
23
+                    GlassFrameThickness="-1"
24
+                    NonClientFrameEdges="None"
25
+                    ResizeBorderThickness="0"
26
+                    UseAeroCaptionButtons="False" />
27
+            </Setter.Value>
28
+        </Setter>
29
+
30
+        <Style.Triggers>
31
+            <Trigger Property="WindowState" Value="Maximized">
32
+                <Setter Property="BorderThickness" Value="6" />
33
+            </Trigger>
34
+        </Style.Triggers>
35
+    </Style>
12 36
 </ResourceDictionary>

+ 73
- 63
XHWK.WKTool/system/CameraHelper.cs Wyświetl plik

@@ -1,92 +1,100 @@
1
-using AForge.Controls;
2
-using AForge.Video.DirectShow;
3
-
4
-using System;
5
-using System.Drawing;
6
-using System.Drawing.Imaging;
7
-using System.IO;
8
-
9
-
10
-namespace Common.system
1
+namespace XHWK.WKTool.system
11 2
 {
3
+    using System;
4
+    using System.Collections.Generic;
5
+    using System.Drawing;
6
+    using System.Drawing.Imaging;
7
+    using System.IO;
8
+    using System.Windows.Media.Imaging;
9
+    using System.Windows.Threading;
10
+    using AForge.Controls;
11
+    using AForge.Video.DirectShow;
12
+
12 13
     public static class CameraHelper
13 14
     {
14
-        private static FilterInfoCollection _cameraDevices;
15
-        private static VideoCaptureDevice div = null;
16
-        private static VideoSourcePlayer sourcePlayer = new VideoSourcePlayer();
17
-        private static bool _isDisplay = false;
15
+        private static List<FilterInfo> _cameraDevices;
16
+        private static VideoCaptureDevice _div;
17
+        private static VideoSourcePlayer _sourcePlayer = new VideoSourcePlayer();
18
+
18 19
         //指示_isDisplay设置为true后,是否设置了其他的sourcePlayer,若未设置则_isDisplay重设为false
19
-        private static bool isSet = false;
20
+        private static bool _isSet;
21
+
22
+        private static Dispatcher _dispatcher;
23
+        public static Action<BitmapImage> imageCallback;
20 24
 
21 25
         /// <summary>
22 26
         /// 获取或设置摄像头设备,无设备为null
23 27
         /// </summary>
24
-        public static FilterInfoCollection CameraDevices
28
+        public static List<FilterInfo> CameraDevices
25 29
         {
26 30
             get => _cameraDevices;
27 31
             set => _cameraDevices = value;
28 32
         }
33
+
29 34
         /// <summary>
30
-        /// 指示是否显示摄像头视频画面
31
-        /// 默认false
32
-        /// </summary>
33
-        public static bool IsDisplay
34
-        {
35
-            get => _isDisplay;
36
-            set => _isDisplay = value;
37
-        }
38
-        /// <summary>
39
-        /// 获取或设置VideoSourcePlayer控件,
40
-        /// 只有当IsDisplay设置为true时,该属性才可以设置成功
35
+        /// 更新摄像头设备信息
41 36
         /// </summary>
42
-        public static VideoSourcePlayer SourcePlayer
37
+        public static void UpdateCameraDevices()
43 38
         {
44
-            get => sourcePlayer;
45
-            set
39
+            var devs = new FilterInfoCollection(FilterCategory.VideoInputDevice); //获取摄像头列表
40
+            List<FilterInfo> allCamera = new List<FilterInfo>();
41
+            foreach (FilterInfo dev in devs)
46 42
             {
47
-                if (_isDisplay)
43
+                if (dev.Name != "screen-capture-recorder" && dev.Name != "OBS Virtual Camera")
48 44
                 {
49
-                    sourcePlayer = value;
50
-                    isSet = true;
45
+                    allCamera.Add(dev);
51 46
                 }
52
-
53 47
             }
48
+            _cameraDevices = allCamera;
54 49
         }
55
-        /// <summary>
56
-        /// 更新摄像头设备信息
57
-        /// </summary>
58
-        public static void UpdateCameraDevices()
59
-        {
60
-            _cameraDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
61
-        }
50
+
62 51
         /// <summary>
63 52
         /// 设置使用的摄像头设备
64 53
         /// </summary>
65 54
         /// <param name="index">设备在CameraDevices中的索引</param>
55
+        /// <param name="dispatcher"></param>
66 56
         /// <returns><see cref="bool"/></returns>
67
-        public static bool SetCameraDevice(int index)
57
+        public static bool StartCameraDevice(int index, Dispatcher dispatcher)
68 58
         {
69
-            if (!isSet)
70
-            {
71
-                _isDisplay = false;
72
-            }
59
+            _dispatcher = dispatcher;
60
+
73 61
             //无设备,返回false
74 62
             if (_cameraDevices.Count <= 0 || index < 0)
75 63
             {
76 64
                 return false;
77 65
             }
78
-
79 66
             if (index > _cameraDevices.Count - 1)
80 67
             {
81 68
                 return false;
82 69
             }
83 70
             // 设定初始视频设备
84
-            div = new VideoCaptureDevice(_cameraDevices[index].MonikerString);
85
-            sourcePlayer.VideoSource = div;
86
-            div.Start();
87
-            sourcePlayer.Start();
71
+            _div = new VideoCaptureDevice(_cameraDevices[index].MonikerString);
72
+            _div.NewFrame += _div_NewFrame;
73
+            _sourcePlayer.VideoSource = _div;
74
+            _div.Start();
75
+            _sourcePlayer.Start();
88 76
             return true;
89 77
         }
78
+
79
+        private static void _div_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
80
+        {
81
+            _dispatcher.Invoke
82
+            (
83
+                () =>
84
+                {
85
+                    MemoryStream ms = new MemoryStream();
86
+                    eventArgs.Frame.Save(ms, ImageFormat.Bmp);
87
+                    BitmapImage image = new BitmapImage();
88
+                    image.BeginInit();
89
+                    image.StreamSource = new MemoryStream(ms.GetBuffer());
90
+                    ms.Close();
91
+                    ms.Dispose();
92
+                    image.EndInit();
93
+                    imageCallback?.Invoke(image);
94
+                }
95
+            );
96
+        }
97
+
90 98
         /// <summary>
91 99
         /// 截取一帧图像并保存
92 100
         /// </summary>
@@ -95,28 +103,30 @@ namespace Common.system
95 103
         /// <returns>如果保存成功,则返回完整路径,否则为 null</returns>
96 104
         public static string CaptureImage(string filePath, string fileName = null)
97 105
         {
98
-            if (sourcePlayer.VideoSource == null)
106
+            if (_sourcePlayer.VideoSource == null)
99 107
             {
100 108
                 return null;
101 109
             }
102
-
103 110
             if (!Directory.Exists(filePath))
104 111
             {
105 112
                 Directory.CreateDirectory(filePath);
106 113
             }
107 114
             try
108 115
             {
109
-                Image bitmap = sourcePlayer.GetCurrentVideoFrame();
116
+                Image bitmap = _sourcePlayer.GetCurrentVideoFrame();
110 117
                 if (bitmap != null)
111 118
                 {
112 119
                     if (fileName == null)
113 120
                     {
114 121
                         fileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
115 122
                     }
116
-
117 123
                     string fullPath = Path.Combine(filePath, fileName + "-cap.jpg");
118
-
119
-                    System.Drawing.Bitmap objNewPic = new System.Drawing.Bitmap(bitmap, 172, 124);//图片保存的大小尺寸  
124
+                    Bitmap objNewPic = new Bitmap
125
+                    (
126
+                        bitmap,
127
+                        172,
128
+                        124
129
+                    ); //图片保存的大小尺寸  
120 130
                     objNewPic.Save(fullPath, ImageFormat.Jpeg);
121 131
                     //bitmap.Save(fullPath, ImageFormat.Jpeg);
122 132
                     bitmap.Dispose();
@@ -127,21 +137,21 @@ namespace Common.system
127 137
             }
128 138
             catch (Exception)
129 139
             {
130
-
131 140
                 return null;
132 141
             }
133 142
         }
143
+
134 144
         /// <summary>
135 145
         /// 关闭摄像头设备
136 146
         /// </summary>
137 147
         public static void CloseDevice()
138 148
         {
139
-            if (div != null && div.IsRunning)
149
+            if (_div != null && _div.IsRunning)
140 150
             {
141
-                sourcePlayer.Stop();
142
-                div.SignalToStop();
143
-                div = null;
144
-                //_cameraDevices = null;
151
+                _div.NewFrame -= _div_NewFrame;
152
+                _sourcePlayer.Stop();
153
+                _div.SignalToStop();
154
+                _div = null;
145 155
             }
146 156
         }
147 157
     }

Ładowanie…
Anuluj
Zapisz