ConverterImgDialog.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using ComPDFKit_Conversion.Converter;
  2. using ComPDFKit_Conversion.Options;
  3. using PDF_Master.CustomControl;
  4. using PDF_Master.Helper;
  5. using PDF_Master.ViewModels.Dialog.ConverterDialogs;
  6. using System.Diagnostics;
  7. using System.Linq;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. namespace PDF_Master.Views.Dialog.ConverterDialogs
  11. {
  12. /// <summary>
  13. /// Interaction logic for ConverterImgDialog
  14. /// </summary>
  15. public partial class ConverterImgDialog : UserControl
  16. {
  17. public ConverterImgDialog()
  18. {
  19. InitializeComponent();
  20. }
  21. private void ConverterPreview_Loaded(object sender, System.Windows.RoutedEventArgs e)
  22. {
  23. ConverterPreview.document = ((ConverterImgDialogViewModel)this.DataContext).currentViewer.Document;
  24. char[] enumerationSeparator = new char[] { ',' };
  25. char[] rangeSeparator = new char[] { '-' };
  26. if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, "1-" + ConverterPreview.document.PageCount.ToString(), ConverterPreview.document.PageCount, enumerationSeparator, rangeSeparator))
  27. { //TODO
  28. Trace.WriteLine("输入不对");
  29. MessageBoxEx.Show("输入不对");
  30. return;
  31. }
  32. ConverterPreview.AwaitRenderBitmap(ConverterPreview.document);
  33. ConverterPreview.PageIndex.Text = ConverterPreview.document.PageCount.ToString();
  34. }
  35. private void PageRangeComboBox_Loaded(object sender, RoutedEventArgs e)
  36. {
  37. PageRangeComboBox.CurrentPage = !((ConverterImgDialogViewModel)this.DataContext).IsCurrentPageIndex;
  38. if (PageRangeComboBox.CurrentPage)
  39. {
  40. ComboBoxItem comboBoxItem = new ComboBoxItem();
  41. comboBoxItem.Content = "当前页面";
  42. PageRangeComboBox.writableComboBox.Items.Insert(1, comboBoxItem);
  43. }
  44. }
  45. }
  46. }