|
@@ -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>
|
|
@@ -53,8 +37,11 @@ namespace XHWK.WKTool
|
53
|
37
|
private System.Windows.Forms.OpenFileDialog ofd;
|
54
|
38
|
//声明一个 DrawingAttributes 类型的变量
|
55
|
39
|
DrawingAttributes drawingAttributes;
|
56
|
|
-
|
57
|
40
|
Model_Video VideoInfo = null;
|
|
41
|
+ //定义事件
|
|
42
|
+ public event ChangeTextHandler ChangeTextEvent;
|
|
43
|
+ //定义委托
|
|
44
|
+ public delegate void ChangeTextHandler(string text);
|
58
|
45
|
#endregion
|
59
|
46
|
|
60
|
47
|
#region 初始化
|
|
@@ -63,7 +50,9 @@ namespace XHWK.WKTool
|
63
|
50
|
/// </summary>
|
64
|
51
|
public XHMicroLessonSystemWindow()
|
65
|
52
|
{
|
|
53
|
+ 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=")));
|
66
|
54
|
InitializeComponent();
|
|
55
|
+
|
67
|
56
|
myblackboard = new BlackboardNew(blackboard_canvas);
|
68
|
57
|
APP.pageData.pagenum = 1;
|
69
|
58
|
APP.pageData.currpage = 1;
|
|
@@ -92,11 +81,11 @@ namespace XHWK.WKTool
|
92
|
81
|
//将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
|
93
|
82
|
//InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
|
94
|
83
|
blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
|
|
84
|
+ blackboard_canvas.UseCustomCursor = true;
|
95
|
85
|
drawingAttributes.FitToCurve = true;
|
96
|
|
-
|
|
86
|
+ drawingAttributes.IgnorePressure = false;
|
|
87
|
+ blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
|
97
|
88
|
wfhCamera.Visibility = Visibility.Hidden;
|
98
|
|
-
|
99
|
|
-
|
100
|
89
|
}
|
101
|
90
|
#endregion
|
102
|
91
|
|
|
@@ -169,9 +158,11 @@ namespace XHWK.WKTool
|
169
|
158
|
APP.W_ScreenRecordingToolbarWindow.Initialize();
|
170
|
159
|
}
|
171
|
160
|
//显示在右下角
|
172
|
|
- APP.W_ScreenRecordingToolbarWindow.Show();
|
|
161
|
+
|
173
|
162
|
APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 10;
|
174
|
|
- APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 60;
|
|
163
|
+ APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 160;
|
|
164
|
+ APP.W_ScreenRecordingToolbarWindow.Topmost = true;
|
|
165
|
+ APP.W_ScreenRecordingToolbarWindow.Show();
|
175
|
166
|
Hide();
|
176
|
167
|
}
|
177
|
168
|
/// <summary>
|
|
@@ -297,12 +288,12 @@ namespace XHWK.WKTool
|
297
|
288
|
/// <param name="e"></param>
|
298
|
289
|
private void BtnWhite_Click(object sender, RoutedEventArgs e)
|
299
|
290
|
{
|
300
|
|
- //创建 DrawingAttributes 类的一个实例
|
301
|
|
- drawingAttributes = new DrawingAttributes();
|
302
|
|
- //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
|
303
|
|
- //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
|
304
|
|
- blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
|
305
|
|
- //设置 DrawingAttributes 的 Color 属性设置颜色
|
|
291
|
+ ////创建 DrawingAttributes 类的一个实例
|
|
292
|
+ //drawingAttributes = new DrawingAttributes();
|
|
293
|
+ ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
|
|
294
|
+ ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
|
|
295
|
+ //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
|
|
296
|
+ ////设置 DrawingAttributes 的 Color 属性设置颜色
|
306
|
297
|
drawingAttributes.Color = Colors.White;
|
307
|
298
|
}
|
308
|
299
|
/// <summary>
|
|
@@ -442,14 +433,39 @@ namespace XHWK.WKTool
|
442
|
433
|
{
|
443
|
434
|
APP.W_JieTuWindow = new JieTuWindow();
|
444
|
435
|
// 订阅事件
|
445
|
|
- //APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
|
446
|
|
- //APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
|
|
436
|
+ APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
|
|
437
|
+ APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
|
447
|
438
|
APP.W_JieTuWindow.Show();
|
448
|
439
|
}
|
449
|
440
|
|
450
|
441
|
//imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
|
451
|
442
|
}
|
452
|
443
|
/// <summary>
|
|
444
|
+ /// 截图关闭窗口
|
|
445
|
+ /// </summary>
|
|
446
|
+ /// <param name="text"></param>
|
|
447
|
+ private void frm_ChangeTextEvent(string text)
|
|
448
|
+ {
|
|
449
|
+ if ("关闭窗口".Equals(text))
|
|
450
|
+ {
|
|
451
|
+ if(!string.IsNullOrWhiteSpace(APP.ImgPath)&&File.Exists(APP.ImgPath))
|
|
452
|
+ {
|
|
453
|
+ APP.JPaths[APP.pageData.currpage]= APP.ImgPath;
|
|
454
|
+ if(!string.IsNullOrWhiteSpace(APP.JPaths[APP.pageData.currpage]))
|
|
455
|
+ {
|
|
456
|
+ imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
|
|
457
|
+ }
|
|
458
|
+ }
|
|
459
|
+ }
|
|
460
|
+ }
|
|
461
|
+ /// <summary>
|
|
462
|
+ /// 截图关闭 非正常关闭截图时,截图清空
|
|
463
|
+ /// </summary>
|
|
464
|
+ private void JietuWindow_click_closeJietuWindowClick()
|
|
465
|
+ {
|
|
466
|
+ APP.W_JieTuWindow = null;
|
|
467
|
+ }
|
|
468
|
+ /// <summary>
|
453
|
469
|
/// 获取时间戳
|
454
|
470
|
/// </summary>
|
455
|
471
|
/// <returns></returns>
|
|
@@ -475,7 +491,7 @@ namespace XHWK.WKTool
|
475
|
491
|
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
|
476
|
492
|
ofd = new System.Windows.Forms.OpenFileDialog
|
477
|
493
|
{
|
478
|
|
- Filter = "文档|*.docx;*.doc",
|
|
494
|
+ Filter = "文档|*.docx;*.doc;*ppt",
|
479
|
495
|
InitialDirectory = desktopPath,
|
480
|
496
|
Multiselect = false,
|
481
|
497
|
AddExtension = true,
|
|
@@ -488,7 +504,7 @@ namespace XHWK.WKTool
|
488
|
504
|
Thread.Sleep(400);
|
489
|
505
|
Dispatcher.Invoke(new Action(() =>
|
490
|
506
|
{
|
491
|
|
- openDialog();
|
|
507
|
+ OpenDialogPPT();
|
492
|
508
|
}
|
493
|
509
|
));
|
494
|
510
|
})
|
|
@@ -501,7 +517,7 @@ namespace XHWK.WKTool
|
501
|
517
|
LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
|
502
|
518
|
}
|
503
|
519
|
}
|
504
|
|
- private void openDialog()
|
|
520
|
+ private void OpenDialog()
|
505
|
521
|
{
|
506
|
522
|
result = ofd.ShowDialog();
|
507
|
523
|
if (result == System.Windows.Forms.DialogResult.OK)
|
|
@@ -515,17 +531,85 @@ namespace XHWK.WKTool
|
515
|
531
|
for (int i = 0; i < APP.Paths.Length; i++)
|
516
|
532
|
{
|
517
|
533
|
APP.pageData.pagenum += 1;
|
518
|
|
- //APP.pageData.currpage = APP.pageData.pagenum;
|
519
|
|
- //myblackboard.changepage(APP.pageData.currpage - 1);
|
520
|
534
|
}
|
521
|
535
|
if (APP.pageData.pagenum > 1)
|
522
|
536
|
{
|
523
|
537
|
APP.pageData.pagenum -= 1;
|
524
|
538
|
}
|
525
|
|
- if (APP.pageData.currpage > 1)
|
|
539
|
+ if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
|
540
|
+ {
|
|
541
|
+ imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));
|
|
542
|
+ }
|
|
543
|
+ else
|
|
544
|
+ {
|
|
545
|
+ imgCanvas.Source = null;
|
|
546
|
+ }
|
|
547
|
+ }
|
|
548
|
+ }
|
|
549
|
+ }
|
|
550
|
+ private void OpenDialogPPT()
|
|
551
|
+ {
|
|
552
|
+ result = ofd.ShowDialog();
|
|
553
|
+ if (result == System.Windows.Forms.DialogResult.OK)
|
|
554
|
+ {
|
|
555
|
+ if (ofd.FileName != "")
|
|
556
|
+ {
|
|
557
|
+ #region PPT转PDF
|
|
558
|
+ string filepath = ofd.FileName;
|
|
559
|
+ string path = ofd.SafeFileName.Replace(".ppt", "").Trim();
|
|
560
|
+ string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
|
561
|
+ path = pathTemp + path + ".pdf";
|
|
562
|
+ //PPT转PDF
|
|
563
|
+ Presentation ppt = new Presentation(filepath);
|
|
564
|
+ ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
|
|
565
|
+ #endregion
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+ #region PDF转图片
|
|
569
|
+ // 图片绝对路径集合
|
|
570
|
+ List<string> images = new List<string>();
|
|
571
|
+ string directoryPath = pathTemp;
|
|
572
|
+ //aspose许可证
|
|
573
|
+ //Aspose.Pdf.License l = new Aspose.Pdf.License();
|
|
574
|
+ //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
|
|
575
|
+ //l.SetLicense(licenseName);
|
|
576
|
+ //定义Jpeg转换设备
|
|
577
|
+ Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
|
|
578
|
+ var device = new Aspose.Pdf.Devices.JpegDevice();
|
|
579
|
+ //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
|
|
580
|
+ //directoryPath += quality;
|
|
581
|
+ Directory.CreateDirectory(directoryPath);
|
|
582
|
+ //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
|
|
583
|
+ device = new Aspose.Pdf.Devices.JpegDevice(100);
|
|
584
|
+ //遍历每一页转为jpg
|
|
585
|
+ for (var i = 1; i <= document.Pages.Count; i++)
|
|
586
|
+ {
|
|
587
|
+ long ii = Timestamp();
|
|
588
|
+ string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
|
|
589
|
+ images.Add(filePathOutPut);
|
|
590
|
+ FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
|
|
591
|
+ try
|
|
592
|
+ {
|
|
593
|
+ device.Process(document.Pages[i], fs);
|
|
594
|
+ fs.Close();
|
|
595
|
+ }
|
|
596
|
+ catch (Exception ex)
|
|
597
|
+ {
|
|
598
|
+ fs.Close();
|
|
599
|
+ File.Delete(filePathOutPut);
|
|
600
|
+ }
|
|
601
|
+ }
|
|
602
|
+ #endregion
|
|
603
|
+
|
|
604
|
+ APP.Paths = images.ToArray();
|
|
605
|
+
|
|
606
|
+ for (int i = 0; i < APP.Paths.Length; i++)
|
|
607
|
+ {
|
|
608
|
+ APP.pageData.pagenum += 1;
|
|
609
|
+ }
|
|
610
|
+ if (APP.pageData.pagenum > 1)
|
526
|
611
|
{
|
527
|
|
- //APP.pageData.currpage -= 1;
|
528
|
|
- //myblackboard.changepage(APP.pageData.currpage - 1);
|
|
612
|
+ APP.pageData.pagenum -= 1;
|
529
|
613
|
}
|
530
|
614
|
if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
531
|
615
|
{
|
|
@@ -538,7 +622,16 @@ namespace XHWK.WKTool
|
538
|
622
|
}
|
539
|
623
|
}
|
540
|
624
|
}
|
541
|
|
-
|
|
625
|
+ /// <summary>
|
|
626
|
+ /// 返回一个时间戳到毫秒
|
|
627
|
+ /// </summary>
|
|
628
|
+ /// <returns></returns>
|
|
629
|
+ public static long Timestamp()
|
|
630
|
+ {
|
|
631
|
+ TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
|
632
|
+ long timestr = Convert.ToInt64(ts.TotalMilliseconds);
|
|
633
|
+ return timestr;
|
|
634
|
+ }
|
542
|
635
|
#region 录制窗口
|
543
|
636
|
#region 变量
|
544
|
637
|
/// <summary>
|
|
@@ -573,7 +666,6 @@ namespace XHWK.WKTool
|
573
|
666
|
/// 是否开始截图计数
|
574
|
667
|
/// </summary>
|
575
|
668
|
bool IsStartCount = false;
|
576
|
|
-
|
577
|
669
|
#endregion
|
578
|
670
|
/// <summary>
|
579
|
671
|
/// 录制窗口内容
|
|
@@ -587,6 +679,8 @@ namespace XHWK.WKTool
|
587
|
679
|
Login();
|
588
|
680
|
return;
|
589
|
681
|
}
|
|
682
|
+
|
|
683
|
+ blackboard_canvas.Visibility = Visibility.Visible;
|
590
|
684
|
StartRecord();
|
591
|
685
|
}
|
592
|
686
|
/// <summary>
|
|
@@ -601,6 +695,7 @@ namespace XHWK.WKTool
|
601
|
695
|
Login();
|
602
|
696
|
return;
|
603
|
697
|
}
|
|
698
|
+ blackboard_canvas.Visibility = Visibility.Collapsed;
|
604
|
699
|
EndRecord();
|
605
|
700
|
}
|
606
|
701
|
System.Timers.Timer timer;
|
|
@@ -813,6 +908,10 @@ namespace XHWK.WKTool
|
813
|
908
|
Login();
|
814
|
909
|
return;
|
815
|
910
|
}
|
|
911
|
+ APP.pageData.pagenum += 1;
|
|
912
|
+ APP.pageData.currpage = APP.pageData.pagenum;
|
|
913
|
+ myblackboard.changepage(APP.pageData.currpage - 1);
|
|
914
|
+ imgCanvas.Source = null;
|
816
|
915
|
}
|
817
|
916
|
/// <summary>
|
818
|
917
|
/// 打印事件
|
|
@@ -858,6 +957,10 @@ namespace XHWK.WKTool
|
858
|
957
|
imgCanvas.Source = null;
|
859
|
958
|
}
|
860
|
959
|
}
|
|
960
|
+ if (!string.IsNullOrWhiteSpace(APP.JPaths[APP.pageData.currpage]))
|
|
961
|
+ {
|
|
962
|
+ imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
|
|
963
|
+ }
|
861
|
964
|
}
|
862
|
965
|
|
863
|
966
|
}
|
|
@@ -875,7 +978,7 @@ namespace XHWK.WKTool
|
875
|
978
|
if (APP.Paths.Length > 0)
|
876
|
979
|
{
|
877
|
980
|
|
878
|
|
- if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage < APP.Paths.Length)
|
|
981
|
+ if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.Paths.Length)
|
879
|
982
|
{
|
880
|
983
|
imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
|
881
|
984
|
}
|
|
@@ -884,20 +987,13 @@ namespace XHWK.WKTool
|
884
|
987
|
imgCanvas.Source = null;
|
885
|
988
|
}
|
886
|
989
|
}
|
|
990
|
+ if (!string.IsNullOrWhiteSpace(APP.JPaths[APP.pageData.currpage]))
|
|
991
|
+ {
|
|
992
|
+ imgCanvas.Source = new BitmapImage(new Uri(APP.JPaths[APP.pageData.currpage]));
|
|
993
|
+ }
|
887
|
994
|
}
|
888
|
995
|
}
|
889
|
996
|
/// <summary>
|
890
|
|
- /// 添加
|
891
|
|
- /// </summary>
|
892
|
|
- /// <param name="sender"></param>
|
893
|
|
- /// <param name="e"></param>
|
894
|
|
- private void add_button_Click(object sender, RoutedEventArgs e)
|
895
|
|
- {
|
896
|
|
- APP.pageData.pagenum += 1;
|
897
|
|
- APP.pageData.currpage = APP.pageData.pagenum;
|
898
|
|
- myblackboard.changepage(APP.pageData.currpage - 1);
|
899
|
|
- }
|
900
|
|
- /// <summary>
|
901
|
997
|
/// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
|
902
|
998
|
/// "ImageFile", 1, 20, ImageFormat.Png, 256);
|
903
|
999
|
/// </summary>
|
|
@@ -978,70 +1074,95 @@ namespace XHWK.WKTool
|
978
|
1074
|
return sf;
|
979
|
1075
|
}
|
980
|
1076
|
|
981
|
|
-
|
982
|
|
-
|
983
|
|
-
|
984
|
|
-
|
985
|
|
-
|
986
|
|
- private bool m_IsMouseLeftButtonDown;
|
987
|
|
-
|
988
|
|
- private void MasterImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
1077
|
+ #region 图像缩放,移动
|
|
1078
|
+ private bool mouseDown;
|
|
1079
|
+ private System.Windows.Point mouseXY;
|
|
1080
|
+ private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
989
|
1081
|
{
|
990
|
|
- Rectangle rectangle = sender as Rectangle;
|
991
|
|
- if (rectangle == null)
|
|
1082
|
+ var img = sender as ContentControl;
|
|
1083
|
+ if (img == null)
|
|
1084
|
+ {
|
992
|
1085
|
return;
|
|
1086
|
+ }
|
|
1087
|
+ img.CaptureMouse();
|
|
1088
|
+ mouseDown = true;
|
|
1089
|
+ mouseXY = e.GetPosition(img);
|
|
1090
|
+ Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
|
993
|
1091
|
|
994
|
|
- rectangle.ReleaseMouseCapture();
|
995
|
|
- m_IsMouseLeftButtonDown = false;
|
996
|
1092
|
}
|
997
|
|
-
|
998
|
|
- private Point m_PreviousMousePoint;
|
999
|
|
- private void MasterImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
1093
|
+ private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
|
|
1094
|
+ {
|
|
1095
|
+ System.Windows.Point point = e.GetPosition(imgCanvas);
|
|
1096
|
+ //Console.WriteLine("PicEmap.X = " + point.X + "; PicEmap.Y = " + point.Y);
|
|
1097
|
+ //if ((point.X - 304) * (point.X - 304) + (point.Y - 86) * (point.Y - 86) < 100)
|
|
1098
|
+ //{
|
|
1099
|
+ // Console.WriteLine("在范围内");
|
|
1100
|
+ //}
|
|
1101
|
+ }
|
|
1102
|
+ private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
1000
|
1103
|
{
|
1001
|
|
- Rectangle rectangle = sender as Rectangle;
|
1002
|
|
- if (rectangle == null)
|
|
1104
|
+ var img = sender as ContentControl;
|
|
1105
|
+ if (img == null)
|
|
1106
|
+ {
|
1003
|
1107
|
return;
|
1004
|
|
-
|
1005
|
|
- rectangle.CaptureMouse();
|
1006
|
|
- m_IsMouseLeftButtonDown = true;
|
1007
|
|
- m_PreviousMousePoint = e.GetPosition(rectangle);
|
|
1108
|
+ }
|
|
1109
|
+ img.ReleaseMouseCapture();
|
|
1110
|
+ mouseDown = false;
|
1008
|
1111
|
}
|
1009
|
|
-
|
1010
|
|
- private void MasterImage_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
|
1112
|
+ private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
1011
|
1113
|
{
|
1012
|
|
- Rectangle rectangle = sender as Rectangle;
|
1013
|
|
- if (rectangle == null)
|
|
1114
|
+ var img = sender as ContentControl;
|
|
1115
|
+ if (img == null)
|
|
1116
|
+ {
|
1014
|
1117
|
return;
|
1015
|
|
-
|
1016
|
|
- if (m_IsMouseLeftButtonDown)
|
1017
|
|
- DoImageMove(rectangle, e);
|
|
1118
|
+ }
|
|
1119
|
+ if (mouseDown)
|
|
1120
|
+ {
|
|
1121
|
+ Domousemove(img, e);
|
|
1122
|
+ }
|
1018
|
1123
|
}
|
1019
|
|
-
|
1020
|
|
- private void DoImageMove(Rectangle rectangle, System.Windows.Input.MouseEventArgs e)
|
|
1124
|
+ private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
|
1021
|
1125
|
{
|
1022
|
|
- //Debug.Assert(e.LeftButton == MouseButtonState.Pressed);
|
1023
|
1126
|
if (e.LeftButton != MouseButtonState.Pressed)
|
|
1127
|
+ {
|
|
1128
|
+ return;
|
|
1129
|
+ }
|
|
1130
|
+ var group = IMG.FindResource("Imageview") as TransformGroup;
|
|
1131
|
+ var transform = group.Children[1] as TranslateTransform;
|
|
1132
|
+ var position = e.GetPosition(img);
|
|
1133
|
+ transform.X -= mouseXY.X - position.X;
|
|
1134
|
+ transform.Y -= mouseXY.Y - position.Y;
|
|
1135
|
+ mouseXY = position;
|
|
1136
|
+ }
|
|
1137
|
+ private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
|
|
1138
|
+ {
|
|
1139
|
+ var img = sender as ContentControl;
|
|
1140
|
+ if (img == null)
|
|
1141
|
+ {
|
1024
|
1142
|
return;
|
|
1143
|
+ }
|
|
1144
|
+ var point = e.GetPosition(img);
|
|
1145
|
+ Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
|
|
1146
|
+ var PicLocate = e.GetPosition(imgCanvas);
|
|
1147
|
+ Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
|
1025
|
1148
|
|
1026
|
|
- TransformGroup group = GridMain.FindResource("ImageTransformResource") as TransformGroup;
|
1027
|
|
- Debug.Assert(group != null);
|
1028
|
|
- TranslateTransform transform = group.Children[1] as TranslateTransform;
|
1029
|
|
- Point position = e.GetPosition(rectangle);
|
1030
|
|
- transform.X += position.X - m_PreviousMousePoint.X;
|
1031
|
|
- transform.Y += position.Y - m_PreviousMousePoint.Y;
|
1032
|
1149
|
|
1033
|
|
- m_PreviousMousePoint = position;
|
|
1150
|
+ var group = IMG.FindResource("Imageview") as TransformGroup;
|
|
1151
|
+ var delta = e.Delta * 0.001;
|
|
1152
|
+ DowheelZoom(group, point, delta);
|
1034
|
1153
|
}
|
1035
|
|
-
|
1036
|
|
- private void MasterImage_MouseWheel(object sender, MouseWheelEventArgs e)
|
|
1154
|
+ private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
|
1037
|
1155
|
{
|
1038
|
|
- TransformGroup group = GridMain.FindResource("ImageTransformResource") as TransformGroup;
|
1039
|
|
- Debug.Assert(group != null);
|
1040
|
|
- ScaleTransform transform = group.Children[0] as ScaleTransform;
|
1041
|
|
- transform.ScaleX += e.Delta * 0.001;
|
1042
|
|
- transform.ScaleY += e.Delta * 0.001;
|
|
1156
|
+ var pointToContent = group.Inverse.Transform(point);
|
|
1157
|
+ var transform = group.Children[0] as ScaleTransform;
|
|
1158
|
+ if (transform.ScaleX + delta < 0.1) return;
|
|
1159
|
+ transform.ScaleX += delta;
|
|
1160
|
+ transform.ScaleY += delta;
|
|
1161
|
+ var transform1 = group.Children[1] as TranslateTransform;
|
|
1162
|
+ transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
|
|
1163
|
+ transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
|
|
1164
|
+ //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
|
1043
|
1165
|
}
|
1044
|
|
-
|
1045
|
|
-
|
|
1166
|
+ #endregion
|
1046
|
1167
|
}
|
1047
|
1168
|
}
|