|
@@ -19,6 +19,7 @@ using ComPDFKit.PDFPage;
|
|
|
using ComPDFKitViewer.PdfViewer;
|
|
|
using System.ComponentModel;
|
|
|
using System.Runtime.CompilerServices;
|
|
|
+using Compdfkit_Tools.Edit;
|
|
|
|
|
|
namespace Forms
|
|
|
{
|
|
@@ -28,7 +29,7 @@ namespace Forms
|
|
|
private PDFViewControl passwordViewer;
|
|
|
private PDFViewControl pdfViewControl;
|
|
|
private CPDFSearchControl searchControl = null;
|
|
|
- private FromPropertyControl fromPropertyControl;
|
|
|
+ private FromPropertyControl formPropertyControl;
|
|
|
|
|
|
bool LoadPDFFormTool = false;
|
|
|
|
|
@@ -72,7 +73,7 @@ namespace Forms
|
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
#endregion
|
|
|
-
|
|
|
+
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -84,7 +85,7 @@ namespace Forms
|
|
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
BotaSideTool.AddBOTAContent(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search);
|
|
|
- fromPropertyControl = new FromPropertyControl();
|
|
|
+ formPropertyControl = new FromPropertyControl();
|
|
|
LoadDefaultDocument();
|
|
|
}
|
|
|
|
|
@@ -140,18 +141,21 @@ namespace Forms
|
|
|
pdfViewControl.PDFView.InitDocument(defaultFilePath);
|
|
|
LoadDocument();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public void InitialPDFViewControl(PDFViewControl newPDFViewer)
|
|
|
{
|
|
|
- PDFFormTool.InitWithPDFViewer(newPDFViewer.PDFView, fromPropertyControl);
|
|
|
- fromPropertyControl.SetPDFViewer(newPDFViewer.PDFView);
|
|
|
+ PDFFormTool.InitWithPDFViewer(newPDFViewer.PDFView, formPropertyControl);
|
|
|
+ formPropertyControl.SetPDFViewer(newPDFViewer.PDFView);
|
|
|
PDFFormTool.ClearAllToolState();
|
|
|
newPDFViewer.PDFView.AnnotEditHandler += PDFView_AnnotEditHandler;
|
|
|
newPDFViewer.PDFView.AnnotActiveHandler += PDFView_AnnotActiveHandler;
|
|
|
newPDFViewer.CustomSignHandle = true;
|
|
|
newPDFViewer.PDFView.WidgetClickHandler += PDFView_WidgetClickHandler;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Save the file in the current path.
|
|
|
+ /// </summary>
|
|
|
private void SaveFile()
|
|
|
{
|
|
|
if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
|
|
@@ -175,6 +179,27 @@ namespace Forms
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region Property changed
|
|
@@ -392,6 +417,27 @@ namespace Forms
|
|
|
|
|
|
#region Expand and collapse panel
|
|
|
|
|
|
+ private void ControlRightPanel()
|
|
|
+ {
|
|
|
+ if (RightPanelButton != null)
|
|
|
+ {
|
|
|
+ if (RightPanelButton.IsChecked == true)
|
|
|
+ {
|
|
|
+
|
|
|
+ ExpandRightPropertyPanel(formPropertyControl, Visibility.Visible);
|
|
|
+
|
|
|
+ if ((bool)ViewSettingBtn.IsChecked)
|
|
|
+ {
|
|
|
+ ViewSettingBtn.IsChecked = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void ExpandLeftPanel(bool isExpand)
|
|
|
{
|
|
|
BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
|
|
@@ -462,37 +508,40 @@ namespace Forms
|
|
|
return standardZoom / 100;
|
|
|
}
|
|
|
|
|
|
- private void ToolExpand_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 LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ControlLeftPanel();
|
|
|
+ }
|
|
|
+
|
|
|
private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
ExpandLeftPanel(true);
|
|
|
- ToolExpandBtn.IsChecked = true;
|
|
|
+ LeftToolPanelButton.IsChecked = true;
|
|
|
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)
|
|
|
{
|
|
|
CPDFDisplaySettingsControl displayPanel = new CPDFDisplaySettingsControl();
|
|
|
displayPanel.InitWithPDFViewer(pdfViewControl.PDFView);
|
|
|
PropertyContainer.Child = displayPanel;
|
|
|
PropertyContainer.Visibility = Visibility.Visible;
|
|
|
- if ((bool)FormBarBtn.IsChecked)
|
|
|
+ if ((bool)RightPanelButton.IsChecked)
|
|
|
{
|
|
|
- FormBarBtn.IsChecked = false;
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -503,7 +552,12 @@ namespace Forms
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void FormBarBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ ShowViewSettings();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void RightPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
ToggleButton toggleButton = sender as ToggleButton;
|
|
|
if (toggleButton != null)
|
|
@@ -511,7 +565,7 @@ namespace Forms
|
|
|
if (toggleButton.IsChecked == true)
|
|
|
{
|
|
|
|
|
|
- ExpandRightPropertyPanel(fromPropertyControl, Visibility.Visible);
|
|
|
+ ExpandRightPropertyPanel(formPropertyControl, Visibility.Visible);
|
|
|
if ((bool)ViewSettingBtn.IsChecked)
|
|
|
{
|
|
|
ViewSettingBtn.IsChecked = false;
|
|
@@ -547,7 +601,7 @@ namespace Forms
|
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
|
}
|
|
|
|
|
|
- private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
|
+ private void OpenFile()
|
|
|
{
|
|
|
string filePath = CommonHelper.GetFilePathOrEmpty();
|
|
|
if (!string.IsNullOrEmpty(filePath) && pdfViewControl != null)
|
|
@@ -584,6 +638,11 @@ namespace Forms
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ OpenFile();
|
|
|
+ }
|
|
|
+
|
|
|
private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
SaveFile();
|
|
@@ -665,10 +724,10 @@ namespace Forms
|
|
|
pdfViewControl.PDFView?.ReloadDocument();
|
|
|
if (PropertyContainer != null)
|
|
|
{
|
|
|
- fromPropertyControl.CleanProperty();
|
|
|
+ formPropertyControl.CleanProperty();
|
|
|
PropertyContainer.Child = null;
|
|
|
ViewSettingBtn.IsChecked = false;
|
|
|
- FormBarBtn.IsChecked = false;
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -683,10 +742,10 @@ namespace Forms
|
|
|
pdfViewControl.PDFView?.ReloadDocument();
|
|
|
if (PropertyContainer != null)
|
|
|
{
|
|
|
- fromPropertyControl.CleanProperty();
|
|
|
+ formPropertyControl.CleanProperty();
|
|
|
PropertyContainer.Child = null;
|
|
|
ViewSettingBtn.IsChecked = false;
|
|
|
- FormBarBtn.IsChecked = false;
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -699,13 +758,13 @@ namespace Forms
|
|
|
{
|
|
|
if (e is WidgetSignArgs)
|
|
|
{
|
|
|
- FormBarBtn.IsChecked = true;
|
|
|
- ExpandRightPropertyPanel(fromPropertyControl, Visibility.Visible);
|
|
|
- fromPropertyControl.SetPropertyForType(e, null);
|
|
|
+ RightPanelButton.IsChecked = true;
|
|
|
+ ExpandRightPropertyPanel(formPropertyControl, Visibility.Visible);
|
|
|
+ formPropertyControl.SetPropertyForType(e, null);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- FormBarBtn.IsChecked = false;
|
|
|
+ RightPanelButton.IsChecked = false;
|
|
|
ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
}
|
|
|
}
|
|
@@ -714,7 +773,7 @@ namespace Forms
|
|
|
{
|
|
|
if (e == null || e.IsAnnotCreateReset)
|
|
|
{
|
|
|
- fromPropertyControl.SetPropertyForType(null, null);
|
|
|
+ formPropertyControl.SetPropertyForType(null, null);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -727,17 +786,17 @@ namespace Forms
|
|
|
case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
|
|
|
case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX:
|
|
|
case ComPDFKit.PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX:
|
|
|
- ExpandRightPropertyPanel(fromPropertyControl, Visibility.Visible);
|
|
|
+ ExpandRightPropertyPanel(formPropertyControl, Visibility.Visible);
|
|
|
if ((bool)ViewSettingBtn.IsChecked)
|
|
|
{
|
|
|
ViewSettingBtn.IsChecked = false;
|
|
|
}
|
|
|
- FormBarBtn.IsChecked = true;
|
|
|
+ RightPanelButton.IsChecked = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- fromPropertyControl.SetPropertyForType(formArgs, e);
|
|
|
+ formPropertyControl.SetPropertyForType(formArgs, e);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -794,7 +853,7 @@ namespace Forms
|
|
|
}
|
|
|
else if (editEvent.EditAction == ActionType.Del)
|
|
|
{
|
|
|
- fromPropertyControl.CleanProperty();
|
|
|
+ formPropertyControl.CleanProperty();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -821,5 +880,115 @@ namespace Forms
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region
|
|
|
+ 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;
|
|
|
+ FileInfoUI.Visibility = Visibility.Visible;
|
|
|
+ FileInfoControl.InitWithPDFViewer(pdfViewControl.PDFView);
|
|
|
+ PopupBorder.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ FileInfoUI.Visibility = Visibility.Collapsed;
|
|
|
+ PopupBorder.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|