using ComPDFKit.PDFAnnotation;
using ComPDFKitViewer.AnnotEvent;
using PDF_Master.CustomControl;
using PDF_Master.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.Controls.Primitives;
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.PropertyPanel.AnnotPanel
{
    /// <summary>
    /// SharpsAnnotProperty.xaml 的交互逻辑
    /// </summary>
    public partial class SharpsAnnotProperty : UserControl
    {
        private SharpsAnnotPropertyViewModel ViewModel => DataContext as SharpsAnnotPropertyViewModel;

        public SharpsAnnotProperty()
        {
            InitializeComponent();
            this.Loaded += Usercontrol_Loaded;
            cusColor.SelectedColorHandler += cusColor_SelectedColor;
            cusFillColor.SelectedColorHandler += CusFillColor_SelectedColorHandler;
        }

        private void CusFillColor_SelectedColorHandler(object sender, Color e)
        {
            if (ViewModel != null)
            {
                ViewModel.SelectedFillColorCommand?.Execute(e);
            }
        }

        private void cusColor_SelectedColor(object sender, Color e)
        {
            if (ViewModel != null)
            {
                ViewModel.SelectedBorderColorCommand?.Execute(e);
            }
        }

        private void Usercontrol_Loaded(object sender, RoutedEventArgs e)
        {
            if (ViewModel != null)
            {
                var str = ViewModel.BasicVm.strOtherTag;
                if (str == "Rect")
                {
                    SharpRectBtn.IsChecked = true;
                }
                else if (str == "Circle")
                {
                    SharpCircleBtn.IsChecked = true;
                }
                else if (str == "Arrow")
                {
                    SharpArrowBtn.IsChecked = true;
                }
                else if (str == "Line")
                {
                    SharpLineBtn.IsChecked = true;
                }
            }
        }
    }
}