Browse Source

无法获取打印机异常退出问题

主页面UI优化
大幅提升进入主页面的速度
设备检测不再在每次开始时检测
master
张剑 2 years ago
parent
commit
e11c567cd8

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

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

+ 7
- 4
XHWK.WKTool/CreateAMicroLessonWindow.xaml View File

@@ -182,7 +182,7 @@
182 182
                                     </Grid>
183 183
                                     <Label Height="1.5" Background="#3F6FFF" />
184 184
                                 </StackPanel>
185
-                            
185
+
186 186
                             </Grid>
187 187
                             <!--  按钮  -->
188 188
                             <Grid Grid.Row="3">
@@ -229,7 +229,11 @@
229 229
                             </Grid>
230 230
 
231 231
                             <Grid Grid.Row="4">
232
-                                <Label Name="versionLabel" Content="版本号:" Foreground="#666666" HorizontalAlignment="Center"></Label>
232
+                                <Label
233
+                                    Name="versionLabel"
234
+                                    HorizontalAlignment="Center"
235
+                                    Content="版本号:"
236
+                                    Foreground="#666666" />
233 237
                             </Grid>
234 238
                         </Grid>
235 239
                     </Grid>
@@ -245,8 +249,7 @@
245 249
                 Content="×"
246 250
                 Cursor="Hand"
247 251
                 FontSize="25"
248
-                Foreground="#FFFFFF"
249
-                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
252
+                Foreground="#FFFFFF" />
250 253
         </Grid>
251 254
         <Grid Visibility="Collapsed">
252 255
             <!--  分4行  -->

+ 0
- 6
XHWK.WKTool/CreateAMicroLessonWindow.xaml.cs View File

@@ -195,9 +195,6 @@ namespace XHWK.WKTool
195 195
                 if (ofd.SelectedPath != "")
196 196
                 {
197 197
                     txbStoragePath.Text = ofd.SelectedPath;
198
-                    //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
199
-                    //string temp = ofd.SelectedPath;
200
-                    //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
201 198
                 }
202 199
             }
203 200
         }
@@ -307,9 +304,6 @@ namespace XHWK.WKTool
307 304
             Hide();
308 305
         }
309 306
 
310
-        private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
311
-        private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
312
-
313 307
         /// <summary>
314 308
         /// 窗体移动
315 309
         /// </summary>

+ 50
- 56
XHWK.WKTool/KeyVerification.xaml View File

@@ -1,21 +1,21 @@
1
-<Window x:Class="XHWK.WKTool.KeyVerification"
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
-         xmlns:Views="clr-namespace:XHWK.WKTool.Helpers"
8
-        Title="KeyVerification"    Width="300"
1
+<Window
2
+    x:Class="XHWK.WKTool.KeyVerification"
3
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
+    xmlns:Views="clr-namespace:XHWK.WKTool.Helpers"
6
+    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"
9
+    Title="KeyVerification"
10
+    Width="400"
9 11
     Height="230"
10 12
     AllowsTransparency="True"
11 13
     Background="Transparent"
12 14
     ShowInTaskbar="False"
13 15
     WindowStartupLocation="CenterOwner"
14 16
     WindowStyle="None"
15
-    mc:Ignorable="d" BorderThickness="7">
16
-    <Window.Effect>
17
-        <DropShadowEffect BlurRadius="10" Color="#bababa" Direction="80" ShadowDepth="0"/>
18
-    </Window.Effect>
17
+    mc:Ignorable="d">
18
+
19 19
     <Window.Resources>
20 20
         <Style x:Key="oiliu" TargetType="ListBoxItem">
21 21
             <!--  设置控件模板  -->
@@ -41,11 +41,11 @@
41 41
                 Height="auto"
42 42
                 Background="Transparent">
43 43
                 <TextBlock
44
-                        Padding="0,12,0,0"
45
-                        HorizontalAlignment="Left"
46
-                        FontSize="20"
47
-                        Foreground="#3C525B"
48
-                        Text="{Binding username}" />
44
+                    Padding="0,12,0,0"
45
+                    HorizontalAlignment="Left"
46
+                    FontSize="20"
47
+                    Foreground="#3C525B"
48
+                    Text="{Binding username}" />
49 49
             </StackPanel>
50 50
         </DataTemplate>
51 51
     </Window.Resources>
@@ -70,57 +70,51 @@
70 70
                     FontSize="16"
71 71
                     Foreground="White"
72 72
                     Text="产品激活" />
73
-                <!--<Button
74
-                    Grid.Column="0"
75
-                    Width="46"
76
-                    Height="46"
77
-                    Margin="0,0,10,0"
73
+
74
+                <Button
75
+                    x:Name="btnDown"
76
+                    Grid.Row="0"
77
+                    Padding="10,0,10,0"
78 78
                     HorizontalAlignment="Right"
79
-                    VerticalAlignment="Center"
80
-                    Background="White"
81
-                    Click="close_click" Cursor="Hand"
82
-                    Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
83
-                    <Button.Template>
84
-                        <ControlTemplate TargetType="{x:Type Button}">
85
-                            <Border
86
-                                BorderBrush="{TemplateBinding Control.BorderBrush}"
87
-                                BorderThickness="0"
88
-                                CornerRadius="20">
89
-                                <ContentPresenter
90
-                                    HorizontalAlignment="Center"
91
-                                    VerticalAlignment="Center"
92
-                                    Content="{TemplateBinding ContentControl.Content}" />
93
-                            </Border>
94
-                        </ControlTemplate>
95
-                    </Button.Template>
96
-                    <Image
97
-                        Width="40"
98
-                        Height="40"
99
-                        HorizontalAlignment="Center"
100
-                        VerticalAlignment="Center"
101
-                        Source="./Images/rollCall_1.png"
102
-                        Stretch="Fill" />
103
-                </Button>-->
104
-                <Button  Cursor="Hand" Grid.Row="0" x:Name="btnDown" Content="×" VerticalAlignment="Top" Foreground="#FFFFFF" FontSize="30" Padding="10,2,10,0" HorizontalAlignment="Right" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="close_click"/>
79
+                    Click="close_click"
80
+                    Content="×"
81
+                    Cursor="Hand"
82
+                    FontSize="30"
83
+                    Foreground="#FFFFFF" />
105 84
             </Grid>
106 85
             <Grid Grid.Row="1" Margin="30,20,30,0">
107
-                <StackPanel Orientation="Horizontal" Height="43">
108
-                    <TextBlock Text="密匙:" FontSize="20" Padding="0,5,0,0"/>
109
-                    <TextBox x:Name="txbKey" Text="" Width="164" Foreground="gray" FontSize="18" VerticalContentAlignment="Center"/>
110
-                </StackPanel>
86
+                <Grid.ColumnDefinitions>
87
+                    <ColumnDefinition Width="Auto" />
88
+                    <ColumnDefinition Width="*" />
89
+                </Grid.ColumnDefinitions>
90
+                <TextBlock
91
+                    Padding="0,0,0,0"
92
+                    VerticalAlignment="Center"
93
+                    FontSize="20"
94
+                    Text="密匙:" />
95
+                <TextBox
96
+                    x:Name="txbKey"
97
+                    Grid.Column="1"
98
+                    Height="46"
99
+                    VerticalAlignment="Center"
100
+                    VerticalContentAlignment="Center"
101
+                    FontSize="18"
102
+                    Foreground="gray"
103
+                    Text="" />
111 104
             </Grid>
112 105
 
113
-            <Button Cursor="Hand"
106
+            <Button
114 107
                 x:Name="btnEnd"
115 108
                 Grid.Row="2"
116
-                    IsDefault="True"
117 109
                 Height="48"
118 110
                 Margin="30,0,30,0"
119 111
                 Click="btnEnd_Click"
120 112
                 Content="验证"
121
-                    FontWeight="Bold"
113
+                Cursor="Hand"
122 114
                 FontSize="18"
123
-                Foreground="White">
115
+                FontWeight="Bold"
116
+                Foreground="White"
117
+                IsDefault="True">
124 118
                 <Button.Template>
125 119
                     <ControlTemplate TargetType="{x:Type Button}">
126 120
                         <Border

+ 4
- 6
XHWK.WKTool/MainWindow.xaml View File

@@ -9,7 +9,7 @@
9 9
     Height="700"
10 10
     AllowsTransparency="False"
11 11
     BorderBrush="#eee"
12
-    BorderThickness="1"
12
+    BorderThickness="0"
13 13
     Loaded="Window_Loaded"
14 14
     MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
15 15
     ResizeMode="CanMinimize"
@@ -479,8 +479,7 @@
479 479
                                 HorizontalAlignment="Center"
480 480
                                 VerticalAlignment="Center"
481 481
                                 Click="BtnLoginType_Click"
482
-                                Cursor="Hand"
483
-                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
482
+                                Cursor="Hand">
484 483
                                 <StackPanel>
485 484
                                     <Border
486 485
                                         x:Name="ImgHeadImgN"
@@ -505,7 +504,7 @@
505 504
                                         x:Name="TxbLoginType"
506 505
                                         Margin="0,10,0,0"
507 506
                                         HorizontalAlignment="Center"
508
-                                        FontSize="12"
507
+                                        FontSize="14"
509 508
                                         Style="{DynamicResource LoginTypeColor}"
510 509
                                         Text="未登录" />
511 510
                                 </StackPanel>
@@ -693,7 +692,6 @@
693 692
                                             Background="#FFFFFF"
694 693
                                             MouseLeftButtonDown="Window_MouseLeftButtonDown_1"
695 694
                                             Visibility="Visible">
696
-
697 695
                                             <Grid>
698 696
                                                 <Border CornerRadius="5">
699 697
                                                     <Grid x:Name="IMG" Margin="0,0,0,0">
@@ -1834,7 +1832,7 @@
1834 1832
                         Height="36"
1835 1833
                         Margin="10,0,10,0"
1836 1834
                         HorizontalAlignment="Stretch"
1837
-                        HorizontalContentAlignment="Center"
1835
+                        HorizontalContentAlignment="Left"
1838 1836
                         VerticalContentAlignment="Center"
1839 1837
                         Background="White"
1840 1838
                         BorderThickness="0"

+ 88
- 75
XHWK.WKTool/MainWindow.xaml.cs View File

@@ -165,7 +165,6 @@ namespace XHWK.WKTool
165 165
             luoBoPenUtil.InitlbPen();
166 166
             //腾千里
167 167
             InitTQLPPen();
168
-            InitPrint();
169 168
 
170 169
             SkinSelectInit();
171 170
             byte[] license = Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=");
@@ -180,8 +179,9 @@ namespace XHWK.WKTool
180 179
                  RectRightDown,
181 180
                 RectImgBorder,
182 181
                 imgCanvas,
183
-                GridM
184
-        );
182
+                GridM);
183
+
184
+            InitPrint();
185 185
         }
186 186
 
187 187
         /// <summary>
@@ -285,11 +285,35 @@ namespace XHWK.WKTool
285 285
         /// </param>
286 286
         /// <param name="e">
287 287
         /// </param>
288
-        private void Window_Loaded(object sender, RoutedEventArgs e)
288
+        private async void Window_Loaded(object sender, RoutedEventArgs e)
289 289
         {
290 290
             //调整录制区域宽高
291 291
             double proportion = 210.0 / 297.0;
292 292
             GridM.Height = GridM.ActualWidth / proportion;
293
+            await checkDevice();
294
+        }
295
+
296
+        private bool microphoneGood = false;
297
+        private bool loudspeakerGood = false;
298
+
299
+        private async Task checkDevice()
300
+        {
301
+            Task<bool> checkMicrophone = Task.Run(() =>
302
+            {
303
+                return ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
304
+            }
305
+              );
306
+
307
+            Task<bool> checkLoudspeaker = Task.Run(
308
+                () =>
309
+                {
310
+                    return ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.loudspeaker);
311
+                });
312
+
313
+            await Task.WhenAll(checkMicrophone, checkLoudspeaker);
314
+
315
+            microphoneGood = checkMicrophone.Result;
316
+            loudspeakerGood = checkMicrophone.Result;
293 317
         }
294 318
 
295 319
         #endregion 初始化
@@ -857,7 +881,7 @@ namespace XHWK.WKTool
857 881
         /// </param>
858 882
         private void btnPrintExplain_Click(object sender, RoutedEventArgs e)
859 883
         {
860
-            System.Diagnostics.Process.Start(FileToolsCommon.GetFileAbsolutePath("/星火微课点阵码打印及印刷指导手册.docx"));
884
+            Process.Start(FileToolsCommon.GetFileAbsolutePath("/星火微课点阵码打印及印刷指导手册.docx"));
861 885
         }
862 886
 
863 887
         private void PageHide()
@@ -2693,56 +2717,48 @@ namespace XHWK.WKTool
2693 2717
         /// </param>
2694 2718
         /// <param name="e">
2695 2719
         /// </param>
2696
-        private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
2720
+        private async void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
2697 2721
         {
2698 2722
             luoBoPenUtil.lb_device_mouse();
2699
-            ThreadPool.QueueUserWorkItem(o =>
2700
-            {
2701
-                bool microphoneGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
2702
-                bool loudspeakerGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.loudspeaker);
2703 2723
 
2704
-                Dispatcher.Invoke(() =>
2705
-                {
2706
-                    if (!microphoneGood)
2707
-                    {
2708
-                        MessageWindow.Show("麦克风不可用");
2709
-                        return;
2710
-                    }
2724
+            if (!microphoneGood)
2725
+            {
2726
+                MessageWindow.Show("麦克风不可用");
2727
+                return;
2728
+            }
2711 2729
 
2712
-                    if (!loudspeakerGood)
2713
-                    {
2714
-                        MessageWindow.Show("扬声器不可用");
2715
-                        return;
2716
-                    }
2730
+            if (!loudspeakerGood)
2731
+            {
2732
+                MessageWindow.Show("扬声器不可用");
2733
+                return;
2734
+            }
2717 2735
 
2718
-                    Record();
2736
+            Record();
2719 2737
 
2720
-                    k_hook.Stop();
2721
-                    if (APP.W_ScreenRecordingToolbarWindow == null)
2722
-                    {
2723
-                        APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
2724
-                        {
2725
-                            Topmost = true
2726
-                        };
2727
-                        APP.W_ScreenRecordingToolbarWindow.Initialize();
2728
-                    }
2729
-                    else
2730
-                    {
2731
-                        APP.W_ScreenRecordingToolbarWindow.Initialize();
2732
-                    }
2733
-                    APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
2734
-                    //显示在右下角
2735
-                    APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
2736
-                    Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
2737
-                    float DIP = graphics.DpiX;
2738
-                    float DIPY = graphics.DpiY;
2739
-                    APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width;
2740
-                    APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.WorkingArea.Height / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Height - 100;
2741
-                    APP.W_ScreenRecordingToolbarWindow.Topmost = true;
2742
-                    APP.W_ScreenRecordingToolbarWindow.Show();
2743
-                    Hide();
2744
-                });
2745
-            });
2738
+            k_hook.Stop();
2739
+            if (APP.W_ScreenRecordingToolbarWindow == null)
2740
+            {
2741
+                APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
2742
+                {
2743
+                    Topmost = true
2744
+                };
2745
+                APP.W_ScreenRecordingToolbarWindow.Initialize();
2746
+            }
2747
+            else
2748
+            {
2749
+                APP.W_ScreenRecordingToolbarWindow.Initialize();
2750
+            }
2751
+            APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
2752
+            //显示在右下角
2753
+            APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
2754
+            Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
2755
+            float DIP = graphics.DpiX;
2756
+            float DIPY = graphics.DpiY;
2757
+            APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.WorkingArea.Width / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Width;
2758
+            APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.WorkingArea.Height / (DIP / 96) - APP.W_ScreenRecordingToolbarWindow.Height - 100;
2759
+            APP.W_ScreenRecordingToolbarWindow.Topmost = true;
2760
+            APP.W_ScreenRecordingToolbarWindow.Show();
2761
+            Hide();
2746 2762
         }
2747 2763
 
2748 2764
         /// <summary>
@@ -2751,10 +2767,8 @@ namespace XHWK.WKTool
2751 2767
         private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
2752 2768
         {
2753 2769
             TxbTime.Text = "00:00";
2754
-            //TxbTime.Visibility = Visibility.Hidden;
2755
-            //ImgLZImg.Visibility = Visibility.Hidden;
2756
-            //TxbType.Visibility = Visibility.Visible;
2757 2770
             TxbType.Text = "保存中";
2771
+            RecordType = 1;
2758 2772
             BtnScreenRecording.IsEnabled = false;
2759 2773
 
2760 2774
             new Thread(new ThreadStart(new Action(() =>
@@ -2766,10 +2780,9 @@ namespace XHWK.WKTool
2766 2780
                 Thread.Sleep(100);
2767 2781
                 Dispatcher.Invoke(() =>
2768 2782
                 {
2783
+                    RecordType = 0;
2769 2784
                     BtnScreenRecording.IsEnabled = true;
2770 2785
                     TxbType.Text = "准备就绪";
2771
-                    //TxbType.Visibility = Visibility.Hidden;
2772
-                    //TxbRecordScreenWord.Text = "录屏";
2773 2786
                 });
2774 2787
             }))).Start();
2775 2788
         }
@@ -2875,14 +2888,10 @@ namespace XHWK.WKTool
2875 2888
 
2876 2889
             if (RecordType == 0)
2877 2890
             {
2878
-                bool microphoneGood = true;
2879 2891
                 start_pause_grid.Visibility = Visibility.Hidden;
2880 2892
                 stop_grid.Visibility = Visibility.Hidden;
2881 2893
                 close_grid.Visibility = Visibility.Hidden;
2882
-                await Task.Run(() =>
2883
-                {
2884
-                    microphoneGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
2885
-                });
2894
+
2886 2895
                 if (!microphoneGood)
2887 2896
                 {
2888 2897
                     start_pause_grid.Visibility = Visibility.Visible;
@@ -4036,27 +4045,31 @@ namespace XHWK.WKTool
4036 4045
         /// <summary>
4037 4046
         /// 打印初始化
4038 4047
         /// </summary>
4039
-        public void InitPrint()
4048
+        public async void InitPrint()
4040 4049
         {
4041 4050
             ResizeMode = ResizeMode.NoResize;
4042
-            List<string> defaList = ZPrintUtils.GetLocalPrinters();
4043
-            if (defaList.Count > 0)
4051
+            await Task.Run(() =>
4044 4052
             {
4045
-                printlist.Columns.Add("Value");
4046
-                printlist.Columns.Add("Key");
4047
-                for (int i = 0; i < defaList.Count; i++)
4053
+                List<string> defaList = ZPrintUtils.GetLocalPrinters();
4054
+                if (defaList.Count > 0)
4048 4055
                 {
4049
-                    //创建一行
4050
-                    DataRow row = printlist.NewRow();
4051
-                    //将此行添加到table中
4052
-                    printlist.Rows.Add(row);
4053
-                    printlist.Rows[i]["Value"] = defaList[i];
4054
-                    printlist.Rows[i]["Key"] = i.ToString();
4056
+                    printlist.Columns.Add("Value");
4057
+                    printlist.Columns.Add("Key");
4058
+                    for (int i = 0; i < defaList.Count; i++)
4059
+                    {
4060
+                        //创建一行
4061
+                        DataRow row = printlist.NewRow();
4062
+                        //将此行添加到table中
4063
+                        printlist.Rows.Add(row);
4064
+                        printlist.Rows[i]["Value"] = defaList[i];
4065
+                        printlist.Rows[i]["Key"] = i.ToString();
4066
+                    }
4067
+                    dtComponentsUniqueNo = printlist.DefaultView.ToTable();
4055 4068
                 }
4056
-                dtComponentsUniqueNo = printlist.DefaultView.ToTable();
4057
-                cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
4058
-                cmbClass.SelectedIndex = 0;
4059
-            }
4069
+            });
4070
+
4071
+            cmbClass.ItemsSource = dtComponentsUniqueNo.DefaultView;
4072
+            cmbClass.SelectedIndex = 0;
4060 4073
 
4061 4074
             TQLPrintInit();
4062 4075
         }

+ 14
- 6
XHWK.WKTool/Utils/ZPrintUtils.cs View File

@@ -4,9 +4,10 @@ using System.Runtime.InteropServices;
4 4
 
5 5
 namespace XHWK.WKTool.Utils
6 6
 {
7
-    class ZPrintUtils
7
+    internal class ZPrintUtils
8 8
     {
9 9
         private static PrintDocument fPrintDocument = new PrintDocument();
10
+
10 11
         /// <summary>
11 12
         /// 获取本机默认打印机名称
12 13
         /// </summary>
@@ -23,14 +24,21 @@ namespace XHWK.WKTool.Utils
23 24
         public static List<string> GetLocalPrinters()
24 25
         {
25 26
             List<string> fPrinters = new List<string>();
26
-            fPrinters.Add(DefaultPrinter()); //默认打印机始终出现在列表的第一项
27
-            foreach (string fPrinterName in PrinterSettings.InstalledPrinters)
27
+            try
28 28
             {
29
-                if (!fPrinters.Contains(fPrinterName))
29
+                fPrinters.Add(DefaultPrinter()); //默认打印机始终出现在列表的第一项
30
+                foreach (string fPrinterName in PrinterSettings.InstalledPrinters)
30 31
                 {
31
-                    fPrinters.Add(fPrinterName);
32
+                    if (!fPrinters.Contains(fPrinterName))
33
+                    {
34
+                        fPrinters.Add(fPrinterName);
35
+                    }
32 36
                 }
33 37
             }
38
+            catch (System.Exception)
39
+            {
40
+                throw;
41
+            }
34 42
             return fPrinters;
35 43
         }
36 44
 
@@ -69,4 +77,4 @@ namespace XHWK.WKTool.Utils
69 77
             p.WaitForExit(15000);
70 78
         }
71 79
     }
72
-}
80
+}

+ 53
- 58
星火微课/星火微课-正式.iss View File

@@ -3,7 +3,7 @@
3 3
 
4 4
 #define MyAppName "星火微课"  
5 5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.1.14"
6
+#define MyAppVersion "3.2.1"
7 7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8 8
 #define MyAppURL "http://www.xhkjedu.com/"
9 9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
@@ -56,61 +56,6 @@ Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Fil
56 56
 Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
57 57
 
58 58
 [Code]  
59
-// 自定义函数,判断软件是否运行,参数为需要判断的软件的exe名称
60
-function CheckSoftRun(strExeName: String): Boolean;
61
-// 变量定义
62
-var ErrorCode: Integer;
63
-var bRes: Boolean;
64
-var strFileContent: AnsiString;
65
-var strTmpPath: String;  // 临时目录
66
-var strTmpFile: String;  // 临时文件,保存查找软件数据结果
67
-var strCmdFind: String;  // 查找软件命令
68
-var strCmdKill: String;  // 终止软件命令
69
-begin
70
-  strTmpPath := GetTempDir();
71
-  strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
72
-  strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
73
-  strCmdKill := Format('/c taskkill /f /t /im %s', [strExeName]);
74
-  bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
75
-  if bRes then begin
76
-      bRes := LoadStringFromFile(strTmpFile, strFileContent);
77
-      strFileContent := Trim(strFileContent);
78
-      if bRes then begin
79
-         if StrToInt(strFileContent) > 0 then begin
80
-            if MsgBox(ExpandConstant('{cm:checkSoftTip}'), mbConfirmation, MB_OKCANCEL) = IDOK then begin
81
-             // 终止程序
82
-             ShellExec('open', ExpandConstant('{cmd}'), strCmdKill, '', SW_HIDE, ewNoWait, ErrorCode);
83
-             Result:= true;// 继续安装
84
-            end else begin
85
-             Result:= false;// 安装程序退出
86
-             Exit;
87
-            end;
88
-         end else begin
89
-            // 软件没在运行
90
-            Result:= true;
91
-            Exit;
92
-         end;
93
-      end;
94
-  end;
95
-  Result :=true;
96
-end;
97
-
98
-// 开始页下一步时判断软件是否运行
99
-function NextButtonClick(CurPageID: Integer): Boolean;
100
-begin
101
-  if 1=CurPageID then begin
102
-      Result := CheckSoftRun('{#MyAppExeName}');
103
-      Exit;
104
-  end; 
105
-  Result:= true;
106
-end;
107
-
108
-// 卸载时关闭软件
109
-function InitializeUninstall(): Boolean;
110
-begin
111
-  Result := CheckSoftRun('{#MyAppExeName}');
112
-end;
113
-
114 59
 function CheckVC():boolean;
115 60
 var Path:string; 
116 61
       ResultCode: Integer;  
@@ -232,5 +177,55 @@ begin
232 177
 end;   
233 178
 
234 179
 
235
-[CustomMessages]
236
-chinesesimp.checkSoftTip=安装程序检测到将安装的软件正在运行!%n%n点击"确定"终止软件后继续操作,否则点击"取消"。
180
+// 自定义函数,判断软件是否运行,参数为需要判断的软件的exe名称
181
+function CheckSoftRun(strExeName: String): Boolean;
182
+// 变量定义
183
+var ErrorCode: Integer;
184
+var bRes: Boolean;
185
+var strFileContent: AnsiString;
186
+var strTmpPath: String;  // 临时目录
187
+var strTmpFile: String;  // 临时文件,保存查找软件数据结果
188
+var strCmdFind: String;  // 查找软件命令
189
+var strCmdKill: String;  // 终止软件命令
190
+begin
191
+  strTmpPath := GetTempDir();
192
+  strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
193
+  strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
194
+  strCmdKill := Format('/c taskkill /f /t /im %s', [strExeName]);
195
+  bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
196
+  if bRes then begin
197
+      bRes := LoadStringFromFile(strTmpFile, strFileContent);
198
+      strFileContent := Trim(strFileContent);
199
+      if bRes then begin
200
+         if StrToInt(strFileContent) > 0 then begin
201
+            // 终止程序
202
+           ShellExec('open', ExpandConstant('{cmd}'), strCmdKill, '', SW_HIDE, ewNoWait, ErrorCode);
203
+           Result:= true;// 继续安装
204
+         end else begin
205
+            // 软件没在运行
206
+            Result:= true;
207
+         end;
208
+      end;
209
+  end;
210
+  Result :=true;
211
+end;
212
+
213
+// 开始页下一步时判断软件是否运行
214
+function NextButtonClick(CurPageID: Integer): Boolean;
215
+begin
216
+  if 1=CurPageID then begin
217
+      Result := CheckSoftRun('{#MyAppExeName}');
218
+  end 
219
+  else begin
220
+      Result:= true;
221
+   end;
222
+end;
223
+
224
+// 卸载时关闭软件
225
+function InitializeUninstall(): Boolean;
226
+begin
227
+  Result := CheckSoftRun('{#MyAppExeName}');
228
+end;
229
+
230
+
231
+

Loading…
Cancel
Save