Browse Source

ppt转图片 画笔图标 工具栏

tags/录制修改前
zhangxueyang 4 years ago
parent
commit
8ecac05845

+ 4
- 0
Common/Common.csproj View File

@@ -71,6 +71,9 @@
71 71
     <Reference Include="NPOI.OpenXmlFormats">
72 72
       <HintPath>dlls\NPOI.OpenXmlFormats.dll</HintPath>
73 73
     </Reference>
74
+    <Reference Include="O2S.Components.PDFRender4NET">
75
+      <HintPath>..\dl\O2S.Components.PDFRender4NET.dll</HintPath>
76
+    </Reference>
74 77
     <Reference Include="PresentationCore" />
75 78
     <Reference Include="PresentationFramework" />
76 79
     <Reference Include="System" />
@@ -114,6 +117,7 @@
114 117
   </ItemGroup>
115 118
   <ItemGroup>
116 119
     <Compile Include="Model\DownloadInfoModel.cs" />
120
+    <Compile Include="system\PdfTrunImage.cs" />
117 121
     <Compile Include="system\BlackboardNew.cs" />
118 122
     <Compile Include="system\CameraHelper.cs" />
119 123
     <Compile Include="system\CLeopardZip.cs" />

+ 87
- 0
Common/system/PdfTrunImage.cs View File

@@ -0,0 +1,87 @@
1
+using System.Collections.Generic;
2
+using System.Drawing;
3
+using System.Drawing.Imaging;
4
+using System.IO;
5
+using O2S.Components.PDFRender4NET;
6
+
7
+namespace Common.system
8
+{
9
+    /// <summary>
10
+    /// 
11
+    /// Class to convert a pdf to an image using GhostScript DLL
12
+    /// Credit for this code go to:Rangel Avulso
13
+    /// i only fix a little bug and refactor a little
14
+    /// http://www.hrangel.com.br/index.php/2006/12/04/converter-pdf-para-imagem-jpeg-em-c/
15
+    /// </summary>
16
+    /// <seealso cref="http://www.hrangel.com.br/index.php/2006/12/04/converter-pdf-para-imagem-jpeg-em-c/"/>
17
+   public class PdfTrunImage
18
+    {
19
+        public enum Definition
20
+        {
21
+            One = 1, Two = 2, Three = 3, Four = 4, Five = 5, Six = 6, Seven = 7, Eight = 8, Nine = 9, Ten = 10
22
+        }
23
+
24
+        /// <summary>
25
+        /// 将PDF文档转换为图片的方法
26
+        /// </summary>
27
+        /// <param name="pdfInputPath">PDF文件路径</param>
28
+        /// <param name="imageOutputPath">图片输出路径</param>
29
+        /// <param name="imageName">生成图片的名字</param>
30
+        /// <param name="startPageNum">从PDF文档的第几页开始转换</param>
31
+        /// <param name="endPageNum">从PDF文档的第几页开始停止转换</param>
32
+        /// <param name="imageFormat">设置所需图片格式</param>
33
+        /// <param name="definition">设置图片的清晰度,数字越大越清晰</param>
34
+        public static List<string> ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
35
+            string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, Definition definition)
36
+        {
37
+            List<string> images = new List<string>();
38
+            try
39
+            {
40
+                PDFFile pdfFile = PDFFile.Open(pdfInputPath);
41
+
42
+                if (!Directory.Exists(imageOutputPath))
43
+                {
44
+                    Directory.CreateDirectory(imageOutputPath);
45
+                }
46
+
47
+                // validate pageNum
48
+                if (startPageNum <= 0)
49
+                {
50
+                    startPageNum = 1;
51
+                }
52
+
53
+                if (endPageNum==0||endPageNum > pdfFile.PageCount)
54
+                {
55
+                    endPageNum = pdfFile.PageCount;
56
+                }
57
+                if (startPageNum > endPageNum)
58
+                {
59
+                    int tempPageNum = startPageNum;
60
+                    startPageNum = endPageNum;
61
+                    endPageNum = startPageNum;
62
+                }
63
+
64
+                // start to convert each page
65
+                for (int i = startPageNum; i <= endPageNum; i++)
66
+                {
67
+                    Bitmap pageImage = pdfFile.GetPageImage(i - 1, 56 * (int)definition);
68
+                    string imgPath = imageOutputPath + imageName + i.ToString() + "." + imageFormat.ToString();
69
+                    pageImage.Save(imgPath, imageFormat);
70
+                    images.Add(imgPath);
71
+                    // 返回的图片绝对路径集合
72
+                    pageImage.Dispose();
73
+                }
74
+
75
+                pdfFile.Dispose();
76
+                return images;
77
+            }
78
+            catch (System.Exception ex)
79
+            {
80
+                LogHelper.WriteErrLog("PDF转图片" +
81
+                    "【PdfTrunImage】" + ex.Message, ex);
82
+                images = new List<string>();
83
+                return images;
84
+            }
85
+        }
86
+    }
87
+}

+ 119
- 1
XHWK.WKTool/PracticeWindow.xaml.cs View File

@@ -8,6 +8,7 @@ using System.Windows;
8 8
 using System.Windows.Controls;
9 9
 using System.Windows.Data;
10 10
 using System.Windows.Documents;
11
+using System.Windows.Ink;
11 12
 using System.Windows.Input;
12 13
 using System.Windows.Media;
13 14
 using System.Windows.Media.Imaging;
@@ -16,10 +17,12 @@ using System.Windows.Shapes;
16 17
 namespace XHWK.WKTool
17 18
 {
18 19
     /// <summary>
19
-    /// PracticeWindow.xaml 的交互逻辑
20
+    /// 录屏画板
20 21
     /// </summary>
21 22
     public partial class PracticeWindow : Window
22 23
     {
24
+        //声明一个 DrawingAttributes 类型的变量  
25
+        DrawingAttributes drawingAttributes;
23 26
         public PracticeWindow()
24 27
         {
25 28
             InitializeComponent();
@@ -27,11 +30,126 @@ namespace XHWK.WKTool
27 30
         public void Initialize(string _imgPath)
28 31
         {
29 32
             blackboard_canvas.Strokes.Clear();
33
+            blackboard_canvas.UseCustomCursor = true;
30 34
             //blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
31 35
             if (File.Exists(_imgPath))
32 36
             {
33 37
                 imgCanvas.Source = new BitmapImage(new Uri(_imgPath));
34 38
             }
39
+            //创建 DrawingAttributes 类的一个实例  
40
+            drawingAttributes = new DrawingAttributes();
41
+            //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
42
+            //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型  
43
+            blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
44
+            Pen();
45
+            blackboard_canvas.Cursor = Cursors.Pen;
46
+            //Cursor cus = new Cursor(@"G:\Icon.ico");
47
+            
48
+            //blackboard_canvas.Cursor = cus;
49
+        }
50
+
51
+
52
+
53
+        /// <summary>
54
+        /// 画笔颜色事件 白色
55
+        /// </summary>
56
+        /// <param name="sender"></param>
57
+        /// <param name="e"></param>
58
+        public void White()
59
+        {
60
+            drawingAttributes.Color = Colors.White;
61
+        }
62
+        /// <summary>
63
+        /// 画笔颜色事件 红色
64
+        /// </summary>
65
+        /// <param name="sender"></param>
66
+        /// <param name="e"></param>
67
+        public void Red()
68
+        {
69
+
70
+            //设置 DrawingAttributes 的 Color 属性设置颜色  
71
+            drawingAttributes.Color = Colors.Red;
72
+        }
73
+        /// <summary>
74
+        /// 画笔颜色事件 灰色
75
+        /// </summary>
76
+        /// <param name="sender"></param>
77
+        /// <param name="e"></param>
78
+        public void Gray()
79
+        {
80
+            drawingAttributes.Color = Colors.Gray;
81
+        }
82
+        /// <summary>
83
+        /// 画笔颜色事件 青色
84
+        /// </summary>
85
+        /// <param name="sender"></param>
86
+        /// <param name="e"></param>
87
+        public void CyanBlue()
88
+        {
89
+            drawingAttributes.Color = Colors.LimeGreen;
90
+        }
91
+        /// <summary>
92
+        /// 画笔颜色事件 黄色
93
+        /// </summary>
94
+        /// <param name="sender"></param>
95
+        /// <param name="e"></param>
96
+        public void Yellow()
97
+        {
98
+            drawingAttributes.Color = Colors.Gold;
99
+        }
100
+        /// <summary>
101
+        /// 画笔颜色事件 蓝色
102
+        /// </summary>
103
+        /// <param name="sender"></param>
104
+        /// <param name="e"></param>
105
+        public void Blue()
106
+        {
107
+            drawingAttributes.Color = Colors.DeepSkyBlue;
108
+        }
109
+        /// <summary>
110
+        /// 画笔粗细事件 细
111
+        /// </summary>
112
+        /// <param name="sender"></param>
113
+        /// <param name="e"></param>
114
+        public void Fine()
115
+        {
116
+            drawingAttributes.Width = 1;
117
+            drawingAttributes.Height = 1;
118
+        }
119
+        /// <summary>
120
+        /// 画笔粗细事件 中
121
+        /// </summary>
122
+        /// <param name="sender"></param>
123
+        /// <param name="e"></param>
124
+        public void In()
125
+        {
126
+            drawingAttributes.Width = 3;
127
+            drawingAttributes.Height = 3;
128
+        }
129
+        /// <summary>
130
+        /// 画笔粗细事件 粗
131
+        /// </summary>
132
+        /// <param name="sender"></param>
133
+        /// <param name="e"></param>
134
+        public void Crude()
135
+        {
136
+            drawingAttributes.Width = 5;
137
+            drawingAttributes.Height = 5;
138
+        }
139
+        public void Eraser() 
140
+        {
141
+            //this.type = ZPenType.Erase;
142
+            blackboard_canvas.UseCustomCursor = false;
143
+            blackboard_canvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
144
+            blackboard_canvas.EraserShape = new EllipseStylusShape(64, 64, 0);
145
+        }
146
+        public void Pen()
147
+        {
148
+            blackboard_canvas.EditingMode = InkCanvasEditingMode.Ink;
149
+            blackboard_canvas.UseCustomCursor = true;
150
+            drawingAttributes.FitToCurve = true;
151
+            drawingAttributes.IgnorePressure = false;
152
+            blackboard_canvas.Cursor = Cursors.Pen;
35 153
         }
36 154
     }
37 155
 }

+ 5
- 5
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml View File

@@ -30,13 +30,13 @@
30 30
                     <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0">
31 31
                         <Image Source="./Images/Toobar12.png"/>
32 32
                     </Button>
33
-                    <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0">
33
+                    <Button  Cursor="Hand" x:Name="btnPen" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0" Click="BtnPen_Click">
34 34
                         <Image Source="./Images/Toobar9.png"/>
35 35
                     </Button>
36 36
                     <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0">
37 37
                         <Image Source="./Images/Toobar16.png"/>
38 38
                     </Button>
39
-                    <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0">
39
+                    <Button  Cursor="Hand" x:Name="btnEraser" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0" Click="BtnEraser_Click">
40 40
                         <Image Source="./Images/Toobar3.png"/>
41 41
                     </Button>
42 42
                     <Button  Cursor="Hand" x:Name="btnColour" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="0,5,0,0" Click="BtnColour_Click">
@@ -66,9 +66,9 @@
66 66
             <Grid Grid.Row="0" x:Name="gridThickness" Visibility="Collapsed">
67 67
                 <Image Grid.Row="0"  Source="./Images/Toobar21.png" HorizontalAlignment="Right" Margin="0,200,62,0"/>
68 68
                 <StackPanel Grid.Row="0" Orientation="Vertical" HorizontalAlignment="Right" Margin="0,260,62,0">
69
-                    <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Background="#FFFFFF" Height="3" Width="20" Margin="0,0,0,0"/>
70
-                    <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Background="#FFFFFF" Height="5" Width="20" Margin="0,10,0,0"/>
71
-                    <Button  Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Background="#FFFFFF" Height="10" Width="20" Margin="0,10,0,0"/>
69
+                    <Button  Cursor="Hand" x:Name="btnFine" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Background="#FFFFFF" Height="3" Width="20" Margin="0,0,0,0" Click="BtnFine_Click"/>
70
+                    <Button  Cursor="Hand" x:Name="btnIn" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Background="#FFFFFF" Height="5" Width="20" Margin="0,10,0,0" Click="BtnIn_Click"/>
71
+                    <Button  Cursor="Hand" x:Name="btnCrude" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Background="#FFFFFF" Height="10" Width="20" Margin="0,10,0,0" Click="BtnCrude_Click"/>
72 72
                 </StackPanel>
73 73
             </Grid>
74 74
 

+ 62
- 10
XHWK.WKTool/ScreenRecordingToolbarWindow.xaml.cs View File

@@ -65,6 +65,7 @@ namespace XHWK.WKTool
65 65
         }
66 66
         #endregion
67 67
 
68
+        #region 事件
68 69
         #region 录制
69 70
         /// <summary>
70 71
         /// 开始或暂停录制
@@ -75,7 +76,7 @@ namespace XHWK.WKTool
75 76
         {
76 77
             if (IsSuspend)
77 78
             {
78
-                if(IsFirstRS)
79
+                if (IsFirstRS)
79 80
                 {
80 81
                     RecordingPath = APP.WKData.WkPath;
81 82
                     //FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
@@ -245,7 +246,6 @@ namespace XHWK.WKTool
245 246
         /// 屏幕宽
246 247
         /// </summary>
247 248
         internal double pwidth = SystemParameters.PrimaryScreenWidth;
248
-
249 249
         /// <summary>
250 250
         /// 屏幕高
251 251
         /// </summary>
@@ -279,8 +279,6 @@ namespace XHWK.WKTool
279 279
             gridColour.Visibility = Visibility.Visible;
280 280
             gridThickness.Visibility = Visibility.Collapsed;
281 281
         }
282
-        #endregion
283
-
284 282
         /// <summary>
285 283
         /// 白色
286 284
         /// </summary>
@@ -288,7 +286,8 @@ namespace XHWK.WKTool
288 286
         /// <param name="e"></param>
289 287
         private void BtnWhite_Click(object sender, RoutedEventArgs e)
290 288
         {
291
-            drawingAttributes.Color = Colors.White;
289
+            //drawingAttributes.Color = Colors.White;
290
+            APP.W_PracticeWindow.White();
292 291
         }
293 292
         /// <summary>
294 293
         /// 红色
@@ -297,7 +296,8 @@ namespace XHWK.WKTool
297 296
         /// <param name="e"></param>
298 297
         private void BtnRed_Click(object sender, RoutedEventArgs e)
299 298
         {
300
-            drawingAttributes.Color = Colors.Red;
299
+            //drawingAttributes.Color = Colors.Red;
300
+            APP.W_PracticeWindow.Red();
301 301
         }
302 302
         /// <summary>
303 303
         /// 黄色
@@ -306,7 +306,8 @@ namespace XHWK.WKTool
306 306
         /// <param name="e"></param>
307 307
         private void BtnYellow_Click(object sender, RoutedEventArgs e)
308 308
         {
309
-            drawingAttributes.Color = Colors.Gold;
309
+            //drawingAttributes.Color = Colors.Gold;
310
+            APP.W_PracticeWindow.Yellow();
310 311
         }
311 312
         /// <summary>
312 313
         /// 青色
@@ -315,7 +316,8 @@ namespace XHWK.WKTool
315 316
         /// <param name="e"></param>
316 317
         private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
317 318
         {
318
-            drawingAttributes.Color = Colors.LimeGreen;
319
+            //drawingAttributes.Color = Colors.LimeGreen;
320
+            APP.W_PracticeWindow.CyanBlue();
319 321
         }
320 322
         /// <summary>
321 323
         /// 灰色
@@ -324,7 +326,8 @@ namespace XHWK.WKTool
324 326
         /// <param name="e"></param>
325 327
         private void BtnGray_Click(object sender, RoutedEventArgs e)
326 328
         {
327
-            drawingAttributes.Color = Colors.Gray;
329
+            //drawingAttributes.Color = Colors.Gray;
330
+            APP.W_PracticeWindow.Gray();
328 331
         }
329 332
         /// <summary>
330 333
         /// 蓝色
@@ -333,7 +336,56 @@ namespace XHWK.WKTool
333 336
         /// <param name="e"></param>
334 337
         private void BtnBlue_Click(object sender, RoutedEventArgs e)
335 338
         {
336
-            drawingAttributes.Color = Colors.DeepSkyBlue;
339
+            //drawingAttributes.Color = Colors.DeepSkyBlue;
340
+            APP.W_PracticeWindow.Blue();
341
+        }
342
+        /// <summary>
343
+        /// 画笔 细
344
+        /// </summary>
345
+        /// <param name="sender"></param>
346
+        /// <param name="e"></param>
347
+        private void BtnFine_Click(object sender, RoutedEventArgs e)
348
+        {
349
+            APP.W_PracticeWindow.Fine();
350
+        }
351
+        /// <summary>
352
+        /// 画笔 中
353
+        /// </summary>
354
+        /// <param name="sender"></param>
355
+        /// <param name="e"></param>
356
+        private void BtnIn_Click(object sender, RoutedEventArgs e)
357
+        {
358
+            APP.W_PracticeWindow.In();
359
+        }
360
+        /// <summary>
361
+        /// 画笔粗
362
+        /// </summary>
363
+        /// <param name="sender"></param>
364
+        /// <param name="e"></param>
365
+        private void BtnCrude_Click(object sender, RoutedEventArgs e)
366
+        {
367
+            APP.W_PracticeWindow.Crude();
368
+        }
369
+        /// <summary>
370
+        /// 橡皮
371
+        /// </summary>
372
+        /// <param name="sender"></param>
373
+        /// <param name="e"></param>
374
+        private void BtnEraser_Click(object sender, RoutedEventArgs e)
375
+        {
376
+            APP.W_PracticeWindow.Eraser();
377
+        }
378
+        #endregion
379
+
380
+        #endregion
381
+        /// <summary>
382
+        /// 🖊
383
+        /// </summary>
384
+        /// <param name="sender"></param>
385
+        /// <param name="e"></param>
386
+        private void BtnPen_Click(object sender, RoutedEventArgs e)
387
+        {
388
+            APP.W_PracticeWindow.Pen();
337 389
         }
338 390
     }
339 391
 }

+ 2
- 14
XHWK.WKTool/XHMicroLessonSystemWindow.xaml View File

@@ -150,8 +150,8 @@
150 150
                 <wfi:WindowsFormsHost Grid.Row="0" Grid.Column="1" x:Name="wfhCamera" Height="124" Width="172" HorizontalAlignment="Right" Margin="0,10,30.10,0" VerticalAlignment="Top">
151 151
                     <aforge:VideoSourcePlayer x:Name="player" Height="124" Width="172"  />
152 152
                 </wfi:WindowsFormsHost>
153
-                <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFFFFF" Width="240" HorizontalAlignment="Right"
154
-            Height="58" Margin="0,718,50.4,17.701" Grid.Column="1">
153
+                <StackPanel Grid.Row="0" Orientation="Horizontal" Background="#FFFFFF" Width="180" HorizontalAlignment="Right"
154
+            Height="58" Margin="0,718,50,0" Grid.Column="1">
155 155
                     <Button Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
156 156
                     x:Name="last_button"
157 157
                     Width="60"
@@ -193,18 +193,6 @@
193 193
                             </StackPanel>
194 194
                         </Button.Content>
195 195
                     </Button>
196
-
197
-                    <Button Cursor="Hand" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
198
-                    x:Name="add_button"
199
-                    Width="60"
200
-                    Click="add_button_Click">
201
-                        <Button.Content>
202
-                            <StackPanel>
203
-                                <Image Width="16" Source=".\Images\class_p3.png" />
204
-                                <TextBlock Margin="0,4,0,0" Text="添加" />
205
-                            </StackPanel>
206
-                        </Button.Content>
207
-                    </Button>
208 196
                 </StackPanel>
209 197
             </Grid>
210 198
             <!--设置-->

+ 100
- 45
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

@@ -1,8 +1,6 @@
1 1
 using Aspose.Words;
2 2
 using Aspose.Words.Saving;
3
-
4 3
 using Common.system;
5
-
6 4
 using System;
7 5
 using System.Collections.Generic;
8 6
 using System.Drawing.Imaging;
@@ -14,25 +12,11 @@ using System.Windows.Ink;
14 12
 using System.Windows.Input;
15 13
 using System.Windows.Media;
16 14
 using System.Windows.Media.Imaging;
17
-
18 15
 using XHWK.Model;
19
-
20
-
21
-using System;
22
-using System.Collections.Generic;
23
-
24
-using System.Text;
25
-using System.Windows;
26 16
 using System.Windows.Controls;
27
-using System.Windows.Data;
28
-using System.Windows.Documents;
29
-using System.Windows.Input;
30
-using System.Windows.Media;
31
-using System.Windows.Media.Imaging;
32
-using System.Windows.Navigation;
33
-using System.Windows.Shapes;
34
-using System.Diagnostics;
35 17
 using ComeCapture;
18
+using Aspose.Slides;
19
+using static Common.system.PdfTrunImage;
36 20
 
37 21
 namespace XHWK.WKTool
38 22
 {
@@ -41,7 +25,7 @@ namespace XHWK.WKTool
41 25
     /// </summary>
42 26
     public partial class XHMicroLessonSystemWindow : Window
43 27
     {
44
-        #region 初始值
28
+        #region 字段
45 29
         /// <summary>
46 30
         /// 文件目录窗口
47 31
         /// </summary>
@@ -65,7 +49,9 @@ namespace XHWK.WKTool
65 49
         /// </summary>
66 50
         public XHMicroLessonSystemWindow()
67 51
         {
52
+            new Aspose.Pdf.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
68 53
             InitializeComponent();
54
+
69 55
             myblackboard = new BlackboardNew(blackboard_canvas);
70 56
             APP.pageData.pagenum = 1;
71 57
             APP.pageData.currpage = 1;
@@ -94,11 +80,11 @@ namespace XHWK.WKTool
94 80
             //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用  
95 81
             //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型  
96 82
             blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
83
+            blackboard_canvas.UseCustomCursor = true;
97 84
             drawingAttributes.FitToCurve = true;
98
-
85
+            drawingAttributes.IgnorePressure = false;
86
+            blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
99 87
             wfhCamera.Visibility = Visibility.Hidden;
100
-
101
-
102 88
         }
103 89
         #endregion
104 90
 
@@ -173,7 +159,7 @@ namespace XHWK.WKTool
173 159
             //显示在右下角
174 160
 
175 161
             APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 10;
176
-            APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 60;
162
+            APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 160;
177 163
             APP.W_ScreenRecordingToolbarWindow.Topmost = true;
178 164
             APP.W_ScreenRecordingToolbarWindow.Show();
179 165
             Hide();
@@ -504,7 +490,7 @@ namespace XHWK.WKTool
504 490
                 string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
505 491
                 ofd = new System.Windows.Forms.OpenFileDialog
506 492
                 {
507
-                    Filter = "文档|*.docx;*.doc",
493
+                    Filter = "文档|*.docx;*.doc;*ppt",
508 494
                     InitialDirectory = desktopPath,
509 495
                     Multiselect = false,
510 496
                     AddExtension = true,
@@ -517,7 +503,7 @@ namespace XHWK.WKTool
517 503
                         Thread.Sleep(400);
518 504
                         Dispatcher.Invoke(new Action(() =>
519 505
                         {
520
-                            openDialog();
506
+                            OpenDialogPPT();
521 507
                         }
522 508
                             ));
523 509
                     })
@@ -530,7 +516,7 @@ namespace XHWK.WKTool
530 516
                 LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
531 517
             }
532 518
         }
533
-        private void openDialog()
519
+        private void OpenDialog()
534 520
         {
535 521
             result = ofd.ShowDialog();
536 522
             if (result == System.Windows.Forms.DialogResult.OK)
@@ -544,17 +530,85 @@ namespace XHWK.WKTool
544 530
                     for (int i = 0; i < APP.Paths.Length; i++)
545 531
                     {
546 532
                         APP.pageData.pagenum += 1;
547
-                        //APP.pageData.currpage = APP.pageData.pagenum;
548
-                        //myblackboard.changepage(APP.pageData.currpage - 1);
549 533
                     }
550 534
                     if (APP.pageData.pagenum > 1)
551 535
                     {
552 536
                         APP.pageData.pagenum -= 1;
553 537
                     }
554
-                    if (APP.pageData.currpage > 1)
538
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
539
+                    {
540
+                        imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
541
+                    }
542
+                    else
543
+                    {
544
+                        imgCanvas.Source = null;
545
+                    }
546
+                }
547
+            }
548
+        }
549
+        private void OpenDialogPPT()
550
+        {
551
+            result = ofd.ShowDialog();
552
+            if (result == System.Windows.Forms.DialogResult.OK)
553
+            {
554
+                if (ofd.FileName != "")
555
+                {
556
+                    #region PPT转PDF
557
+                    string filepath = ofd.FileName;
558
+                    string path = ofd.SafeFileName.Replace(".ppt", "").Trim();
559
+                    string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
560
+                    path = pathTemp + path + ".pdf";
561
+                    //PPT转PDF
562
+                    Presentation ppt = new Presentation(filepath);
563
+                    ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf); 
564
+                    #endregion
565
+
566
+
567
+                    #region PDF转图片
568
+                    // 图片绝对路径集合
569
+                    List<string> images = new List<string>();
570
+                    string directoryPath = pathTemp;
571
+                    //aspose许可证
572
+                    //Aspose.Pdf.License l = new Aspose.Pdf.License();
573
+                    //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
574
+                    //l.SetLicense(licenseName);
575
+                    //定义Jpeg转换设备
576
+                    Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
577
+                    var device = new Aspose.Pdf.Devices.JpegDevice();
578
+                    //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
579
+                    //directoryPath += quality;
580
+                    Directory.CreateDirectory(directoryPath);
581
+                    //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
582
+                    device = new Aspose.Pdf.Devices.JpegDevice(100);
583
+                    //遍历每一页转为jpg
584
+                    for (var i = 1; i <= document.Pages.Count; i++)
585
+                    {
586
+                        long ii = Timestamp();
587
+                        string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
588
+                        images.Add(filePathOutPut);
589
+                        FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
590
+                        try
591
+                        {
592
+                            device.Process(document.Pages[i], fs);
593
+                            fs.Close();
594
+                        }
595
+                        catch (Exception ex)
596
+                        {
597
+                            fs.Close();
598
+                            File.Delete(filePathOutPut);
599
+                        }
600
+                    } 
601
+                    #endregion
602
+
603
+                    APP.Paths = images.ToArray(); 
604
+
605
+                    for (int i = 0; i < APP.Paths.Length; i++)
606
+                    {
607
+                        APP.pageData.pagenum += 1;
608
+                    }
609
+                    if (APP.pageData.pagenum > 1)
555 610
                     {
556
-                        //APP.pageData.currpage -= 1;
557
-                        //myblackboard.changepage(APP.pageData.currpage - 1);
611
+                        APP.pageData.pagenum -= 1;
558 612
                     }
559 613
                     if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
560 614
                     {
@@ -567,6 +621,16 @@ namespace XHWK.WKTool
567 621
                 }
568 622
             }
569 623
         }
624
+        /// <summary>
625
+        /// 返回一个时间戳到毫秒
626
+        /// </summary>
627
+        /// <returns></returns>
628
+        public static long Timestamp()
629
+        {
630
+            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
631
+            long timestr = Convert.ToInt64(ts.TotalMilliseconds);
632
+            return timestr;
633
+        }
570 634
         #region 录制窗口
571 635
         #region 变量
572 636
         /// <summary>
@@ -601,7 +665,6 @@ namespace XHWK.WKTool
601 665
         /// 是否开始截图计数
602 666
         /// </summary>
603 667
         bool IsStartCount = false;
604
-
605 668
         #endregion
606 669
         /// <summary>
607 670
         /// 录制窗口内容
@@ -846,6 +909,10 @@ namespace XHWK.WKTool
846 909
                 Login();
847 910
                 return;
848 911
             }
912
+            APP.pageData.pagenum += 1;
913
+            APP.pageData.currpage = APP.pageData.pagenum;
914
+            myblackboard.changepage(APP.pageData.currpage - 1);
915
+            imgCanvas.Source = null;
849 916
         }
850 917
         /// <summary>
851 918
         /// 打印事件
@@ -912,7 +979,7 @@ namespace XHWK.WKTool
912 979
                 if (APP.Paths.Length > 0)
913 980
                 {
914 981
 
915
-                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
982
+                    if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.Paths.Length)
916 983
                     {
917 984
                         imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
918 985
                     }
@@ -928,18 +995,6 @@ namespace XHWK.WKTool
928 995
             }
929 996
         }
930 997
         /// <summary>
931
-        /// 添加
932
-        /// </summary>
933
-        /// <param name="sender"></param>
934
-        /// <param name="e"></param>
935
-        private void add_button_Click(object sender, RoutedEventArgs e)
936
-        {
937
-            APP.pageData.pagenum += 1;
938
-            APP.pageData.currpage = APP.pageData.pagenum;
939
-            myblackboard.changepage(APP.pageData.currpage - 1);
940
-            imgCanvas.Source = null;
941
-        }
942
-        /// <summary>
943 998
         /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
944 999
         /// "ImageFile", 1, 20, ImageFormat.Png, 256);
945 1000
         /// </summary>

+ 6
- 0
XHWK.WKTool/XHWK.WKTool.csproj View File

@@ -53,6 +53,12 @@
53 53
     <Reference Include="AForge.Video.DirectShow, Version=2.2.5.0, Culture=neutral, PublicKeyToken=61ea4348d43881b7, processorArchitecture=MSIL">
54 54
       <HintPath>..\packages\AForge.Video.DirectShow.2.2.5\lib\AForge.Video.DirectShow.dll</HintPath>
55 55
     </Reference>
56
+    <Reference Include="Aspose.PDF, Version=19.1.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56, processorArchitecture=MSIL">
57
+      <HintPath>..\packages\Aspose.PDF.19.1.0\lib\net4.0\Aspose.PDF.dll</HintPath>
58
+    </Reference>
59
+    <Reference Include="Aspose.Slides">
60
+      <HintPath>..\dl\Aspose.Slides.dll</HintPath>
61
+    </Reference>
56 62
     <Reference Include="Aspose.Words">
57 63
       <HintPath>..\dl\Aspose.Words.dll</HintPath>
58 64
     </Reference>

+ 1
- 0
XHWK.WKTool/packages.config View File

@@ -6,5 +6,6 @@
6 6
   <package id="AForge.Math" version="2.2.5" targetFramework="net452" />
7 7
   <package id="AForge.Video" version="2.2.5" targetFramework="net452" />
8 8
   <package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net452" />
9
+  <package id="Aspose.PDF" version="19.1.0" targetFramework="net452" />
9 10
   <package id="WpfAnimatedGif" version="2.0.0" targetFramework="net452" />
10 11
 </packages>

BIN
dl/Aspose.Slides.dll View File


BIN
dl/O2S.Components.PDFRender4NET.dll View File


Loading…
Cancel
Save