using ComPDFKitViewer;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace Compdfkit_Tools.PDFControl
{
    public partial class CPDFDrawModeControl : UserControl
    {
        public PDFViewControl ViewControl;

        public Dictionary<string, DrawModess> GetDrawMode = new Dictionary<string, DrawModess>();

        public CPDFDrawModeControl()
        {
            InitializeComponent();
            CPDFDrawModeUI.Loaded += CPDFDrawModeUI_Loaded;
        }

        private void CPDFDrawModeUI_Loaded(object sender, RoutedEventArgs e)
        {
            GetDrawMode.Clear();
            GetDrawMode.Add("Normal", DrawModess.Normal);
            GetDrawMode.Add("Soft", DrawModess.Soft);
            GetDrawMode.Add("Dark", DrawModess.Dark);
            GetDrawMode.Add("Green", DrawModess.Green);
            GetDrawMode.Add("Custom", DrawModess.Custom);
            CPDFDrawModeUI.SetDrawModeEvent += CPDFDrawModeUI_SetDrawModeEvent;
        }

        private void CPDFDrawModeUI_SetDrawModeEvent(object sender, string e)
        {
            if(ViewControl != null && ViewControl.PDFViewTool!=null)
            {
                CPDFViewer pdfViewer=ViewControl.PDFViewTool.GetCPDFViewer();
                pdfViewer?.SetDrawModes(GetDrawMode[(sender as RadioButton).Tag as string]);
            }
        }

        public void InitWithPDFViewer(PDFViewControl viewControl)
        {
            this.ViewControl = viewControl;
        }
    }
}
