|
@@ -1,5 +1,6 @@
|
|
|
using ComPDFKit.PDFDocument;
|
|
|
using ComPDFKit.PDFPage;
|
|
|
+using ComPDFKit.PDFPage.Edit;
|
|
|
using Compdfkit_Tools.Data;
|
|
|
using Compdfkit_Tools.Edit;
|
|
|
using Compdfkit_Tools.Helper;
|
|
@@ -16,18 +17,14 @@ using System.Drawing;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
|
using System.Windows.Controls.Primitives;
|
|
|
-using System.Windows.Data;
|
|
|
-using System.Windows.Documents;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
-using System.Windows.Navigation;
|
|
|
using Path = System.IO.Path;
|
|
|
+using Point = System.Windows.Point;
|
|
|
|
|
|
namespace PDFViewer
|
|
|
{
|
|
@@ -39,12 +36,16 @@ namespace PDFViewer
|
|
|
private PDFViewControl passwordViewer;
|
|
|
private PDFViewControl pdfViewControl = new PDFViewControl();
|
|
|
private CPDFAnnotationControl pdfAnnotationControl = null;
|
|
|
- private UIElement pdfEditControl = null;
|
|
|
private CPDFPageEditControl pageEditControl = null;
|
|
|
private FromPropertyControl pdfFormControl = new FromPropertyControl();
|
|
|
- private PDFImageEditControl imageEditControl = null;
|
|
|
- private CPDFDisplaySettingsControl displayPanel = null;
|
|
|
-
|
|
|
+ private PDFContentEditControl pdfContentEditControl = new PDFContentEditControl();
|
|
|
+ private CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
|
|
|
+ private PDFEditEvent lastPDFEditEvent = null;
|
|
|
+ public event Func<string[], bool> CheckExistBeforeOpenFileEvent;
|
|
|
+ public event PropertyChangedEventHandler PropertyChanged;
|
|
|
+ public event EventHandler FileChangeEvent;
|
|
|
+ private PDFEditEvent pdfTextCreateParam;
|
|
|
+ private KeyEventHandler KeyDownHandler;
|
|
|
private double[] zoomLevelList = { 1f, 8f, 12f, 25, 33f, 50, 66f, 75, 100, 125, 150, 200, 300, 400, 600, 800, 1000 };
|
|
|
public bool CanSave
|
|
|
{
|
|
@@ -82,10 +83,7 @@ namespace PDFViewer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private PDFEditEvent lastPDFEditEvent = null;
|
|
|
- public event Func<string[], bool> CheckExistBeforeOpenFileEvent;
|
|
|
- public event PropertyChangedEventHandler PropertyChanged;
|
|
|
- public event EventHandler FileChangeEvent;
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
public MainPage()
|
|
@@ -105,6 +103,7 @@ namespace PDFViewer
|
|
|
pdfAnnotationControl.SetPDFViewer(newPDFViewer.PDFView);
|
|
|
FormBarControl.InitWithPDFViewer(newPDFViewer.PDFView, pdfFormControl);
|
|
|
pdfFormControl.SetPDFViewer(newPDFViewer.PDFView);
|
|
|
+ pdfContentEditControl.InitWithPDFViewer(newPDFViewer.PDFView);
|
|
|
pdfAnnotationControl.AnnotationCancel();
|
|
|
AnnotationBarControl.ClearAllToolState();
|
|
|
ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
@@ -245,6 +244,7 @@ namespace PDFViewer
|
|
|
PasswordUI.ClearPassword();
|
|
|
PasswordUI.Visibility = Visibility.Collapsed;
|
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
|
+ pdfViewControl.PDFView.Document.Release();
|
|
|
pdfViewControl = passwordViewer;
|
|
|
LoadDocument();
|
|
|
FileChangeEvent?.Invoke(null, EventArgs.Empty);
|
|
@@ -261,7 +261,6 @@ namespace PDFViewer
|
|
|
SaveFile();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void PageView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
UIElement pageView = sender as UIElement;
|
|
@@ -271,27 +270,21 @@ namespace PDFViewer
|
|
|
}
|
|
|
if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditImage)
|
|
|
{
|
|
|
- if (imageEditControl == null)
|
|
|
- {
|
|
|
- imageEditControl = new PDFImageEditControl();
|
|
|
- }
|
|
|
- imageEditControl.InitWithPDFViewer(pdfViewControl.PDFView);
|
|
|
- imageEditControl.SetPDFImageEditData(lastPDFEditEvent);
|
|
|
- pdfEditControl = imageEditControl as UIElement;
|
|
|
- PropertyContainer.Child = pdfEditControl;
|
|
|
- ExpandRightPropertyPanel(pdfEditControl, Visibility.Visible);
|
|
|
+ pdfContentEditControl.SetPDFImageEditData(lastPDFEditEvent);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
PasswordUI.Visibility = Visibility.Collapsed;
|
|
|
- FileInfoUI.Visibility = Visibility.Visible;
|
|
|
- FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
|
|
|
+ CPDFInfoControl.Visibility = Visibility.Visible;
|
|
|
+ CPDFInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
|
|
|
+ CPDFInfoControl.CloseInfoEvent -= CPDFInfoControl_CloseInfoEvent;
|
|
|
+ CPDFInfoControl.CloseInfoEvent += CPDFInfoControl_CloseInfoEvent;
|
|
|
PopupBorder.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
|
|
|
- private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ private void CPDFInfoControl_CloseInfoEvent(object sender, EventArgs e)
|
|
|
{
|
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
@@ -304,18 +297,52 @@ namespace PDFViewer
|
|
|
ClearPDFEditState(senderBtn);
|
|
|
if (senderBtn.IsChecked == true)
|
|
|
{
|
|
|
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
|
|
|
+ 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?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
- pdfViewControl.PDFView?.ReloadDocument();
|
|
|
+
|
|
|
+ pdfViewControl.PDFView?.SetPDFEditParam(createParam);
|
|
|
+ pdfContentEditControl.SetPDFTextEditData(createParam);
|
|
|
+ ExpandRightPropertyPanel(pdfContentEditControl, 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);
|
|
|
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
- pdfViewControl.PDFView?.ReloadDocument();
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
+ if ((bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ pdfContentEditControl.ClearContentControl();
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -333,12 +360,15 @@ namespace PDFViewer
|
|
|
ClearPDFEditState(senderBtn);
|
|
|
pdfViewControl.PDFView?.ClearSelectPDFEdit();
|
|
|
pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditImage | CPDFEditType.EditText);
|
|
|
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
- pdfViewControl.PDFView?.ReloadDocument();
|
|
|
|
|
|
- ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
+ if (PropertyContainer.Child != null && !(bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ }
|
|
|
pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditImage);
|
|
|
pdfViewControl.PDFView?.AddPDFEditImage(openFileDialog.FileName);
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -629,7 +659,7 @@ namespace PDFViewer
|
|
|
{
|
|
|
lastPDFEditEvent.Rotate = -90;
|
|
|
lastPDFEditEvent.UpdatePDFEditByEventArgs();
|
|
|
- imageEditControl?.SetImageThumb();
|
|
|
+ pdfContentEditControl.RefreshThumb();
|
|
|
}
|
|
|
};
|
|
|
editCommand.PopupMenu.Items.Add(rotateLeftMenu);
|
|
@@ -642,7 +672,7 @@ namespace PDFViewer
|
|
|
{
|
|
|
lastPDFEditEvent.Rotate = 90;
|
|
|
lastPDFEditEvent.UpdatePDFEditByEventArgs();
|
|
|
- imageEditControl?.SetImageThumb();
|
|
|
+ pdfContentEditControl.RefreshThumb();
|
|
|
}
|
|
|
};
|
|
|
editCommand.PopupMenu.Items.Add(rotateRightMenu);
|
|
@@ -660,7 +690,7 @@ namespace PDFViewer
|
|
|
lastPDFEditEvent.ReplaceImagePath = openFileDialog.FileName;
|
|
|
lastPDFEditEvent.UpdatePDFEditByEventArgs();
|
|
|
pdfViewControl.PDFView?.ClearSelectPDFEdit();
|
|
|
- imageEditControl?.SetImageThumb();
|
|
|
+ pdfContentEditControl.RefreshThumb();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -742,6 +772,11 @@ namespace PDFViewer
|
|
|
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
|
|
|
{
|
|
@@ -870,9 +905,11 @@ namespace PDFViewer
|
|
|
pdfViewControl.PDFView.PDFEditCommandHandler -= PDFView_PDFEditCommandHandler;
|
|
|
pdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
|
|
|
|
|
|
+ //
|
|
|
pdfViewControl.PDFView.AnnotCommandHandler -= PDFView_AnnotCommandHandler;
|
|
|
pdfViewControl.PDFView.AnnotCommandHandler += PDFView_AnnotCommandHandler;
|
|
|
|
|
|
+ //Can undo, can redo
|
|
|
pdfViewControl.PDFView.UndoManager.PropertyChanged -= UndoManager_PropertyChanged;
|
|
|
pdfViewControl.PDFView.UndoManager.PropertyChanged += UndoManager_PropertyChanged;
|
|
|
|
|
@@ -898,7 +935,14 @@ namespace PDFViewer
|
|
|
ViewSettingBtn.IsChecked = false;
|
|
|
PropertyContainer.Child = null;
|
|
|
PropertyContainer.Visibility = Visibility.Collapsed;
|
|
|
+
|
|
|
ModeComboBox.SelectedIndex = 0;
|
|
|
+ if (KeyDownHandler != null)
|
|
|
+ {
|
|
|
+ pdfViewControl.PDFView.RemoveHandler(KeyDownEvent, KeyDownHandler);
|
|
|
+ }
|
|
|
+ KeyDownHandler = new KeyEventHandler(PDFView_KeyDown);
|
|
|
+ pdfViewControl.PDFView.AddHandler(KeyDownEvent, KeyDownHandler, false, true);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -986,6 +1030,7 @@ namespace PDFViewer
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ pdfViewControl.PDFView.Document.Release();
|
|
|
pdfViewControl = passwordViewer;
|
|
|
LoadDocument();
|
|
|
FileChangeEvent?.Invoke(null, EventArgs.Empty);
|
|
@@ -1016,16 +1061,59 @@ namespace PDFViewer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ private void ControlLeftPanel()
|
|
|
{
|
|
|
- ToggleButton expandBtn = sender as ToggleButton;
|
|
|
- if (expandBtn != null)
|
|
|
+ if (LeftToolPanelButton != null)
|
|
|
{
|
|
|
- bool isExpand = expandBtn.IsChecked == true;
|
|
|
+ bool isExpand = LeftToolPanelButton.IsChecked == true;
|
|
|
ExpandLeftPanel(isExpand);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void ControlRightPanel()
|
|
|
+ {
|
|
|
+ if ((bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ViewSettingBtn.IsChecked = false;
|
|
|
+ }
|
|
|
+ if (RightPanelButton != null)
|
|
|
+ {
|
|
|
+ if (RightPanelButton.IsChecked == true)
|
|
|
+ {
|
|
|
+ if (currentMode == "Annotation")
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
|
|
|
+ }
|
|
|
+ else if (currentMode == "Edit")
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(pdfContentEditControl, Visibility.Visible);
|
|
|
+ }
|
|
|
+ else if (currentMode == "Forms")
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(pdfFormControl, Visibility.Visible);
|
|
|
+ }
|
|
|
+ else if (currentMode == "Content Editor")
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(pdfContentEditControl, Visibility.Visible);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ControlLeftPanel();
|
|
|
+ }
|
|
|
+
|
|
|
private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
ExpandLeftPanel(true);
|
|
@@ -1033,17 +1121,12 @@ namespace PDFViewer
|
|
|
BotaSideTool.SelectBotaTool(BOTATools.Search);
|
|
|
}
|
|
|
|
|
|
- private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ private void ShowViewSettings()
|
|
|
{
|
|
|
- ToggleButton toggleButton = sender as ToggleButton;
|
|
|
- if (toggleButton != null)
|
|
|
+ if (ViewSettingBtn != null)
|
|
|
{
|
|
|
- if (toggleButton.IsChecked == true)
|
|
|
+ if (ViewSettingBtn.IsChecked == true)
|
|
|
{
|
|
|
- if (displayPanel == null)
|
|
|
- {
|
|
|
- displayPanel = new CPDFDisplaySettingsControl();
|
|
|
- }
|
|
|
displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
|
|
|
PropertyContainer.Child = displayPanel;
|
|
|
PropertyContainer.Visibility = Visibility.Visible;
|
|
@@ -1060,6 +1143,11 @@ namespace PDFViewer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ShowViewSettings();
|
|
|
+ }
|
|
|
+
|
|
|
public void ExpandRightPropertyPanel(UIElement properytPanel, Visibility visible)
|
|
|
{
|
|
|
PropertyContainer.Width = 260;
|
|
@@ -1073,37 +1161,7 @@ namespace PDFViewer
|
|
|
|
|
|
private void RightPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- ToggleButton toggleButton = sender as ToggleButton;
|
|
|
- if (toggleButton != null)
|
|
|
- {
|
|
|
- if (toggleButton.IsChecked == true)
|
|
|
- {
|
|
|
- if (currentMode == "Annotation")
|
|
|
- {
|
|
|
- ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
|
|
|
- }
|
|
|
- else if (currentMode == "Edit")
|
|
|
- {
|
|
|
- ExpandRightPropertyPanel(pdfEditControl, Visibility.Visible);
|
|
|
- }
|
|
|
- else if (currentMode == "Forms")
|
|
|
- {
|
|
|
- ExpandRightPropertyPanel(pdfFormControl, Visibility.Visible);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ExpandRightPropertyPanel(pdfAnnotationControl, Visibility.Visible);
|
|
|
- }
|
|
|
- if ((bool)ViewSettingBtn.IsChecked)
|
|
|
- {
|
|
|
- ViewSettingBtn.IsChecked = false;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
- }
|
|
|
- }
|
|
|
+ ControlRightPanel();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
@@ -1121,6 +1179,11 @@ namespace PDFViewer
|
|
|
|
|
|
private void PDFView_AnnotActiveHandler(object sender, AnnotAttribEvent e)
|
|
|
{
|
|
|
+ if ((bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ViewSettingBtn.IsChecked = false;
|
|
|
+ RightPanelButton.IsChecked = true;
|
|
|
+ }
|
|
|
PropertyContainer.Child = pdfAnnotationControl;
|
|
|
pdfAnnotationControl.SetAnnotEventData(e);
|
|
|
}
|
|
@@ -1140,7 +1203,6 @@ namespace PDFViewer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void PDFView_PDFEditCommandHandler(object sender, PDFEditCommand e)
|
|
|
{
|
|
|
if (e == null)
|
|
@@ -1166,38 +1228,52 @@ namespace PDFViewer
|
|
|
/// </summary>
|
|
|
private void PDFView_PDFEditActiveHandler(object sender, ComPDFKitViewer.PDFEditEvent e)
|
|
|
{
|
|
|
+ PropertyContainer.Child = pdfContentEditControl;
|
|
|
lastPDFEditEvent = e;
|
|
|
- ViewSettingBtn.IsChecked = false;
|
|
|
- if (e == null)
|
|
|
+ if ((bool)ViewSettingBtn.IsChecked)
|
|
|
{
|
|
|
- pdfEditControl = null;
|
|
|
- PropertyContainer.Child = pdfEditControl;
|
|
|
- ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
- return;
|
|
|
+ ViewSettingBtn.IsChecked = false;
|
|
|
+ RightPanelButton.IsChecked = true;
|
|
|
+ ExpandRightPropertyPanel(pdfContentEditControl, Visibility.Visible);
|
|
|
}
|
|
|
- if (Mouse.RightButton == MouseButtonState.Pressed)
|
|
|
+
|
|
|
+ if (e == null)
|
|
|
{
|
|
|
+ PropertyContainer.Child = pdfContentEditControl;
|
|
|
+
|
|
|
+ if (pdfTextCreateParam != null && pdfViewControl != null && pdfViewControl.PDFView != null)
|
|
|
+ {
|
|
|
+ if (pdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.EditText)
|
|
|
+ {
|
|
|
+ pdfContentEditControl.SetPDFTextEditData(pdfTextCreateParam);
|
|
|
+ }
|
|
|
+ else if (pdfViewControl.PDFView.GetPDFEditCreateType() == CPDFEditType.None)
|
|
|
+ {
|
|
|
+ pdfContentEditControl.ClearContentControl();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pdfContentEditControl.ClearContentControl();
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
if (e.EditType == CPDFEditType.EditText)
|
|
|
{
|
|
|
- RightPanelButton.IsChecked = true;
|
|
|
- PDFTextEditControl textEditControl = new PDFTextEditControl();
|
|
|
- textEditControl.SetPDFTextEditData(e);
|
|
|
- pdfEditControl = textEditControl as UIElement;
|
|
|
- PropertyContainer.Child = pdfEditControl;
|
|
|
- ExpandRightPropertyPanel(pdfEditControl, Visibility.Visible);
|
|
|
+ pdfContentEditControl.SetPDFTextEditData(e, true);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (e.EditType == CPDFEditType.EditImage && pdfViewControl != null)
|
|
|
{
|
|
|
- RightPanelButton.IsChecked = true;
|
|
|
UIElement pageView = sender as UIElement;
|
|
|
if (pageView != null)
|
|
|
{
|
|
|
- pageView.MouseLeftButtonUp += PageView_MouseLeftButtonUp; ;
|
|
|
+ pageView.MouseLeftButtonUp += PageView_MouseLeftButtonUp;
|
|
|
}
|
|
|
+ pdfContentEditControl.SetPDFImageEditData(e);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -1320,6 +1396,137 @@ namespace PDFViewer
|
|
|
{
|
|
|
OpenFile();
|
|
|
}
|
|
|
+
|
|
|
+ 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 Change mode
|
|
@@ -1330,6 +1537,7 @@ namespace PDFViewer
|
|
|
/// </summary>
|
|
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
+ pdfTextCreateParam = null;
|
|
|
if (isFirstLoad)
|
|
|
{
|
|
|
isFirstLoad = false;
|
|
@@ -1354,7 +1562,10 @@ namespace PDFViewer
|
|
|
AnnotationBarControl.Visibility = Visibility.Collapsed;
|
|
|
AnnotationBarControl.ClearAllToolState();
|
|
|
pdfAnnotationControl.ClearPanel();
|
|
|
- ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ if (!(bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ }
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
|
|
|
pdfViewControl.PDFView.AnnotEditHandler -= PDFView_AnnotEditHandler;
|
|
|
pdfAnnotationControl.ClearAnnotationBar -= PdfAnnotationControl_ClearAnnotationBar;
|
|
@@ -1381,13 +1592,17 @@ namespace PDFViewer
|
|
|
pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None);
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
|
|
|
pdfViewControl.PDFView?.ReloadDocument();
|
|
|
+ pdfContentEditControl.ClearPanel();
|
|
|
pdfViewControl.PDFView.PDFEditActiveHandler -= PDFView_PDFEditActiveHandler;
|
|
|
- ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ if (!(bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ }
|
|
|
ClearPDFEditState();
|
|
|
pdfViewControl.PDFView?.UndoManager.ClearHistory();
|
|
|
if (displayPanel != null)
|
|
|
{
|
|
|
- displayPanel.SetSplitContainerVisibility(Visibility.Visible);
|
|
|
+ displayPanel.SetVisibilityWhenContentEdit(Visibility.Visible);
|
|
|
}
|
|
|
break;
|
|
|
/*
|
|
@@ -1398,7 +1613,10 @@ namespace PDFViewer
|
|
|
* Clear undo history
|
|
|
*/
|
|
|
case "Forms":
|
|
|
- ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ if (!(bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ }
|
|
|
FormBarControl.ClearAllToolState();
|
|
|
FormBarControl.Visibility = Visibility.Collapsed;
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
|
|
@@ -1475,6 +1693,7 @@ namespace PDFViewer
|
|
|
PageEditBarControl.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);
|
|
|
+ pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
pdfViewControl.PDFView?.ReloadDocument();
|
|
|
|
|
@@ -1482,7 +1701,7 @@ namespace PDFViewer
|
|
|
pdfViewControl.PDFView.SetSplitMode(SplitMode.None);
|
|
|
if (displayPanel != null)
|
|
|
{
|
|
|
- displayPanel.SetSplitContainerVisibility(Visibility.Collapsed);
|
|
|
+ displayPanel.SetVisibilityWhenContentEdit(Visibility.Collapsed);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1534,7 +1753,181 @@ namespace PDFViewer
|
|
|
|
|
|
currentMode = (string)item.Content;
|
|
|
}
|
|
|
+ #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)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ LeftToolPanelButton.IsChecked = !LeftToolPanelButton.IsChecked;
|
|
|
+ ControlLeftPanel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_ControlRightPanel(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ RightPanelButton.IsChecked = !RightPanelButton.IsChecked;
|
|
|
+ ControlRightPanel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Bookmark(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ ExpandLeftPanel(true);
|
|
|
+ LeftToolPanelButton.IsChecked = true;
|
|
|
+ BotaSideTool.SelectBotaTool(BOTATools.Bookmark);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Outline(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ ExpandLeftPanel(true);
|
|
|
+ LeftToolPanelButton.IsChecked = true;
|
|
|
+ BotaSideTool.SelectBotaTool(BOTATools.Outline);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void CommandBinding_Executed_Thumbnail(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ ExpandLeftPanel(true);
|
|
|
+ LeftToolPanelButton.IsChecked = true;
|
|
|
+ BotaSideTool.SelectBotaTool(BOTATools.Thumbnail);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Annotation(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ ExpandLeftPanel(true);
|
|
|
+ LeftToolPanelButton.IsChecked = true;
|
|
|
+ BotaSideTool.SelectBotaTool(BOTATools.Annotation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Search(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ 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)
|
|
|
+ {
|
|
|
+ if (currentMode != "Docs Editor")
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ this.Focus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Highlight(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode == "Annotations")
|
|
|
+ {
|
|
|
+ AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Highlight);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Underline(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode == "Annotations")
|
|
|
+ {
|
|
|
+ AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Underline);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Strikeout(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode == "Annotations")
|
|
|
+ {
|
|
|
+ AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Strikeout);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CommandBinding_Executed_Squiggly(object sender, ExecutedRoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (currentMode == "Annotations")
|
|
|
+ {
|
|
|
+ AnnotationBarControl.SetAnnotationType(CPDFAnnotationType.Squiggly);
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
}
|
|
|
}
|