CreateBlankPageSettingDialog.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Forms.VisualStyles;
  5. using Compdfkit_Tools.Helper;
  6. namespace Compdfkit_Tools.PDFControl
  7. {
  8. public class BlankPageSetting
  9. {
  10. public Size Size { get; set; } = new Size(210, 297);
  11. public Orientation Orientation { get; set; } = Orientation.Vertical;
  12. }
  13. public partial class CreateBlankPageSettingDialog : Window
  14. {
  15. public event EventHandler<BlankPageSetting> CreateBlankPage;
  16. public CreateBlankPageSettingDialog()
  17. {
  18. InitializeComponent();
  19. Title = LanguageHelper.CommonManager.GetString("Title_NewFile");
  20. }
  21. private void Cancel_Click(object sender, RoutedEventArgs e)
  22. {
  23. Close();
  24. }
  25. private void Confirm_Click(object sender, RoutedEventArgs e)
  26. {
  27. var blankPageSetting = new BlankPageSetting
  28. {
  29. Size = GetSettingSize(),
  30. Orientation = GetSettingOrientation()
  31. };
  32. CreateBlankPage?.Invoke(this, blankPageSetting);
  33. Close();
  34. }
  35. private Orientation GetSettingOrientation()
  36. {
  37. return HorizontalRdo.IsChecked == true ? Orientation.Horizontal : Orientation.Vertical;
  38. }
  39. private Size GetSettingSize()
  40. {
  41. if (A3Rdo.IsChecked == true)
  42. return new Size(297, 420);
  43. if (A4Rdo.IsChecked == true)
  44. return new Size(210, 297);
  45. if (A5Rdo.IsChecked == true)
  46. return new Size(148, 219);
  47. return new Size(210, 297);
  48. }
  49. }
  50. }