|
@@ -31,9 +31,6 @@ using Path = System.IO.Path;
|
|
|
|
|
|
namespace compdfkit
|
|
|
{
|
|
|
- /// <summary>
|
|
|
- /// MainPage.xaml 的交互逻辑
|
|
|
- /// </summary>
|
|
|
public partial class MainPage : UserControl, INotifyPropertyChanged
|
|
|
{
|
|
|
private bool isFirstLoad = true;
|
|
@@ -112,13 +109,21 @@ namespace compdfkit
|
|
|
|
|
|
private void LoadDocument()
|
|
|
{
|
|
|
+ //Load the Document
|
|
|
pdfViewControl.PDFView?.Load();
|
|
|
+
|
|
|
+ //Highlight the link annotation
|
|
|
pdfViewControl.PDFView?.SetShowLink(true);
|
|
|
+
|
|
|
+ //Add PDFViewControl to PDFGrid
|
|
|
PDFGrid.Child = pdfViewControl;
|
|
|
|
|
|
+ // Register the InfoChanged event handler,
|
|
|
+ // which is used to notify the CPDFScalingControl of real-time changes in the displayed number when the page size changes.
|
|
|
pdfViewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
|
|
|
pdfViewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
|
|
|
|
|
|
+ //
|
|
|
pdfViewControl.PDFView.PDFEditCommandHandler -= PDFView_PDFEditCommandHandler;
|
|
|
pdfViewControl.PDFView.PDFEditCommandHandler += PDFView_PDFEditCommandHandler;
|
|
|
|
|
@@ -205,6 +210,7 @@ namespace compdfkit
|
|
|
CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private void PDFView_PDFEditCommandHandler(object sender, PDFEditCommand e)
|
|
|
{
|
|
|
if (e == null)
|
|
@@ -488,7 +494,7 @@ namespace compdfkit
|
|
|
|
|
|
#region ContextMenu
|
|
|
/// <summary>
|
|
|
- /// 文字编辑右键菜单
|
|
|
+ /// TextEdit right-click menu.
|
|
|
/// </summary>
|
|
|
private void PDFEditTextContextMenu(object sender, PDFEditCommand editCommand)
|
|
|
{
|
|
@@ -499,20 +505,6 @@ namespace compdfkit
|
|
|
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 });
|
|
|
- //MenuItem propertyMenu = new MenuItem();
|
|
|
- //propertyMenu.Header = "Property";
|
|
|
- //propertyMenu.Click += (o, p) =>
|
|
|
- //{
|
|
|
-
|
|
|
- // if (lastPDFEditEvent != null && lastPDFEditEvent.EditType == CPDFEditType.EditText)
|
|
|
- // {
|
|
|
- // PDFTextEditControl textEditControl = new PDFTextEditControl();
|
|
|
- // textEditControl.SetPDFTextEditData(lastPDFEditEvent);
|
|
|
- // PropertyContainer.Child = textEditControl;
|
|
|
- // PropertyContainer.Visibility = Visibility.Visible;
|
|
|
- // }
|
|
|
- //};
|
|
|
- //editCommand.PopupMenu.Items.Add(propertyMenu);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -525,7 +517,7 @@ namespace compdfkit
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 图片编辑右键菜单
|
|
|
+ /// ImageEdit right-click menu.
|
|
|
/// </summary>
|
|
|
private void PDFEditImageContextMenu(object sender, PDFEditCommand editCommand)
|
|
|
{
|
|
@@ -668,7 +660,7 @@ namespace compdfkit
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 图片编辑透明度二级菜单
|
|
|
+ /// ImageEdit transparency submenu.
|
|
|
/// </summary>
|
|
|
private void AppendOpacityMenu(MenuItem parentMenu)
|
|
|
{
|
|
@@ -768,6 +760,9 @@ namespace compdfkit
|
|
|
|
|
|
#region UI Action
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Save the file to another PDF file.
|
|
|
+ /// </summary>
|
|
|
public void SaveAsFile()
|
|
|
{
|
|
|
{
|
|
@@ -794,6 +789,9 @@ namespace compdfkit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Save the file in the current path.
|
|
|
+ /// </summary>
|
|
|
public void SaveFile()
|
|
|
{
|
|
|
if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
|
|
@@ -1017,8 +1015,6 @@ namespace compdfkit
|
|
|
/// <summary>
|
|
|
/// Text and Image Selected Event
|
|
|
/// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
private void PDFView_PDFEditActiveHandler(object sender, ComPDFKitViewer.PDFEditEvent e)
|
|
|
{
|
|
|
lastPDFEditEvent = e;
|
|
@@ -1070,16 +1066,19 @@ namespace compdfkit
|
|
|
}
|
|
|
|
|
|
var item = (sender as ComboBox).SelectedItem as ComboBoxItem;
|
|
|
+ //Behavior when exit mode
|
|
|
switch (currentMode)
|
|
|
{
|
|
|
case "Viewer":
|
|
|
break;
|
|
|
-
|
|
|
- //Behavior when exit Edit mode
|
|
|
- // Clear the ToolBar
|
|
|
- // Collapse the ToolBar
|
|
|
- // Clear And Collapse the property panel.
|
|
|
- // Change the mousemode
|
|
|
+ /*
|
|
|
+ * Behavior when exit Edit mode
|
|
|
+ * Clear and collapse the ToolBar
|
|
|
+ * Clear And collapse the property panel.
|
|
|
+ * Change the mousemode to PanTool
|
|
|
+ * Unsubscribe the event handles
|
|
|
+ * Clear the undo history
|
|
|
+ */
|
|
|
case "Annotations":
|
|
|
AnnotationBarControl.Visibility = Visibility.Collapsed;
|
|
|
AnnotationBarControl.ClearAllToolState();
|
|
@@ -1091,21 +1090,26 @@ namespace compdfkit
|
|
|
pdfViewControl.PDFView.AnnotActiveHandler -= PDFView_AnnotActiveHandler;
|
|
|
pdfViewControl.PDFView?.UndoManager.ClearHistory();
|
|
|
break;
|
|
|
-
|
|
|
- // Behavior when exit Edit mode:
|
|
|
- // Collapsed the ToolBar
|
|
|
- // Set the mode to allow editing None
|
|
|
- // Set the mouse mode to PanTool
|
|
|
- // Reload Document
|
|
|
- // Unsubscribe click event.
|
|
|
- // Clear And Collapse the property panel.
|
|
|
+ /*
|
|
|
+ * Behavior when exit edit mode:
|
|
|
+ * Collapsed the ToolBar
|
|
|
+ * Highlight the link annotation
|
|
|
+ * Set the mode to not allow edit
|
|
|
+ * Set the mouse mode to PanTool
|
|
|
+ * Reload Document
|
|
|
+ * Unsubscribe click event.
|
|
|
+ * Clear And collapse the property panel.
|
|
|
+ * Clear and collapse the ToolBar
|
|
|
+ * Clear undo history
|
|
|
+ * CPDFDisplaySettingsControl
|
|
|
+ * Enable the configuration of the split view.
|
|
|
+ */
|
|
|
case "Content Editor":
|
|
|
PDFEditTool.Visibility = Visibility.Collapsed;
|
|
|
pdfViewControl.PDFView?.SetShowLink(true);
|
|
|
pdfViewControl.PDFView?.SetPDFEditType(CPDFEditType.None);
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
|
|
|
pdfViewControl.PDFView?.ReloadDocument();
|
|
|
-
|
|
|
pdfViewControl.PDFView.PDFEditActiveHandler -= PDFView_PDFEditActiveHandler;
|
|
|
ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
ClearPDFEditState();
|
|
@@ -1113,20 +1117,32 @@ namespace compdfkit
|
|
|
if (displayPanel != null)
|
|
|
{
|
|
|
displayPanel.SetSplitContainerVisibility(Visibility.Visible);
|
|
|
-
|
|
|
}
|
|
|
break;
|
|
|
-
|
|
|
+ /*
|
|
|
+ * Behavior when exit form mode:
|
|
|
+ * Clear and collapsed the ToolBar
|
|
|
+ * Clear And Collapse the property panel.
|
|
|
+ * Unsubscribe event.
|
|
|
+ * Clear undo history
|
|
|
+ */
|
|
|
case "Forms":
|
|
|
- FormBarControl.ClearAllToolState();
|
|
|
ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ FormBarControl.ClearAllToolState();
|
|
|
FormBarControl.Visibility = Visibility.Collapsed;
|
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.PanTool);
|
|
|
pdfViewControl.PDFView.AnnotActiveHandler -= PDFView_FormActiveHandler;
|
|
|
pdfViewControl.PDFView.AnnotEditHandler -= PDFView_FormEditHandler;
|
|
|
pdfViewControl.PDFView?.UndoManager.ClearHistory();
|
|
|
break;
|
|
|
-
|
|
|
+ /*
|
|
|
+ * Unsubscribe event.
|
|
|
+ * Show Undo Redo Button
|
|
|
+ * Collapse PageEditBarControl
|
|
|
+ * Replace PDFGrid.Child to pdfViewControl.
|
|
|
+ * Reload Document
|
|
|
+ * Enable Button
|
|
|
+ */
|
|
|
case "Docs Editor":
|
|
|
pageEditControl.ExitPageEdit -= PageEditControl_ExitPageEdit;
|
|
|
pageEditControl.PageMoved -= PageEditControl_PageMoved;
|
|
@@ -1145,17 +1161,23 @@ namespace compdfkit
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- // Behavior when switching to Viewer mode:
|
|
|
- // Hide the ToolBar
|
|
|
+ /*
|
|
|
+ * Behavior when switching to Viewer mode:
|
|
|
+ * Hide the ToolBar
|
|
|
+ * Set mousemode to Viewer
|
|
|
+ */
|
|
|
if ((string)item.Content == "Viewer")
|
|
|
{
|
|
|
ToolBarContainer.Visibility = Visibility.Collapsed;
|
|
|
pdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
}
|
|
|
|
|
|
- // Behavior when switching to Annotation mode:
|
|
|
- // Show the ToolBar
|
|
|
- // Show the AnnotationBar
|
|
|
+ /*
|
|
|
+ * Behavior when switching to Annotation mode:
|
|
|
+ * Show the ToolBar
|
|
|
+ * Show the AnnotationBar
|
|
|
+ */
|
|
|
+
|
|
|
else if ((string)item.Content == "Annotations")
|
|
|
{
|
|
|
ToolBarContainer.Visibility = Visibility.Visible;
|
|
@@ -1166,12 +1188,15 @@ namespace compdfkit
|
|
|
pdfViewControl.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
|
|
|
}
|
|
|
|
|
|
- // Behavior when switching to Edit mode:
|
|
|
- // Show the ToolBar
|
|
|
- // Show the EditBar
|
|
|
- // Set the mode to allow editing of both text and images
|
|
|
- // Set the mouse mode to PDFEdit
|
|
|
- // Reload Document
|
|
|
+ /*
|
|
|
+ * Behavior when switching to Edit mode:
|
|
|
+ * Show the ToolBar
|
|
|
+ * Show the EditBar
|
|
|
+ * Set the mode to allow editing of both text and images
|
|
|
+ * Set the mouse mode to PDFEdit
|
|
|
+ * Reload Document
|
|
|
+ * Set the
|
|
|
+ */
|
|
|
else if ((string)item.Content == "Content Editor")
|
|
|
{
|
|
|
ToolBarContainer.Visibility = Visibility.Visible;
|
|
@@ -1187,10 +1212,13 @@ namespace compdfkit
|
|
|
if (displayPanel != null)
|
|
|
{
|
|
|
displayPanel.SetSplitContainerVisibility(Visibility.Collapsed);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ *
|
|
|
+ *
|
|
|
+ */
|
|
|
else if ((string)item.Content == "Forms")
|
|
|
{
|
|
|
ToolBarContainer.Visibility = Visibility.Visible;
|