CreateBlankPageSettingDialog.xaml.cs 1.5 KB

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