CreateBlankPageSettingDialog.xaml.cs 1.4 KB

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