|
@@ -31,6 +31,8 @@ namespace ContentEditorViewControl
|
|
|
/// </summary>
|
|
|
public partial class MainWindow: Window, INotifyPropertyChanged
|
|
|
{
|
|
|
+ #region Properties
|
|
|
+
|
|
|
private PanelState panelState = PanelState.GetInstance();
|
|
|
private CPDFDisplaySettingsControl displaySettingsControl = new CPDFDisplaySettingsControl();
|
|
|
private RegularViewerControl regularViewerControl = new RegularViewerControl();
|
|
@@ -38,6 +40,7 @@ namespace ContentEditorViewControl
|
|
|
private PDFViewControl passwordViewer;
|
|
|
private ContentEditControl contentEditControl = new ContentEditControl();
|
|
|
private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
|
|
|
+ public event PropertyChangedEventHandler PropertyChanged;
|
|
|
private string currentMode = "Viewer";
|
|
|
|
|
|
private bool _canSave = false;
|
|
@@ -87,7 +90,7 @@ namespace ContentEditorViewControl
|
|
|
OnPropertyChanged();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ #endregion
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -143,25 +146,44 @@ namespace ContentEditorViewControl
|
|
|
panelState.PropertyChanged += PanelState_PropertyChanged;
|
|
|
}
|
|
|
|
|
|
- private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
+ private void OpenFile()
|
|
|
{
|
|
|
- if (e.PropertyName == "RightPanel")
|
|
|
+ string filePath = CommonHelper.GetExistedPathOrEmpty();
|
|
|
+ if (!string.IsNullOrEmpty(filePath) && contentEditControl.PdfViewControl != null)
|
|
|
{
|
|
|
- OnPropertyChanged(nameof(RightToolPanelButtonIsChecked));
|
|
|
- OnPropertyChanged(nameof(ViewSettingBtnIsChecked));
|
|
|
- }
|
|
|
- }
|
|
|
+ if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
|
|
|
+ {
|
|
|
+ string oldFilePath = pdfViewer.PDFView.Document.FilePath;
|
|
|
+ if (oldFilePath.ToLower() == filePath.ToLower())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- private void PdfContentEditControlRefreshAnnotList(object sender, EventArgs e)
|
|
|
- {
|
|
|
- botaBarControl.LoadAnnotationList();
|
|
|
- }
|
|
|
+ passwordViewer = new PDFViewControl();
|
|
|
+ passwordViewer.PDFView.InitDocument(filePath);
|
|
|
+ if (passwordViewer.PDFView.Document == null)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Open File Failed");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- private void ControlOnCanSaveChanged(object sender, bool e)
|
|
|
- {
|
|
|
- this.CanSave = e;
|
|
|
+ if (passwordViewer.PDFView.Document.IsLocked)
|
|
|
+ {
|
|
|
+ PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
|
|
|
+ PasswordUI.ClearPassword();
|
|
|
+ PopupBorder.Visibility = Visibility.Visible;
|
|
|
+ PasswordUI.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pdfViewer.PDFView.Document.Release();
|
|
|
+ pdfViewer = passwordViewer;
|
|
|
+ LoadDocument();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region Password
|
|
@@ -203,8 +225,7 @@ namespace ContentEditorViewControl
|
|
|
|
|
|
#region Load Unload custom control
|
|
|
|
|
|
-
|
|
|
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
|
|
+ private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
pdfViewer = new PDFViewControl();
|
|
|
LoadDefaultDocument();
|
|
@@ -229,62 +250,13 @@ namespace ContentEditorViewControl
|
|
|
CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)((double)e.Value * 100)));
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
|
|
|
- pdfViewer = new PDFViewControl();
|
|
|
- LoadDefaultDocument();
|
|
|
- }
|
|
|
-
|
|
|
private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
SaveFile();
|
|
|
pdfViewer.PDFView.UndoManager.CanSave = false;
|
|
|
}
|
|
|
|
|
|
- private void OpenFile()
|
|
|
- {
|
|
|
- string filePath = CommonHelper.GetExistedPathOrEmpty();
|
|
|
- if (!string.IsNullOrEmpty(filePath) && contentEditControl.PdfViewControl != null)
|
|
|
- {
|
|
|
- if (pdfViewer.PDFView != null && pdfViewer.PDFView.Document != null)
|
|
|
- {
|
|
|
- string oldFilePath = pdfViewer.PDFView.Document.FilePath;
|
|
|
- if (oldFilePath.ToLower() == filePath.ToLower())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- passwordViewer = new PDFViewControl();
|
|
|
- passwordViewer.PDFView.InitDocument(filePath);
|
|
|
- if (passwordViewer.PDFView.Document == null)
|
|
|
- {
|
|
|
- MessageBox.Show("Open File Failed");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (passwordViewer.PDFView.Document.IsLocked)
|
|
|
- {
|
|
|
- PasswordUI.SetShowText(System.IO.Path.GetFileName(filePath) + " password encrypted.");
|
|
|
- PasswordUI.ClearPassword();
|
|
|
- PopupBorder.Visibility = Visibility.Visible;
|
|
|
- PasswordUI.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pdfViewer.PDFView.Document.Release();
|
|
|
- pdfViewer = passwordViewer;
|
|
|
- LoadDocument();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
OpenFile();
|
|
@@ -381,6 +353,36 @@ namespace ContentEditorViewControl
|
|
|
LeftToolPanelButtonIsChecked = true;
|
|
|
botaBarControl.SelectBotaTool(BOTATools.Search);
|
|
|
}
|
|
|
+
|
|
|
+ private void PanelState_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
|
+ {
|
|
|
+ if (e.PropertyName == "RightPanel")
|
|
|
+ {
|
|
|
+ OnPropertyChanged(nameof(RightToolPanelButtonIsChecked));
|
|
|
+ OnPropertyChanged(nameof(ViewSettingBtnIsChecked));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PdfContentEditControlRefreshAnnotList(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ botaBarControl.LoadAnnotationList();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ControlOnCanSaveChanged(object sender, bool e)
|
|
|
+ {
|
|
|
+ this.CanSave = e;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ PopupBorder.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
+ {
|
|
|
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
#region Save file
|
|
|
/// <summary>
|
|
@@ -437,18 +439,6 @@ namespace ContentEditorViewControl
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
-
|
|
|
- private void FileInfoCloseBtn_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- PopupBorder.Visibility = Visibility.Collapsed;
|
|
|
- }
|
|
|
-
|
|
|
- public event PropertyChangedEventHandler PropertyChanged;
|
|
|
-
|
|
|
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
|
|
- {
|
|
|
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|