|
@@ -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+CiAgPER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3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+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>
|