MergeDialogViewModel.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKit.PDFPage;
  3. using ComPDFKitViewer.PdfViewer;
  4. using Dropbox.Api.TeamLog;
  5. using Microsoft.Office.Interop.Word;
  6. using Microsoft.Win32;
  7. using PDF_Master.CustomControl;
  8. using PDF_Master.EventAggregators;
  9. using PDF_Master.Helper;
  10. using PDF_Master.Model;
  11. using PDF_Master.Model.Dialog.ToolsDialogs;
  12. using PDF_Master.Properties;
  13. using PDF_Master.Views.Dialog;
  14. using Prism.Commands;
  15. using Prism.Events;
  16. using Prism.Mvvm;
  17. using Prism.Services.Dialogs;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Collections.ObjectModel;
  21. using System.IO;
  22. using System.Linq;
  23. using System.Reflection;
  24. using System.Text;
  25. using System.Threading.Tasks;
  26. using System.Windows;
  27. using System.Windows.Controls;
  28. using System.Windows.Media;
  29. using System.Windows.Media.Imaging;
  30. using static Dropbox.Api.TeamLog.PaperDownloadFormat;
  31. using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySettintgsModel;
  32. namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
  33. {
  34. class MergeDialogViewModel : BindableBase, IDialogAware
  35. {
  36. // Fix:存储当前程序加载的文档的路径和tag,
  37. //如果路径相同则用tag里的密码解锁,
  38. //解锁失败再另行提权
  39. private string CurrentFilePath = string.Empty;
  40. private string currentLoadedPassword = string.Empty;
  41. private IEventAggregator eventAggregator;
  42. enum PageSizeType
  43. {
  44. kDefault = 0,
  45. A4 = 1,
  46. A3 = 2,
  47. Letter = 3,
  48. Legal = 4,
  49. Customized = 5,
  50. }
  51. #region 框架内容
  52. public string Title => "";
  53. public event Action<IDialogResult> RequestClose;
  54. public bool CanCloseDialog()
  55. {
  56. return true;
  57. }
  58. public void OnDialogClosed()
  59. {
  60. }
  61. public void OnDialogOpened(IDialogParameters parameters)
  62. {
  63. CPDFViewer pdfViewer = null;
  64. if (parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out pdfViewer) && pdfViewer != null && pdfViewer.Document != null)
  65. {
  66. VerifyPasswordResult condition = SecurityHelper.VerifyPasswordByPasswordKind(pdfViewer.Document, EnumPasswordKind.StatusPermissionsPassword, dialogs);
  67. if (condition.IsDiscryptied)
  68. {
  69. if (!string.IsNullOrEmpty(condition.Password))
  70. {
  71. if (pdfViewer.Document.UnlockWithPassword(condition.Password))
  72. {
  73. pdfViewer.Document.CheckOwnerPassword(condition.Password);
  74. }
  75. }
  76. string unicode;
  77. if (parameters.TryGetValue<string>(ParameterNames.Unicode, out unicode))
  78. {
  79. this.eventAggregator.GetEvent<ShowTipEvent>().Publish(new ShowTipEventArgs() { enumTipKind = EnumTipKind.StatusNone, Unicode = unicode });
  80. }
  81. }
  82. currentLoadedPassword = pdfViewer.Document.Password;
  83. }
  84. if (pdfViewer != null && pdfViewer.Document != null)
  85. {
  86. CurrentFilePath = pdfViewer.Document.FilePath;
  87. List<string> list = new List<string>();
  88. list.Add(CurrentFilePath);
  89. AddFiles(list.ToArray());
  90. }
  91. string[] Paths;
  92. parameters.TryGetValue<string[]>(ParameterNames.FilePath, out Paths);
  93. if (Paths != null)
  94. {
  95. AddFiles(Paths);
  96. }
  97. }
  98. #endregion
  99. #region 定义与初始化
  100. public ObservableCollection<MergeObject> MergeObjectlist { get; set; }
  101. public DelegateCommand CancelCommand { get; set; }
  102. public DelegateCommand<object> PreviewCancelDownCommand { get; set; }
  103. public DelegateCommand MergeCommand { get; set; }
  104. public DelegateCommand<object> AddFilesCommand { get; set; }
  105. public DelegateCommand ClearCommand { get; set; }
  106. public DelegateCommand<object> SetPageSizeTypeCommand { get; set; }
  107. public IDialogService dialogs;
  108. private PageSizeType pageSizeType = PageSizeType.kDefault;
  109. private string inputWidth;
  110. public string InputWidth
  111. {
  112. get { return inputWidth; }
  113. set
  114. {
  115. SetProperty(ref inputWidth, value);
  116. }
  117. }
  118. private string inputHeight;
  119. public string InputHeight
  120. {
  121. get { return inputHeight; }
  122. set
  123. {
  124. SetProperty(ref inputHeight, value);
  125. }
  126. }
  127. private int comboBoxSelectedIndex = 0;
  128. public int ComboBoxSelectedIndex
  129. {
  130. get { return comboBoxSelectedIndex; }
  131. set
  132. {
  133. SetProperty(ref comboBoxSelectedIndex, value);
  134. }
  135. }
  136. public MergeDialogViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
  137. {
  138. this.eventAggregator = eventAggregator;
  139. dialogs = dialogService;
  140. MergeObjectlist = new ObservableCollection<MergeObject>();
  141. CancelCommand = new DelegateCommand(Cancel);
  142. PreviewCancelDownCommand = new DelegateCommand<object>(PreviewCancelDown);
  143. AddFilesCommand = new DelegateCommand<object>(ButtonAddFiles);
  144. MergeCommand = new DelegateCommand(Merge);
  145. ClearCommand = new DelegateCommand(Clear);
  146. SetPageSizeTypeCommand = new DelegateCommand<object>(SetPageSizeType);
  147. }
  148. #endregion
  149. #region 私有方法
  150. private void UpDataMergeObjectIndex()
  151. {
  152. for (int i = 0; i < MergeObjectlist.Count; i++)
  153. {
  154. MergeObjectlist[i].ItemIndex = i + 1;
  155. }
  156. }
  157. private void Cancel()
  158. {
  159. Clear();
  160. RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
  161. }
  162. /// <summary>
  163. /// 点击取消页面范围控件使失去焦点不生效
  164. /// </summary>
  165. private void PreviewCancelDown(object e)
  166. {
  167. var listView = e as ListView;
  168. if (listView != null)
  169. {
  170. if (listView.ItemsSource != null)
  171. {
  172. foreach (var item in listView.ItemsSource)
  173. {
  174. var pagerange= listView.ItemContainerGenerator.ContainerFromItem(item) as ListViewItem;
  175. if (pagerange != null)
  176. {
  177. var pagerangecombobox= CommonHelper.FindVisualChild<WritableComboBox>(pagerange);
  178. if(pagerangecombobox!=null)
  179. pagerangecombobox.IsloseFocus = false;
  180. }
  181. }
  182. }
  183. }
  184. }
  185. public void ButtonAddFiles(object data)
  186. {
  187. int index = Convert.ToInt32(data);
  188. switch (index)
  189. {
  190. case 0:
  191. //打开文件
  192. ComboBoxSelectedIndex = 0;//打开文件弹窗会影响UI更新,所以手动更新
  193. AddFiles(OpenFile());
  194. break;
  195. case 1:
  196. //打开文件夹
  197. ComboBoxSelectedIndex = 1;//打开文件夹弹窗会影响UI更新,所以手动更新
  198. AddFiles(OpenFileFolder());
  199. break;
  200. case 2:
  201. //打开当前文件
  202. List<string> list = new List<string>();
  203. for (int i = 0; i < App.OpenedFileList.Count; i++)
  204. {
  205. list.Add(App.OpenedFileList[i]);
  206. }
  207. AddFiles(list.ToArray());
  208. break;
  209. default:
  210. break;
  211. }
  212. }
  213. private string[] OpenFileFolder()
  214. {
  215. System.Windows.Forms.FolderBrowserDialog openFile = new System.Windows.Forms.FolderBrowserDialog();
  216. if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
  217. {
  218. return null;
  219. }
  220. DirectoryInfo tempfolder = new DirectoryInfo(openFile.SelectedPath);
  221. FileInfo[] fileInfos = tempfolder.GetFiles();
  222. List<string> list = new List<string>();
  223. foreach (FileInfo item in fileInfos)
  224. {
  225. list.Add(item.FullName);
  226. }
  227. DirectoryInfo[] directoryInfos = tempfolder.GetDirectories();
  228. foreach (DirectoryInfo fileInfo in directoryInfos)
  229. {
  230. FileInfo[] fileinfo = fileInfo.GetFiles();
  231. foreach (FileInfo item in fileinfo)
  232. {
  233. list.Add(item.FullName);
  234. }
  235. }
  236. return list.ToArray();
  237. }
  238. private string[] OpenFile()
  239. {
  240. OpenFileDialog openFile = new OpenFileDialog();
  241. openFile.Multiselect = true;
  242. openFile.Filter = Properties.Resources.imageex.ToLower() + "|*";
  243. if (openFile.ShowDialog() == false)
  244. {
  245. return null;
  246. }
  247. return openFile.FileNames;
  248. }
  249. private void Merge()
  250. {
  251. bool result = true;
  252. CPDFDocument SaveDoc = CPDFDocument.CreateDocument();
  253. for (int i = 0; i < MergeObjectlist.Count; i++)
  254. {
  255. List<int> listnum = new List<int>();
  256. if (MergeObjectlist[i].SetPageRange == null || MergeObjectlist[i].SetPageRange.Count == 0)
  257. {
  258. AlertsMessage alertsMessage = new AlertsMessage();
  259. alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageRangeWarning"), App.ServiceLoader.GetString("Text_ok"));
  260. return;
  261. }
  262. }
  263. for (int i = 0; i < MergeObjectlist.Count; i++)
  264. {
  265. if (MergeObjectlist[i].SetPageRange == null)
  266. {
  267. AlertsMessage alertsMessage = new AlertsMessage();
  268. alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageRangeWarning"), App.ServiceLoader.GetString("Text_ok"));
  269. }
  270. //图片
  271. if (Path.GetExtension(MergeObjectlist[i].FilePath).Trim().ToLower() != ".pdf")
  272. {
  273. if (Path.GetExtension(MergeObjectlist[i].FilePath).Trim().ToLower() == ".gif")
  274. {//GIF下面方法产生虚影改成与图片转PDF一致
  275. System.Drawing.Image img = System.Drawing.Image.FromFile(MergeObjectlist[i].FilePath);
  276. string tempFileName = Path.GetTempPath() + "pngtemp.jpg";
  277. if (!PictureConverter.SaveJpeg(MergeObjectlist[i].FilePath, tempFileName))
  278. {
  279. MessageBoxEx.Show("图片格式有问题");
  280. }
  281. // 之前插入位置为零点导致插入为第一页,改为尾插 2023/5/24
  282. result = SaveDoc.InsertPage(SaveDoc.PageCount, img.Width, img.Height, tempFileName);
  283. try { if (File.Exists(tempFileName)) File.Delete(tempFileName); }
  284. catch
  285. { }
  286. if (!result)
  287. {
  288. SaveDoc.Release();
  289. return;
  290. }
  291. continue;
  292. }
  293. else
  294. {
  295. BitmapSource frame = MergeObjectlist[i].DocThumbnail;
  296. byte[] imageData = new byte[frame.PixelWidth * frame.PixelHeight * 4];
  297. if (frame.Format != PixelFormats.Bgra32)
  298. {
  299. FormatConvertedBitmap covert = new FormatConvertedBitmap(frame, PixelFormats.Bgra32, frame.Palette, 0);
  300. covert.CopyPixels(imageData, frame.PixelWidth * 4, 0);
  301. }
  302. else
  303. {
  304. frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
  305. }
  306. frame.CopyPixels(imageData, frame.PixelWidth * 4, 0);
  307. // 之前插入位置为零点导致插入为第一页,改为尾插 2023/5/24
  308. result = SaveDoc.InsertPage(SaveDoc.PageCount, frame.PixelWidth, frame.PixelHeight, imageData, CPDFDocumentImageMode.CPDFDocumentImageModeScaleToFill);
  309. if (!result)
  310. {
  311. SaveDoc.Release();
  312. return;
  313. }
  314. continue;
  315. }
  316. }
  317. else
  318. {
  319. CPDFDocument tempDoc = CPDFDocument.InitWithFilePath(MergeObjectlist[i].FilePath);
  320. if (!string.IsNullOrEmpty(MergeObjectlist[i].Password))
  321. {
  322. tempDoc.UnlockWithPassword(MergeObjectlist[i].Password);
  323. }
  324. if (!string.IsNullOrEmpty(MergeObjectlist[i].SetPageRangeStr))
  325. {
  326. result = SaveDoc.ImportPages(tempDoc, MergeObjectlist[i].SetPageRangeStr);
  327. }
  328. else
  329. {
  330. //下拉框控件传出来的list是页面索引集合,
  331. //此处传给SDK的合并接口的是页码集合,因此需要将集合项遍历+1,只有合并接口是接收页码集合,其余接口是接受页面索引集合
  332. List<int> pageIndexs = new List<int>();
  333. for (int j = 0; j < MergeObjectlist[i].SetPageRange.Count; j++)
  334. {
  335. pageIndexs.Add(MergeObjectlist[i].SetPageRange[j] + 1);
  336. }
  337. result = SaveDoc.ImportPages(tempDoc, CommonHelper.GetPageParmFromList(pageIndexs));
  338. }
  339. if (!result)
  340. {
  341. SaveDoc.Release();
  342. tempDoc.Release();
  343. return;
  344. }
  345. tempDoc.Release();
  346. }
  347. }
  348. SaveFileDialog saveFileDialog = new SaveFileDialog();
  349. saveFileDialog.FileName = "Untitle";
  350. saveFileDialog.Filter = "PDF|*.pdf;";
  351. if (saveFileDialog.ShowDialog() == false)
  352. {
  353. return;
  354. }
  355. string path = saveFileDialog.FileName;
  356. System.Windows.Rect rect = new System.Windows.Rect();
  357. switch (pageSizeType)
  358. {
  359. case PageSizeType.kDefault:
  360. break;
  361. case PageSizeType.A4:
  362. rect.Width = CommonHelper.GetPageSizeFomrUnit(210);
  363. rect.Height = CommonHelper.GetPageSizeFomrUnit(297);
  364. break;
  365. case PageSizeType.A3:
  366. rect.Width = CommonHelper.GetPageSizeFomrUnit(297);
  367. rect.Height = CommonHelper.GetPageSizeFomrUnit(420);
  368. break;
  369. case PageSizeType.Letter:
  370. rect.Width = CommonHelper.GetPageSizeFomrUnit(216);
  371. rect.Height = CommonHelper.GetPageSizeFomrUnit(279);
  372. break;
  373. case PageSizeType.Legal:
  374. rect.Width = CommonHelper.GetPageSizeFomrUnit(216);
  375. rect.Height = CommonHelper.GetPageSizeFomrUnit(356);
  376. break;
  377. case PageSizeType.Customized:
  378. if (!string.IsNullOrEmpty(InputWidth) && !string.IsNullOrEmpty(InputHeight))
  379. {
  380. rect.Width = CommonHelper.GetPageSizeFomrUnit(Convert.ToInt32(InputWidth));
  381. rect.Height = CommonHelper.GetPageSizeFomrUnit(Convert.ToInt32(InputHeight));
  382. }
  383. else
  384. {
  385. rect.Width = CommonHelper.GetPageSizeFomrUnit(595);
  386. rect.Height = CommonHelper.GetPageSizeFomrUnit(841);
  387. }
  388. break;
  389. default:
  390. break;
  391. }
  392. if (rect.Width > 0 && rect.Height > 0)
  393. {
  394. //裁剪
  395. for (int i = 0; i < SaveDoc.PageCount; i++)
  396. {
  397. CPDFPage page = SaveDoc.PageAtIndex(i);
  398. page.CropPage(CPDFDisplayBox.MediaBox, rect);
  399. }
  400. }
  401. bool saveResult = SaveDoc.WriteToFilePath(path);
  402. SaveDoc.Release();
  403. CommonHelper.ShowFileBrowser(path);
  404. DialogParameters valuePairs = new DialogParameters();
  405. valuePairs.Add(ParameterNames.FilePath, path);
  406. RequestClose.Invoke(new DialogResult(ButtonResult.OK, valuePairs));
  407. }
  408. private void Clear()
  409. {
  410. MergeObjectlist.Clear();
  411. }
  412. private void SetPageSizeType(object button)
  413. {
  414. if (button is RadioButton)
  415. {
  416. pageSizeType = (PageSizeType)Convert.ToInt32((button as RadioButton).Tag);
  417. }
  418. }
  419. #endregion
  420. #region 公开方法
  421. public void DeleteItem(MergeObject merge)
  422. {
  423. MergeObjectlist.Remove(merge);
  424. UpDataMergeObjectIndex();
  425. }
  426. /// <summary>
  427. /// 拖拽插入
  428. /// </summary>
  429. public void MoveMerge(MergeObject targetNode, MergeObject soureNode)
  430. {
  431. int targetindex = MergeObjectlist.IndexOf(targetNode);
  432. MergeObjectlist.Remove(soureNode);
  433. if (targetNode.IsForward)
  434. {
  435. if (targetindex + 1 < MergeObjectlist.Count)
  436. {
  437. MergeObjectlist.Insert(targetindex + 1, soureNode);
  438. }
  439. else
  440. {
  441. MergeObjectlist.Add(soureNode);
  442. }
  443. }
  444. else
  445. {
  446. MergeObjectlist.Insert(targetindex, soureNode);
  447. }
  448. UpDataMergeObjectIndex();
  449. }
  450. public void AddFiles(string[] FilePath)
  451. {
  452. if (FilePath == null)
  453. {
  454. return;
  455. }
  456. bool showDialog = false;
  457. for (int i = 0; i < FilePath.Length; i++)
  458. {
  459. MergeObject mergeObject = new MergeObject();
  460. mergeObject.FilePath = FilePath[i];
  461. //通过路径判断文件是否已添加
  462. bool IsExists = false;
  463. for (int j = 0; j < MergeObjectlist.Count; j++)
  464. {
  465. if (MergeObjectlist[j].FilePath == mergeObject.FilePath)
  466. {
  467. IsExists = true;
  468. }
  469. }
  470. if (IsExists)
  471. {
  472. continue;
  473. }
  474. string FileType = Path.GetExtension(mergeObject.FilePath).Trim().ToLower();
  475. if (string.IsNullOrEmpty(FileType))
  476. {
  477. showDialog = true;
  478. //获取不到文件类型
  479. continue;
  480. }
  481. if (FileType != ".pdf")
  482. {
  483. string imagetype = "*" + FileType;
  484. string[] x = Properties.Resources.imageex.ToLower().Split(';');
  485. List<string> list = x.ToList();
  486. int imageindex = list.IndexOf(imagetype);
  487. if (imageindex < 0)
  488. {
  489. showDialog = true;
  490. //图片格式不支持
  491. continue;
  492. };
  493. mergeObject.DocName = Path.GetFileName(mergeObject.FilePath);
  494. mergeObject.DocPageCount = 1 + " " + App.MainPageLoader.GetString("Merge_ItemPages");
  495. mergeObject.SDKPageCount = 1;
  496. mergeObject.DocSize = CommonHelper.GetFileSize(mergeObject.FilePath);
  497. try
  498. {
  499. mergeObject.DocThumbnail = new BitmapImage(new Uri(mergeObject.FilePath));
  500. }
  501. catch (Exception)
  502. {
  503. showDialog = true;
  504. //解码错误
  505. continue;
  506. }
  507. }
  508. else
  509. {
  510. CPDFDocument doc = CPDFDocument.InitWithFilePath(mergeObject.FilePath);
  511. if (doc == null)
  512. {
  513. showDialog = true;
  514. //PDF打开失败
  515. continue;
  516. }
  517. ///Fix:
  518. ///情况分为:
  519. ///开启路径是当前路径:
  520. ///已解锁或本身就无密码->直接加入
  521. ///未解锁-> release
  522. ///
  523. /// 不是当前路径
  524. ///解锁或取消->
  525. ///
  526. if (CurrentFilePath == doc.FilePath)
  527. {
  528. if ((!(!doc.IsLocked && (SecurityHelper.CheckHaveAllPermissions(doc)))) &&
  529. (!(!string.IsNullOrEmpty(currentLoadedPassword) &&
  530. doc.UnlockWithPassword(currentLoadedPassword) &&
  531. (doc.CheckOwnerPassword(currentLoadedPassword) || SecurityHelper.CheckHaveAllPermissions(doc)))))
  532. {
  533. doc.Release();
  534. continue;
  535. }
  536. //添加的第一个文档有权限密码时,保存密码,避免合并时因没有密码导致合并失败
  537. //表现为在首页打开一个带权限的文档进入合并,点击合并按钮没有反应
  538. if (!string.IsNullOrEmpty(currentLoadedPassword))
  539. {
  540. mergeObject.Password = currentLoadedPassword;
  541. }
  542. }
  543. else
  544. {
  545. VerifyPasswordResult condition = SecurityHelper.VerifyPasswordByPasswordKind(doc, EnumPasswordKind.StatusPermissionsPassword, dialogs);
  546. if (condition.IsDiscryptied)
  547. {
  548. if (condition.Password != null)
  549. {
  550. mergeObject.Password = condition.Password;
  551. if (doc.UnlockWithPassword(condition.Password) && doc.CheckOwnerPassword(condition.Password))
  552. {
  553. }
  554. }
  555. }
  556. else
  557. {
  558. doc.Release();
  559. continue;
  560. }
  561. }
  562. mergeObject.DocName = doc.FileName;
  563. mergeObject.DocPageCount = doc.PageCount.ToString() + " " + App.MainPageLoader.GetString("Merge_ItemPages");
  564. if (doc.PageCount > 1)
  565. {
  566. mergeObject.IsEvenPageIsEnabled = true;
  567. }
  568. else
  569. {
  570. mergeObject.IsEvenPageIsEnabled = false;
  571. }
  572. mergeObject.SDKPageCount = doc.PageCount;
  573. mergeObject.DocSize = CommonHelper.GetFileSize(mergeObject.FilePath);
  574. //获取第一页缩略图
  575. CPDFPage page = doc.PageAtIndex(0);
  576. Size size = doc.GetPageSize(0);
  577. byte[] bmpData = new byte[(int)(size.Width * size.Height * 4)];
  578. WriteableBitmap WirteBitmap = new WriteableBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Bgra32, null);
  579. page.RenderPageBitmap(0, 0, (int)size.Width, (int)size.Height, 0xFFFFFFFF, bmpData, 1);
  580. WirteBitmap.WritePixels(new Int32Rect(0, 0, (int)size.Width, (int)size.Height), bmpData, WirteBitmap.BackBufferStride, 0);
  581. WirteBitmap.Freeze();
  582. mergeObject.DocThumbnail = WirteBitmap;
  583. doc.Release();
  584. }
  585. MergeObjectlist.Add(mergeObject);
  586. UpDataMergeObjectIndex();
  587. }
  588. if (showDialog)
  589. {
  590. AlertsMessage alertsMessage = new AlertsMessage();
  591. alertsMessage.ShowDialog("", App.MainPageLoader.GetString("ErrorFile_Warning"), App.ServiceLoader.GetString("Text_ok"));
  592. if (alertsMessage.result == ContentResult.Ok)
  593. {
  594. }
  595. }
  596. }
  597. #endregion
  598. }
  599. }