ConverterExcelDialog.xaml.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using ComPDFKit_Conversion.Options;
  2. using PDF_Master.CustomControl;
  3. using PDF_Master.Helper;
  4. using PDF_Master.ViewModels.Dialog.ConverterDialogs;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. namespace PDF_Master.Views.Dialog.ConverterDialogs
  10. {
  11. /// <summary>
  12. /// Interaction logic for ConverterExcelDialog
  13. /// </summary>
  14. public partial class ConverterExcelDialog : UserControl
  15. {
  16. public ConverterExcelDialog()
  17. {
  18. InitializeComponent();
  19. }
  20. private void ConverterPreview_Loaded(object sender, System.Windows.RoutedEventArgs e)
  21. {
  22. ConverterPreview.document = ((ConverterExcelDialogViewModel)this.DataContext).currentViewer.Document;
  23. char[] enumerationSeparator = new char[] { ',' };
  24. char[] rangeSeparator = new char[] { '-' };
  25. if (!CommonHelper.GetPagesInRange(ref ConverterPreview.PageIndexLists, "1-" + ConverterPreview.document.PageCount.ToString(), ConverterPreview.document.PageCount, enumerationSeparator, rangeSeparator))
  26. { //TODO
  27. Trace.WriteLine("输入不对");
  28. AlertsMessage alertsMessage = new AlertsMessage();
  29. alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageRangeWarning"), App.ServiceLoader.GetString("Text_ok"));
  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 = !((ConverterExcelDialogViewModel)this.DataContext).IsCurrentPageIndex;
  38. if (PageRangeComboBox.CurrentPage)
  39. {
  40. ComboBoxItem comboBoxItem = new ComboBoxItem();
  41. comboBoxItem.Content = App.MainPageLoader.GetString("WritableComboBox_CurrentPage");
  42. PageRangeComboBox.writableComboBox.Items.Insert(1, comboBoxItem);
  43. }
  44. }
  45. }
  46. }