Browse Source

多摄像头处理

摄像头渲染
窗口阴影
master
张剑 1 year ago
parent
commit
3bbab01e05

+ 119
- 0
.editorconfig View File

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 View File

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

+ 12
- 18
XHWK.WKTool/AppUpdateWin.xaml View File

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

+ 8
- 9
XHWK.WKTool/AppUpdateWin.xaml.cs View File

67
 
67
 
68
         public void downloadBegin(int position)
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
         public void downloadProgress(int position, int progress)
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
         public void downloadEnd(int position, string filepath)
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
             try
86
             try
88
             {
87
             {
89
                 using (var managementClass = new ManagementClass("Win32_Process"))
88
                 using (var managementClass = new ManagementClass("Win32_Process"))

+ 3
- 36
XHWK.WKTool/CreateAMicroLessonWindow.xaml View File

3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
-    xmlns:local="clr-namespace:XHWK.WKTool"
7
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8
     Title="星火微课"
7
     Title="星火微课"
9
     Width="800"
8
     Width="800"
10
     Height="450"
9
     Height="450"
11
-    Margin="0"
12
-    AllowsTransparency="True"
13
     Closed="Window_Closed"
10
     Closed="Window_Closed"
14
     Loaded="Window_Loaded"
11
     Loaded="Window_Loaded"
12
+    Style="{StaticResource ZWinStyle}"
15
     WindowStartupLocation="CenterScreen"
13
     WindowStartupLocation="CenterScreen"
16
-    WindowStyle="None"
14
+    WindowStyle="SingleBorderWindow"
17
     mc:Ignorable="d">
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
     <Grid>
18
     <Grid>
52
         <Grid Background="#FF4B95FF" MouseLeftButtonDown="Window_MouseLeftButtonDown">
19
         <Grid Background="#FF4B95FF" MouseLeftButtonDown="Window_MouseLeftButtonDown">
53
             <Grid.ColumnDefinitions>
20
             <Grid.ColumnDefinitions>

+ 7
- 5
XHWK.WKTool/DeviceWindow.xaml View File

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

+ 127
- 131
XHWK.WKTool/DeviceWindow.xaml.cs View File

1
 using Accord.Video;
1
 using Accord.Video;
2
 using Accord.Video.DirectShow;
2
 using Accord.Video.DirectShow;
3
-
4
 using Common.system;
3
 using Common.system;
5
-
6
 using NAudio.Wave;
4
 using NAudio.Wave;
7
-
8
 using System;
5
 using System;
9
-using System.Collections.Generic;
10
 using System.Data;
6
 using System.Data;
11
 using System.Diagnostics;
7
 using System.Diagnostics;
12
 using System.Drawing.Imaging;
8
 using System.Drawing.Imaging;
17
 using System.Windows.Input;
13
 using System.Windows.Input;
18
 using System.Windows.Media.Imaging;
14
 using System.Windows.Media.Imaging;
19
 
15
 
20
-using System.Windows.Threading;
21
-
22
 namespace XHWK.WKTool
16
 namespace XHWK.WKTool
23
 {
17
 {
18
+    using System.Linq;
19
+    using system;
20
+
24
     /// <summary>
21
     /// <summary>
25
     /// DeviceWindow.xaml 的交互逻辑
22
     /// DeviceWindow.xaml 的交互逻辑
26
     /// </summary>
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
         public DeviceWindow()
30
         public DeviceWindow()
34
         {
31
         {
35
             InitializeComponent();
32
             InitializeComponent();
36
-
37
             MicrophoneSetting.Click += MicrophoneSetting_Click;
33
             MicrophoneSetting.Click += MicrophoneSetting_Click;
38
-
39
-            cameraCheck();
34
+            CameraCheck();
40
         }
35
         }
41
 
36
 
42
         private void MicrophoneSetting_Click(object sender, RoutedEventArgs e)
37
         private void MicrophoneSetting_Click(object sender, RoutedEventArgs e)
76
         private void BtnDown_Click(object sender, RoutedEventArgs e)
71
         private void BtnDown_Click(object sender, RoutedEventArgs e)
77
         {
72
         {
78
             imgPlayer.Visibility = Visibility.Hidden;
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
             Close();
79
             Close();
86
         }
80
         }
87
 
81
 
88
         #region 摄像头
82
         #region 摄像头
89
 
83
 
90
-        private void cameraCheck()
84
+        private void CameraCheck()
91
         {
85
         {
92
             HidePage();
86
             HidePage();
93
             GridCamera.Visibility = Visibility.Visible;
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
                 CmbCameraList.SelectedIndex = 0;
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
         /// <summary>
109
         /// <summary>
112
         /// 检测
110
         /// 检测
113
         /// </summary>
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
             try
114
             try
121
             {
115
             {
122
-                closeCamera();
123
-
116
+                CloseCamera();
124
                 imgPlayer.Visibility = Visibility.Visible;
117
                 imgPlayer.Visibility = Visibility.Visible;
125
                 if (CmbCameraList.SelectedIndex >= 0)
118
                 if (CmbCameraList.SelectedIndex >= 0)
126
                 {
119
                 {
127
                     var info = CmbCameraList.SelectedItem as FilterInfo;
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
                     //配置录像参数(宽,高,帧率,比特率等参数)VideoCapabilities这个属性会返回摄像头支持哪些配置
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
             catch (Exception ex)
130
             catch (Exception ex)
138
             }
133
             }
139
         }
134
         }
140
 
135
 
141
-        private void closeCamera()
136
+        private void CloseCamera()
142
         {
137
         {
143
             try
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
             catch (Exception)
145
             catch (Exception)
151
             {
146
             {
147
+                // ignored
152
             }
148
             }
153
         }
149
         }
154
 
150
 
157
         /// </summary>
153
         /// </summary>
158
         private void Camera_NewFrame(object sender, NewFrameEventArgs eventArgs)
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
         /// <summary>
172
         /// <summary>
180
         /// </param>
178
         /// </param>
181
         private void BtnCameraStop_Click(object sender, RoutedEventArgs e)
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
         /// <summary>
191
         /// <summary>
194
         /// 扬声器
192
         /// 扬声器
195
         /// </summary>
193
         /// </summary>
196
-        /// <param name="sender">
197
-        /// </param>
198
-        /// <param name="e">
199
-        /// </param>
200
         private void Speaker_Check()
194
         private void Speaker_Check()
201
         {
195
         {
202
-            closeCamera();
196
+            CloseCamera();
203
             CmbCameraList.SelectedIndex = -1;
197
             CmbCameraList.SelectedIndex = -1;
204
             HidePage();
198
             HidePage();
205
             GridSpeaker.Visibility = Visibility.Visible;
199
             GridSpeaker.Visibility = Visibility.Visible;
214
         /// </param>
208
         /// </param>
215
         private void BtnSpeakerDetection_Click(object sender, RoutedEventArgs e)
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
             MediaAudio.Position = TimeSpan.Zero;
214
             MediaAudio.Position = TimeSpan.Zero;
220
             MediaAudio.Play();
215
             MediaAudio.Play();
221
             ImgAcousticWave.Visibility = Visibility.Visible;
216
             ImgAcousticWave.Visibility = Visibility.Visible;
232
         /// </param>
227
         /// </param>
233
         private void MediaAudio_MediaOpened(object sender, RoutedEventArgs e)
228
         private void MediaAudio_MediaOpened(object sender, RoutedEventArgs e)
234
         {
229
         {
235
-            Console.WriteLine("播放中。。。");
230
+            Console.WriteLine(@"播放中。。。");
236
         }
231
         }
237
 
232
 
238
         private void MediaAudio_MediaEnded(object sender, RoutedEventArgs e)
233
         private void MediaAudio_MediaEnded(object sender, RoutedEventArgs e)
250
         /// <summary>
245
         /// <summary>
251
         /// 麦克风
246
         /// 麦克风
252
         /// </summary>
247
         /// </summary>
253
-        /// <param name="sender">
254
-        /// </param>
255
         /// <param name="e">
248
         /// <param name="e">
256
         /// </param>
249
         /// </param>
257
         private async void Microphone_Check()
250
         private async void Microphone_Check()
263
             DataTable data = new DataTable();
256
             DataTable data = new DataTable();
264
             data.Columns.Add("Value");
257
             data.Columns.Add("Value");
265
             data.Columns.Add("Key");
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
             CmbMicrophoneList.ItemsSource = data.DefaultView;
276
             CmbMicrophoneList.ItemsSource = data.DefaultView;
282
             if (WaveIn.DeviceCount > 0)
277
             if (WaveIn.DeviceCount > 0)
283
             {
278
             {
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
             volumeProgressBar.Value = 0;
292
             volumeProgressBar.Value = 0;
297
-
298
             if (CmbMicrophoneList.SelectedIndex >= 0)
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
         {
346
         {
349
             HidePage();
347
             HidePage();
350
             GridDetection.Visibility = Visibility.Visible;
348
             GridDetection.Visibility = Visibility.Visible;
351
-            if (cameraGood)
349
+            if (_cameraGood)
352
             {
350
             {
353
                 TxbCamera.Text = "可用";
351
                 TxbCamera.Text = "可用";
354
             }
352
             }
356
             {
354
             {
357
                 TxbCamera.Text = "不可用";
355
                 TxbCamera.Text = "不可用";
358
             }
356
             }
359
-
360
-            if (loudspeakerGood)
357
+            if (_loudspeakerGood)
361
             {
358
             {
362
                 TxbSpeaker.Text = "可用";
359
                 TxbSpeaker.Text = "可用";
363
             }
360
             }
365
             {
362
             {
366
                 TxbSpeaker.Text = "不可用";
363
                 TxbSpeaker.Text = "不可用";
367
             }
364
             }
368
-
369
-            if (microphoneGood)
365
+            if (_microphoneGood)
370
             {
366
             {
371
                 TxbMicrophone.Text = "可用";
367
                 TxbMicrophone.Text = "可用";
372
             }
368
             }
391
             }
387
             }
392
             catch (Exception)
388
             catch (Exception)
393
             {
389
             {
390
+                // ignored
394
             }
391
             }
395
         }
392
         }
396
 
393
 
400
 
397
 
401
         private void btn_camera_good_Click(object sender, RoutedEventArgs e)
398
         private void btn_camera_good_Click(object sender, RoutedEventArgs e)
402
         {
399
         {
403
-            cameraGood = true;
400
+            _cameraGood = true;
404
             Speaker_Check();
401
             Speaker_Check();
405
         }
402
         }
406
 
403
 
407
         private void btn_camera_bad_Click(object sender, RoutedEventArgs e)
404
         private void btn_camera_bad_Click(object sender, RoutedEventArgs e)
408
         {
405
         {
409
-            cameraGood = false;
406
+            _cameraGood = false;
410
             Speaker_Check();
407
             Speaker_Check();
411
         }
408
         }
412
 
409
 
413
         private void btn_speaker_good_Click(object sender, RoutedEventArgs e)
410
         private void btn_speaker_good_Click(object sender, RoutedEventArgs e)
414
         {
411
         {
415
-            loudspeakerGood = true;
412
+            _loudspeakerGood = true;
416
             Microphone_Check();
413
             Microphone_Check();
417
         }
414
         }
418
 
415
 
419
         private void btn_speaker_bad_Click(object sender, RoutedEventArgs e)
416
         private void btn_speaker_bad_Click(object sender, RoutedEventArgs e)
420
         {
417
         {
421
-            loudspeakerGood = false;
418
+            _loudspeakerGood = false;
422
             Microphone_Check();
419
             Microphone_Check();
423
         }
420
         }
424
 
421
 
425
         private void btn_microphone_good_Click(object sender, RoutedEventArgs e)
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
             result_show();
429
             result_show();
434
             CmbMicrophoneList.SelectedIndex = -1;
430
             CmbMicrophoneList.SelectedIndex = -1;
435
         }
431
         }
436
 
432
 
437
         private void btn_microphone_bad_Click(object sender, RoutedEventArgs e)
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
             result_show();
440
             result_show();
445
             CmbMicrophoneList.SelectedIndex = -1;
441
             CmbMicrophoneList.SelectedIndex = -1;
446
         }
442
         }
454
         /// </param>
450
         /// </param>
455
         private void BtnDetection_Click(object sender, RoutedEventArgs e)
451
         private void BtnDetection_Click(object sender, RoutedEventArgs e)
456
         {
452
         {
457
-            cameraCheck();
453
+            CameraCheck();
458
         }
454
         }
459
 
455
 
460
         #endregion 事件
456
         #endregion 事件

+ 8
- 38
XHWK.WKTool/LoginWindow.xaml View File

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

+ 21
- 11
XHWK.WKTool/LoginWindow.xaml.cs View File

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

+ 20
- 28
XHWK.WKTool/MainWindow.xaml View File

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

+ 2084
- 1396
XHWK.WKTool/MainWindow.xaml.cs
File diff suppressed because it is too large
View File


+ 11
- 9
XHWK.WKTool/MessageWindow.xaml View File

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

+ 5
- 5
XHWK.WKTool/MessageWindow.xaml.cs View File

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

+ 70
- 25
XHWK.WKTool/PromptWindow.xaml View File

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
     <Window.Effect>
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
     </Window.Effect>
24
     </Window.Effect>
15
     <Grid Background="#FFFFFF">
25
     <Grid Background="#FFFFFF">
16
         <Grid.RowDefinitions>
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
         </Grid.RowDefinitions>
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
         </StackPanel>
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
             </Border>
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
             </Border>
78
             </Border>
34
         </StackPanel>
79
         </StackPanel>
35
     </Grid>
80
     </Grid>

+ 24
- 0
XHWK.WKTool/Resources/OverwrideDefaultControlStyles.xaml View File

9
     <Style BasedOn="{StaticResource for_scrollviewer}" TargetType="ScrollViewer" />
9
     <Style BasedOn="{StaticResource for_scrollviewer}" TargetType="ScrollViewer" />
10
 
10
 
11
     <Style BasedOn="{StaticResource MyButton}" TargetType="Button" />
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
 </ResourceDictionary>
36
 </ResourceDictionary>

+ 73
- 63
XHWK.WKTool/system/CameraHelper.cs View File

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
     public static class CameraHelper
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
         //指示_isDisplay设置为true后,是否设置了其他的sourcePlayer,若未设置则_isDisplay重设为false
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
         /// <summary>
25
         /// <summary>
22
         /// 获取或设置摄像头设备,无设备为null
26
         /// 获取或设置摄像头设备,无设备为null
23
         /// </summary>
27
         /// </summary>
24
-        public static FilterInfoCollection CameraDevices
28
+        public static List<FilterInfo> CameraDevices
25
         {
29
         {
26
             get => _cameraDevices;
30
             get => _cameraDevices;
27
             set => _cameraDevices = value;
31
             set => _cameraDevices = value;
28
         }
32
         }
33
+
29
         /// <summary>
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
         /// </summary>
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
         /// <summary>
51
         /// <summary>
63
         /// 设置使用的摄像头设备
52
         /// 设置使用的摄像头设备
64
         /// </summary>
53
         /// </summary>
65
         /// <param name="index">设备在CameraDevices中的索引</param>
54
         /// <param name="index">设备在CameraDevices中的索引</param>
55
+        /// <param name="dispatcher"></param>
66
         /// <returns><see cref="bool"/></returns>
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
             //无设备,返回false
61
             //无设备,返回false
74
             if (_cameraDevices.Count <= 0 || index < 0)
62
             if (_cameraDevices.Count <= 0 || index < 0)
75
             {
63
             {
76
                 return false;
64
                 return false;
77
             }
65
             }
78
-
79
             if (index > _cameraDevices.Count - 1)
66
             if (index > _cameraDevices.Count - 1)
80
             {
67
             {
81
                 return false;
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
             return true;
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
         /// <summary>
98
         /// <summary>
91
         /// 截取一帧图像并保存
99
         /// 截取一帧图像并保存
92
         /// </summary>
100
         /// </summary>
95
         /// <returns>如果保存成功,则返回完整路径,否则为 null</returns>
103
         /// <returns>如果保存成功,则返回完整路径,否则为 null</returns>
96
         public static string CaptureImage(string filePath, string fileName = null)
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
                 return null;
108
                 return null;
101
             }
109
             }
102
-
103
             if (!Directory.Exists(filePath))
110
             if (!Directory.Exists(filePath))
104
             {
111
             {
105
                 Directory.CreateDirectory(filePath);
112
                 Directory.CreateDirectory(filePath);
106
             }
113
             }
107
             try
114
             try
108
             {
115
             {
109
-                Image bitmap = sourcePlayer.GetCurrentVideoFrame();
116
+                Image bitmap = _sourcePlayer.GetCurrentVideoFrame();
110
                 if (bitmap != null)
117
                 if (bitmap != null)
111
                 {
118
                 {
112
                     if (fileName == null)
119
                     if (fileName == null)
113
                     {
120
                     {
114
                         fileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
121
                         fileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
115
                     }
122
                     }
116
-
117
                     string fullPath = Path.Combine(filePath, fileName + "-cap.jpg");
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
                     objNewPic.Save(fullPath, ImageFormat.Jpeg);
130
                     objNewPic.Save(fullPath, ImageFormat.Jpeg);
121
                     //bitmap.Save(fullPath, ImageFormat.Jpeg);
131
                     //bitmap.Save(fullPath, ImageFormat.Jpeg);
122
                     bitmap.Dispose();
132
                     bitmap.Dispose();
127
             }
137
             }
128
             catch (Exception)
138
             catch (Exception)
129
             {
139
             {
130
-
131
                 return null;
140
                 return null;
132
             }
141
             }
133
         }
142
         }
143
+
134
         /// <summary>
144
         /// <summary>
135
         /// 关闭摄像头设备
145
         /// 关闭摄像头设备
136
         /// </summary>
146
         /// </summary>
137
         public static void CloseDevice()
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
     }

Loading…
Cancel
Save