123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- 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();
- }
- /// <summary>
- /// 重置
- /// </summary>
- 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;
- }
- }
- }
|