using ComPDFKitViewer.AnnotEvent;
using ComPDFKitViewer.PdfViewer;
using PDF_Office.Model;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace PDF_Office.ViewModels.Form
{

    public class RadioButtonPropertyViewModel : FormBaseVM, INavigationAware
    {
        #region 属性

        #region 选项
        //单选按钮选项
        private string _OptionContent;
        public string OptionContent
        {
            get { return _OptionContent; }
            set { SetProperty(ref _OptionContent, value); }
        }

        private bool _isDefaultChecked = false;
        public bool IsDefaultChecked
        {
            get { return _isDefaultChecked; }
            set { SetProperty(ref _isDefaultChecked, value); }
        }
        #endregion


        #endregion

        #region Command

        #endregion

        #region 变量
        private CPDFViewer PDFViewer;
        private WidgetRadioButtonArgs radioButtonArgs;
        #endregion

        #region 初始化
        public RadioButtonPropertyViewModel()
        {
            InitVariable();
            InitCommand();
        }

        private void InitVariable()
        {

        }

        private void InitCommand()
        {
            ChangeValueHandler -= ChangeValue;
            ChangeValueHandler += ChangeValue;
        }

        #endregion


        #region 一般处理

        #endregion

        #region 外观处理

        #endregion

        #region 选项处理

        #endregion

        #region Navegation
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            radioButtonArgs = null;
        }

        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
            navigationContext.Parameters.TryGetValue<WidgetRadioButtonArgs>("WidgetArgs", out radioButtonArgs);

            GetWidgeText();
        }

        private void GetWidgeText()
        {
            PDFViewer.SetMouseMode(MouseModes.FormEditTool);

            if (radioButtonArgs == null)
            {
                radioButtonArgs = new WidgetRadioButtonArgs();
                radioButtonArgs.FieldName = NameStr;
                radioButtonArgs.BgColor =  Colors.Transparent;
                radioButtonArgs.FontColor = Colors.Black;
                radioButtonArgs.LineColor = Colors.Black;
                radioButtonArgs.LineWidth = 1;
                PDFViewer.SetToolParam(radioButtonArgs);
            }
            else
            {
                PDFViewer.SetToolParam(new AnnotHandlerEventArgs());
            }
           
           
        }

        //更改基类公共属性后，触发的事件
        private void ChangeValue(object sender, FormAttributeType e)
        {
            switch (e)
            {
                case FormAttributeType.Name:
                    break;

                case FormAttributeType.ToolTip:

                    break;

                case FormAttributeType.IsSolid:
                    break;

                case FormAttributeType.IsLocked:
                    break;

                case FormAttributeType.HeightSize:
                    break;

                case FormAttributeType.BorderThiness:
                    break;

                case FormAttributeType.BorderColor:
                    break;

                case FormAttributeType.ContentColor:
                    break;

                case FormAttributeType.IsReadOnly:
                    break;

                case FormAttributeType.WidthSize:
                    break;

                case FormAttributeType.IsRequiredField:
                    break;

            }

        }
        #endregion
    }
}
