123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953 |
- 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 属性面板
- /// <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, List<AnnotHandlerEventArgs> 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<AnnotAttribEvent>();
- 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);
- }
- }
- /// <summary>
- /// 展开显示属性面板
- /// </summary>
- 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;
- }
- }
- /// <summary>
- /// 选择文本或者图像的右键菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="annotCommand"></param>
- /// <returns></returns>
- 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;
- /// <summary>
- /// 高亮注释,右键菜单
- /// </summary>
- 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();
- }
- }
- }
- }
- /// <summary>
- /// 手绘
- /// </summary>
- 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;
- }
- /// <summary>
- /// 文本
- /// </summary>
- 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;
- }
- /// <summary>
- /// 便签
- /// </summary>
- 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;
- }
- /// <summary>
- /// 形状
- /// </summary>
- 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;
- }
- /// <summary>
- /// 链接
- /// </summary>
- 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;
- }
- /// <summary>
- /// 图章、签名
- /// </summary>
- 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;
- }
- /// <summary>
- /// 多选注释
- /// </summary>
- 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 注释-右键菜单
- }
- }
|