using PDF_Office.CustomControl;
using PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs;
using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs;
using PDF_Office.ViewModels.Dialog.ToolsDialogs.SaftyDialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using System.Xml.Linq;

namespace PDF_Office.Views.Dialog.HomePageToolsDialogs
{
    /// <summary>
    /// MainPageSplitDialog.xaml 的交互逻辑
    /// </summary>
    public partial class HomePageSplitDialog : UserControl
    {
        public HomePageSplitDialog()
        {
            InitializeComponent();
        }

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBox = sender as TextBox;
            switch (textBox.Name.ToString())
            {
                case "FileNameLabelTextBox":
                    {
                        ((HomePageSplitDialogViewModel)this.DataContext).FileNameLabelText = FileNameLabelTextBox.Text;
                        ((HomePageSplitDialogViewModel)this.DataContext).FileNameLabelChangeCommand.Execute();
                    }
                    break;
                case "FileNameDeimiterTextBox":
                    {
                        ((HomePageSplitDialogViewModel)this.DataContext).FileNameDeimiterText = FileNameDeimiterTextBox.Text;
                        ((HomePageSplitDialogViewModel)this.DataContext).FileNameDeimiterChangeCommand.Execute();
                    }
                    break;
                default:
                    break;
            }
        }

        private void PageTurningPreview_Loaded(object sender, RoutedEventArgs e)
        {
            SplitPreview.document = ((HomePageSplitDialogViewModel)this.DataContext).document;
            SplitPreview.AwaitRenderBitmap(SplitPreview.document);
            SplitPreview.PageIndex.Text = SplitPreview.document.PageCount.ToString();
        }
    }
}
