using ComPDFKitViewer.AnnotEvent;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Linq;
using System.Windows;
using ComPDFKit.PDFAnnotation;

namespace PDFSettings
{
    public class DefaultAnnotProperty
    {
        public AnnotArgsType AnnotToolType;
        public Color ForgoundColor;
        public Color BackgroundColor;
        public Color BorderColor;
        public double Opacity;
        public double Thickness;
        public double FontSize;
        public FontStyle FontStyle;
        public FontWeight FontWeight;
        public TextAlignment TextAlign;
        public string FontFamily = string.Empty;
        public string NoteText = string.Empty;
        public string SaveKey;
        public C_LINE_TYPE HeadLineType;
        public C_LINE_TYPE TailLineType;
        public List<double> DashArray;
        public DefaultAnnotProperty()
        {
            AnnotToolType = AnnotArgsType.AnnotNone;
        }
    }

    public class DefaultAnnotProperties : List<DefaultAnnotProperty>
    {
        public DefaultAnnotProperty GetAnnotProperty(AnnotArgsType annotToolType)
        {
            return this.AsEnumerable().Where(x => x.AnnotToolType == annotToolType).FirstOrDefault();
        }

        public DefaultAnnotProperty GetAnnotProperty(AnnotArgsType annotToolType,string saveKey)
        {
            return this.AsEnumerable().Where(x => x.AnnotToolType == annotToolType && x.SaveKey==saveKey).FirstOrDefault();
        }
        public void SetAnnotProperty(DefaultAnnotProperty annotProperty)
        {
            DefaultAnnotProperty[] deleteArray = new DefaultAnnotProperty[0];
            if (annotProperty.SaveKey != null && annotProperty.SaveKey != string.Empty)
            {
                deleteArray = this.AsEnumerable().Where(x => x.AnnotToolType == annotProperty.AnnotToolType && x.SaveKey == annotProperty.SaveKey).ToArray();
            }
            else
            {
                deleteArray = this.AsEnumerable().Where(x => x.AnnotToolType == annotProperty.AnnotToolType).ToArray();
            }
            foreach (DefaultAnnotProperty deleteProperty in deleteArray)
            {
                this.Remove(deleteProperty);
            }
            this.Add(annotProperty);
        }
    }

}