Ver código fonte

录制完全C#重写

tags/3.0.0
张剑 3 anos atrás
pai
commit
b492f42b95

+ 73
- 0
XHWK.WKTool/Utils/PrintUtils.cs Ver arquivo

@@ -0,0 +1,73 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Drawing.Printing;
4
+using System.Runtime.InteropServices;
5
+
6
+namespace XHWK.WKTool.Utils
7
+{
8
+    class PrintUtils
9
+    {
10
+        private static PrintDocument fPrintDocument = new PrintDocument();
11
+        /// <summary>
12
+        /// 获取本机默认打印机名称
13
+        /// </summary>
14
+        /// <returns></returns>
15
+        public static String DefaultPrinter()
16
+        {
17
+            return fPrintDocument.PrinterSettings.PrinterName;
18
+        }
19
+
20
+        /// <summary>
21
+        /// 获取打印机列表
22
+        /// </summary>
23
+        /// <returns></returns>
24
+        public static List<string> GetLocalPrinters()
25
+        {
26
+            List<string> fPrinters = new List<string>();
27
+            fPrinters.Add(DefaultPrinter()); //默认打印机始终出现在列表的第一项
28
+            foreach (string fPrinterName in PrinterSettings.InstalledPrinters)
29
+            {
30
+                if (!fPrinters.Contains(fPrinterName))
31
+                {
32
+                    fPrinters.Add(fPrinterName);
33
+                }
34
+            }
35
+            return fPrinters;
36
+        }
37
+
38
+        /// <summary>
39
+        /// 调用win api将指定名称的打印机设置为默认打印机
40
+        /// </summary>
41
+        /// <param name="Name"></param>
42
+        /// <returns></returns>
43
+        [DllImport("winspool.drv")]
44
+        public static extern bool SetDefaultPrinter(string Name);
45
+
46
+        /// <summary>
47
+        /// 打印
48
+        /// </summary>
49
+        /// <param name="PDFPath">打印文件的路径</param>
50
+        /// <param name="PrinterName">打印机的名称</param>
51
+        public static void Print(string PDFPath, string PrinterName)
52
+        {
53
+            //设置默认打印机
54
+            SetDefaultPrinter(PrinterName);
55
+            System.Diagnostics.Process p = new System.Diagnostics.Process();
56
+            //不能启动进程是否显示错误弹窗,如果文件没有打开方式会提示选择文件的打开方式
57
+            p.StartInfo.ErrorDialog = true;
58
+            //不显示调用程序窗口,但是对于某些应用无效
59
+            p.StartInfo.CreateNoWindow = true;
60
+            p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
61
+            //采用操作系统自动识别的模式
62
+            p.StartInfo.UseShellExecute = true;
63
+            //要打印的文件路径
64
+            p.StartInfo.FileName = PDFPath;
65
+            //指定执行的动作,是打印,即print,打开是 open
66
+            p.StartInfo.Verb = "print";
67
+            //开始打印
68
+            p.Start();
69
+            //等待15秒
70
+            p.WaitForExit(15000);
71
+        }
72
+    }
73
+}

+ 5
- 105
XHWK.WKTool/XHMicroLessonSystemWindow.xaml Ver arquivo

@@ -532,25 +532,9 @@
532 532
                                 Style="{DynamicResource TxbMesColor}"
533 533
                                 Text="打印机:" />
534 534
 
535
-                            <TextBlock
536
-                                Margin="523,0,273,10"
537
-                                Padding="50,5,0,0"
538
-                                FontSize="{Binding WordSize18}"
539
-                                Text="类型:"
540
-                                Visibility="Hidden" />
541
-                            <ComboBox
542
-                                x:Name="CbxType"
543
-                                Margin="626,0,64,10"
544
-                                Padding="30,0,10,0"
545
-                                VerticalContentAlignment="Center"
546
-                                BorderThickness="0"
547
-                                Cursor="Hand"
548
-                                DisplayMemberPath="Value"
549
-                                FontSize="{Binding WordSize12}"
550
-                                SelectedValuePath="Key"
551
-                                Visibility="Hidden" />
535
+
552 536
                         </Grid>
553
-                        <Grid Grid.Column="1">
537
+                        <Grid Grid.Column="1" Grid.ColumnSpan="2">
554 538
                             <ComboBox
555 539
                                 x:Name="cmbClass"
556 540
                                 Height="Auto"
@@ -568,93 +552,9 @@
568 552
                                 Style="{StaticResource stlComboBox}"
569 553
                                 Text="请选择" />
570 554
                         </Grid>
571
-                        <Grid Grid.Column="2">
572
-                            <TextBlock
573
-                                HorizontalAlignment="Right"
574
-                                VerticalAlignment="Center"
575
-                                FontSize="{Binding WordSize18}"
576
-                                Style="{DynamicResource TxbMesColor}"
577
-                                Text="份数:" />
578
-                        </Grid>
579
-                        <Grid Grid.Column="3">
580
-                            <Border
581
-                                Margin="0,12"
582
-                                Padding="0"
583
-                                BorderBrush="#FFDCDCDC"
584
-                                BorderThickness="1"
585
-                                CornerRadius="3">
586
-                                <Grid>
587
-                                    <Grid.ColumnDefinitions>
588
-                                        <ColumnDefinition Width="89*" />
589
-                                        <ColumnDefinition Width="21*" />
590
-                                    </Grid.ColumnDefinitions>
591
-                                    <Label
592
-                                        x:Name="txbNumberOfCopies"
593
-                                        Grid.Column="0"
594
-                                        Margin="0"
595
-                                        Padding="0"
596
-                                        HorizontalAlignment="Stretch"
597
-                                        VerticalAlignment="Stretch"
598
-                                        HorizontalContentAlignment="Center"
599
-                                        VerticalContentAlignment="Center"
600
-                                        Background="White"
601
-                                        Content="1"
602
-                                        FontSize="{Binding WordSize12}" />
603
-                                    <Grid Grid.Column="1" Margin="0">
604
-                                        <Grid.RowDefinitions>
605
-                                            <RowDefinition Height="10*" />
606
-                                            <RowDefinition Height="10*" />
607
-                                        </Grid.RowDefinitions>
608
-                                        <Button
609
-                                            x:Name="btnPrintAdd"
610
-                                            Grid.Row="0"
611
-                                            Margin="0"
612
-                                            Padding="0,-2"
613
-                                            Background="White"
614
-                                            BorderBrush="#FFDCDCDC"
615
-                                            Click="BtnPrintAdd_Click"
616
-                                            Content="+"
617
-                                            Cursor="Hand"
618
-                                            FontSize="{Binding WordSize12}" />
619
-                                        <Button
620
-                                            x:Name="btnPrintLess"
621
-                                            Grid.Row="1"
622
-                                            Margin="0"
623
-                                            Padding="0,-3"
624
-                                            Background="White"
625
-                                            BorderBrush="#FFDCDCDC"
626
-                                            Click="BtnPrintLess_Click"
627
-                                            Content="-"
628
-                                            Cursor="Hand"
629
-                                            FontSize="{Binding WordSize12}" />
630
-                                    </Grid>
631
-                                </Grid>
632
-                            </Border>
633
-                        </Grid>
634
-                        <Grid Grid.Column="4" Visibility="Hidden">
635
-                            <TextBlock
636
-                                HorizontalAlignment="Right"
637
-                                VerticalAlignment="Center"
638
-                                FontSize="{Binding WordSize18}"
639
-                                Style="{DynamicResource TxbMesColor}"
640
-                                Text="DPI:" />
641
-                        </Grid>
642
-                        <Grid Grid.Column="5" Visibility="Hidden">
643
-                            <ComboBox
644
-                                x:Name="CbxDpi"
645
-                                Height="Auto"
646
-                                Margin="0,12,20,12"
647
-                                Padding="20,0,10,0"
648
-                                HorizontalAlignment="Stretch"
649
-                                VerticalContentAlignment="Center"
650
-                                BorderThickness="0"
651
-                                Cursor="Hand"
652
-                                DisplayMemberPath="Value"
653
-                                FontSize="{Binding WordSize12}"
654
-                                SelectedValuePath="Key"
655
-                                Style="{StaticResource stlComboBox}"
656
-                                Text="600" />
657
-                        </Grid>
555
+
556
+
557
+
658 558
                         <Grid Grid.Column="6">
659 559
                             <StackPanel Orientation="Horizontal" />
660 560
                             <Button

+ 371
- 541
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 7
- 0
XHWK.WKTool/XHWK.WKTool.csproj Ver arquivo

@@ -143,6 +143,12 @@
143 143
     <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
144 144
       <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
145 145
     </Reference>
146
+    <Reference Include="NReco, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
147
+      <HintPath>..\packages\NReco.2.0.3.0\lib\net40\NReco.dll</HintPath>
148
+    </Reference>
149
+    <Reference Include="NReco.VideoConverter, Version=1.1.4.0, Culture=neutral, PublicKeyToken=395ccb334978a0cd, processorArchitecture=MSIL">
150
+      <HintPath>..\packages\NReco.VideoConverter.1.1.4\lib\net40\NReco.VideoConverter.dll</HintPath>
151
+    </Reference>
146 152
     <Reference Include="O2S.Components.PDFRender4NET">
147 153
       <HintPath>..\DLL\O2S.Components.PDFRender4NET.dll</HintPath>
148 154
     </Reference>
@@ -327,6 +333,7 @@
327 333
     <Compile Include="UploadWindow.xaml.cs">
328 334
       <DependentUpon>UploadWindow.xaml</DependentUpon>
329 335
     </Compile>
336
+    <Compile Include="Utils\PrintUtils.cs" />
330 337
     <Compile Include="VideoClipWindow.xaml.cs">
331 338
       <DependentUpon>VideoClipWindow.xaml</DependentUpon>
332 339
     </Compile>

+ 2
- 0
XHWK.WKTool/packages.config Ver arquivo

@@ -20,6 +20,8 @@
20 20
   <package id="log4net" version="2.0.12" targetFramework="net452" />
21 21
   <package id="NAudio" version="1.9.0" targetFramework="net452" />
22 22
   <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net452" />
23
+  <package id="NReco" version="2.0.3.0" targetFramework="net452" />
24
+  <package id="NReco.VideoConverter" version="1.1.4" targetFramework="net452" />
23 25
   <package id="System.Management" version="4.7.0" targetFramework="net452" />
24 26
   <package id="VisioForge.DotNet.Core.TRIAL" version="12.0.56" targetFramework="net452" />
25 27
   <package id="WpfAnimatedGif" version="2.0.0" targetFramework="net452" />

+ 5
- 4
XHWK.WKTool/system/FFMpeg.cs Ver arquivo

@@ -937,7 +937,10 @@ namespace Common.system
937 937
                 myProcess = new Process();
938 938
                 LogPath = CreateffmpegLog();
939 939
                 myProcess.StartInfo.FileName = ffmpegPath;   //ffmpeg.exe的绝对路径
940
-                myProcess.StartInfo.Arguments = "-i " + VideoPathName + " -i " + mp3path + " -acodec copy -vcodec libx264 " + "-s " + Width + "*" + Height + " " + VideoSavePathName;
940
+
941
+                string ffmpegstr = "-i " + VideoPathName + " -i " + mp3path + " -acodec copy -vcodec libx264 " + "-s " + Width + "*" + Height + " " + VideoSavePathName;
942
+                Console.WriteLine("ffmpegstr:"+ ffmpegstr);
943
+                myProcess.StartInfo.Arguments = ffmpegstr;
941 944
 
942 945
                 if (OutputVideoLog)
943 946
                 {
@@ -974,8 +977,6 @@ namespace Common.system
974 977
                 #endregion 进程是否已经释放
975 978
 
976 979
                 myProcess = null;
977
-                Thread.Sleep(200);
978
-                FileToolsCommon.DeleteFile(VideoPathName);
979 980
                 return true;
980 981
             }
981 982
             catch (Exception ex)
@@ -1594,7 +1595,7 @@ namespace Common.system
1594 1595
             }
1595 1596
             catch (Exception ex)
1596 1597
             {
1597
-                LogHelper.WriteErrLog("【麦克风】麦克风不可用:" + ex.Message, ex);
1598
+                LogHelper.WriteErrLog("【扬声器】扬声器不可用:" + ex.Message, ex);
1598 1599
                 return false;
1599 1600
             }
1600 1601
         }

+ 2
- 2
XHWK.WKTool/system/FileToolsCommon.cs Ver arquivo

@@ -965,14 +965,14 @@ namespace Common.system
965 965
                 Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.ReadKey);
966 966
             foreach (string subKeyName in uninstallNode.GetSubKeyNames())
967 967
             {
968
-                Console.WriteLine(" subKeyName:" + subKeyName);
968
+                //Console.WriteLine(" subKeyName:" + subKeyName);
969 969
                 Microsoft.Win32.RegistryKey subKey = uninstallNode.OpenSubKey(subKeyName);
970 970
                 object displayName = subKey.GetValue("DisplayName");
971 971
                 if (displayName != null)
972 972
                 {
973 973
                     if (displayName.ToString().Contains(softWareName))
974 974
                     {
975
-                        Console.WriteLine(uninstallNode.Name+" subKeyName:" + subKeyName);
975
+                        //Console.WriteLine(uninstallNode.Name+" subKeyName:" + subKeyName);
976 976
                         return true;
977 977
                         // MessageWindow.Show(displayName.ToString());  
978 978
                     }

Carregando…
Cancelar
Salvar