12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451 |
- using ComPDFKit.PDFDocument;
- using ComPDFKit.PDFPage;
- using ComPDFKit.PDFPage.Edit;
- using Compdfkit_Tools.Edit;
- using Compdfkit_Tools.Helper;
- using Compdfkit_Tools.PDFControl;
- using ComPDFKitViewer;
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using Microsoft.Win32;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Runtime.CompilerServices;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Controls.Primitives;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using Point = System.Windows.Point;
- namespace ContentEditor
- {
- public partial class MainWindow : Window, INotifyPropertyChanged
- {
- #region Property
- public bool CanUndo
- {
- get
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- return pdfViewControl.PDFView.UndoManager.CanUndo;
- }
- return false;
- }
- }
- public bool CanRedo
- {
- get
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- return pdfViewControl.PDFView.UndoManager.CanRedo;
- }
- return false;
- }
- }
- public bool CanSave
- {
- get
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- return pdfViewControl.PDFView.UndoManager.CanSave;
- }
- return false;
- }
- }
- /// <summary>
- /// The last PDF edit object
- /// </summary>
- private PDFEditEvent lastPDFEditEvent = null;
- private PDFViewControl passwordViewer;
- private PDFViewControl pdfViewControl;
- private PDFImageEditControl imageEditControl = new PDFImageEditControl();
- private PDFTextEditControl textEditControl = new PDFTextEditControl();
- private Border empytPanel = new Border();
- private UIElement prevPanel = null;
- private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
- public event PropertyChangedEventHandler PropertyChanged;
- private PDFEditEvent pdfTextCreateParam;
- private KeyEventHandler KeyDownHandler;
- #endregion
- public MainWindow()
- {
- InitializeComponent();
- Loaded += MainWindow_Loaded;
- DataContext = this;
- }
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- TextBlock emptyBlock = new TextBlock();
- emptyBlock.HorizontalAlignment = HorizontalAlignment.Center;
- emptyBlock.VerticalAlignment = VerticalAlignment.Center;
- empytPanel.Child = emptyBlock;
- empytPanel.Width = 260;
- BotaSideTool.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search);
- LoadDefaultDocument();
- }
- #region Load document
- private void LoadDocument()
- {
- if (pdfViewControl.PDFView.Document == null)
- {
- return;
- }
- pdfViewControl.PDFView?.Load();
- PDFGrid.Child = pdfViewControl;
- pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
- pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
- PasswordUI.Closed -= PasswordUI_Closed;
- PasswordUI.Canceled -= PasswordUI_Canceled;
- PasswordUI.Confirmed -= PasswordUI_Confirmed;
- PasswordUI.Closed += PasswordUI_Closed;
- PasswordUI.Canceled += PasswordUI_Canceled;
- PasswordUI.Confirmed += PasswordUI_Confirmed;
- pdfViewControl.PDFView.PDFEditActiveHandler -= PDFView_PDFEditActiveHandler;
- pdfViewControl.PDFView.PDFEditActiveHandler += PDFView_PDFEditActiveHandler;
- pdfViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
- pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
- pdfViewControl.PDFView.PDFEditCommandHandler -= PDFView_PDFEditCommandHandler;
- pdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
- pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
- pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
- pdfViewControl.PDFView.SetFormFieldHighlight(true);
- pdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
- CPDFSaclingControl.InitWithPDFViewer(pdfViewControl.PDFView);
- CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(pdfViewControl.PDFView.ZoomFactor * 100)));
- FloatPageTool.InitWithPDFViewer(pdfViewControl.PDFView);
- BotaSideTool.InitWithPDFViewer(pdfViewControl.PDFView);
- BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
- ViewSettingBtn.IsChecked = false;
- PropertyContainer.Child = null;
- PropertyContainer.Visibility = Visibility.Collapsed;
- SetEditMode();
- if (KeyDownHandler != null)
- {
- pdfViewControl.PDFView.RemoveHandler(KeyDownEvent, KeyDownHandler);
- }
- KeyDownHandler = new KeyEventHandler(PDFView_KeyDown);
- pdfViewControl.PDFView.AddHandler(KeyDownEvent, KeyDownHandler, false, true);
- }
- private void LoadDefaultDocument()
- {
- string defaultFilePath = "PDF32000_2008.pdf";
- pdfViewControl = new PDFViewControl();
- pdfViewControl.PDFView.InitDocument(defaultFilePath);
- LoadDocument();
- }
- #endregion
- #region Password
- private void PasswordUI_Confirmed(object sender, string e)
- {
- if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
- {
- passwordViewer.PDFView.Document.UnlockWithPassword(e);
- if (passwordViewer.PDFView.Document.IsLocked == false)
- {
- PasswordUI.SetShowError("", Visibility.Collapsed);
- PasswordUI.ClearPassword();
- PasswordUI.Visibility = Visibility.Collapsed;
- PopupBorder.Visibility = Visibility.Collapsed;
- pdfViewControl.PDFView.Document.Release();
- pdfViewControl = passwordViewer;
- LoadDocument();
- }
- else
- {
- PasswordUI.SetShowError("Wrong Password", Visibility.Visible);
- }
- }
- }
- private void PasswordUI_Canceled(object sender, EventArgs e)
- {
- PopupBorder.Visibility = Visibility.Collapsed;
- PasswordUI.Visibility = Visibility.Collapsed;
- }
- private void PasswordUI_Closed(object sender, EventArgs e)
- {
- PopupBorder.Visibility = Visibility.Collapsed;
- PasswordUI.Visibility = Visibility.Collapsed;
- }
- #endregion
- #region Expand and collapse Panel
- private void ExpandLeftPanel(bool isExpand)
- {
- BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
- Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
- if (isExpand)
- {
- BodyGrid.ColumnDefinitions[0].Width = new GridLength(260);
- BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
- }
- else
- {
- BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
- BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
- }
- }
- #endregion
- #region Context menu
- private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
- {
- if (e != null && e.CommandType == CommandType.Context)
- {
- if (e.PressOnSelectedText)
- {
- e.Handle = true;
- e.PopupMenu = new ContextMenu();
- e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
- }
- else if (e.CommandTarget == TargetType.ImageSelection)
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.GetSelectImageCount() > 0)
- {
- e.Handle = true;
- e.PopupMenu = new ContextMenu();
- MenuItem imageCopyMenu = new MenuItem();
- imageCopyMenu = new MenuItem();
- imageCopyMenu.Header = "Copy Images";
- WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageCopyMenu, "Click", CopyImage_Click);
- imageCopyMenu.CommandParameter = e;
- e.PopupMenu.Items.Add(imageCopyMenu);
- MenuItem imageExtraMenu = new MenuItem();
- imageExtraMenu = new MenuItem();
- imageExtraMenu.Header = "Extract Images";
- WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageExtraMenu, "Click", ExtraImage_Click);
- imageExtraMenu.CommandParameter = e;
- e.PopupMenu.Items.Add(imageExtraMenu);
- }
- }
- else
- {
- e.Handle = true;
- e.PopupMenu = new ContextMenu();
- MenuItem fitWidthMenu = new MenuItem();
- fitWidthMenu.Header = "Automatically Resize";
- fitWidthMenu.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
- }
- };
- e.PopupMenu.Items.Add(fitWidthMenu);
- MenuItem fitSizeMenu = new MenuItem();
- fitSizeMenu.Header = "Actual Size";
- fitSizeMenu.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
- }
- };
- e.PopupMenu.Items.Add(fitSizeMenu);
- MenuItem zoomInMenu = new MenuItem();
- zoomInMenu.Header = "Zoom In";
- zoomInMenu.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
- pdfViewControl.PDFView?.Zoom(newZoom);
- }
- };
- e.PopupMenu.Items.Add(zoomInMenu);
- MenuItem zoomOutMenu = new MenuItem();
- zoomOutMenu.Header = "Zoom Out";
- zoomOutMenu.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
- pdfViewControl.PDFView?.Zoom(newZoom);
- }
- };
- e.PopupMenu.Items.Add(zoomOutMenu);
- e.PopupMenu.Items.Add(new Separator());
- MenuItem singleView = new MenuItem();
- singleView.Header = "Single Page";
- singleView.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
- }
- };
- e.PopupMenu.Items.Add(singleView);
- MenuItem singleContinuousView = new MenuItem();
- singleContinuousView.Header = "Single Page Continuous";
- singleContinuousView.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
- }
- };
- e.PopupMenu.Items.Add(singleContinuousView);
- MenuItem doubleView = new MenuItem();
- doubleView.Header = "Two Pages";
- doubleView.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
- }
- };
- e.PopupMenu.Items.Add(doubleView);
- MenuItem doubleContinuousView = new MenuItem();
- doubleContinuousView.Header = "Two Pages Continuous";
- doubleContinuousView.Click += (o, p) =>
- {
- if (pdfViewControl != null)
- {
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
- }
- };
- e.PopupMenu.Items.Add(doubleContinuousView);
- }
- }
- if (e != null && e.CommandType == CommandType.Copy)
- {
- e.DoCommand();
- }
- }
- private void CopyImage_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
- if (imageDict != null && imageDict.Count > 0)
- {
- foreach (int pageIndex in imageDict.Keys)
- {
- List<Bitmap> imageList = imageDict[pageIndex];
- foreach (Bitmap image in imageList)
- {
- MemoryStream ms = new MemoryStream();
- image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
- BitmapImage imageData = new BitmapImage();
- imageData.BeginInit();
- imageData.StreamSource = ms;
- imageData.CacheOption = BitmapCacheOption.OnLoad;
- imageData.EndInit();
- imageData.Freeze();
- Clipboard.SetImage(imageData);
- break;
- }
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- private void ExtraImage_Click(object sender, RoutedEventArgs e)
- {
- System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
- if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- string choosePath = folderDialog.SelectedPath;
- string openPath = choosePath;
- try
- {
- Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
- if (imageDict != null && imageDict.Count > 0)
- {
- foreach (int pageIndex in imageDict.Keys)
- {
- List<Bitmap> imageList = imageDict[pageIndex];
- foreach (Bitmap image in imageList)
- {
- string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
- image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
- openPath = savePath;
- }
- }
- }
- Process.Start("explorer", "/select,\"" + openPath + "\"");
- }
- catch (Exception ex)
- {
- }
- }
- }
- private void PDFEditImageContextMenu(object sender, PDFEditCommand editCommand)
- {
- editCommand.PopupMenu = new ContextMenu();
- if (ApplicationCommands.Copy.CanExecute(null, (UIElement)sender) && lastPDFEditEvent != null)
- {
- MenuItem rotateLeftMenu = new MenuItem();
- rotateLeftMenu.Header = "Rotate Left";
- rotateLeftMenu.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- lastPDFEditEvent.Rotate = -90;
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- imageEditControl?.SetImageThumb();
- }
- };
- editCommand.PopupMenu.Items.Add(rotateLeftMenu);
- MenuItem rotateRightMenu = new MenuItem();
- rotateRightMenu.Header = "Rotate Right";
- rotateRightMenu.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- lastPDFEditEvent.Rotate = 90;
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- imageEditControl?.SetImageThumb();
- }
- };
- editCommand.PopupMenu.Items.Add(rotateRightMenu);
- MenuItem replaceMenu = new MenuItem();
- replaceMenu.Header = "Replace";
- replaceMenu.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
- if (openFileDialog.ShowDialog() == true)
- {
- lastPDFEditEvent.ReplaceImagePath = openFileDialog.FileName;
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- pdfViewControl.PDFView?.ClearSelectPDFEdit();
- }
- }
- };
- editCommand.PopupMenu.Items.Add(replaceMenu);
- MenuItem exportMenu = new MenuItem();
- exportMenu.Header = "Export";
- exportMenu.Click += (o, p) =>
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView.GetSelectedImages();
- if (imageDict != null && imageDict.Count > 0)
- {
- System.Windows.Forms.FolderBrowserDialog folderBrowser = new System.Windows.Forms.FolderBrowserDialog();
- if (folderBrowser.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- string choosePath = folderBrowser.SelectedPath;
- string openPath = choosePath;
- try
- {
- foreach (int pageIndex in imageDict.Keys)
- {
- List<Bitmap> imageList = imageDict[pageIndex];
- foreach (Bitmap image in imageList)
- {
- string savePath = System.IO.Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
- image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
- openPath = savePath;
- }
- }
- Process.Start("explorer", "/select,\"" + openPath + "\"");
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
- };
- editCommand.PopupMenu.Items.Add(exportMenu);
- MenuItem opacityMenu = new MenuItem();
- opacityMenu.Header = "Opacity";
- editCommand.PopupMenu.Items.Add(opacityMenu);
- AppendOpacityMenu(opacityMenu);
- MenuItem horizonMirror = new MenuItem();
- horizonMirror.Header = "Flip horizontal";
- horizonMirror.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- lastPDFEditEvent.HorizontalMirror = true;
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- imageEditControl?.SetImageThumb();
- }
- };
- editCommand.PopupMenu.Items.Add(horizonMirror);
- MenuItem verticalMirror = new MenuItem();
- verticalMirror.Header = "Flip vertical";
- verticalMirror.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- lastPDFEditEvent.VerticalMirror = true;
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- imageEditControl?.SetImageThumb();
- }
- };
- editCommand.PopupMenu.Items.Add(verticalMirror);
- MenuItem cropMenu = new MenuItem();
- cropMenu.Header = "Crop";
- cropMenu.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- lastPDFEditEvent.ClipImage = true;
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- }
- };
- editCommand.PopupMenu.Items.Add(cropMenu);
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
- if (editCommand.TextAreaCopied)
- {
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste And Match Style", Command = CustomCommands.PasteMatchStyle, CommandTarget = (UIElement)sender });
- }
- }
- else
- {
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
- }
- }
- private void AppendOpacityMenu(MenuItem parentMenu)
- {
- List<int> opacityList = new List<int>()
- {
- 25,50,75,100
- };
- foreach (int opacity in opacityList)
- {
- MenuItem opacityMenu = new MenuItem();
- opacityMenu.Header = string.Format("{0}%", opacity);
- opacityMenu.Click += (o, p) =>
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- lastPDFEditEvent.Transparency = (int)(opacity * 255 / 100D);
- lastPDFEditEvent.UpdatePDFEditByEventArgs();
- imageEditControl?.SetImageTransparency(lastPDFEditEvent.Transparency);
- imageEditControl?.SetImageThumb();
- }
- };
- parentMenu.Items.Add(opacityMenu);
- }
- }
- private void PDFEditTextContextMenu(object sender, PDFEditCommand editCommand)
- {
- editCommand.PopupMenu = new ContextMenu();
- if (lastPDFEditEvent != null)
- {
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Cut", Command = ApplicationCommands.Cut, CommandTarget = (UIElement)sender });
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Delete", Command = ApplicationCommands.Delete, CommandTarget = (UIElement)sender });
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
- }
- else
- {
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste", Command = ApplicationCommands.Paste, CommandTarget = (UIElement)sender });
- if (editCommand.TextAreaCopied)
- {
- editCommand.PopupMenu.Items.Add(new MenuItem() { Header = "Paste And Match Style", Command = CustomCommands.PasteMatchStyle, CommandTarget = (UIElement)sender });
- }
- }
- }
- #endregion
- #region UI
- /// <summary>
- /// Check the zoom factor
- /// </summary>
- private double CheckZoomLevel(double zoom, bool IsGrowth)
- {
- double standardZoom = 100;
- if (zoom <= 0.01)
- {
- return 0.01;
- }
- if (zoom >= 10)
- {
- return 10;
- }
- zoom *= 100;
- for (int i = 0; i < zoomLevelList.Length - 1; i++)
- {
- if (zoom > zoomLevelList[i] && zoom <= zoomLevelList[i + 1] && IsGrowth)
- {
- standardZoom = zoomLevelList[i + 1];
- break;
- }
- if (zoom >= zoomLevelList[i] && zoom < zoomLevelList[i + 1] && !IsGrowth)
- {
- standardZoom = zoomLevelList[i];
- break;
- }
- }
- return standardZoom / 100;
- }
- private void PageView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- UIElement pageView = sender as UIElement;
- if (pageView != null)
- {
- pageView.MouseLeftButtonUp -= PageView_MouseLeftButtonUp;
- }
- SetImageEditProperty();
- }
- private void ControlRightPanel()
- {
- if ((bool)ViewSettingBtn.IsChecked)
- {
- ViewSettingBtn.IsChecked = false;
- }
- if (RightPanelButton != null)
- {
- if (RightPanelButton.IsChecked == true)
- {
- if (PropertyContainer.Child is CPDFDisplaySettingsControl)
- {
- PropertyContainer.Child = prevPanel;
- }
- if (PropertyContainer.Child == null)
- {
- PropertyContainer.Child = empytPanel;
- }
- PropertyContainer.Visibility = Visibility.Visible;
- }
- else
- {
- PropertyContainer.Visibility = Visibility.Collapsed;
- }
- }
- }
- private void RightPanelButton_Click(object sender, RoutedEventArgs e)
- {
- ControlRightPanel();
- }
- private void ControlLeftPanel()
- {
- if (LeftToolPanelButton != null)
- {
- bool isExpand = LeftToolPanelButton.IsChecked == true;
- ExpandLeftPanel(isExpand);
- }
- }
- private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
- {
- ControlLeftPanel();
- }
- private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
- {
- LeftToolPanelButton.IsChecked = true;
- ExpandLeftPanel(true);
- BotaSideTool.SelectBotaTool(BOTATools.Search);
- }
- private void ShowViewSettings()
- {
- if (RightPanelButton != null)
- {
- RightPanelButton.IsChecked = false;
- }
- if (ViewSettingBtn != null)
- {
- if (ViewSettingBtn.IsChecked == true)
- {
- CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
- displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
- if (ViewComboBox.SelectedIndex == 1)
- {
- displayPanel.SetVisibilityWhenContentEdit(Visibility.Collapsed);
- }
- else
- {
- displayPanel.SetVisibilityWhenContentEdit(Visibility.Visible);
- }
- prevPanel = PropertyContainer.Child;
- PropertyContainer.Child = displayPanel;
- PropertyContainer.Visibility = Visibility.Visible;
- }
- else
- {
- PropertyContainer.Child = null;
- PropertyContainer.Visibility = Visibility.Collapsed;
- }
- }
- }
- private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
- {
- ShowViewSettings();
- }
- private void NextPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex + 1);
- }
- private void PrevPageBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- pdfViewControl.PDFView?.GoToPage(pdfViewControl.PDFView.CurrentIndex - 1);
- }
- private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
- {
- PasswordUI.Visibility = Visibility.Collapsed;
- CPDFInfoControl.Visibility = Visibility.Visible;
- CPDFInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
- CPDFInfoControl.CloseInfoEvent -= CPDFInfoControl_CloseInfoEvent;
- CPDFInfoControl.CloseInfoEvent += CPDFInfoControl_CloseInfoEvent;
- PopupBorder.Visibility = Visibility.Visible;
- }
- private void CPDFInfoControl_CloseInfoEvent(object sender, EventArgs e)
- {
- PopupBorder.Visibility = Visibility.Collapsed;
- }
- private void OpenFile()
- {
- string filePath = CommonHelper.GetFilePathOrEmpty();
- if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
- {
- if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
- {
- string oldFilePath = pdfViewControl.PDFView.Document.FilePath;
- if (oldFilePath.ToLower() == filePath.ToLower())
- {
- return;
- }
- }
- passwordViewer = new PDFViewControl();
- passwordViewer.PDFView.InitDocument(filePath);
- if (passwordViewer.PDFView.Document == null)
- {
- MessageBox.Show("Open File Failed");
- return;
- }
- if (passwordViewer.PDFView.Document.IsLocked)
- {
- PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
- PasswordUI.ClearPassword();
- PopupBorder.Visibility = Visibility.Visible;
- PasswordUI.Visibility = Visibility.Visible;
- }
- else
- {
- pdfViewControl.PDFView.Document.Release();
- pdfViewControl = passwordViewer;
- LoadDocument();
- }
- }
- }
- private void OpenFile_Click(object sender, RoutedEventArgs e)
- {
- OpenFile();
- }
- private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
- {
- SaveFile();
- }
- private void PDFTextEditButton_Click(object sender, RoutedEventArgs e)
- {
- ToggleButton senderBtn = sender as ToggleButton;
- if (senderBtn != null && pdfViewControl != null)
- {
- ClearPDFEditState(senderBtn);
- if (senderBtn.IsChecked == true)
- {
- PDFEditEvent createParam = new PDFEditEvent();
- createParam.EditType = CPDFEditType.EditText;
- createParam.IsBold = false;
- createParam.IsItalic = false;
- createParam.FontSize = 14;
- createParam.FontName = "Helvetica";
- createParam.FontColor = Colors.Black;
- createParam.TextAlign = TextAlignType.AlignLeft;
- createParam.Transparency = 255;
- if (pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
- {
- CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
- if (pdfDoc.PageCount > 0)
- {
- CPDFPage pdfPage = pdfDoc.PageAtIndex(0);
- CPDFEditPage editPage = pdfPage.GetEditPage();
- editPage.BeginEdit(CPDFEditType.EditText);
- createParam.SystemFontNameList.AddRange(editPage.GetFontList());
- editPage.EndEdit();
- }
- }
-
- pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
- pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
- pdfViewControl.PDFView?.SetPDFEditParam(createParam);
- if (textEditControl == null)
- {
- textEditControl = new PDFTextEditControl();
- }
- textEditControl.SetPDFTextEditData(createParam);
- PropertyContainer.Child = textEditControl;
- PropertyContainer.Visibility = Visibility.Visible;
- if ((bool)ViewSettingBtn.IsChecked)
- {
- ViewSettingBtn.IsChecked = false;
- }
- RightPanelButton.IsChecked = true;
- pdfTextCreateParam = createParam;
- }
- else
- {
- pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
- pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
- RightPanelButton.IsChecked = false;
- if ((bool)ViewSettingBtn.IsChecked)
- {
- return;
- }
- else
- {
- if (PropertyContainer.Child != null)
- {
- PropertyContainer.Child = empytPanel;
- }
- }
- PropertyContainer.Visibility = Visibility.Collapsed;
- }
- }
- }
- private void PDFImageEditButton_Click(object sender, RoutedEventArgs e)
- {
- ToggleButton senderBtn = sender as ToggleButton;
- if (senderBtn != null && pdfViewControl != null)
- {
- senderBtn.IsChecked = false;
- OpenFileDialog openFileDialog = new OpenFileDialog();
- openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
- if (openFileDialog.ShowDialog() == true)
- {
- ClearPDFEditState(senderBtn);
- pdfViewControl.PDFView?.ClearSelectPDFEdit();
- pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
- RightPanelButton.IsChecked = false;
- if (PropertyContainer.Child != null && !(bool)ViewSettingBtn.IsChecked)
- {
- PropertyContainer.Child = empytPanel;
- PropertyContainer.Visibility = Visibility.Collapsed;
- }
- pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
- pdfViewControl.PDFView?.AddPDFEditImage(openFileDialog.FileName);
- }
- }
- }
- private void ClearPDFEditState(ToggleButton ignoreBtn = null)
- {
- List<ToggleButton> clearBtnList = new List<ToggleButton>()
- {
- PDFTextEditButton,
- PDFImageEditButton
- };
- foreach (ToggleButton item in clearBtnList)
- {
- if (ignoreBtn == item)
- {
- continue;
- }
- item.IsChecked = false;
- }
- }
- private void UndoBtn_Click(object sender, RoutedEventArgs e)
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- pdfViewControl.PDFView.UndoManager?.Undo();
- }
- }
- private void RedoBtn_Click(object sender, RoutedEventArgs e)
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- pdfViewControl.PDFView.UndoManager?.Redo();
- }
- }
- #endregion
- #region Property changed
- protected void OnPropertyChanged([CallerMemberName] string name = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
- }
- private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- OnPropertyChanged(e.PropertyName);
- }
- #endregion
- #region Event handle
- private void PDFView_PDFEditCommandHandler(object sender, PDFEditCommand e)
- {
- if (e == null)
- {
- return;
- }
- if (e.EditType == CPDFEditType.EditText)
- {
- e.Handle = true;
- PDFEditTextContextMenu(sender, e);
- }
- if (e.EditType == CPDFEditType.EditImage)
- {
- e.Handle = true;
- PDFEditImageContextMenu(sender, e);
- }
- }
- private void PDFView_PDFEditActiveHandler(object sender, PDFEditEvent e)
- {
- PDFEditEvent tempEvent = lastPDFEditEvent;
- lastPDFEditEvent = e;
- if ((bool)ViewSettingBtn.IsChecked)
- {
- ViewSettingBtn.IsChecked = false;
- RightPanelButton.IsChecked = true;
- }
- if (e == null)
- {
- PropertyContainer.Child = empytPanel;
- if (pdfTextCreateParam != null && pdfViewControl != null && pdfViewControl.PDFView != null)
- {
- if (pdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.EditText)
- {
- if (textEditControl == null)
- {
- textEditControl = new PDFTextEditControl();
- }
- textEditControl.SetPDFTextEditData(pdfTextCreateParam);
- PropertyContainer.Child = textEditControl;
- }
- }
- return;
- }
- if (Mouse.RightButton == MouseButtonState.Pressed && PropertyContainer.Visibility != Visibility.Visible)
- {
- return;
- }
- if (e.EditType == CPDFEditType.EditText)
- {
- if (textEditControl == null)
- {
- textEditControl = new PDFTextEditControl();
- }
- textEditControl.SetPDFTextEditData(e);
- PropertyContainer.Child = textEditControl;
- return;
- }
- if (e.EditType == CPDFEditType.EditImage && pdfViewControl != null)
- {
- UIElement pageView = sender as UIElement;
- if (pageView != null)
- {
- pageView.MouseLeftButtonUp -= PageView_MouseLeftButtonUp;
- pageView.MouseLeftButtonUp += PageView_MouseLeftButtonUp;
- }
- if (Mouse.RightButton == MouseButtonState.Pressed)
- {
- SetImageEditProperty();
- }
- return;
- }
- }
- #endregion
- #region Save file
- /// <summary>
- /// Save the file to another PDF file.
- /// </summary>
- public void SaveAsFile()
- {
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
- {
- CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
- SaveFileDialog saveDialog = new SaveFileDialog();
- saveDialog.Filter = "(*.pdf)|*.pdf";
- saveDialog.DefaultExt = ".pdf";
- saveDialog.OverwritePrompt = true;
- if (saveDialog.ShowDialog() == true)
- {
- pdfDoc.WriteToFilePath(saveDialog.FileName);
- }
- }
- }
- }
- private void SaveFile()
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
- {
- CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
- if (pdfDoc.WriteToLoadedPath())
- {
- return;
- }
- SaveFileDialog saveDialog = new SaveFileDialog();
- saveDialog.Filter = "(*.pdf)|*.pdf";
- saveDialog.DefaultExt = ".pdf";
- saveDialog.OverwritePrompt = true;
- if (saveDialog.ShowDialog() == true)
- {
- pdfDoc.WriteToFilePath(saveDialog.FileName);
- }
- }
- }
- #endregion
- #region Selected changed
- private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
- {
- if (e.Key == "Zoom")
- {
- CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
- }
- }
- private void SetImageEditProperty()
- {
- if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
- {
- if (imageEditControl == null)
- {
- imageEditControl = new PDFImageEditControl();
- }
- imageEditControl.InitWithPDFViewer(pdfViewControl.PDFView);
- imageEditControl.SetPDFImageEditData(lastPDFEditEvent);
- PropertyContainer.Child = imageEditControl;
- }
- }
- private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- SetEditMode();
- }
- private void SetEditMode()
- {
- ClearPDFEditState(null);
- if (pdfViewControl != null && ViewComboBox != null)
- {
- if (ViewComboBox.SelectedIndex == 0)
- {
- PDFEditTool.Visibility = Visibility.Collapsed;
- pdfViewControl.PDFView?.SetShowLink(true);
- pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None);
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
- pdfViewControl.PDFView?.ReloadDocument();
- }
- if (ViewComboBox.SelectedIndex == 1)
- {
- PDFEditTool.Visibility = Visibility.Visible;
- pdfViewControl.PDFView?.SetShowLink(false);
- pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);
- pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
- pdfViewControl.PDFView?.ReloadDocument();
- }
- RightPanelButton.IsChecked = false;
- ViewSettingBtn.IsChecked = false;
- PropertyContainer.Visibility = Visibility.Collapsed;
- if (PropertyContainer != null)
- {
- PropertyContainer.Child = null;
- }
- }
- }
- public void PDFView_KeyDown(object sender, KeyEventArgs e)
- {
- if (pdfViewControl.PDFView.MouseMode != MouseModes.PDFEdit)
- {
- return;
- }
- if (Keyboard.Modifiers == ModifierKeys.Control)
- {
- if (e.Key == Key.Left)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypePreWord, false);
- e.Handled = true;
- }
- if (e.Key == Key.Right)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeNextWord, false);
- e.Handled = true;
- }
- if (e.Key == Key.Up)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeSectionBegin, false);
- e.Handled = true;
- }
- if (e.Key == Key.Down)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeSectionEnd, false);
- e.Handled = true;
- }
- }
- if (Keyboard.Modifiers == ModifierKeys.Shift)
- {
- if (e.Key == Key.Left)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypePreCharPlace, true);
- e.Handled = true;
- }
- if (e.Key == Key.Right)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeNextCharPlace, true);
- e.Handled = true;
- }
- if (e.Key == Key.Up)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeUpCharPlace, true);
- e.Handled = true;
- }
- if (e.Key == Key.Down)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeDownCharPlace, true);
- e.Handled = true;
- }
- }
- if (Keyboard.Modifiers == ModifierKeys.Alt)
- {
- if (e.SystemKey == Key.Up)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLocationLineBegin, false);
- e.Handled = true;
- }
- if (e.SystemKey == Key.Down)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeLineEnd, false);
- e.Handled = true;
- }
- }
- if (Keyboard.Modifiers == ModifierKeys.None)
- {
- if (e.Key == Key.Left)
- {
- pdfViewControl.PDFView.MoveEditArea(new Point(-5, 0));
- e.Handled = true;
- }
- if (e.Key == Key.Right)
- {
- pdfViewControl.PDFView.MoveEditArea(new Point(5, 0));
- e.Handled = true;
- }
- if (e.Key == Key.Up)
- {
- pdfViewControl.PDFView.MoveEditArea(new Point(0, -5));
- e.Handled = true;
- }
- if (e.Key == Key.Down)
- {
- pdfViewControl.PDFView.MoveEditArea(new Point(0, 5));
- e.Handled = true;
- }
- }
- if (Keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift))
- {
- if (e.Key == Key.Left)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypePreWord, true);
- e.Handled = true;
- }
- if (e.Key == Key.Right)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeNextWord, true);
- e.Handled = true;
- }
- if (e.Key == Key.Up)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeSectionBegin, true);
- e.Handled = true;
- }
- if (e.Key == Key.Down)
- {
- pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeSectionEnd, true);
- e.Handled = true;
- }
- }
- }
- #endregion
- #region Close window
- protected override void OnClosing(CancelEventArgs e)
- {
- if (pdfViewControl.PDFView.UndoManager.CanSave)
- {
- MessageBoxResult result = MessageBox.Show("Do you want to save your changes before closing the application?", "Message", MessageBoxButton.YesNoCancel);
- if (result == MessageBoxResult.Yes)
- {
- SaveFile();
- }
- else if (result == MessageBoxResult.No)
- {
- }
- else
- {
- e.Cancel = true;
- }
- }
- }
- #endregion
- #region Shortcut
- private void CommandBinding_Executed_Open(object sender, ExecutedRoutedEventArgs e)
- {
- OpenFile();
- }
- private void CommandBinding_Executed_Save(object sender, ExecutedRoutedEventArgs e)
- {
- if (CanSave)
- {
- SaveFile();
- }
- }
- private void CommandBinding_Executed_SaveAs(object sender, ExecutedRoutedEventArgs e)
- {
- SaveAsFile();
- }
- private void CommandBinding_Executed_Undo(object sender, ExecutedRoutedEventArgs e)
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null && CanUndo)
- {
- pdfViewControl.PDFView.UndoManager?.Undo();
- }
- }
- private void CommandBinding_Executed_Redo(object sender, ExecutedRoutedEventArgs e)
- {
- if (pdfViewControl != null && pdfViewControl.PDFView != null && CanRedo)
- {
- pdfViewControl.PDFView.UndoManager?.Redo();
- }
- }
- private void CommandBinding_Executed_ControlLeftPanel(object sender, ExecutedRoutedEventArgs e)
- {
- LeftToolPanelButton.IsChecked = !LeftToolPanelButton.IsChecked;
- ControlLeftPanel();
- }
- private void CommandBinding_Executed_ControlRightPanel(object sender, ExecutedRoutedEventArgs e)
- {
- RightPanelButton.IsChecked = !RightPanelButton.IsChecked;
- ControlRightPanel();
- }
- private void CommandBinding_Executed_Bookmark(object sender, ExecutedRoutedEventArgs e)
- {
- ExpandLeftPanel(true);
- LeftToolPanelButton.IsChecked = true;
- BotaSideTool.SelectBotaTool(BOTATools.Bookmark);
- }
- private void CommandBinding_Executed_Outline(object sender, ExecutedRoutedEventArgs e)
- {
- ExpandLeftPanel(true);
- LeftToolPanelButton.IsChecked = true;
- BotaSideTool.SelectBotaTool(BOTATools.Outline);
- }
- private void CommandBinding_Executed_Thumbnail(object sender, ExecutedRoutedEventArgs e)
- {
- ExpandLeftPanel(true);
- LeftToolPanelButton.IsChecked = true;
- BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
- }
- private void CommandBinding_Executed_Search(object sender, ExecutedRoutedEventArgs e)
- {
- ExpandLeftPanel(true);
- LeftToolPanelButton.IsChecked = true;
- BotaSideTool.SelectBotaTool(BOTATools.Search);
- }
- private void CommandBinding_Executed_ScaleAdd(object sender, ExecutedRoutedEventArgs e)
- {
- double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
- pdfViewControl.PDFView?.Zoom(newZoom);
- }
- private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
- {
- double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
- pdfViewControl.PDFView?.Zoom(newZoom);
- }
- private void CommandBinding_Executed_DisplaySettings(object sender, ExecutedRoutedEventArgs e)
- {
- ViewSettingBtn.IsChecked = !ViewSettingBtn.IsChecked;
- ShowViewSettings();
- }
- private void CommandBinding_Executed_DocumentInfo(object sender, ExecutedRoutedEventArgs e)
- {
- if (PopupBorder.Visibility != Visibility.Visible)
- {
- PasswordUI.Visibility = Visibility.Collapsed;
- CPDFInfoControl.Visibility = Visibility.Visible;
- CPDFInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
- CPDFInfoControl.CloseInfoEvent -= CPDFInfoControl_CloseInfoEvent;
- CPDFInfoControl.CloseInfoEvent += CPDFInfoControl_CloseInfoEvent;
- PopupBorder.Visibility = Visibility.Visible;
- }
- else
- {
- CPDFInfoControl.Visibility = Visibility.Collapsed;
- PopupBorder.Visibility = Visibility.Collapsed;
- }
- }
- #endregion
- }
- }
|