CPDFPageExtractUI.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. namespace ComPDFKit.Controls.PDFControlUI
  5. {
  6. public partial class CPDFPageExtractUI : UserControl
  7. {
  8. public int MaxiumIndex
  9. {
  10. get;
  11. set;
  12. }
  13. private int _maxIndex;
  14. public int MaxIndex
  15. {
  16. get => _maxIndex;
  17. set
  18. {
  19. _maxIndex = value;
  20. MaxPageTextBlock.Text = _maxIndex.ToString();
  21. }
  22. }
  23. public string CurrentPageRange
  24. {
  25. set => CustomPageRangeTextBox.Text = value;
  26. }
  27. public PageRange PageRange
  28. {
  29. set
  30. {
  31. if (value == PageRange.AllPages)
  32. {
  33. AllPagesRadioButton.IsChecked = true;
  34. }
  35. else if (value == PageRange.OddPages)
  36. {
  37. OddPagesRadioButton.IsChecked = true;
  38. }
  39. else if (value == PageRange.EvenPages)
  40. {
  41. EvenPagesRadioButton.IsChecked = true;
  42. }
  43. else
  44. {
  45. CustomPagesRadioButton.IsChecked = true;
  46. }
  47. }
  48. }
  49. public event EventHandler<PageRange> PageRangeChanged;
  50. public event EventHandler<string> CustomPageRangeChanged;
  51. public event EventHandler<bool> SeparateChanged;
  52. public event EventHandler<bool> DeleteChanged;
  53. public event EventHandler ExtractEvent;
  54. public event EventHandler CancelEvent;
  55. public CPDFPageExtractUI()
  56. {
  57. InitializeComponent();
  58. }
  59. private void PageRangeRadioButtonClick(object sender, RoutedEventArgs e)
  60. {
  61. var radioButton = sender as RadioButton;
  62. PageRange pageRange = (PageRange)System.Enum.Parse(typeof(PageRange), radioButton.Tag.ToString());
  63. if(pageRange == PageRange.AllPages)
  64. {
  65. DeleteCheckBox.IsChecked = false;
  66. DeleteChanged?.Invoke(null, (bool)false);
  67. }
  68. PageRangeChanged?.Invoke(sender, pageRange);
  69. }
  70. private void SeparateCheckBoxClick(object sender, RoutedEventArgs e)
  71. {
  72. var checkBox = sender as CheckBox;
  73. SeparateChanged?.Invoke(sender, (bool)checkBox.IsChecked);
  74. }
  75. private void DeleteCheckBoxClick(object sender, RoutedEventArgs e)
  76. {
  77. var checkBox = sender as CheckBox;
  78. DeleteChanged?.Invoke(sender, (bool)checkBox.IsChecked);
  79. }
  80. private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
  81. {
  82. var textBox = sender as TextBox;
  83. CustomPageRangeChanged?.Invoke(sender, textBox.Text);
  84. }
  85. private void ExtractButton_Click(object sender, RoutedEventArgs e)
  86. {
  87. ExtractEvent?.Invoke(null, EventArgs.Empty);
  88. }
  89. private void CancelButton_Click(object sender, RoutedEventArgs e)
  90. {
  91. CancelEvent?.Invoke(null, EventArgs.Empty);
  92. }
  93. }
  94. public enum PageRange
  95. {
  96. AllPages = 1,
  97. OddPages,
  98. EvenPages,
  99. CustomPages
  100. }
  101. }