|
@@ -21,6 +21,7 @@ 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
|
|
|
{
|
|
@@ -87,7 +88,7 @@ namespace ContentEditor
|
|
|
|
|
|
private PDFEditEvent pdfTextCreateParam;
|
|
|
|
|
|
-
|
|
|
+ private KeyEventHandler KeyDownHandler;
|
|
|
#endregion
|
|
|
|
|
|
public MainWindow()
|
|
@@ -146,6 +147,12 @@ namespace ContentEditor
|
|
|
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()
|
|
@@ -814,11 +821,6 @@ namespace ContentEditor
|
|
|
ClearPDFEditState(senderBtn);
|
|
|
if (senderBtn.IsChecked == true)
|
|
|
{
|
|
|
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
|
|
|
- pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
|
|
|
- pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
|
|
|
- pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
- pdfViewControl.PDFView?.ReloadDocument();
|
|
|
PDFEditEvent createParam = new PDFEditEvent();
|
|
|
createParam.EditType = CPDFEditType.EditText;
|
|
|
createParam.IsBold = false;
|
|
@@ -828,11 +830,32 @@ namespace ContentEditor
|
|
|
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?.SetMouseMode(MouseModes.Viewer);
|
|
|
+ pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText);
|
|
|
+ pdfViewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.EditText);
|
|
|
+ pdfViewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
+ pdfViewControl.PDFView?.ReloadDocument();
|
|
|
+
|
|
|
pdfViewControl.PDFView?.SetPDFEditParam(createParam);
|
|
|
if (textEditControl == null)
|
|
|
{
|
|
|
textEditControl = new PDFTextEditControl();
|
|
|
}
|
|
|
+
|
|
|
textEditControl.SetPDFTextEditData(createParam);
|
|
|
PropertyContainer.Child = textEditControl;
|
|
|
PropertyContainer.Visibility = Visibility.Visible;
|
|
@@ -1094,7 +1117,8 @@ namespace ContentEditor
|
|
|
pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None);
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
|
|
|
pdfViewControl.PDFView?.ReloadDocument();
|
|
|
- }
|
|
|
+
|
|
|
+ }
|
|
|
if (ViewComboBox.SelectedIndex == 1)
|
|
|
{
|
|
|
PDFEditTool.Visibility = Visibility.Visible;
|
|
@@ -1113,6 +1137,112 @@ namespace ContentEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ 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, false);
|
|
|
+ e.Handled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e.Key == Key.Right)
|
|
|
+ {
|
|
|
+ pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeNextCharPlace, false);
|
|
|
+ e.Handled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e.Key == Key.Up)
|
|
|
+ {
|
|
|
+ pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeUpCharPlace, false);
|
|
|
+ e.Handled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e.Key == Key.Down)
|
|
|
+ {
|
|
|
+ pdfViewControl.PDFView.JumpEditingLoction(CEditingLocation.CEditingLoadTypeDownCharPlace, false);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Close window
|