RemoveWatermarkListDialog.xaml.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_Tools.Helper;
  17. using Path = System.IO.Path;
  18. namespace Compdfkit_Tools.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) + "_RemoveWatermark.pdf");
  47. fileInfo.Document.WriteToFilePath(savePath);
  48. }
  49. System.Diagnostics.Process.Start(path);
  50. Close();
  51. }
  52. }
  53. protected override void OnClosed(EventArgs e)
  54. {
  55. foreach (var fileInfo in RemoveWatermarkListControl.FileInfoDataList)
  56. {
  57. fileInfo.Document.Release();
  58. }
  59. base.OnClosed(e);
  60. }
  61. }
  62. }