RemoveWatermarkListDialog.xaml.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Forms;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. using ComPDFKit.Controls.Helper;
  17. using Path = System.IO.Path;
  18. namespace ComPDFKit.Controls.PDFControl {
  19. /// <summary>
  20. /// Interaction logic for RemoveWatermarkListDialog.xaml
  21. /// </summary>
  22. public partial class RemoveWatermarkListDialog : Window
  23. {
  24. public RemoveWatermarkListDialog()
  25. {
  26. InitializeComponent();
  27. Title = LanguageHelper.SecurityManager.GetString("Title_RemoveWatermark");
  28. }
  29. private void CancelBtn_Click(object sender, RoutedEventArgs e)
  30. {
  31. Close();
  32. }
  33. private void ApplyBtn_Click(object sender, RoutedEventArgs e)
  34. {
  35. var dialog = new FolderBrowserDialog();
  36. if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
  37. {
  38. return;
  39. }
  40. else
  41. {
  42. var path = dialog.SelectedPath;
  43. foreach (var fileInfo in RemoveWatermarkListControl.FileInfoDataList)
  44. {
  45. fileInfo.Document.DeleteWatermarks();
  46. string savePath = Path.Combine(path, Path.GetFileNameWithoutExtension(fileInfo.Document.FileName) + "_"
  47. + LanguageHelper.SecurityManager.GetString("FileName_RemoveWatermark"));
  48. fileInfo.Document.WriteToFilePath(savePath);
  49. }
  50. System.Diagnostics.Process.Start(path);
  51. Close();
  52. }
  53. }
  54. protected override void OnClosed(EventArgs e)
  55. {
  56. foreach (var fileInfo in RemoveWatermarkListControl.FileInfoDataList)
  57. {
  58. fileInfo.Document.Release();
  59. }
  60. base.OnClosed(e);
  61. }
  62. }
  63. }