|
@@ -19,8 +19,13 @@ using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
|
|
+using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media;
|
|
|
|
+using ContextMenu = System.Windows.Controls.ContextMenu;
|
|
|
|
+using HorizontalAlignment = System.Windows.HorizontalAlignment;
|
|
|
|
+using MenuItem = System.Windows.Controls.MenuItem;
|
|
|
|
+using OpenFileDialog = Microsoft.Win32.OpenFileDialog;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Tools
|
|
namespace PDF_Office.ViewModels.Tools
|
|
{
|
|
{
|
|
@@ -29,6 +34,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
#region 初始化
|
|
#region 初始化
|
|
|
|
|
|
#region 初始化数据
|
|
#region 初始化数据
|
|
|
|
+
|
|
//初始化注释的属性值,并存在本地缓存数据集里
|
|
//初始化注释的属性值,并存在本地缓存数据集里
|
|
private void InitDefaultValue()
|
|
private void InitDefaultValue()
|
|
{
|
|
{
|
|
@@ -131,13 +137,15 @@ namespace PDF_Office.ViewModels.Tools
|
|
ToolExpandDict.Add("Line", AnnotArgsType.AnnotLine);
|
|
ToolExpandDict.Add("Line", AnnotArgsType.AnnotLine);
|
|
ToolExpandDict.Add("Link", AnnotArgsType.AnnotLink);
|
|
ToolExpandDict.Add("Link", AnnotArgsType.AnnotLink);
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion 初始化数据
|
|
|
|
+
|
|
|
|
+ #endregion 初始化
|
|
|
|
|
|
#region 注释工具
|
|
#region 注释工具
|
|
|
|
+
|
|
//注释工具
|
|
//注释工具
|
|
- private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs)
|
|
|
|
|
|
+ private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
|
|
{
|
|
{
|
|
switch (tag)
|
|
switch (tag)
|
|
{
|
|
{
|
|
@@ -200,7 +208,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
break;
|
|
break;
|
|
|
|
|
|
case "Link"://链接
|
|
case "Link"://链接
|
|
- viewContentViewModel.IsCreateLink = false;
|
|
|
|
|
|
+ viewContentViewModel.IsRightMenuCreateLink = isRightMenuAdd;
|
|
annotArgs = GetLink();
|
|
annotArgs = GetLink();
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -735,7 +743,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
|
|
annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
|
|
annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
|
|
AddToPropertyPanel("StampAnnotProperty", null, stampAnnotArgs, annotAttribsList);
|
|
AddToPropertyPanel("StampAnnotProperty", null, stampAnnotArgs, annotAttribsList);
|
|
- return null;
|
|
|
|
|
|
+ return stampAnnotArgs;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -835,7 +843,6 @@ namespace PDF_Office.ViewModels.Tools
|
|
|
|
|
|
#endregion 注释工具
|
|
#endregion 注释工具
|
|
|
|
|
|
-
|
|
|
|
#region 属性面板
|
|
#region 属性面板
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -846,7 +853,7 @@ namespace PDF_Office.ViewModels.Tools
|
|
viewContentViewModel.IsPropertyOpen = show;
|
|
viewContentViewModel.IsPropertyOpen = show;
|
|
}
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
|
|
|
+ #endregion 属性面板
|
|
|
|
|
|
#region 菜单
|
|
#region 菜单
|
|
|
|
|
|
@@ -854,11 +861,11 @@ namespace PDF_Office.ViewModels.Tools
|
|
{
|
|
{
|
|
ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
|
|
//contextMenu.Loaded += ContextMenu_Loaded;
|
|
//contextMenu.Loaded += ContextMenu_Loaded;
|
|
- ContextMenu_Loaded(contextMenu, null);
|
|
|
|
|
|
+ ViewerContextMenu_Loaded(contextMenu, null);
|
|
return contextMenu;
|
|
return contextMenu;
|
|
}
|
|
}
|
|
|
|
|
|
- private void ContextMenu_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
+ private void ViewerContextMenu_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
ContextMenu contextMenu = sender as ContextMenu;
|
|
ContextMenu contextMenu = sender as ContextMenu;
|
|
if (contextMenu.Items.Count > 0)
|
|
if (contextMenu.Items.Count > 0)
|
|
@@ -925,20 +932,12 @@ namespace PDF_Office.ViewModels.Tools
|
|
break;
|
|
break;
|
|
|
|
|
|
case "AddBookMark":
|
|
case "AddBookMark":
|
|
- //if (isAddBookMark)
|
|
|
|
- //{
|
|
|
|
- // menuItem1.Visibility = Visibility.Visible;
|
|
|
|
- //}
|
|
|
|
menuItem1.Click -= AddBookMark_Click;
|
|
menuItem1.Click -= AddBookMark_Click;
|
|
menuItem1.Click += AddBookMark_Click;
|
|
menuItem1.Click += AddBookMark_Click;
|
|
SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
|
|
SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
|
|
break;
|
|
break;
|
|
|
|
|
|
case "DelBookMark":
|
|
case "DelBookMark":
|
|
- //if (isAddBookMark == false)
|
|
|
|
- //{
|
|
|
|
- // menuItem1.Visibility = Visibility.Visible;
|
|
|
|
- //}
|
|
|
|
menuItem1.Click -= DelBookMark_Click;
|
|
menuItem1.Click -= DelBookMark_Click;
|
|
menuItem1.Click += DelBookMark_Click;
|
|
menuItem1.Click += DelBookMark_Click;
|
|
SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
|
|
SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
|
|
@@ -989,26 +988,24 @@ namespace PDF_Office.ViewModels.Tools
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void SetMenuItemVisibility(MenuItem menuItem1, string v2, string v3, bool flag)
|
|
|
|
|
|
+ private void SetMenuItemVisibility(MenuItem menuItem1, string right, string deny, bool flag)
|
|
{
|
|
{
|
|
- if (menuItem1.Tag.ToString() == v2 && flag)
|
|
|
|
|
|
+ if (menuItem1.Tag.ToString() == right && flag)
|
|
{
|
|
{
|
|
menuItem1.Visibility = Visibility.Collapsed;
|
|
menuItem1.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
- if (menuItem1.Tag.ToString() == v2 && flag == false)
|
|
|
|
|
|
+ if (menuItem1.Tag.ToString() == right && flag == false)
|
|
{
|
|
{
|
|
menuItem1.Visibility = Visibility.Visible;
|
|
menuItem1.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
- if (menuItem1.Tag.ToString() == v3 && flag == false)
|
|
|
|
|
|
+ if (menuItem1.Tag.ToString() == deny && flag == false)
|
|
{
|
|
{
|
|
menuItem1.Visibility = Visibility.Collapsed;
|
|
menuItem1.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
- if (menuItem1.Tag.ToString() == v3 && flag)
|
|
|
|
|
|
+ if (menuItem1.Tag.ToString() == deny && flag)
|
|
{
|
|
{
|
|
menuItem1.Visibility = Visibility.Visible;
|
|
menuItem1.Visibility = Visibility.Visible;
|
|
}
|
|
}
|
|
@@ -1044,7 +1041,10 @@ namespace PDF_Office.ViewModels.Tools
|
|
{
|
|
{
|
|
ContextMenu popMenu = new ContextMenu();
|
|
ContextMenu popMenu = new ContextMenu();
|
|
popMenu.FontSize = 14;
|
|
popMenu.FontSize = 14;
|
|
-
|
|
|
|
|
|
+ //if (popMenu.Items.Count > 0)
|
|
|
|
+ //{
|
|
|
|
+ // popMenu.Items.Clear();
|
|
|
|
+ //}
|
|
MenuItem menuItem = new MenuItem();
|
|
MenuItem menuItem = new MenuItem();
|
|
menuItem = new MenuItem();
|
|
menuItem = new MenuItem();
|
|
menuItem.CommandTarget = (UIElement)sender;
|
|
menuItem.CommandTarget = (UIElement)sender;
|
|
@@ -1056,16 +1056,157 @@ namespace PDF_Office.ViewModels.Tools
|
|
menuItem.Command = ApplicationCommands.Paste;
|
|
menuItem.Command = ApplicationCommands.Paste;
|
|
popMenu.Items.Add(menuItem);
|
|
popMenu.Items.Add(menuItem);
|
|
|
|
|
|
|
|
+ //Separator separator = (Separator)App.Current.FindResource("Separator");
|
|
|
|
+ Separator separator = new Separator();
|
|
|
|
+ separator.Height = 1;
|
|
|
|
+ separator.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#33000000"));
|
|
|
|
+ separator.BorderThickness = new Thickness(1);
|
|
|
|
+ separator.Width = popMenu.Width;
|
|
|
|
+ separator.Style = (Style)App.Current.FindResource(System.Windows.Controls.ToolBar.SeparatorStyleKey);
|
|
|
|
+ popMenu.Items.Add(separator);
|
|
|
|
+
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ SetSelectTextOrImageMenuItem("高亮", "HighLight", annotCommand, out menuItem);
|
|
|
|
+ popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
menuItem = new MenuItem();
|
|
menuItem = new MenuItem();
|
|
- menuItem.CommandTarget = (UIElement)sender;
|
|
|
|
- menuItem.Header = "创建链接";
|
|
|
|
- menuItem.CommandParameter = new object[] { this, annotCommand };
|
|
|
|
- menuItem.Command = viewContentViewModel.CreateLinkCommand;
|
|
|
|
- menuItem.Click += MenuItem_Click;
|
|
|
|
|
|
+ SetSelectTextOrImageMenuItem("下划线", "UnderLine", annotCommand, out menuItem);
|
|
popMenu.Items.Add(menuItem);
|
|
popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ SetSelectTextOrImageMenuItem("删除线", "Strikeout", annotCommand, out menuItem);
|
|
|
|
+ popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ SetSelectTextOrImageMenuItem("文本", "Freetext", annotCommand, out menuItem);
|
|
|
|
+ popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ SetSelectTextOrImageMenuItem("便签", "StickyNote", annotCommand, out menuItem);
|
|
|
|
+ popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ SetSelectTextOrImageMenuItem("矩形", "Rect", annotCommand, out menuItem);
|
|
|
|
+ popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ SetSelectTextOrImageMenuItem("添加链接", "Link", annotCommand, out menuItem);
|
|
|
|
+ popMenu.Items.Add(menuItem);
|
|
|
|
+
|
|
|
|
+ //menuItem.CommandParameter = new object[] { this, annotCommand };
|
|
|
|
+ //menuItem.Command = viewContentViewModel.CreateLinkCommand;
|
|
|
|
+ //menuItem.Click -= AddLink_Click;
|
|
|
|
+ //menuItem.Click += AddLink_Click;
|
|
|
|
+ //popMenu.Items.Add(menuItem);
|
|
return popMenu;
|
|
return popMenu;
|
|
}
|
|
}
|
|
- #endregion
|
|
|
|
|
|
|
|
|
|
+ private void AnnotToolMenu_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ MenuItem clickMenu = sender as MenuItem;
|
|
|
|
+ if (clickMenu != null && clickMenu.CommandParameter is AnnotCommandArgs)
|
|
|
|
+ {
|
|
|
|
+ AnnotCommandArgs annotCommand = clickMenu.CommandParameter as AnnotCommandArgs;
|
|
|
|
+ //AnnotHandlerEventArgs annotHandlerEvent = null;
|
|
|
|
+ //FindAnnotTypeKey(clickMenu.Tag.ToString(), ref annotHandlerEvent, true);
|
|
|
|
+
|
|
|
|
+ switch (clickMenu.Tag.ToString())
|
|
|
|
+ {
|
|
|
|
+ case "SnapshotEdit"://内容选择
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "HighLight"://字体高亮
|
|
|
|
+ TextHighlightAnnotArgs highlightArgs = (TextHighlightAnnotArgs)GetHighLight();
|
|
|
|
+ highlightArgs.ClientRect = annotCommand.TextRect;
|
|
|
|
+ highlightArgs.Content = annotCommand.Text;
|
|
|
|
+ bool flag = PDFViewer.CreatePageAnnot(annotCommand.PageIndex, highlightArgs);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "UnderLine"://下划线
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Squiggly"://波浪线
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Strikeout"://删除线
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Freehand"://手绘
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Freetext"://文本
|
|
|
|
+ FreeTextAnnotArgs textArgs = new FreeTextAnnotArgs();
|
|
|
|
+ textArgs.ClientRect = annotCommand.TextRect;
|
|
|
|
+ textArgs.Transparency = 1;
|
|
|
|
+ textArgs.BgColor = Colors.Transparent;
|
|
|
|
+ textArgs.LineColor = Colors.Red;
|
|
|
|
+ textArgs.LineWidth = 2;
|
|
|
|
+ //textArgs.TextContent = annotCommand.Text;
|
|
|
|
+ PDFViewer.CreatePageAnnot(annotCommand.PageIndex, textArgs);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "StickyNote"://便签
|
|
|
|
+ StickyAnnotArgs stickyAnnotArgs = (StickyAnnotArgs)GetStickyNote();
|
|
|
|
+
|
|
|
|
+ //stickyAnnotArgs.StickyNote = annotCommand.Text;
|
|
|
|
+ //stickyAnnotArgs.Color = annotProperty.ForgoundColor;
|
|
|
|
+ //stickyAnnotArgs.StickyNote = annotProperty.NoteText;
|
|
|
|
+ //stickyAnnotArgs.Transparency = annotProperty.Opacity;
|
|
|
|
+
|
|
|
|
+ stickyAnnotArgs.ClientRect = annotCommand.TextRect;
|
|
|
|
+ PDFViewer.CreatePageAnnot(annotCommand.PageIndex, stickyAnnotArgs);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Rect"://矩形
|
|
|
|
+ SquareAnnotArgs squareAnnotArgs = (SquareAnnotArgs)GetRect();
|
|
|
|
+ squareAnnotArgs.ClientRect = annotCommand.TextRect;
|
|
|
|
+ PDFViewer.CreatePageAnnot(annotCommand.PageIndex, squareAnnotArgs);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Circle"://圆
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Arrow"://箭头
|
|
|
|
+ case "Line"://线
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Stamp"://图章
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Image":
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Signature"://签名
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case "Link"://链接
|
|
|
|
+ LinkAnnotArgs linkArgs = new LinkAnnotArgs();
|
|
|
|
+ linkArgs.ClientRect = annotCommand.TextRect;
|
|
|
|
+ linkArgs.URI = string.Empty;
|
|
|
|
+ linkArgs.LinkType = LINK_TYPE.GOTO;
|
|
|
|
+ linkArgs.DestIndex = annotCommand.PageIndex;
|
|
|
|
+ PDFViewer.CreatePageAnnot(annotCommand.PageIndex, linkArgs);
|
|
|
|
+ BtnLinkIsChecked = true;
|
|
|
|
+ AnnotHandlerEventArgs annotArgs = GetLink(linkArgs);
|
|
|
|
+ PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
|
+ PDFViewer.SetToolParam(annotArgs);
|
|
|
|
+ viewContentViewModel.IsPropertyOpen = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void SetSelectTextOrImageMenuItem(string header, string tag, AnnotCommandArgs annotCommand, out MenuItem menuItem)
|
|
|
|
+ {
|
|
|
|
+ menuItem = new MenuItem();
|
|
|
|
+ menuItem.Header = header;
|
|
|
|
+ menuItem.Tag = tag;
|
|
|
|
+ menuItem.Click -= AnnotToolMenu_Click;
|
|
|
|
+ menuItem.Click += AnnotToolMenu_Click;
|
|
|
|
+ menuItem.CommandParameter = annotCommand;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion 菜单
|
|
}
|
|
}
|
|
}
|
|
}
|