123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620 |
- using ComPDFKit.PDFAnnotation;
- using ComPDFKitViewer;
- using ComPDFKitViewer.AnnotEvent;
- using Microsoft.Win32;
- using PDF_Office.CustomControl;
- using PDF_Office.Helper;
- using PDF_Office.Properties;
- using PDFSettings;
- 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;
- using System.Windows.Media;
- namespace PDF_Office.ViewModels.Tools
- {
- public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
- {
- #region 初始化
- private void BindingEvent()
- {
- propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
- propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
- propertyPanel.AnnotTypeChanged += AnnotPropertyPanel_AnnotTypeChanged;
- }
- private void InitDefaultValue()
- {
- InitAnnotHighlight();
- InitAnnotUnderline();
- InitAnnotSquiggly();
- InitAnnotStrikeout();
- }
- private void InitAnnotHighlight()
- {
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
- if (annotProperty == null)
- {
- annotProperty = new DefaultAnnotProperty();
- annotProperty.AnnotToolType = AnnotArgsType.AnnotHighlight;
- annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.Opacity = 0.5;
- SettingHelper.SetAnnotDefaultProperty(annotProperty);
- }
- else
- {
- HighLightColor = new SolidColorBrush(annotProperty.BackgroundColor);
- HighLightOpacity = annotProperty.Opacity;
- }
- }
- private void InitAnnotUnderline()
- {
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
- if (annotProperty == null)
- {
- annotProperty = new DefaultAnnotProperty();
- annotProperty.AnnotToolType = AnnotArgsType.AnnotUnderline;
- annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.Opacity = 0.5;
- SettingHelper.SetAnnotDefaultProperty(annotProperty);
- }
- else
- {
- UnderLineColor = new SolidColorBrush(annotProperty.BackgroundColor);
- UnderLineOpacity = annotProperty.Opacity;
- }
- }
- private void InitAnnotSquiggly()
- {
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquiggly);
- if (annotProperty == null)
- {
- annotProperty = new DefaultAnnotProperty();
- annotProperty.AnnotToolType = AnnotArgsType.AnnotSquiggly;
- annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.Opacity = 0.5;
- SettingHelper.SetAnnotDefaultProperty(annotProperty);
- }
- else
- {
- SquigglyColor = new SolidColorBrush(annotProperty.BackgroundColor);
- SquigglyOpacity = annotProperty.Opacity;
- }
- }
- private void InitAnnotStrikeout()
- {
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStrikeout);
- if (annotProperty == null)
- {
- annotProperty = new DefaultAnnotProperty();
- annotProperty.AnnotToolType = AnnotArgsType.AnnotStrikeout;
- annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
- annotProperty.Opacity = 0.5;
- SettingHelper.SetAnnotDefaultProperty(annotProperty);
- }
- else
- {
- StrikeoutColor = new SolidColorBrush(annotProperty.BackgroundColor);
- StrikeoutOpacity = annotProperty.Opacity;
- }
- }
- #endregion
- #region 注释工具
- /// <summary>
- /// 高亮注释
- /// </summary>
- /// <returns></returns>
- private AnnotHandlerEventArgs GetHighLight(TextHighlightAnnotArgs selectedhighlightArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- TextHighlightAnnotArgs highlightArgs = null;
- if(selectedhighlightArgs == null)
- {
- highlightArgs = new TextHighlightAnnotArgs();
- highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
- highlightArgs.Transparency = 0.5;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
- if (annotProperty != null)
- {
- highlightArgs.Color = annotProperty.ForgoundColor;
- highlightArgs.Transparency = annotProperty.Opacity;
- highlightArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- highlightArgs = selectedhighlightArgs;
- }
- annotAttribsList[AnnotAttrib.Color] = highlightArgs.Color;
- annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
- AddToPropertyPanel("TextAnnotProperty", "HighLight", highlightArgs, annotAttribsList);
- return highlightArgs;
- }
- private AnnotHandlerEventArgs GetUnderLine(TextUnderlineAnnotArgs selectedunderlineArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- TextUnderlineAnnotArgs underlineArgs = null;
- if (selectedunderlineArgs == null)
- {
- underlineArgs = new TextUnderlineAnnotArgs();
- underlineArgs.Color = Color.FromRgb(0x12, 0xFD, 0xFF);
- underlineArgs.Transparency = 1;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
- if (annotProperty != null)
- {
- underlineArgs.Color = annotProperty.ForgoundColor;
- underlineArgs.Transparency = annotProperty.Opacity;
- underlineArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- underlineArgs = selectedunderlineArgs;
- }
- annotAttribsList[AnnotAttrib.Color] = underlineArgs.Color;
- annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
-
- AddToPropertyPanel("TextAnnotProperty", "UnderLine", underlineArgs, annotAttribsList);
- return underlineArgs;
- }
- private AnnotHandlerEventArgs GetSquiggly(TextSquigglyAnnotArgs selectedsquigglyArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- TextSquigglyAnnotArgs squigglyArgs = null;
- if (selectedsquigglyArgs == null)
- {
- squigglyArgs = new TextSquigglyAnnotArgs();
- squigglyArgs.Color = Color.FromRgb(0xFF, 0x87, 0x16);
- squigglyArgs.Transparency = 1;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquiggly);
- if (annotProperty != null)
- {
- squigglyArgs.Color = annotProperty.ForgoundColor;
- squigglyArgs.Transparency = annotProperty.Opacity;
- squigglyArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- squigglyArgs = selectedsquigglyArgs;
- }
- annotAttribsList[AnnotAttrib.Color] = squigglyArgs.Color;
- annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
- AddToPropertyPanel("TextAnnotProperty", "Squiggly", squigglyArgs, annotAttribsList);
- return squigglyArgs;
- }
- private AnnotHandlerEventArgs GetStrikeout(TextStrikeoutAnnotArgs selectedstrikeoutArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- TextStrikeoutAnnotArgs strikeoutArgs = null;
- if(selectedstrikeoutArgs == null)
- {
- strikeoutArgs = new TextStrikeoutAnnotArgs();
- strikeoutArgs.Color = Color.FromRgb(0xFF, 0x3B, 0x30);
- strikeoutArgs.Transparency = 1;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStrikeout);
- if (annotProperty != null)
- {
- strikeoutArgs.Color = annotProperty.ForgoundColor;
- strikeoutArgs.Transparency = annotProperty.Opacity;
- strikeoutArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- strikeoutArgs = selectedstrikeoutArgs;
- }
-
- annotAttribsList[AnnotAttrib.Color] = strikeoutArgs.Color;
- annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
- AddToPropertyPanel("TextAnnotProperty", "Strikeout", strikeoutArgs, annotAttribsList);
- return strikeoutArgs;
- }
- private AnnotHandlerEventArgs GetFreehand(FreehandAnnotArgs selectedfreehandArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- FreehandAnnotArgs freehandArgs = null;
- if(selectedfreehandArgs == null)
- {
- freehandArgs = new FreehandAnnotArgs();
- freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
- freehandArgs.Transparency = 1;
- freehandArgs.LineWidth = 1;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreehand);
- if (annotProperty != null)
- {
- freehandArgs.InkColor = annotProperty.ForgoundColor;
- freehandArgs.Transparency = annotProperty.Opacity;
- freehandArgs.LineWidth = annotProperty.Thickness;
- freehandArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- freehandArgs = selectedfreehandArgs;
- }
-
- annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
- annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
- annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
- annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
- AddToPropertyPanel("FreehandAnnotProperty", "Freehand", freehandArgs, annotAttribsList);
- return freehandArgs;
- }
- private AnnotHandlerEventArgs GetFreetext(FreeTextAnnotArgs selectedfreetextArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- FreeTextAnnotArgs freetextArgs = null;
- TextAlignment textAlignment;
- if (selectedfreetextArgs == null)
- {
- freetextArgs = new FreeTextAnnotArgs();
- freetextArgs.Align = TextAlignment.Left;
- freetextArgs.BgColor = Colors.Transparent;
- freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
- freetextArgs.FontColor = Colors.Black;
- freetextArgs.FontSize = 14;
- freetextArgs.Transparency = 1;
- freetextArgs.LineColor = Colors.Black;
- freetextArgs.LineWidth = 0;
- freetextArgs.TextContent = string.Empty;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
- if (annotProperty != null)
- {
- freetextArgs.Align = annotProperty.TextAlign;
- freetextArgs.BgColor = annotProperty.BackgroundColor;
- freetextArgs.FontFamily = new FontFamily(annotProperty.FontFamily);
- freetextArgs.FontColor = annotProperty.ForgoundColor;
- freetextArgs.FontSize = annotProperty.FontSize;
- freetextArgs.Transparency = annotProperty.Opacity;
- freetextArgs.LineColor = annotProperty.BorderColor;
- freetextArgs.LineWidth = annotProperty.Thickness;
- freetextArgs.TextContent = annotProperty.NoteText;
- freetextArgs.FontWeight = annotProperty.FontWeight;
- freetextArgs.FontStyle = annotProperty.FontStyle;
- }
- int align = Settings.Default.AppProperties.Annotate.TextAlign;
- if (align == 0)
- textAlignment = TextAlignment.Left;
- else if (align == 1)
- textAlignment = TextAlignment.Center;
- else
- textAlignment = TextAlignment.Right;
- }
- else
- {
- freetextArgs = selectedfreetextArgs;
- textAlignment = freetextArgs.Align;
- }
-
- annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
- annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
- annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
- annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
- annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
- annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
- annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
- annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
- annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
- annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
- annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
- AddToPropertyPanel("FreetextAnnotProperty", "Freetext", freetextArgs, annotAttribsList);
- return freetextArgs;
- }
- private AnnotHandlerEventArgs GetStickyNote()
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- StickyAnnotArgs stickyAnnotArgs = new StickyAnnotArgs();
- stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
- stickyAnnotArgs.StickyNote = string.Empty;
- stickyAnnotArgs.Transparency = 1;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSticky);
- if (annotProperty != null)
- {
- stickyAnnotArgs.Color = annotProperty.ForgoundColor;
- stickyAnnotArgs.StickyNote = annotProperty.NoteText;
- stickyAnnotArgs.Transparency = annotProperty.Opacity;
- }
- annotAttribsList[AnnotAttrib.Color] = stickyAnnotArgs.Color;
- annotAttribsList[AnnotAttrib.Transparency] = stickyAnnotArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = stickyAnnotArgs.StickyNote;
- AddToPropertyPanel("FreetextAnnotProperty", "StickyNote", stickyAnnotArgs, annotAttribsList);
- return stickyAnnotArgs;
- }
- private AnnotHandlerEventArgs GetRect(SquareAnnotArgs selectedsquareArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- SquareAnnotArgs squareArgs = null;
- if(selectedsquareArgs == null)
- {
- squareArgs = new SquareAnnotArgs();
- squareArgs.LineColor = Colors.Red;
- squareArgs.BgColor = Colors.Transparent;
- squareArgs.LineWidth = 1;
- squareArgs.Transparency = 1;
- squareArgs.LineDash = DashStyles.Solid;
- squareArgs.Content = string.Empty;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquare);
- if (annotProperty != null)
- {
- squareArgs.LineColor = annotProperty.BorderColor;
- squareArgs.BgColor = annotProperty.BackgroundColor;
- if (annotProperty.DashArray == null || annotProperty.DashArray.Count == 0)
- {
- squareArgs.LineDash = DashStyles.Solid;
- }
- else
- {
- DashStyle dash = new DashStyle();
- foreach (var offset in annotProperty.DashArray)
- {
- dash.Dashes.Add(offset);
- }
- squareArgs.LineDash = dash;
- }
- squareArgs.LineWidth = annotProperty.Thickness;
- squareArgs.Transparency = annotProperty.Opacity;
- squareArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- squareArgs = selectedsquareArgs;
- }
-
- annotAttribsList[AnnotAttrib.Color] = squareArgs.LineColor;
- annotAttribsList[AnnotAttrib.FillColor] = squareArgs.BgColor;
- annotAttribsList[AnnotAttrib.LineStyle] = squareArgs.LineDash;
- annotAttribsList[AnnotAttrib.Thickness] = squareArgs.LineWidth;
- annotAttribsList[AnnotAttrib.Transparency] = squareArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = squareArgs.Content;
- AddToPropertyPanel("SharpsAnnotProperty", "Rect", squareArgs, annotAttribsList);
- return squareArgs;
- }
- private AnnotHandlerEventArgs GetCircle(CircleAnnotArgs selectedcircleAnnotArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- CircleAnnotArgs circleAnnotArgs = null;
- if(selectedcircleAnnotArgs == null)
- {
- circleAnnotArgs = new CircleAnnotArgs();
- circleAnnotArgs.LineColor = Colors.Red;
- circleAnnotArgs.BgColor = Colors.Transparent;
- circleAnnotArgs.LineWidth = 1;
- circleAnnotArgs.Transparency = 1;
- circleAnnotArgs.LineDash = DashStyles.Solid;
- circleAnnotArgs.Content = string.Empty;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotCircle);
- if (annotProperty != null)
- {
- circleAnnotArgs.LineColor = annotProperty.BorderColor;
- circleAnnotArgs.BgColor = annotProperty.BackgroundColor;
- if (annotProperty.DashArray == null || annotProperty.DashArray.Count == 0)
- {
- circleAnnotArgs.LineDash = DashStyles.Solid;
- }
- else
- {
- DashStyle dash = new DashStyle();
- foreach (var offset in annotProperty.DashArray)
- {
- dash.Dashes.Add(offset);
- }
- circleAnnotArgs.LineDash = dash;
- }
- circleAnnotArgs.LineWidth = annotProperty.Thickness;
- circleAnnotArgs.Transparency = annotProperty.Opacity;
- circleAnnotArgs.Content = annotProperty.NoteText;
- }
- }
- else
- {
- circleAnnotArgs = selectedcircleAnnotArgs;
- }
-
- annotAttribsList[AnnotAttrib.Color] = circleAnnotArgs.LineColor;
- annotAttribsList[AnnotAttrib.FillColor] = circleAnnotArgs.BgColor;
- annotAttribsList[AnnotAttrib.LineStyle] = circleAnnotArgs.LineDash;
- annotAttribsList[AnnotAttrib.Thickness] = circleAnnotArgs.LineWidth;
- annotAttribsList[AnnotAttrib.Transparency] = circleAnnotArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = circleAnnotArgs.Content;
- AddToPropertyPanel("SharpsAnnotProperty", "Circle", circleAnnotArgs, annotAttribsList);
- return circleAnnotArgs;
- }
- private AnnotHandlerEventArgs GetArrowLine(string TagStr,LineAnnotArgs selectedLineAnnotArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- LineAnnotArgs lineArgs = new LineAnnotArgs();
- if(selectedLineAnnotArgs == null)
- {
- lineArgs.LineColor = Colors.Red;
- lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
- if (TagStr == "Line")
- {
- lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
- }
- else
- {
- lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
- }
- lineArgs.LineDash = DashStyles.Solid;
- lineArgs.LineWidth = 1;
- lineArgs.Transparency = 1;
- lineArgs.Content = string.Empty;
- }
- else
- {
- lineArgs = selectedLineAnnotArgs;
- }
- DefaultAnnotProperty annotProperty = null;
- if (TagStr == "Line")
- {
- annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLine, "Line");
- if (annotProperty != null)
- {
- annotProperty.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
- annotProperty.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
- }
- }
- else
- {
- annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLine, "Arrow");
- }
- if (annotProperty != null)
- {
- lineArgs.LineColor = annotProperty.BorderColor;
- lineArgs.HeadLineType = annotProperty.HeadLineType;
- lineArgs.TailLineType = annotProperty.TailLineType;
- DashStyle dash = new DashStyle();
- foreach (var offset in annotProperty.DashArray)
- {
- dash.Dashes.Add(offset);
- }
- lineArgs.LineDash = dash;
- lineArgs.LineWidth = annotProperty.Thickness;
- lineArgs.Transparency = annotProperty.Opacity;
- lineArgs.Content = annotProperty.NoteText;
- }
- annotAttribsList[AnnotAttrib.Color] = lineArgs.LineColor;
- annotAttribsList[AnnotAttrib.LineStart] = lineArgs.HeadLineType;
- annotAttribsList[AnnotAttrib.LineEnd] = lineArgs.TailLineType;
- annotAttribsList[AnnotAttrib.LineStyle] = lineArgs.LineDash;
- annotAttribsList[AnnotAttrib.Thickness] = lineArgs.LineWidth;
- annotAttribsList[AnnotAttrib.Transparency] = lineArgs.Transparency;
- annotAttribsList[AnnotAttrib.NoteText] = lineArgs.Content;
- AddToPropertyPanel("SharpsAnnotProperty", TagStr, lineArgs, annotAttribsList);
- return lineArgs;
- }
- private AnnotHandlerEventArgs GetStamp()
- {
- AddToPropertyPanel("StampAnnotProperty");
- return null;
- }
- private AnnotHandlerEventArgs GetSignature()
- {
- AddToPropertyPanel("SignatureAnnotProperty");
- return null;
- }
- private AnnotHandlerEventArgs GetImage(CustomIconToggleBtn annotBtn)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- annotBtn.IsChecked = false;
- StampAnnotArgs stampArgs = new StampAnnotArgs();
- stampArgs.Opacity = 1;
- stampArgs.Type = StampType.IMAGE_STAMP;
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
- if (openFileDialog.ShowDialog() == true)
- {
- stampArgs.ImagePath = openFileDialog.FileName;
-
- }
- AddToPropertyPanel("ImageAnnotProperty", null, stampArgs, annotAttribsList);
- return stampArgs;
- }
- /// <summary>
- /// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
- /// </summary>
- /// <param name="viewContent">对应的注释面板</param>
- /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
- /// <param name="annot">注释</param>
- /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
- private void AddToPropertyPanel(string viewContent, string toolTag = null, AnnotHandlerEventArgs annot = null, Dictionary<AnnotAttrib, object> annotAttribsList = null)
- {
- if (string.IsNullOrEmpty(toolTag) == false)
- {
- if (!ToolExpandDict.ContainsKey(toolTag))
- {
- ToolExpandDict[toolTag] = true;
- }
- }
- if (annot != null)
- propertyPanel.annot = annot;
- if (annotAttribsList != null)
- propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annotAttribsList);
- if (string.IsNullOrEmpty(viewContent) == false)
- viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
- }
- #endregion
- }
- }
|