using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
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;

namespace PDF_Office.Views.PropertyPanel.AnnotPanel
{
    /// <summary>
    /// FreehandAnnotProperty.xaml 的交互逻辑
    /// </summary>
    public partial class FreehandAnnotProperty : UserControl
    {
        public FreehandAnnotProperty()
        {
            InitializeComponent();
            cusColor.SelectedColorHandler += cusColor_SelectedColor;
            layerThick.SelectedValueChanged += layerThick_SelectedValue;
        }

        private void layerThick_SelectedValue(object sender, double e)
        {
            var data = this.DataContext as FreehandAnnotPropertyViewModel;
            if (data != null)
            {
                data.SelectedValueChangedCommand?.Execute(e);
            }
        }

        private void cusColor_SelectedColor(object sender, Color e)
        {
            var data = this.DataContext as FreehandAnnotPropertyViewModel;
            if (data != null)
            {
                data.SelectedColorChangedCommand?.Execute(e);
            }
        }

        private void EraseBtn_Click(object sender, RoutedEventArgs e)
        {
            if (EraseBtn.IsChecked == true)
            {
                PenBtn.IsChecked = !EraseBtn.IsChecked;
            }
            else
            {
                EraseBtn.IsChecked = true;
            }
               
        }

        private void PenBtn_Click(object sender, RoutedEventArgs e)
        {
            if (PenBtn.IsChecked == true)
            {
                EraseBtn.IsChecked = !PenBtn.IsChecked;
            }
            else
            {
                PenBtn.IsChecked = true;
            }
        }

        private void PenBtn_Checked(object sender, RoutedEventArgs e)
        {
            EraseBtn.IsChecked = false;
        }
    }
}
