using ComPDFKitViewer.AnnotEvent; using PDF_Master.Helper; using PDF_Master.Properties; using PDFSettings; using Prism.Mvvm; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media; namespace PDF_Master.Model.SettingsDialog { public class AnnotateModel:BindableBase { private Color highLightColor; public Color HighLightColor { get { return highLightColor; } set { SetProperty(ref highLightColor, value); } } private Color underLineColor; public Color UnderLineColor { get { return underLineColor; } set { SetProperty(ref underLineColor, value); } } private Color strikethroughColor; public Color StrikethroughColor { get { return strikethroughColor; } set { SetProperty(ref strikethroughColor, value); } } private Color freeHandColor; public Color FreeHandColor { get { return freeHandColor; } set { SetProperty(ref freeHandColor, value); } } private Color textAnnoteColor; public Color TextAnnoteColor { get { return textAnnoteColor; } set { SetProperty(ref textAnnoteColor, value); } } private Color noteAnnoteColor; public Color NoteAnnoteColor { get { return noteAnnoteColor; } set { SetProperty(ref noteAnnoteColor, value); } } private Color rectangleBorderColor; public Color RectangleBorderColor { get { return rectangleBorderColor; } set { SetProperty(ref rectangleBorderColor, value); } } private Color rectangleFillColor; public Color RectangleFillColor { get { return rectangleFillColor; } set { SetProperty(ref rectangleFillColor, value); } } private Color circleBorderColor; public Color CircleBorderColor { get { return circleBorderColor; } set { SetProperty(ref circleBorderColor, value); } } private Color circleFillColor; public Color CircleFillColor { get { return circleFillColor; } set { SetProperty(ref circleFillColor, value); } } private Color lineColor; public Color LineColor { get { return lineColor; } set { SetProperty(ref lineColor, value); } } private Color arrowColor; public Color ArrowColor { get { return arrowColor; } set { SetProperty(ref arrowColor, value); } } private TextAlignment textAlign; public TextAlignment TextAlign { get { return textAlign; } set { SetProperty(ref textAlign, value); } } private string textFontFamaily; public string TextFontFamaily { get { return textFontFamaily; } set { SetProperty(ref textFontFamaily, value); } } private string anchoredFamaily; public string AnchoredFamaily { get { return anchoredFamaily; } set { SetProperty(ref anchoredFamaily, value); } } public AnnotateModel() { InitFromSettings(); } private void InitFromSettings() { var annote = Settings.Default.AppProperties.Annotate; this.HighLightColor = annote.HighLightColor; this.UnderLineColor = annote.UnderLineColor; this.StrikethroughColor = annote.StrikethroughColor; this.FreeHandColor = annote.FreeHandColor; this.TextAnnoteColor = annote.TextAnnoteColor; this.NoteAnnoteColor = annote.NoteAnnoteColor; this.RectangleBorderColor = annote.RectangleBorderColor; this.RectangleFillColor = annote.RectangleFillColor; this.CircleBorderColor = annote.CircleBorderColor; this.CircleFillColor = annote.CircleFillColor; this.LineColor = annote.LineColor; this.ArrowColor = annote.ArrowColor; this.TextFontFamaily = annote.TextFontFamaily; this.AnchoredFamaily = annote.AnchoredFamaily; this.TextAlign = annote.TextAlign; } private void SaveDefaultAnnotSettings() { var highLightAnnot = GetAnnotDefault(AnnotArgsType.AnnotHighlight); highLightAnnot.ForgoundColor = this.HighLightColor; SetDefautAnnotProperties(highLightAnnot); var UnderLineAnnot = GetAnnotDefault(AnnotArgsType.AnnotUnderline); UnderLineAnnot.ForgoundColor = this.UnderLineColor; SetDefautAnnotProperties(UnderLineAnnot); var StrikethroughColor = GetAnnotDefault(AnnotArgsType.AnnotStrikeout); StrikethroughColor.ForgoundColor = this.strikethroughColor; SetDefautAnnotProperties(StrikethroughColor); var FreeHandAnnot = GetAnnotDefault(AnnotArgsType.AnnotFreehand); FreeHandAnnot.ForgoundColor = this.FreeHandColor; SetDefautAnnotProperties(FreeHandAnnot); var TextAnnoteAnnot = GetAnnotDefault(AnnotArgsType.AnnotFreeText); TextAnnoteAnnot.ForgoundColor = this.textAnnoteColor; SetDefautAnnotProperties(TextAnnoteAnnot); var NoteAnnoteAnnot = GetAnnotDefault(AnnotArgsType.AnnotSticky); NoteAnnoteAnnot.ForgoundColor = this.NoteAnnoteColor; SetDefautAnnotProperties(NoteAnnoteAnnot); var RectangleAnnot = GetAnnotDefault(AnnotArgsType.AnnotSquare); RectangleAnnot.BorderColor = this.RectangleBorderColor; RectangleAnnot.BackgroundColor = this.RectangleFillColor; SetDefautAnnotProperties(RectangleAnnot); var AnnotLineAnnot = GetAnnotDefault(AnnotArgsType.AnnotLine); AnnotLineAnnot.BorderColor = this.LineColor; SetDefautAnnotProperties(AnnotLineAnnot); var ArrowAnnot = GetAnnotDefault(AnnotArgsType.AnnotLine,"Arrow"); AnnotLineAnnot.BorderColor = this.LineColor; SetDefautAnnotProperties(AnnotLineAnnot); Settings.Default.Save(); } private void SetDefautAnnotProperties(DefaultAnnotProperty annotProperty) { if (Settings.Default.DefautAnnotProperties == null) { Settings.Default.DefautAnnotProperties = new DefaultAnnotProperties(); } Settings.Default.DefautAnnotProperties.SetAnnotProperty(annotProperty); } private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType,string saveKey="") { var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType,saveKey); if (Annot == null) { Annot = new DefaultAnnotProperty(); } return Annot; } public void Save() { AnnotatePropertyClass annote = new AnnotatePropertyClass(); annote.HighLightColor = this.HighLightColor; annote.UnderLineColor = this.UnderLineColor; annote.StrikethroughColor = this.StrikethroughColor; annote.FreeHandColor = this.FreeHandColor; annote.TextAnnoteColor = this.TextAnnoteColor; annote.NoteAnnoteColor = this.NoteAnnoteColor; annote.RectangleBorderColor = this.RectangleBorderColor; annote.RectangleFillColor = this.RectangleFillColor; annote.CircleBorderColor = this.CircleBorderColor; annote.CircleFillColor = this.CircleFillColor; annote.LineColor = this.LineColor; annote.ArrowColor = this.ArrowColor; annote.TextFontFamaily = this.TextFontFamaily; annote.AnchoredFamaily = this.AnchoredFamaily; annote.TextAlign = this.TextAlign; Settings.Default.AppProperties.Annotate = annote; SaveDefaultAnnotSettings(); } /// /// 重置 /// public void Reset() { var defualtannote = new AnnotatePropertyClass(); this.HighLightColor = defualtannote.HighLightColor; this.UnderLineColor = defualtannote.UnderLineColor; this.StrikethroughColor = defualtannote.StrikethroughColor; this.FreeHandColor = defualtannote.FreeHandColor; this.TextAnnoteColor = defualtannote.TextAnnoteColor; this.NoteAnnoteColor = defualtannote.NoteAnnoteColor; this.RectangleBorderColor = defualtannote.RectangleBorderColor; this.RectangleFillColor = defualtannote.RectangleFillColor; this.CircleBorderColor = defualtannote.CircleBorderColor; this.CircleFillColor = defualtannote.CircleFillColor; this.LineColor = defualtannote.LineColor; this.ArrowColor = defualtannote.ArrowColor; this.TextFontFamaily = defualtannote.TextFontFamaily; this.AnchoredFamaily = defualtannote.AnchoredFamaily; this.TextAlign = defualtannote.TextAlign; } } }