ConverterImgDialog.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. AlertsMessage alertsMessage = new AlertsMessage();
  30. alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageRangeWarning"), App.ServiceLoader.GetString("Text_ok"));
  31. return;
  32. }
  33. ConverterPreview.AwaitRenderBitmap(ConverterPreview.document);
  34. ConverterPreview.PageIndex.Text = ConverterPreview.document.PageCount.ToString();
  35. }
  36. private void PageRangeComboBox_Loaded(object sender, RoutedEventArgs e)
  37. {
  38. PageRangeComboBox.CurrentPage = !((ConverterImgDialogViewModel)this.DataContext).IsCurrentPageIndex;
  39. if (PageRangeComboBox.CurrentPage)
  40. {
  41. ComboBoxItem comboBoxItem = new ComboBoxItem();
  42. comboBoxItem.Content = App.MainPageLoader.GetString("WritableComboBox_CurrentPage");
  43. PageRangeComboBox.writableComboBox.Items.Insert(1, comboBoxItem);
  44. }
  45. }
  46. }
  47. }