|
@@ -122,7 +122,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
|
|
|
//在xaml里引用
|
|
|
- public Dictionary<string, string> GetToolTipDict { get { return ToolTipDict; } }
|
|
|
+ public Dictionary<string, string> GetToolTipDict
|
|
|
+ { get { return ToolTipDict; } }
|
|
|
|
|
|
//用来记录选中、创建注释的标识
|
|
|
private void InitToolDict()
|
|
@@ -142,7 +143,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
ToolExpandDict.Add("Link", AnnotArgsType.AnnotLink);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//注释工具按钮悬浮文案
|
|
|
private void InitToolTipDict()
|
|
|
{
|
|
@@ -167,18 +167,16 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
ToolTipDict.Add("ShowAnnot", "显示/隐藏注释");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//便签批注弹窗
|
|
|
private void LoaedStickyNotePopup()
|
|
|
{
|
|
|
if (PDFViewer == null) return;
|
|
|
|
|
|
- if(customStickyPopup == null)
|
|
|
+ if (customStickyPopup == null)
|
|
|
{
|
|
|
customStickyPopup = new StickyNotePopup();
|
|
|
PDFViewer.SetStickyNotePop(customStickyPopup);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
#endregion 初始化数据
|
|
@@ -251,15 +249,14 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
break;
|
|
|
|
|
|
case "Link"://链接
|
|
|
+ propertyPanel.IsAddLink = true;
|
|
|
viewContentViewModel.IsRightMenuCreateLink = isRightMenuAdd;
|
|
|
annotArgs = GetLink();
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if(annotArgs != null)
|
|
|
- annotArgs.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
-
|
|
|
-
|
|
|
+ if (annotArgs != null)
|
|
|
+ annotArgs.Author = Settings.Default.AppProperties.Description.Author;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -275,11 +272,20 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
highlightArgs.Transparency = highLightOpacity;
|
|
|
highlightArgs.Color = (highLightColor as SolidColorBrush).Color;
|
|
|
|
|
|
- if (highlightArgs != null)
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(highlightArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
{
|
|
|
- selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
- selectedArgs.Add(highlightArgs);
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = highlightArgs.EventType;
|
|
|
+ defaultAnnot.ForgoundColor = (highLightColor as SolidColorBrush).Color;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
}
|
|
|
+
|
|
|
+ highLightOpacity = highlightArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
+ selectedArgs.Add(highlightArgs);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -313,7 +319,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
selectedArgs.Add(linkArgs);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
AddToPropertyPanel("LinkAnnotProperty", "Link", selectedArgs, annotAttribEvent);
|
|
|
return linkArgs;
|
|
|
}
|
|
@@ -332,11 +337,20 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
underlineArgs.Transparency = UnderLineOpacity;
|
|
|
underlineArgs.Color = (UnderLineColor as SolidColorBrush).Color;
|
|
|
|
|
|
- if (underlineArgs != null)
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(underlineArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
{
|
|
|
- selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
- selectedArgs.Add(underlineArgs);
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = underlineArgs.EventType;
|
|
|
+ defaultAnnot.ForgoundColor = (UnderLineColor as SolidColorBrush).Color;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
}
|
|
|
+
|
|
|
+ UnderLineOpacity = underlineArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
+ selectedArgs.Add(underlineArgs);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -362,11 +376,20 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
squigglyArgs.Transparency = SquigglyOpacity;
|
|
|
squigglyArgs.Color = (squigglyColor as SolidColorBrush).Color;
|
|
|
|
|
|
- if (squigglyArgs != null)
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squigglyArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
{
|
|
|
- selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
- selectedArgs.Add(squigglyArgs);
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = squigglyArgs.EventType;
|
|
|
+ defaultAnnot.ForgoundColor = (squigglyColor as SolidColorBrush).Color;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
}
|
|
|
+
|
|
|
+ SquigglyOpacity = squigglyArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
+ selectedArgs.Add(squigglyArgs);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -392,11 +415,20 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
strikeoutArgs.Transparency = strikeoutOpacity;
|
|
|
strikeoutArgs.Color = (strikeoutColor as SolidColorBrush).Color;
|
|
|
|
|
|
- if (strikeoutArgs != null)
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(strikeoutArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
{
|
|
|
- selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
- selectedArgs.Add(strikeoutArgs);
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = strikeoutArgs.EventType;
|
|
|
+ defaultAnnot.ForgoundColor = (strikeoutColor as SolidColorBrush).Color;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
}
|
|
|
+
|
|
|
+ strikeoutArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
+ selectedArgs.Add(strikeoutArgs);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -429,14 +461,39 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
|
|
|
}
|
|
|
|
|
|
- freehandArgs.Transparency = 1;
|
|
|
- freehandArgs.LineWidth = 2;
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freehandArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
+ {
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = freehandArgs.EventType;
|
|
|
+ defaultAnnot.ForgoundColor = annotate.FreeHandColor;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+
|
|
|
+ freehandArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+ freehandArgs.LineWidth = defaultAnnot.Thickness;
|
|
|
|
|
|
- if (freehandArgs != null)
|
|
|
+ if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
|
|
|
{
|
|
|
- selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
- selectedArgs.Add(freehandArgs);
|
|
|
+ freehandArgs.LineDash = DashStyles.Solid;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var collect = new DoubleCollection();
|
|
|
+ foreach (var item in defaultAnnot.DashArray)
|
|
|
+ {
|
|
|
+ collect.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (freehandArgs.LineDash == null)
|
|
|
+ freehandArgs.LineDash = new DashStyle();
|
|
|
+
|
|
|
+ freehandArgs.LineDash.Dashes = collect;
|
|
|
+ }
|
|
|
+
|
|
|
+ selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
|
+ selectedArgs.Add(freehandArgs);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -471,15 +528,33 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
freetextArgs.FontColor = Colors.Black;
|
|
|
}
|
|
|
|
|
|
- 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;
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(freetextArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
+ {
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = freetextArgs.EventType;
|
|
|
+ defaultAnnot.ForgoundColor = freetextArgs.FontColor;
|
|
|
+ defaultAnnot.BorderColor = Colors.Transparent;
|
|
|
+ defaultAnnot.BackgroundColor = Colors.Transparent;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ defaultAnnot.FontFamily = Settings.Default.AppProperties.Annotate.TextFontFamaily;
|
|
|
+ defaultAnnot.FontSize = 14;
|
|
|
+ defaultAnnot.TextAlign = TextAlignment.Left;
|
|
|
+ defaultAnnot.Thickness = 0;
|
|
|
+ defaultAnnot.NoteText = string.Empty;
|
|
|
+
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+
|
|
|
+ freetextArgs.FontColor = defaultAnnot.ForgoundColor;
|
|
|
+ freetextArgs.LineColor = defaultAnnot.BorderColor;
|
|
|
+ freetextArgs.BgColor = defaultAnnot.BackgroundColor;
|
|
|
+ freetextArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+ freetextArgs.FontFamily = new FontFamily(defaultAnnot.FontFamily);
|
|
|
+ freetextArgs.FontSize = defaultAnnot.FontSize;
|
|
|
+ freetextArgs.FontWeight = defaultAnnot.FontWeight;
|
|
|
+ freetextArgs.FontStyle = defaultAnnot.FontStyle;
|
|
|
+ freetextArgs.LineWidth = defaultAnnot.Thickness;
|
|
|
|
|
|
int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
|
|
|
|
|
@@ -490,6 +565,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
else
|
|
|
textAlignment = TextAlignment.Right;
|
|
|
|
|
|
+ freetextArgs.Align = textAlignment;
|
|
|
+
|
|
|
if (freetextArgs != null)
|
|
|
{
|
|
|
selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
@@ -526,8 +603,18 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
|
|
|
}
|
|
|
- stickyAnnotArgs.StickyNote = string.Empty;
|
|
|
- stickyAnnotArgs.Transparency = 1;
|
|
|
+
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(stickyAnnotArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
+ {
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = stickyAnnotArgs.EventType;
|
|
|
+ defaultAnnot.NoteText = string.Empty;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+
|
|
|
+ stickyAnnotArgs.Transparency = defaultAnnot.Opacity;
|
|
|
|
|
|
if (stickyAnnotArgs != null)
|
|
|
{
|
|
@@ -572,10 +659,36 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
squareArgs.BgColor = Colors.Red;
|
|
|
}
|
|
|
|
|
|
- squareArgs.LineWidth = 1;
|
|
|
- squareArgs.Transparency = 1;
|
|
|
- squareArgs.LineDash = DashStyles.Solid;
|
|
|
- squareArgs.Content = string.Empty;
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(squareArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
+ {
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = squareArgs.EventType;
|
|
|
+ defaultAnnot.Thickness = 1;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+
|
|
|
+ squareArgs.LineWidth = defaultAnnot.Thickness;
|
|
|
+ squareArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
|
|
|
+ {
|
|
|
+ squareArgs.LineDash = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var collect = new DoubleCollection();
|
|
|
+ foreach (var item in defaultAnnot.DashArray)
|
|
|
+ {
|
|
|
+ collect.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (squareArgs.LineDash == null)
|
|
|
+ squareArgs.LineDash = new DashStyle();
|
|
|
+
|
|
|
+ squareArgs.LineDash.Dashes = collect;
|
|
|
+ }
|
|
|
|
|
|
if (squareArgs != null)
|
|
|
{
|
|
@@ -616,10 +729,38 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
circleAnnotArgs.BgColor = Colors.Red;
|
|
|
}
|
|
|
|
|
|
- circleAnnotArgs.LineWidth = 1;
|
|
|
- circleAnnotArgs.Transparency = 1;
|
|
|
- circleAnnotArgs.LineDash = DashStyles.Solid;
|
|
|
- circleAnnotArgs.Content = string.Empty;
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(circleAnnotArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
+ {
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = circleAnnotArgs.EventType;
|
|
|
+ defaultAnnot.Thickness = 1;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ defaultAnnot.NoteText = string.Empty;
|
|
|
+ defaultAnnot.DashArray = null;
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+
|
|
|
+ circleAnnotArgs.LineWidth = defaultAnnot.Thickness;
|
|
|
+ circleAnnotArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
|
|
|
+ {
|
|
|
+ circleAnnotArgs.LineDash = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var collect = new DoubleCollection();
|
|
|
+ foreach (var item in defaultAnnot.DashArray)
|
|
|
+ {
|
|
|
+ collect.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (circleAnnotArgs.LineDash == null)
|
|
|
+ circleAnnotArgs.LineDash = new DashStyle();
|
|
|
+
|
|
|
+ circleAnnotArgs.LineDash.Dashes = collect;
|
|
|
+ }
|
|
|
|
|
|
if (circleAnnotArgs != null)
|
|
|
{
|
|
@@ -667,10 +808,40 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
|
|
|
}
|
|
|
+
|
|
|
+ var defaultAnnot = SettingHelper.GetAnnotDefaultProperty(lineArgs.EventType);
|
|
|
+ if (defaultAnnot == null)
|
|
|
+ {
|
|
|
+ defaultAnnot = new DefaultAnnotProperty();
|
|
|
+ defaultAnnot.AnnotToolType = lineArgs.EventType;
|
|
|
+ defaultAnnot.Thickness = 1;
|
|
|
+ defaultAnnot.Opacity = 1;
|
|
|
+ defaultAnnot.NoteText = string.Empty;
|
|
|
+ defaultAnnot.DashArray = null;
|
|
|
+ Settings.Default.Save();
|
|
|
+ }
|
|
|
+
|
|
|
lineArgs.LineDash = DashStyles.Solid;
|
|
|
- lineArgs.LineWidth = 1;
|
|
|
- lineArgs.Transparency = 1;
|
|
|
- lineArgs.Content = string.Empty;
|
|
|
+ lineArgs.LineWidth = defaultAnnot.Thickness;
|
|
|
+ lineArgs.Transparency = defaultAnnot.Opacity;
|
|
|
+
|
|
|
+ if (defaultAnnot.DashArray == null || defaultAnnot.DashArray.Count == 0)
|
|
|
+ {
|
|
|
+ lineArgs.LineDash = DashStyles.Solid;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var collect = new DoubleCollection();
|
|
|
+ foreach (var item in defaultAnnot.DashArray)
|
|
|
+ {
|
|
|
+ collect.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (lineArgs.LineDash == null)
|
|
|
+ lineArgs.LineDash = new DashStyle();
|
|
|
+
|
|
|
+ lineArgs.LineDash.Dashes = collect;
|
|
|
+ }
|
|
|
|
|
|
if (lineArgs != null)
|
|
|
{
|
|
@@ -832,6 +1003,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
case "StickyNote"://便签
|
|
|
StickyAnnotArgs stickyAnnotArgs = (StickyAnnotArgs)GetStickyNote();
|
|
|
stickyAnnotArgs.ClientRect = annotCommand.TextRect;
|
|
|
+ stickyAnnotArgs.StickyNote = annotCommand.Text;
|
|
|
PDFViewer.CreatePageAnnot(annotCommand.PageIndex, stickyAnnotArgs);
|
|
|
break;
|
|
|
|
|
@@ -865,6 +1037,8 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
BtnLinkIsChecked = true;
|
|
|
List<AnnotHandlerEventArgs> lists = new List<AnnotHandlerEventArgs>();
|
|
|
lists.Add(linkArgs);
|
|
|
+ propertyPanel.IsAddLink = true;
|
|
|
+
|
|
|
AnnotHandlerEventArgs annotArgs = GetLink(lists);
|
|
|
PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
PDFViewer.SetToolParam(annotArgs);
|
|
@@ -889,19 +1063,23 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
str = annotCommand.Text;
|
|
|
}
|
|
|
- OutlineNode outline = outLineControl.AddOutlineNode(str);
|
|
|
- CPDFOutline result = outline.Outline;
|
|
|
- if (result != null)
|
|
|
- {
|
|
|
- outLineControlViewModel.SetTitle(result, str);
|
|
|
- outLineControlViewModel.Updata(false);
|
|
|
-
|
|
|
- //outLineControl.IsReName = true;
|
|
|
- //if (outLineControl.OutlineView.SelectedItem is OutlineNode selectOutLine)
|
|
|
- //{
|
|
|
- // outLineControl.ReNameOutlineNode = outline;
|
|
|
- //}
|
|
|
- }
|
|
|
+ //App.Current.Dispatcher.BeginInvoke((System.Action)(() =>
|
|
|
+ //{
|
|
|
+ // OutlineNode outline = outLineControl.AddOutlineNode(str);
|
|
|
+ //}));
|
|
|
+ App.Current.Dispatcher.Invoke(() => outLineControl.AddOutlineNode(str));
|
|
|
+ //CPDFOutline result = outline.Outline;
|
|
|
+ //if (result != null)
|
|
|
+ //{
|
|
|
+ // outLineControlViewModel.SetTitle(result, str);
|
|
|
+ // outLineControlViewModel.Updata(false);
|
|
|
+
|
|
|
+ // //outLineControl.IsReName = true;
|
|
|
+ // //if (outLineControl.OutlineView.SelectedItem is OutlineNode selectOutLine)
|
|
|
+ // //{
|
|
|
+ // // outLineControl.ReNameOutlineNode = outline;
|
|
|
+ // //}
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -1016,25 +1194,66 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
if (annot is TextHighlightAnnotArgs)
|
|
|
{
|
|
|
var color = (annot as TextHighlightAnnotArgs).Color;
|
|
|
- Settings.Default.AppProperties.Annotate.HighLightColor = color;
|
|
|
HighLightColor = new SolidColorBrush(color);
|
|
|
+
|
|
|
+ Settings.Default.AppProperties.Annotate.HighLightColor = color;
|
|
|
+
|
|
|
+ var hightlight = GetAnnotDefault(AnnotArgsType.AnnotHighlight);
|
|
|
+ hightlight.ForgoundColor = color;
|
|
|
+ hightlight.Opacity = (annot as TextHighlightAnnotArgs).Transparency;
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(hightlight);
|
|
|
}
|
|
|
else if (annot is TextUnderlineAnnotArgs)
|
|
|
{
|
|
|
- var color = (annot as TextHighlightAnnotArgs).Color;
|
|
|
- Settings.Default.AppProperties.Annotate.UnderLineColor = color;
|
|
|
+ var color = (annot as TextUnderlineAnnotArgs).Color;
|
|
|
UnderLineColor = new SolidColorBrush(color);
|
|
|
+
|
|
|
+ Settings.Default.AppProperties.Annotate.UnderLineColor = color;
|
|
|
+
|
|
|
+ var Underline = GetAnnotDefault(AnnotArgsType.AnnotUnderline);
|
|
|
+ Underline.ForgoundColor = color;
|
|
|
+ Underline.Opacity = (annot as TextUnderlineAnnotArgs).Transparency;
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(Underline);
|
|
|
}
|
|
|
else if (annot is TextStrikeoutAnnotArgs)
|
|
|
{
|
|
|
- var color = (annot as TextHighlightAnnotArgs).Color;
|
|
|
- Settings.Default.AppProperties.Annotate.StrikethroughColor = color;
|
|
|
+ var color = (annot as TextStrikeoutAnnotArgs).Color;
|
|
|
StrikeoutColor = new SolidColorBrush(color);
|
|
|
+
|
|
|
+ Settings.Default.AppProperties.Annotate.StrikethroughColor = color;
|
|
|
+
|
|
|
+ var Strikeout = GetAnnotDefault(AnnotArgsType.AnnotStrikeout);
|
|
|
+ Strikeout.ForgoundColor = color;
|
|
|
+ Strikeout.Opacity = (annot as TextStrikeoutAnnotArgs).Transparency;
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(Strikeout);
|
|
|
}
|
|
|
else if (annot is FreehandAnnotArgs)
|
|
|
{
|
|
|
- var color = (annot as FreehandAnnotArgs).InkColor;
|
|
|
+ var freeHand = annot as FreehandAnnotArgs;
|
|
|
+ var color = freeHand.InkColor;
|
|
|
+
|
|
|
Settings.Default.AppProperties.Annotate.FreeHandColor = color;
|
|
|
+
|
|
|
+ var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand);
|
|
|
+ FreehandDefault.ForgoundColor = color;
|
|
|
+ FreehandDefault.Opacity = freeHand.Transparency;
|
|
|
+ FreehandDefault.Thickness = freeHand.LineWidth;
|
|
|
+
|
|
|
+ var isSolid = AnnotPropertyPanel.IsSolidStyle(freeHand.LineDash);
|
|
|
+ if (isSolid)
|
|
|
+ {
|
|
|
+ FreehandDefault.DashArray = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FreehandDefault.DashArray = new List<double>();
|
|
|
+ foreach (var item in freeHand.LineDash.Dashes)
|
|
|
+ {
|
|
|
+ FreehandDefault.DashArray.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(FreehandDefault);
|
|
|
}
|
|
|
else if (annot is FreeTextAnnotArgs)
|
|
|
{
|
|
@@ -1042,30 +1261,113 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
Settings.Default.AppProperties.Annotate.TextAnnoteColor = freeText.FontColor;
|
|
|
Settings.Default.AppProperties.Annotate.TextFontFamaily = freeText.FontFamily.ToString();
|
|
|
Settings.Default.AppProperties.Annotate.TextAlign = freeText.Align;
|
|
|
+
|
|
|
+ var FreeTextDefalut = GetAnnotDefault(AnnotArgsType.AnnotFreeText);
|
|
|
+ FreeTextDefalut.ForgoundColor = freeText.FontColor;
|
|
|
+ FreeTextDefalut.FontFamily = freeText.FontFamily.ToString();
|
|
|
+ FreeTextDefalut.TextAlign = freeText.Align;
|
|
|
+ FreeTextDefalut.FontSize = freeText.FontSize;
|
|
|
+ FreeTextDefalut.FontWeight = freeText.FontWeight;
|
|
|
+ FreeTextDefalut.FontStyle = freeText.FontStyle;
|
|
|
+ FreeTextDefalut.BackgroundColor = freeText.BgColor;
|
|
|
+ FreeTextDefalut.Opacity = (annot as FreeTextAnnotArgs).Transparency;
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(FreeTextDefalut);
|
|
|
}
|
|
|
else if (annot is StickyAnnotArgs)
|
|
|
{
|
|
|
var color = (annot as StickyAnnotArgs).Color;
|
|
|
Settings.Default.AppProperties.Annotate.NoteAnnoteColor = color;
|
|
|
+ var StickyDefalut = GetAnnotDefault(AnnotArgsType.AnnotSticky);
|
|
|
+ StickyDefalut.ForgoundColor = color;
|
|
|
+
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(StickyDefalut);
|
|
|
}
|
|
|
else if (annot is SquareAnnotArgs)
|
|
|
{
|
|
|
- var bgColor = (annot as SquareAnnotArgs).BgColor;
|
|
|
+ var square = annot as SquareAnnotArgs;
|
|
|
+ var bgColor = square.BgColor;
|
|
|
Settings.Default.AppProperties.Annotate.RectangleFillColor = bgColor;
|
|
|
- var borderColor = (annot as SquareAnnotArgs).LineColor;
|
|
|
+ var borderColor = square.LineColor;
|
|
|
Settings.Default.AppProperties.Annotate.RectangleBorderColor = borderColor;
|
|
|
+
|
|
|
+ var SquareDefalut = GetAnnotDefault(AnnotArgsType.AnnotSquare);
|
|
|
+ SquareDefalut.BorderColor = borderColor;
|
|
|
+ SquareDefalut.BackgroundColor = bgColor;
|
|
|
+ SquareDefalut.Opacity = square.Transparency;
|
|
|
+ SquareDefalut.Thickness = square.LineWidth;
|
|
|
+
|
|
|
+ var isSolid = AnnotPropertyPanel.IsSolidStyle(square.LineDash);
|
|
|
+ if (isSolid)
|
|
|
+ {
|
|
|
+ SquareDefalut.DashArray = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SquareDefalut.DashArray = new List<double>();
|
|
|
+ foreach (var item in square.LineDash.Dashes)
|
|
|
+ {
|
|
|
+ SquareDefalut.DashArray.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(SquareDefalut);
|
|
|
}
|
|
|
else if (annot is CircleAnnotArgs)
|
|
|
{
|
|
|
- var bgColor = (annot as CircleAnnotArgs).BgColor;
|
|
|
+ var circle = annot as CircleAnnotArgs;
|
|
|
+ var bgColor = circle.BgColor;
|
|
|
Settings.Default.AppProperties.Annotate.CircleFillColor = bgColor;
|
|
|
- var borderColor = (annot as CircleAnnotArgs).LineColor;
|
|
|
+ var borderColor = circle.LineColor;
|
|
|
Settings.Default.AppProperties.Annotate.CircleBorderColor = borderColor;
|
|
|
+
|
|
|
+ var CircleDefalut = GetAnnotDefault(AnnotArgsType.AnnotCircle);
|
|
|
+ CircleDefalut.BorderColor = borderColor;
|
|
|
+ CircleDefalut.BackgroundColor = bgColor;
|
|
|
+ CircleDefalut.Opacity = circle.Transparency;
|
|
|
+ CircleDefalut.Thickness = circle.LineWidth;
|
|
|
+
|
|
|
+ var isSolid = AnnotPropertyPanel.IsSolidStyle(circle.LineDash);
|
|
|
+ if (isSolid)
|
|
|
+ {
|
|
|
+ CircleDefalut.DashArray = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CircleDefalut.DashArray = new List<double>();
|
|
|
+ foreach (var item in circle.LineDash.Dashes)
|
|
|
+ {
|
|
|
+ CircleDefalut.DashArray.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(CircleDefalut);
|
|
|
}
|
|
|
else if (annot is LineAnnotArgs)
|
|
|
{
|
|
|
+ var line = (annot as LineAnnotArgs);
|
|
|
var color = (annot as LineAnnotArgs).LineColor;
|
|
|
Settings.Default.AppProperties.Annotate.LineColor = color;
|
|
|
+
|
|
|
+ var lineDefalut = GetAnnotDefault(AnnotArgsType.AnnotLine);
|
|
|
+ lineDefalut.BorderColor = color;
|
|
|
+ lineDefalut.Opacity = (annot as LineAnnotArgs).Transparency;
|
|
|
+ lineDefalut.Thickness = (annot as LineAnnotArgs).LineWidth;
|
|
|
+
|
|
|
+ var isSolid = AnnotPropertyPanel.IsSolidStyle(line.LineDash);
|
|
|
+ if (isSolid)
|
|
|
+ {
|
|
|
+ lineDefalut.DashArray = null;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ lineDefalut.DashArray = new List<double>();
|
|
|
+ foreach (var item in line.LineDash.Dashes)
|
|
|
+ {
|
|
|
+ lineDefalut.DashArray.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SettingHelper.SetAnnotDefaultProperty(lineDefalut);
|
|
|
}
|
|
|
|
|
|
Settings.Default.Save();
|
|
@@ -1073,8 +1375,21 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType)
|
|
|
+ {
|
|
|
+ var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType);
|
|
|
+ if (Annot == null)
|
|
|
+ {
|
|
|
+ Annot = new DefaultAnnotProperty();
|
|
|
+ Annot.AnnotToolType = annotArgsType;
|
|
|
+ }
|
|
|
+ return Annot;
|
|
|
+ }
|
|
|
+
|
|
|
+ private System.Windows.Controls.Primitives.Popup popup = null;
|
|
|
+
|
|
|
//更改颜色
|
|
|
- private void AnnotColorPalette_Menu(object obj)
|
|
|
+ private async void AnnotColorPalette_Menu(object obj)
|
|
|
{
|
|
|
if (obj as CusMenuItem != null)
|
|
|
{
|
|
@@ -1083,15 +1398,49 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
if (annot != null)
|
|
|
{
|
|
|
var item = new ColorDropBoxPop();
|
|
|
- item.DataContext = annot;
|
|
|
+ item.DataContext = menu;
|
|
|
item.ColorSelected -= AnnotMenu_ColorSelected;
|
|
|
item.ColorSelected += AnnotMenu_ColorSelected;
|
|
|
-
|
|
|
- System.Windows.Controls.Primitives.Popup popup = new System.Windows.Controls.Primitives.Popup();
|
|
|
+
|
|
|
+ if (popup == null)
|
|
|
+ popup = new System.Windows.Controls.Primitives.Popup();
|
|
|
+
|
|
|
+ ContentControl window = null;
|
|
|
+ if (PDFViewer.Parent as ContentControl != null)
|
|
|
+ window = PDFViewer.Parent as ContentControl;
|
|
|
+ else
|
|
|
+ window = App.Current.MainWindow;
|
|
|
+
|
|
|
popup.Child = item;
|
|
|
- popup.PlacementRectangle = new Rect(Mouse.GetPosition(App.Current.MainWindow), new Size(item.Width, item.Height));
|
|
|
- popup.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
|
|
|
+ popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
|
|
|
+ popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
|
|
|
+ popup.PlacementTarget = window;
|
|
|
popup.IsOpen = true;
|
|
|
+
|
|
|
+ Window parentWnd = Window.GetWindow(App.Current.MainWindow);
|
|
|
+ if (parentWnd != null)
|
|
|
+ {
|
|
|
+ parentWnd.MouseDown -= parentWnd_MouseDown;
|
|
|
+ parentWnd.MouseDown += parentWnd_MouseDown;
|
|
|
+ }
|
|
|
+
|
|
|
+ while (popup.IsOpen)
|
|
|
+ await Task.Delay(20);
|
|
|
+
|
|
|
+ parentWnd.MouseDown -= parentWnd_MouseDown;
|
|
|
+ popup = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void parentWnd_MouseDown(object sender, MouseButtonEventArgs e)
|
|
|
+ {
|
|
|
+ var ui = Mouse.DirectlyOver as FrameworkElement;
|
|
|
+ if (ui != null)
|
|
|
+ {
|
|
|
+ if (popup != null)
|
|
|
+ {
|
|
|
+ popup.IsOpen = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1100,7 +1449,10 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
if (sender != null)
|
|
|
{
|
|
|
- var annot = (sender as FrameworkElement).DataContext as AnnotHandlerEventArgs;
|
|
|
+ var menu = (sender as FrameworkElement).DataContext as CusMenuItem;
|
|
|
+ if (menu == null) return;
|
|
|
+
|
|
|
+ var annot = menu.Parameter as AnnotHandlerEventArgs;
|
|
|
if (annot != null)
|
|
|
{
|
|
|
if (annot is FreehandAnnotArgs || annot is StickyAnnotArgs || annot is LineAnnotArgs)
|
|
@@ -1112,13 +1464,27 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
else if (annot is FreeTextAnnotArgs)
|
|
|
{
|
|
|
var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
|
|
|
+ if (menu.tag.ToString() == "FontColor")
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
|
|
|
+ else
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
|
|
|
+
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
|
}
|
|
|
else if (annot is SquareAnnotArgs || annot is CircleAnnotArgs)
|
|
|
{
|
|
|
var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
|
|
|
+ if (menu.tag.ToString() == "FillColor")
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
|
|
|
+ else
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
|
|
|
+
|
|
|
+ AnnotEvent?.UpdateAnnot();
|
|
|
+ }
|
|
|
+ else if (annot is TextHighlightAnnotArgs || annot is TextUnderlineAnnotArgs || annot is TextStrikeoutAnnotArgs)
|
|
|
+ {
|
|
|
+ var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
|
}
|
|
|
}
|
|
@@ -1232,6 +1598,11 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
|
|
|
}
|
|
|
+ else if (strTag == "Justify")
|
|
|
+ {
|
|
|
+ AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
|
|
|
+ }
|
|
|
+
|
|
|
AnnotEvent?.UpdateAnnot();
|
|
|
}
|
|
|
}
|
|
@@ -1302,7 +1673,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
{
|
|
|
var strTag = tag.ToString();
|
|
|
var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
|
|
|
- if (strTag == "ver")
|
|
|
+ if (strTag == "Ver")
|
|
|
{
|
|
|
annot.SetLineVertical();
|
|
|
}
|
|
@@ -1314,6 +1685,30 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void Link_Menu(object obj)
|
|
|
+ {
|
|
|
+ if (obj is CusMenuItem menuItem)
|
|
|
+ {
|
|
|
+ if (menuItem.Parameter is LinkAnnotArgs linkAnnotArgs)
|
|
|
+ {
|
|
|
+ var result = PDFViewer.RemovePageAnnot(linkAnnotArgs.PageIndex, linkAnnotArgs.AnnotIndex);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
|
|
|
+ bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
|
|
|
+ if (isTabItemAnnotation)
|
|
|
+ {
|
|
|
+ AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
|
|
|
+ if (viewModel != null)
|
|
|
+ {
|
|
|
+ viewModel.UpdateModifiedAnnot(linkAnnotArgs.PageIndex, linkAnnotArgs.AnnotIndex, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//图章
|
|
|
private void StampExportPicture_Menu(object obj)
|
|
|
{
|