|
@@ -177,8 +177,7 @@ namespace XHWK.WKTool
|
177
|
177
|
txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
|
178
|
178
|
Initialize();
|
179
|
179
|
InitPen();
|
180
|
|
- k_hook = new KeyboardHookCommon();
|
181
|
|
- k_hook.KeyDownEvent += K_hook_KeyDownEvent;
|
|
180
|
+
|
182
|
181
|
}
|
183
|
182
|
/// <summary>
|
184
|
183
|
/// 初始化
|
|
@@ -1043,8 +1042,8 @@ namespace XHWK.WKTool
|
1043
|
1042
|
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
|
1044
|
1043
|
ofd = new System.Windows.Forms.OpenFileDialog
|
1045
|
1044
|
{
|
1046
|
|
- //Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
|
1047
|
1045
|
Filter = "文档|*.docx;*.doc;*.ppt;*.pptx",
|
|
1046
|
+ //Filter = "文档|*.docx;*.doc;*.ppt;*.pptx;*.pdf",
|
1048
|
1047
|
InitialDirectory = desktopPath,
|
1049
|
1048
|
Multiselect = false,
|
1050
|
1049
|
AddExtension = true,
|
|
@@ -1240,94 +1239,132 @@ namespace XHWK.WKTool
|
1240
|
1239
|
}
|
1241
|
1240
|
else if (type.Contains("typepdf"))
|
1242
|
1241
|
{
|
1243
|
|
- string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
1244
|
|
- #region PDF转图片
|
1245
|
|
- // 图片绝对路径集合
|
1246
|
|
- List<string> images = new List<string>();
|
1247
|
|
- string directoryPath = pathTemp;
|
1248
|
|
- //aspose许可证
|
1249
|
|
- //Aspose.Pdf.License l = new Aspose.Pdf.License();
|
1250
|
|
- //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
|
1251
|
|
- //l.SetLicense(licenseName);
|
1252
|
|
- //定义Jpeg转换设备
|
1253
|
|
- Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
|
1254
|
|
- Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
|
1255
|
|
- //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
|
1256
|
|
- //directoryPath += quality;
|
1257
|
|
- Directory.CreateDirectory(directoryPath);
|
1258
|
|
- //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
|
1259
|
|
- device = new Aspose.Pdf.Devices.JpegDevice(100);
|
1260
|
|
- //遍历每一页转为jpg
|
1261
|
|
- for (int i = 1; i <= document.Pages.Count; i++)
|
1262
|
|
- {
|
1263
|
|
- long ii = Timestamp();
|
1264
|
|
- string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
|
1265
|
|
- images.Add(filePathOutPut);
|
1266
|
|
- FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
|
1267
|
|
- try
|
1268
|
|
- {
|
1269
|
|
- device.Process(document.Pages[i], fs);
|
1270
|
|
- fs.Close();
|
1271
|
|
- }
|
1272
|
|
- catch (Exception)
|
1273
|
|
- {
|
1274
|
|
- fs.Close();
|
1275
|
|
- File.Delete(filePathOutPut);
|
1276
|
|
- }
|
1277
|
|
- }
|
1278
|
|
- #endregion
|
1279
|
|
- string[] page = images.ToArray();
|
1280
|
|
- int num = 0;
|
1281
|
|
- for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
|
|
1242
|
+ try
|
1282
|
1243
|
{
|
1283
|
|
- if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
|
|
1244
|
+ string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
|
|
1245
|
+ #region PDF转图片
|
|
1246
|
+ // 图片绝对路径集合
|
|
1247
|
+ List<string> images = new List<string>();
|
|
1248
|
+ string directoryPath = pathTemp;
|
|
1249
|
+ //aspose许可证
|
|
1250
|
+ //Aspose.Pdf.License l = new Aspose.Pdf.License();
|
|
1251
|
+ //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
|
|
1252
|
+ //l.SetLicense(licenseName);
|
|
1253
|
+ //定义Jpeg转换设备
|
|
1254
|
+ Aspose.Pdf.Document document = new Aspose.Pdf.Document(filepath);
|
|
1255
|
+ Aspose.Pdf.Devices.JpegDevice device = new Aspose.Pdf.Devices.JpegDevice();
|
|
1256
|
+ //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
|
|
1257
|
+ //directoryPath += quality;
|
|
1258
|
+ Directory.CreateDirectory(directoryPath);
|
|
1259
|
+ //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
|
|
1260
|
+ device = new Aspose.Pdf.Devices.JpegDevice(100);
|
|
1261
|
+
|
|
1262
|
+ //遍历每一页转为jpg
|
|
1263
|
+ for (int i = 1; i <= document.Pages.Count; i++)
|
1284
|
1264
|
{
|
1285
|
|
- APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
|
1286
|
|
- APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
|
1287
|
|
- APP.PageDrawList[i].PageNum = i + 1;
|
1288
|
|
- APP.PageDrawList[i].ImgDocumentation = true;
|
|
1265
|
+ long ii = Timestamp();
|
|
1266
|
+ string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
|
|
1267
|
+ images.Add(filePathOutPut);
|
|
1268
|
+ FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
|
|
1269
|
+ try
|
|
1270
|
+ {
|
|
1271
|
+ device.Process(document.Pages[i], fs);
|
|
1272
|
+ fs.Close();
|
|
1273
|
+ }
|
|
1274
|
+ catch (Exception)
|
|
1275
|
+ {
|
|
1276
|
+ fs.Close();
|
|
1277
|
+ File.Delete(filePathOutPut);
|
|
1278
|
+ }
|
1289
|
1279
|
}
|
1290
|
|
- else
|
|
1280
|
+ #endregion
|
|
1281
|
+ string[] page = images.ToArray();
|
|
1282
|
+ int num = 0;
|
|
1283
|
+ int iStart = APP.pageData.pagenum;//导入文档的开始下标
|
|
1284
|
+ int iEnd = page.Length + APP.pageData.pagenum;//导入文档的结束下标
|
|
1285
|
+ Dispatcher.Invoke(new Action(() =>
|
1291
|
1286
|
{
|
|
1287
|
+ for (int i = APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
|
|
1288
|
+ {
|
|
1289
|
+ if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
|
|
1290
|
+ {
|
|
1291
|
+ APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
|
|
1292
|
+ APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
|
|
1293
|
+ APP.PageDrawList[i].PageNum = i + 1;
|
|
1294
|
+ APP.PageDrawList[i].ImgDocumentation = true;
|
|
1295
|
+ APP.PageDrawList[i].Type = "ppt";
|
|
1296
|
+ }
|
|
1297
|
+ else
|
|
1298
|
+ {
|
|
1299
|
+
|
|
1300
|
+ Model_DrawData model_DrawData = new Model_DrawData
|
|
1301
|
+ {
|
|
1302
|
+ PageImagePath = page[i - APP.pageData.pagenum],
|
|
1303
|
+ PdfImagePath = page[i - APP.pageData.pagenum],
|
|
1304
|
+ PageNum = i + 1,
|
|
1305
|
+ ImgDocumentation = true,
|
|
1306
|
+ Type = "ppt"
|
|
1307
|
+ };
|
|
1308
|
+ APP.PageDrawList.Add(model_DrawData);
|
|
1309
|
+ }
|
1292
|
1310
|
|
1293
|
|
- Model_DrawData model_DrawData = new Model_DrawData
|
|
1311
|
+ ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
|
|
1312
|
+ ImgPrintTwo.Visibility = Visibility.Collapsed;
|
|
1313
|
+ btnPrint.IsEnabled = true;
|
|
1314
|
+ APP.SaveDraw();
|
|
1315
|
+ num++;
|
|
1316
|
+ }
|
|
1317
|
+ if (num > 0)
|
1294
|
1318
|
{
|
1295
|
|
- PageImagePath = page[i - APP.pageData.pagenum],
|
1296
|
|
- PdfImagePath = page[i - APP.pageData.pagenum],
|
1297
|
|
- PageNum = i + 1,
|
1298
|
|
- ImgDocumentation = true
|
1299
|
|
- };
|
1300
|
|
- APP.PageDrawList.Add(model_DrawData);
|
1301
|
|
- }
|
1302
|
|
- ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
|
1303
|
|
- ImgPrintTwo.Visibility = Visibility.Collapsed;
|
1304
|
|
- btnPrint.IsEnabled = true;
|
1305
|
|
- APP.SaveDraw();
|
1306
|
|
- num++;
|
1307
|
|
- }
|
1308
|
|
- if (num > 0)
|
1309
|
|
- {
|
1310
|
|
- APP.pageData.currpage = APP.pageData.pagenum + 1;
|
1311
|
|
- APP.pageData.pagenum += num;
|
1312
|
|
- gridPage.Visibility = Visibility.Visible;//页码大于0 显示
|
1313
|
|
- }
|
1314
|
|
- if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
|
1315
|
|
- {
|
1316
|
|
- imgCanvas.Source = null;
|
1317
|
|
- ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
|
1318
|
|
- ImgScreenshotTwo.Visibility = Visibility.Visible;
|
1319
|
|
- btnScreenshot.IsEnabled = false;
|
1320
|
|
- imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
|
|
1319
|
+ APP.pageData.currpage = APP.pageData.pagenum + 1;
|
|
1320
|
+ APP.pageData.pagenum += num;
|
|
1321
|
+ gridPage.Visibility = Visibility.Visible;//页码大于0 显示
|
|
1322
|
+ }
|
|
1323
|
+ if (APP.pageData.currpage > 0 && APP.pageData.currpage <= APP.PageDrawList.Count)
|
|
1324
|
+ {
|
|
1325
|
+ imgCanvas.Source = null;
|
|
1326
|
+ ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
|
|
1327
|
+ ImgScreenshotTwo.Visibility = Visibility.Visible;
|
|
1328
|
+ btnScreenshot.IsEnabled = false;
|
|
1329
|
+ imgDocumentation.Source = null;
|
|
1330
|
+ imgPPT.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
|
|
1331
|
+ for (int i = iStart; i < iEnd; i++)
|
|
1332
|
+ {
|
|
1333
|
+ APP.PageDrawList[i].ImageLocation = new TranslateTransform
|
|
1334
|
+ {
|
|
1335
|
+ X = 0.1,
|
|
1336
|
+ Y = 0.1
|
|
1337
|
+ };
|
|
1338
|
+ APP.PageDrawList[i].IsImageLocation = true;
|
|
1339
|
+ APP.PageDrawList[i].ImageSizes = new ScaleTransform
|
|
1340
|
+ {
|
|
1341
|
+ CenterX = imgCanvas.Width,
|
|
1342
|
+ CenterY = imgCanvas.Height
|
|
1343
|
+ };
|
|
1344
|
+ }
|
|
1345
|
+ }
|
|
1346
|
+ else
|
|
1347
|
+ {
|
|
1348
|
+ imgDocumentation.Source = null;
|
|
1349
|
+ imgCanvas.Source = null;
|
|
1350
|
+ imgPPT.Source = null;
|
|
1351
|
+ ///截图可用
|
|
1352
|
+ ImgScreenshot.Visibility = Visibility.Visible;
|
|
1353
|
+ ImgScreenshotTwo.Visibility = Visibility.Collapsed;
|
|
1354
|
+ btnScreenshot.IsEnabled = true;
|
|
1355
|
+ }
|
|
1356
|
+ }));
|
1321
|
1357
|
}
|
1322
|
|
- else
|
|
1358
|
+ catch (Exception ex)
|
1323
|
1359
|
{
|
1324
|
|
- imgDocumentation.Source = null;
|
1325
|
|
- imgCanvas.Source = null;
|
1326
|
|
- ///截图可用
|
1327
|
|
- ImgScreenshot.Visibility = Visibility.Visible;
|
1328
|
|
- ImgScreenshotTwo.Visibility = Visibility.Collapsed;
|
1329
|
|
- btnScreenshot.IsEnabled = true;
|
|
1360
|
+ Dispatcher.Invoke(new Action(() =>
|
|
1361
|
+ {
|
|
1362
|
+ MessageWindow.Show(ex.Message);
|
|
1363
|
+ }));
|
|
1364
|
+
|
|
1365
|
+ LogHelper.WriteErrLog("【打开pdf】(OpenDialog pdf)" + ex.Message, ex);
|
1330
|
1366
|
}
|
|
1367
|
+
|
1331
|
1368
|
}
|
1332
|
1369
|
else//word
|
1333
|
1370
|
{
|
|
@@ -3464,6 +3501,7 @@ namespace XHWK.WKTool
|
3464
|
3501
|
///清空页面图片UI
|
3465
|
3502
|
imgCanvas.Source = null;
|
3466
|
3503
|
imgDocumentation.Source = null;
|
|
3504
|
+ imgPPT.Source = null;
|
3467
|
3505
|
///画板模型增加一页
|
3468
|
3506
|
Model_DrawData model_DrawData = new Model_DrawData
|
3469
|
3507
|
{
|