|
@@ -44,7 +44,7 @@ namespace PDFViewer
|
|
public event EventHandler<string> AfterSaveAsFileEvent;
|
|
public event EventHandler<string> AfterSaveAsFileEvent;
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
- private bool _canSave = true;
|
|
|
|
|
|
+ private bool _canSave = false;
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Whether the save operation can be performed.
|
|
/// Whether the save operation can be performed.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -123,7 +123,7 @@ namespace PDFViewer
|
|
public MainPage()
|
|
public MainPage()
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
- this.DataContext = this;
|
|
|
|
|
|
+ this.DataContext = this;
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
@@ -162,13 +162,6 @@ namespace PDFViewer
|
|
SizeChanged -= MainPage_SizeChanged;
|
|
SizeChanged -= MainPage_SizeChanged;
|
|
SizeChanged += MainPage_SizeChanged;
|
|
SizeChanged += MainPage_SizeChanged;
|
|
|
|
|
|
- //viewControl.PDFView.Load();
|
|
|
|
- //viewControl.PDFView.SetShowLink(true);
|
|
|
|
-
|
|
|
|
- //viewControl.PDFView.InfoChanged -= PdfViewer_InfoChanged;
|
|
|
|
- //viewControl.PDFView.InfoChanged += PdfViewer_InfoChanged;
|
|
|
|
-
|
|
|
|
- //viewControl.PDFView.SetFormFieldHighlight(true);
|
|
|
|
PasswordUI.Closed -= PasswordUI_Closed;
|
|
PasswordUI.Closed -= PasswordUI_Closed;
|
|
PasswordUI.Canceled -= PasswordUI_Canceled;
|
|
PasswordUI.Canceled -= PasswordUI_Canceled;
|
|
PasswordUI.Confirmed -= PasswordUI_Confirmed;
|
|
PasswordUI.Confirmed -= PasswordUI_Confirmed;
|
|
@@ -176,7 +169,6 @@ namespace PDFViewer
|
|
PasswordUI.Canceled += PasswordUI_Canceled;
|
|
PasswordUI.Canceled += PasswordUI_Canceled;
|
|
PasswordUI.Confirmed += PasswordUI_Confirmed;
|
|
PasswordUI.Confirmed += PasswordUI_Confirmed;
|
|
|
|
|
|
- //viewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
|
|
|
|
CPDFSaclingControl.InitWithPDFViewer(viewControl);
|
|
CPDFSaclingControl.InitWithPDFViewer(viewControl);
|
|
ModeComboBox.SelectedIndex = 0;
|
|
ModeComboBox.SelectedIndex = 0;
|
|
|
|
|
|
@@ -500,7 +492,6 @@ namespace PDFViewer
|
|
{
|
|
{
|
|
PDFGrid.Child = regularViewerControl;
|
|
PDFGrid.Child = regularViewerControl;
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.Viewer);
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.Viewer);
|
|
- //viewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
|
regularViewerControl.OnCanSaveChanged -= ControlOnCanSaveChanged;
|
|
regularViewerControl.OnCanSaveChanged -= ControlOnCanSaveChanged;
|
|
regularViewerControl.OnCanSaveChanged += ControlOnCanSaveChanged;
|
|
regularViewerControl.OnCanSaveChanged += ControlOnCanSaveChanged;
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
@@ -513,8 +504,6 @@ namespace PDFViewer
|
|
PDFGrid.Child = annotationControl;
|
|
PDFGrid.Child = annotationControl;
|
|
|
|
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.CreateAnnot);
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.CreateAnnot);
|
|
- //viewControl.PDFView.SetMouseMode(MouseModes.AnnotCreate);
|
|
|
|
- //annotationControl.PDFViewControl.PDFView.SetToolParam(new AnnotHandlerEventArgs());
|
|
|
|
annotationControl.PDFViewControl = viewControl;
|
|
annotationControl.PDFViewControl = viewControl;
|
|
annotationControl.InitWithPDFViewer(viewControl);
|
|
annotationControl.InitWithPDFViewer(viewControl);
|
|
if (annotationControl.PDFViewControl != null)
|
|
if (annotationControl.PDFViewControl != null)
|
|
@@ -533,7 +522,7 @@ namespace PDFViewer
|
|
formControl.SetToolBarContainerVisibility(Visibility.Visible);
|
|
formControl.SetToolBarContainerVisibility(Visibility.Visible);
|
|
formControl.PdfViewControl = viewControl;
|
|
formControl.PdfViewControl = viewControl;
|
|
formControl.InitWithPDFViewer(viewControl);
|
|
formControl.InitWithPDFViewer(viewControl);
|
|
- if (formControl.PdfViewControl != null )
|
|
|
|
|
|
+ if (formControl.PdfViewControl != null)
|
|
{
|
|
{
|
|
PDFGrid.Child = formControl;
|
|
PDFGrid.Child = formControl;
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.WidgetEdit);
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.WidgetEdit);
|
|
@@ -551,12 +540,8 @@ namespace PDFViewer
|
|
contentEditControl.PdfViewControl = viewControl;
|
|
contentEditControl.PdfViewControl = viewControl;
|
|
contentEditControl.InitWithPDFViewer(viewControl);
|
|
contentEditControl.InitWithPDFViewer(viewControl);
|
|
displaySettingsControl.SetVisibilityWhenContentEdit(Visibility.Collapsed);
|
|
displaySettingsControl.SetVisibilityWhenContentEdit(Visibility.Collapsed);
|
|
- if (contentEditControl.pdfContentEditControl != null && contentEditControl.PdfViewControl!= null)
|
|
|
|
|
|
+ if (contentEditControl.pdfContentEditControl != null && contentEditControl.PdfViewControl != null)
|
|
{
|
|
{
|
|
- //viewControl.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);
|
|
|
|
- //viewControl.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
|
|
|
|
- //viewControl.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
|
- //viewControl.PDFView?.ReloadDocument();
|
|
|
|
|
|
|
|
PDFGrid.Child = contentEditControl;
|
|
PDFGrid.Child = contentEditControl;
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.ContentEdit);
|
|
viewControl.SetToolType(ComPDFKit.Tool.CPDFToolManager.ToolType.ContentEdit);
|
|
@@ -666,7 +651,7 @@ namespace PDFViewer
|
|
|
|
|
|
CPDFTitleBarControl.SaveFileEvent -= CPDFTitleBarControl_SaveFileEvent;
|
|
CPDFTitleBarControl.SaveFileEvent -= CPDFTitleBarControl_SaveFileEvent;
|
|
CPDFTitleBarControl.SaveFileEvent += CPDFTitleBarControl_SaveFileEvent;
|
|
CPDFTitleBarControl.SaveFileEvent += CPDFTitleBarControl_SaveFileEvent;
|
|
-
|
|
|
|
|
|
+
|
|
CPDFTitleBarControl.FlattenEvent -= CPDFTitleBarControl_FlattenEvent;
|
|
CPDFTitleBarControl.FlattenEvent -= CPDFTitleBarControl_FlattenEvent;
|
|
CPDFTitleBarControl.FlattenEvent += CPDFTitleBarControl_FlattenEvent;
|
|
CPDFTitleBarControl.FlattenEvent += CPDFTitleBarControl_FlattenEvent;
|
|
}
|
|
}
|
|
@@ -681,12 +666,12 @@ namespace PDFViewer
|
|
if (CanSave)
|
|
if (CanSave)
|
|
{
|
|
{
|
|
SaveFile();
|
|
SaveFile();
|
|
-
|
|
|
|
|
|
+
|
|
viewControl.PDFViewTool.IsDocumentModified = false;
|
|
viewControl.PDFViewTool.IsDocumentModified = false;
|
|
}
|
|
}
|
|
CPDFDocument document = CPDFDocument.InitWithFilePath(viewControl.GetCPDFViewer().GetDocument().FilePath);
|
|
CPDFDocument document = CPDFDocument.InitWithFilePath(viewControl.GetCPDFViewer().GetDocument().FilePath);
|
|
if (document?.WriteFlattenToFilePath(savePath) == true)
|
|
if (document?.WriteFlattenToFilePath(savePath) == true)
|
|
- {
|
|
|
|
|
|
+ {
|
|
System.Diagnostics.Process.Start("Explorer.exe", "/select," + savePath);
|
|
System.Diagnostics.Process.Start("Explorer.exe", "/select," + savePath);
|
|
}
|
|
}
|
|
document?.Release();
|
|
document?.Release();
|
|
@@ -746,6 +731,7 @@ namespace PDFViewer
|
|
private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
SaveFile();
|
|
SaveFile();
|
|
|
|
+ CanSave = false;
|
|
}
|
|
}
|
|
|
|
|
|
private void OpenFile(string filePath = "")
|
|
private void OpenFile(string filePath = "")
|
|
@@ -842,9 +828,9 @@ namespace PDFViewer
|
|
{
|
|
{
|
|
if (viewControl != null && viewControl.PDFViewTool != null)
|
|
if (viewControl != null && viewControl.PDFViewTool != null)
|
|
{
|
|
{
|
|
- CPDFViewer pdfviewer=viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
|
- CPDFDocument pdfDoc=pdfviewer?.GetDocument();
|
|
|
|
- if(pdfDoc==null)
|
|
|
|
|
|
+ CPDFViewer pdfviewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
|
+ CPDFDocument pdfDoc = pdfviewer?.GetDocument();
|
|
|
|
+ if (pdfDoc == null)
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -986,15 +972,15 @@ namespace PDFViewer
|
|
double newZoom = CheckZoomLevel(pdfViewer.GetZoom() + 0.01, true);
|
|
double newZoom = CheckZoomLevel(pdfViewer.GetZoom() + 0.01, true);
|
|
pdfViewer.SetZoom(newZoom);
|
|
pdfViewer.SetZoom(newZoom);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
|
|
private void CommandBinding_Executed_ScaleSubtract(object sender, ExecutedRoutedEventArgs e)
|
|
{
|
|
{
|
|
- if(viewControl!=null && viewControl.PDFViewTool!=null)
|
|
|
|
|
|
+ if (viewControl != null && viewControl.PDFViewTool != null)
|
|
{
|
|
{
|
|
- CPDFViewer pdfViewer= viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
|
- if(pdfViewer!=null)
|
|
|
|
|
|
+ CPDFViewer pdfViewer = viewControl.PDFViewTool.GetCPDFViewer();
|
|
|
|
+ if (pdfViewer != null)
|
|
{
|
|
{
|
|
double newZoom = CheckZoomLevel(pdfViewer.GetZoom() - 0.01, false);
|
|
double newZoom = CheckZoomLevel(pdfViewer.GetZoom() - 0.01, false);
|
|
pdfViewer.SetZoom(newZoom);
|
|
pdfViewer.SetZoom(newZoom);
|