using PDF_Master.CustomControl; using PDF_Master.Helper; using PDF_Master.ViewModels.Dialog.HomePageToolsDialogs; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace PDF_Master.Views.Dialog.HomePageToolsDialogs { /// /// MainPageInsertDialog.xaml 的交互逻辑 /// public partial class HomePageInsertDialog : UserControl { public HomePageInsertDialog() { InitializeComponent(); } private void PageInsertIndexTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (this.PageInsertIndexTextBox.Text == "" || int.Parse(this.PageInsertIndexTextBox.Text) < 1) { this.PageInsertIndexTextBox.Text = "1"; } if (this.PageCountText != null&&this.PageCountText.Text !="") { if (int.Parse(this.PageInsertIndexTextBox.Text) > int.Parse(this.PageCountText.Text)) { this.PageInsertIndexTextBox.Text = this.PageCountText.Text; } } ((HomePageInsertDialogViewModel)this.DataContext).PageInsertIndex = this.PageInsertIndexTextBox.Text; } private void CountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e) { e.Handled = new Regex("[^0-9]+").IsMatch(e.Text); } private void PageTurningPreview_Loaded(object sender, RoutedEventArgs e) { InsertPreview.document = ((HomePageInsertDialogViewModel)this.DataContext).document; char[] enumerationSeparator = new char[] { ',' }; char[] rangeSeparator = new char[] { '-' }; if (!CommonHelper.GetPagesInRange(ref InsertPreview.PageIndexLists, "1-" + InsertPreview.document.PageCount.ToString(), InsertPreview.document.PageCount, enumerationSeparator, rangeSeparator)) { //TODO Trace.WriteLine("输入不对"); MessageBoxEx.Show("输入不对"); return; } InsertPreview.AwaitRenderBitmap(InsertPreview.document); InsertPreview.PageIndex.Text = InsertPreview.document.PageCount.ToString(); } } }