using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter;
using System.Windows.Controls;

namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePagePrinter
{
    /// <summary>
    /// Interaction logic for HomePagePrinterModSizeContent
    /// </summary>
    public partial class HomePagePrinterModSizeContent : UserControl
    {
        public HomePagePrinterModSizeContent()
        {
            InitializeComponent();
        }

        private void CustomRatioUpDown_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            CustomRatioUpDown.TextBox_Num.Text = ((HomePagePrinterModSizeContentViewModel)this.DataContext).DisplayRatio;
            CustomRatioUpDown.TextBox_Num.KeyDown += TextBox_Num_KeyDown;
            CustomRatioUpDown.Button_Add.Click += Button_Add_Click;
            CustomRatioUpDown.Button_Sub.Click += Button_Sub_Click;
        }

        private void Button_Sub_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ((HomePagePrinterModSizeContentViewModel)this.DataContext).SetDisplayRatioCommand.Execute();
        }

        private void Button_Add_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ((HomePagePrinterModSizeContentViewModel)this.DataContext).SetDisplayRatioCommand.Execute();
        }

        private void TextBox_Num_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if(e.Key == System.Windows.Input.Key.Enter)
            {
                ((HomePagePrinterModSizeContentViewModel)this.DataContext).SetDisplayRatioCommand.Execute();
            }
        } 
    }
}
