using ComPDFKit.PDFDocument;
using ComPDFKitViewer;
using ComPDFKitViewer.AnnotEvent;
using ComPDFKitViewer.PdfViewer;
using PDF_Master.CustomControl;
using PDF_Master.CustomControl.CompositeControl;
using PDF_Master.Helper;
using PDF_Master.Model.PropertyPanel.AnnotPanel;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using static Dropbox.Api.TeamLog.AdminAlertSeverityEnum;
using MenuItem = System.Windows.Controls.MenuItem;
namespace PDF_Master.ViewModels.Tools
{
//文件说明:与布局相关的代码逻辑:菜单、属性面板
public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
{
#region 属性面板
///
/// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
///
/// 对应的注释面板
/// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
/// 注释
/// 更改注释属性的键值对,更改值后会自动记录undoRedo容器里
private void AddToPropertyPanel(string viewContent, string toolTag = null, List annots = null, AnnotAttribEvent annotAttribEvent = null)
{
if (annots != null)
{
propertyPanel.annotlists = annots;
propertyPanel.annot = annots[0];
}
else
{
propertyPanel.annotlists = null;
propertyPanel.annot = null;
}
if (annots != null)
{
if (annots.Count > 1)
{
if (propertyPanel.AnnotEvents == null)
propertyPanel.AnnotEvents = new List();
propertyPanel.AnnotEvents.Clear();
foreach (var itemAnnot in annots)
{
var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, itemAnnot.GetAnnotAttrib());
propertyPanel.AnnotEvents.Add(eventitem);
}
}
propertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annots[0].GetAnnotAttrib());
if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
{
propertyPanel.AnnotEvent = annotAttribEvent;
}
}
propertyPanel.SetIsTextFill(false);
if (string.IsNullOrEmpty(viewContent) == false)
{
viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
}
}
///
/// 展开显示属性面板
///
private void ShowPropertyPanel(bool show = true)
{
viewContentViewModel.IsPropertyOpen = show;
}
#endregion 属性面板
#region 阅读页 - 右键菜单
private ContextMenu ViewerContextMenu(object sender)
{
ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
//contextMenu.Loaded += ContextMenu_Loaded;
ViewerContextMenu_Loaded(contextMenu, sender);
return contextMenu;
}
private void ViewerContextMenu_Loaded(object sender, object e)
{
ContextMenu contextMenu = sender as ContextMenu;
contextMenu.DataContext = viewContentViewModel;
if (contextMenu.Items.Count > 0)
{
int index = PDFViewer.CurrentIndex;
//检测是否已存在相同数据
CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
if (list != null)
{
isAddBookMark = false;
}
else
{
isAddBookMark = true;
}
foreach (var item in contextMenu.Items)
{
if (item is MenuItem menuItem1)
{
switch (menuItem1.Tag.ToString())
{
case "Paste":
//粘贴
//if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
//{
// menuItem1.IsEnabled = false;
// menuItem1.Opacity = 0.5;
//}
//else
//{
// menuItem1.IsEnabled = true;
// menuItem1.Opacity = 1;
//}
menuItem1.CommandTarget = (UIElement)e;
menuItem1.Command = ApplicationCommands.Paste;
break;
case "AddAnnotation":
if (menuItem1.Items.Count > 0)
{
SetAddAnnotation(menuItem1.Items);
}
break;
case "HiddenAnnot":
menuItem1.Click -= HiddenAnnot_Click;
menuItem1.Click += HiddenAnnot_Click;
SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", BtnShowAnnotIsChecked);
break;
case "DisplayAnnot":
menuItem1.Click -= DisplayAnnot_Click;
menuItem1.Click += DisplayAnnot_Click;
SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", BtnShowAnnotIsChecked);
break;
case "AddBookMark":
menuItem1.Command = AddBookMarkCommand;
SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
if (viewContentViewModel.mainViewModel.IsBookMode)
{
menuItem1.IsEnabled = false;
}
break;
case "DelBookMark":
menuItem1.Click -= DelBookMark_Click;
menuItem1.Click += DelBookMark_Click;
SetMenuItemVisibility(menuItem1, "DelBookMark", "AddBookMark", isAddBookMark);
break;
case "ToolMode":
if (menuItem1.Items.Count > 0)
{
SetToolMode(menuItem1.Items);
}
break;
case "ReadModel":
SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", viewContentViewModel.mainViewModel.IsBookMode);
menuItem1.Click -= ReadModel_Click;
menuItem1.Click += ReadModel_Click;
break;
case "UnReadModel":
SetMenuItemVisibility(menuItem1, "ReadModel", "UnReadModel", viewContentViewModel.mainViewModel.IsBookMode);
menuItem1.Click -= UnReadModel_Click;
menuItem1.Click += UnReadModel_Click;
break;
case "ViewZoom":
if (menuItem1.Items.Count > 0)
{
ViewZoom(menuItem1.Items);
}
break;
case "PageDisplay":
if (menuItem1.Items.Count > 0)
{
PageDisplay(menuItem1.Items);
}
break;
case "Select":
menuItem1.Click -= Select_Click;
menuItem1.Click += Select_Click;
break;
case "Print":
menuItem1.Command = viewContentViewModel.PrintCommand;
break;
case "HighlightLinks":
if (OpenFileInfo != null)
{
menuItem1.IsChecked = OpenFileInfo.ShowHighLightLink;
}
menuItem1.Click -= HighlightLinks_Click;
menuItem1.Click += HighlightLinks_Click;
break;
}
}
}
}
}
private void HighlightLinks_Click(object sender, RoutedEventArgs e)
{
if (sender is MenuItem menuItem)
{
//if (OpenFileInfo != null)
//{
// menuItem.IsChecked = OpenFileInfo.ShowHighLightLink;
//}
if (menuItem.IsChecked)
{
PDFViewer.SetShowLink(true);
}
else
{
PDFViewer.SetShowLink(false);
}
if (OpenFileInfo != null)
{
OpenFileInfo.ShowHighLightLink = menuItem.IsChecked;
}
//if (menuItem.IsChecked == true)
//{
// menuItem.IsChecked = false;
//}
}
}
private void SetMenuItemVisibility(MenuItem menuItem1, string right, string deny, bool flag)
{
if (menuItem1.Tag.ToString() == right && flag)
{
menuItem1.Visibility = Visibility.Collapsed;
}
if (menuItem1.Tag.ToString() == right && flag == false)
{
menuItem1.Visibility = Visibility.Visible;
}
if (menuItem1.Tag.ToString() == deny && flag == false)
{
menuItem1.Visibility = Visibility.Collapsed;
}
if (menuItem1.Tag.ToString() == deny && flag)
{
menuItem1.Visibility = Visibility.Visible;
}
}
///
/// 选择文本或者图像的右键菜单
///
///
///
///
private ContextMenu SelectedTextOrImageContextMenu(object sender, AnnotCommandArgs annotCommand)
{
ContextMenu popMenu = new ContextMenu();
popMenu.FontSize = 14;
MenuItem menuItem = new MenuItem();
menuItem = new MenuItem();
menuItem.CommandTarget = (UIElement)sender;
menuItem.Command = ApplicationCommands.Copy;
popMenu.Items.Add(menuItem);
menuItem = new MenuItem();
menuItem.CommandTarget = (UIElement)sender;
menuItem.Command = ApplicationCommands.Paste;
popMenu.Items.Add(menuItem);
Separator separator = null;
if (annotCommand.CommandTarget == TargetType.ImageSelection)
{
separator = SetSeparator();
popMenu.Items.Add(separator);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_ExtractImage"), "ExportPicture", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
}
else if (annotCommand.CommandTarget == TargetType.Annot)
{
separator = SetSeparator();
popMenu.Items.Add(separator);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Highlight"), "HighLight", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Underline"), "UnderLine", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Strikethrough"), "Strikeout", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
}
separator = SetSeparator();
popMenu.Items.Add(separator);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Text"), "Freetext", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Note"), "StickyNote", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
separator = SetSeparator();
popMenu.Items.Add(separator);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Rectangle"), "Rect", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_Oval"), "Circle", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_StraightLine"), "Line", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
separator = SetSeparator();
popMenu.Items.Add(separator);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_AddLink"), "Link", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
SetSelectTextOrImageMenuItem(App.MainPageLoader.GetString("ViewRightMenu_AddOutline"), "OutLine", annotCommand, out menuItem);
popMenu.Items.Add(menuItem);
return popMenu;
}
private void SetSelectTextOrImageMenuItem(string header, string tag, AnnotCommandArgs annotCommand, out MenuItem menuItem)
{
menuItem = new MenuItem();
menuItem.Header = header;
menuItem.Tag = tag;
if (tag == "OutLine")
{
if (viewContentViewModel.mainViewModel.IsBookMode)
{
menuItem.IsEnabled = false;
}
else
{
menuItem.IsEnabled = true;
}
}
menuItem.Click -= AnnotToolMenu_Click;
menuItem.Click += AnnotToolMenu_Click;
menuItem.CommandParameter = annotCommand;
}
private Separator SetSeparator()
{
Separator separator = new Separator
{
Height = 1,
BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#33000000")),
BorderThickness = new Thickness(1),
Style = (Style)App.Current.FindResource(System.Windows.Controls.ToolBar.SeparatorStyleKey)
};
return separator;
}
#endregion 阅读页 - 右键菜单
#region 注释-右键菜单
private ColorMenuItem colorContent;
///
/// 高亮注释,右键菜单
///
private void InitSelectHightAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
colorContent = new ColorMenuItem();
colorContent.Name = "hightcolor";
colorContent.ColorChanged -= colorContent_SelectedColorHandler;
colorContent.ColorChanged += colorContent_SelectedColorHandler;
colorContent.VerticalAlignment = VerticalAlignment.Top;
colorContent.Margin = new Thickness(0, 0, 0, -15);
var menuItem = new MenuItem();
menuItem.Name = "hightColor";
menuItem.Height = 20 + 15;
menuItem.Header = colorContent;
var hightColorStyle = App.Current.FindResource("UIElementMenuItem") as Style;
if (hightColorStyle != null)
menuItem.Style = hightColorStyle;
colorContent.DataContext = pop.AddItem(menuItem);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "hightCopyText";
menuItem.Header = "复制文本";
pop.BindingEvent(pop.AddItem(menuItem), HightAnnotCopyText_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "hightdelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "hightAddNote";
menuItem.Header = "添加笔记";
pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "hightdefault";
menuItem.Header = "设置当前属性为默认值";
pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
HightAnnotPopMenu = pop;
}
private Separator GetSeparator()
{
Separator separator = new Separator();
separator.Height = 1;
separator.BorderBrush = new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00));
separator.BorderThickness = new Thickness(1);
return separator;
}
private async void colorContent_SelectedColorHandler(object sender, Color e)
{
if (e == null) return;
if (sender is Ellipse)
{
var item = new ColorDropBoxPop();
item.DataContext = (sender as Ellipse).DataContext;
item.ColorSelected -= AnnotMenu_ColorSelected;
item.ColorSelected += AnnotMenu_ColorSelected;
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(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;
}
else
{
var cusMenuItem = (sender as FrameworkElement).DataContext as CusMenuItem;
if (cusMenuItem != null && cusMenuItem.Parameter != null)
{
var test = cusMenuItem.Parameter as TextHighlightAnnotArgs;
if (test != null)
{
var anvent = AnnotAttribEvent.GetAnnotAttribEvent(test, test.GetAnnotAttrib());
anvent.UpdateAttrib(AnnotAttrib.Color, e);
anvent.UpdateAnnot();
}
}
}
}
///
/// 手绘
///
private void InitSelectFreeHandAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "FreeHandCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "FreeHandCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "FreeHandPaste";
menuItem.Header = "粘贴";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
menuItem = new MenuItem();
menuItem.Name = "FreeHandDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "FreeHandColor";
menuItem.Header = "边框颜色";
menuItem.Tag = "Color";
pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "FreeHandLineStyle";
menuItem.Header = "线段样式";
pop.AddItem(menuItem);
RadioButton radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "FreeHandSolid";
radioButton.Content = "实线";
radioButton.GroupName = "LineStyle";
radioButton.Tag = "Solid";
pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "FreeHandDash";
radioButton.Content = "虚线";
radioButton.GroupName = "LineStyle";
radioButton.Tag = "Dash";
pop.BindingEvent(pop.AddChild("FreeHandLineStyle", radioButton), FreeHandLineStyle_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "FreeHandAddNote";
menuItem.Header = "添加笔记";
pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "FreeHandDefault";
menuItem.Header = "设置当前属性为默认值";
pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
FreeHandAnnotPopMenu = pop;
}
///
/// 文本
///
private void InitSelectFreeTextAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "FreeTextCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "FreeTextCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "FreeTextPaste";
menuItem.Header = "粘贴";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
menuItem = new MenuItem();
menuItem.Name = "FreeTextDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "FreeTextColor";
menuItem.Header = "字体颜色";
menuItem.Tag = "FontColor";
pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "FreeTextFillColor";
menuItem.Header = "填充颜色";
menuItem.Tag = "FillColor";
pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "FreeTextFontFamily";
menuItem.Header = "字体";
pop.AddItem(menuItem);
var family = TextFont.GetFamily();
foreach (var item in family)
{
RadioButton familyRdioBtn = new RadioButton();
familyRdioBtn.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
familyRdioBtn.Background = new SolidColorBrush(Colors.Transparent);
familyRdioBtn.Name = item.ValueStr;
familyRdioBtn.Tag = item.ValueStr;
familyRdioBtn.GroupName = "FontFamily";
familyRdioBtn.Content = item.Content;
pop.BindingEvent(pop.AddChild("FreeTextFontFamily", familyRdioBtn), FreeTextFontFamily_MenuCommand);
}
menuItem = new MenuItem();
menuItem.Name = "FreeTextAglin";
menuItem.Header = "文本对齐";
pop.AddItem(menuItem);
var radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "FreeTextAglinLeft";
radioButton.Tag = "Left";
radioButton.GroupName = "Aglin";
radioButton.Content = "左对齐";
pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "FreeTextAglinCenter";
radioButton.Tag = "Center";
radioButton.GroupName = "Aglin";
radioButton.Content = "居中对齐";
pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "FreeTextAglinRight";
radioButton.Tag = "Right";
radioButton.GroupName = "Aglin";
radioButton.Content = "右对齐";
pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "FreeTextAglinJustify";
radioButton.Tag = "Justify";
radioButton.GroupName = "Aglin";
radioButton.Content = "两端对齐";
pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "FreeHandDefault";
menuItem.Header = "设置当前属性为默认值";
pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
FreeTextAnnotPopMenu = pop;
}
///
/// 便签
///
private void InitSelectStrickNoteAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "StrickNoteCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "StrickNoteCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "StrickNotePaste";
menuItem.Header = "粘贴";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
menuItem = new MenuItem();
menuItem.Name = "StrickNoteDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "StrickNoteColor";
menuItem.Header = "颜色";
pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "StrickNoteEdit";
menuItem.Header = "编辑便签";
pop.BindingEvent(pop.AddItem(menuItem), StrikeNoteEditStrike_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "StrickNoteDefault";
menuItem.Header = "设置当前属性为默认值";
pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
StrickNoteAnnotPopMenu = pop;
}
///
/// 形状
///
private void InitSelectShapeAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "ShapeCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "ShapeCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "ShapePaste";
menuItem.Header = "粘贴";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
menuItem = new MenuItem();
menuItem.Name = "ShapeDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "ShapeColor";
menuItem.Header = "边框颜色";
menuItem.Tag = "Color";
pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "ShapeFillColor";
menuItem.Header = "填充颜色";
menuItem.Tag = "FillColor";
pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "ShapeLineStyle";
menuItem.Header = "线段样式";
pop.AddItem(menuItem);
RadioButton radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "ShapeSolid";
radioButton.Content = "实线";
radioButton.GroupName = "LineStyle";
radioButton.Tag = "Solid";
pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
radioButton = new RadioButton();
radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
radioButton.Background = new SolidColorBrush(Colors.Transparent);
radioButton.Name = "ShapeDash";
radioButton.Content = "虚线";
radioButton.GroupName = "LineStyle";
radioButton.Tag = "Dash";
pop.BindingEvent(pop.AddChild("ShapeLineStyle", radioButton), ShapeLineStyle_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "ShapeDirect";
menuItem.Header = "线段方向";
pop.AddItem(menuItem);
menuItem = new MenuItem();
menuItem.Name = "ShapeVer";
menuItem.Header = "垂直";
menuItem.Tag = "Ver";
pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "ShapeHor";
menuItem.Header = "横向";
menuItem.Tag = "Hor";
pop.BindingEvent(pop.AddChild("ShapeDirect", menuItem), ShapeLineDirect_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "ShapeNoteText";
menuItem.Header = "添加笔记";
pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "ShapeDefault";
menuItem.Header = "设置当前属性为默认值";
pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
ShapeAnnotPopMenu = pop;
}
///
/// 链接
///
private void InitSelectLinkAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "LinkCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "LinkCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "LinkPaste";
menuItem.Header = "粘贴";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
menuItem = new MenuItem();
menuItem.Name = "LinkDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), Link_MenuCommand);
LinkAnnotPopMenu = pop;
}
///
/// 图章、签名
///
private void InitSelectStampAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "StampCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "StampCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "StampPaste";
menuItem.Header = "粘贴";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
menuItem = new MenuItem();
menuItem.Name = "StampDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
pop.AddItem(GetSeparator());
menuItem = new MenuItem();
menuItem.Name = "StampExportPicture";
menuItem.Header = "导出";
pop.AddItem(menuItem);
//已跟设计确认,暂时不需要PNG格式
//menuItem = new MenuItem();
//menuItem.Name = "StampExportPNG";
//menuItem.Header = "PNG";
//menuItem.Tag = "PNG";
//pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "StampExportPNG";
menuItem.Header = "JPG";
menuItem.Tag = "JPG";
pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "StampExportPDF";
menuItem.Header = "PDF";
menuItem.Tag = "PDF";
pop.BindingEvent(pop.AddChild("StampExportPicture", menuItem), StampExportPicture_MenuCommand);
menuItem = new MenuItem();
menuItem.Name = "StampAddNote";
menuItem.Header = "添加笔记";
pop.BindingEvent(pop.AddItem(menuItem), AnnotAddNoteText_MenuCommand);
StampAnnotPopMenu = pop;
}
///
/// 多选注释
///
private void InitSelectMultiAnnotMenu()
{
var popMenu = new ContextMenu();
PopMenu pop = new PopMenu(popMenu);
var menuItem = new MenuItem();
menuItem.Name = "MultiCopy";
menuItem.Header = "复制";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
menuItem = new MenuItem();
menuItem.Name = "MultiCut";
menuItem.Header = "剪切";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
menuItem = new MenuItem();
menuItem.Name = "MultiDelete";
menuItem.Header = "删除";
pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
MultiAnnotPopMenu = pop;
}
#endregion 注释-右键菜单
}
}