|
@@ -31,12 +31,14 @@ namespace ContentEditorViewControl
|
|
|
/// </summary>
|
|
|
public partial class MainWindow: Window, INotifyPropertyChanged
|
|
|
{
|
|
|
+ private PanelState panelState = PanelState.GetInstance();
|
|
|
private CPDFDisplaySettingsControl displaySettingsControl = new CPDFDisplaySettingsControl();
|
|
|
private RegularViewerControl regularViewerControl = new RegularViewerControl();
|
|
|
private PDFViewControl pdfViewer;
|
|
|
private PDFViewControl passwordViewer;
|
|
|
private ContentEditControl contentEditControl = new ContentEditControl();
|
|
|
private CPDFBOTABarControl botaBarControl = new CPDFBOTABarControl(BOTATools.Thumbnail | BOTATools.Outline | BOTATools.Bookmark | BOTATools.Search | BOTATools.Annotation);
|
|
|
+ private string currentMode = "Viewer";
|
|
|
|
|
|
private bool _canSave = false;
|
|
|
public bool CanSave
|
|
@@ -50,6 +52,42 @@ namespace ContentEditorViewControl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public bool LeftToolPanelButtonIsChecked
|
|
|
+ {
|
|
|
+ get => panelState.IsLeftPanelExpand;
|
|
|
+ set
|
|
|
+ {
|
|
|
+ panelState.IsLeftPanelExpand = value;
|
|
|
+ OnPropertyChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool ViewSettingBtnIsChecked
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return (panelState.RightPanel == PanelState.RightPanelState.ViewSettings);
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ panelState.RightPanel = (value) ? PanelState.RightPanelState.ViewSettings : PanelState.RightPanelState.None;
|
|
|
+ OnPropertyChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool RightToolPanelButtonIsChecked
|
|
|
+ {
|
|
|
+ get
|
|
|
+ {
|
|
|
+ return (panelState.RightPanel == PanelState.RightPanelState.PropertyPanel);
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ panelState.RightPanel = (value) ? PanelState.RightPanelState.PropertyPanel : PanelState.RightPanelState.None;
|
|
|
+ OnPropertyChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
@@ -64,13 +102,6 @@ namespace ContentEditorViewControl
|
|
|
pdfViewer.PDFView.InitDocument(defaultFilePath);
|
|
|
LoadDocument();
|
|
|
}
|
|
|
-
|
|
|
- private void LoadCustomControl()
|
|
|
- {
|
|
|
- regularViewerControl.PdfViewControl = pdfViewer;
|
|
|
- regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
- regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
|
- }
|
|
|
|
|
|
private void LoadDocument()
|
|
|
{
|
|
@@ -98,6 +129,7 @@ namespace ContentEditorViewControl
|
|
|
PasswordUI.Canceled += PasswordUI_Canceled;
|
|
|
PasswordUI.Confirmed += PasswordUI_Confirmed;
|
|
|
|
|
|
+ ViewComboBox.SelectedIndex = 1;
|
|
|
contentEditControl.PdfViewControl.PDFView.ChangeFitMode(FitMode.FitWidth);
|
|
|
CPDFSaclingControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
|
|
|
CPDFSaclingControl.SetZoomTextBoxText(string.Format("{0}", (int)(contentEditControl.PdfViewControl.PDFView.ZoomFactor * 100)));
|
|
@@ -107,7 +139,17 @@ namespace ContentEditorViewControl
|
|
|
botaBarControl.SelectBotaTool(BOTATools.Thumbnail);
|
|
|
contentEditControl.SetBOTAContainer(botaBarControl);
|
|
|
displaySettingsControl.InitWithPDFViewer(contentEditControl.PdfViewControl.PDFView);
|
|
|
- LoadCustomControl();
|
|
|
+ panelState.PropertyChanged -= PanelState_PropertyChanged;
|
|
|
+ panelState.PropertyChanged += PanelState_PropertyChanged;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
@@ -249,28 +291,34 @@ namespace ContentEditorViewControl
|
|
|
|
|
|
private void LeftToolPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- ToggleButton expandBtn = sender as ToggleButton;
|
|
|
- if (expandBtn != null)
|
|
|
- {
|
|
|
- bool isExpand = expandBtn.IsChecked == true;
|
|
|
- contentEditControl.ExpandLeftPanel(isExpand);
|
|
|
- }
|
|
|
+ panelState.IsLeftPanelExpand = (sender as ToggleButton).IsChecked == true;
|
|
|
}
|
|
|
|
|
|
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
{
|
|
|
var item = (sender as ComboBox).SelectedItem as ComboBoxItem;
|
|
|
+ if (item.Content as string == currentMode)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ClearPanelState();
|
|
|
+
|
|
|
+ if (currentMode == "Viewer")
|
|
|
+ {
|
|
|
+ regularViewerControl.ClearViewerControl();
|
|
|
+ }
|
|
|
+ else if(currentMode == "Content Edit")
|
|
|
+ {
|
|
|
+ contentEditControl.ClearViewerControl();
|
|
|
+ }
|
|
|
if ((string)item.Content == "Viewer")
|
|
|
{
|
|
|
if (regularViewerControl.PdfViewControl != null && regularViewerControl.PdfViewControl.PDFView != null)
|
|
|
{
|
|
|
- contentEditControl.ClearViewerControl();
|
|
|
PDFGrid.Child = regularViewerControl;
|
|
|
regularViewerControl.PdfViewControl.PDFView.SetMouseMode(MouseModes.Viewer);
|
|
|
regularViewerControl.PdfViewControl = pdfViewer;
|
|
|
regularViewerControl.InitWithPDFViewer(pdfViewer.PDFView);
|
|
|
- regularViewerControl.OnCanSaveChanged -= ControlOnCanSaveChanged;
|
|
|
- regularViewerControl.OnCanSaveChanged += ControlOnCanSaveChanged;
|
|
|
regularViewerControl.SetBOTAContainer(botaBarControl);
|
|
|
regularViewerControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
|
}
|
|
@@ -279,12 +327,9 @@ namespace ContentEditorViewControl
|
|
|
{
|
|
|
if (contentEditControl.PdfViewControl != null && contentEditControl.PdfViewControl.PDFView != null)
|
|
|
{
|
|
|
- regularViewerControl.ClearViewerControl();
|
|
|
pdfViewer.PDFView?.SetPDFEditType(CPDFEditType.EditText | CPDFEditType.EditImage);
|
|
|
pdfViewer.PDFView?.SetPDFEditCreateType(CPDFEditType.None);
|
|
|
pdfViewer.PDFView?.SetMouseMode(MouseModes.PDFEdit);
|
|
|
- pdfViewer.PDFView?.ReloadDocument();
|
|
|
-
|
|
|
pdfViewer.PDFView?.SetSplitMode(SplitMode.None);
|
|
|
|
|
|
PDFGrid.Child = contentEditControl;
|
|
@@ -297,6 +342,7 @@ namespace ContentEditorViewControl
|
|
|
contentEditControl.SetDisplaySettingsControl(displaySettingsControl);
|
|
|
}
|
|
|
}
|
|
|
+ currentMode = item.Content as string;
|
|
|
}
|
|
|
|
|
|
private void PageInfoBtn_Click(object sender, RoutedEventArgs e)
|
|
@@ -309,59 +355,31 @@ namespace ContentEditorViewControl
|
|
|
|
|
|
private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- ShowViewSettings();
|
|
|
+ panelState.RightPanel =
|
|
|
+ ((sender as ToggleButton).IsChecked == true) ?
|
|
|
+ PanelState.RightPanelState.ViewSettings : PanelState.RightPanelState.None;
|
|
|
}
|
|
|
-
|
|
|
- private void ShowViewSettings()
|
|
|
+
|
|
|
+ private void RightPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- if (ViewSettingBtn != null)
|
|
|
- {
|
|
|
- if (ViewSettingBtn.IsChecked == true)
|
|
|
- {
|
|
|
- contentEditControl.SetViewSettings(Visibility.Visible, displaySettingsControl);
|
|
|
- if ((bool)RightPanelButton.IsChecked)
|
|
|
- {
|
|
|
- RightPanelButton.IsChecked = false;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- contentEditControl.SetViewSettings(Visibility.Collapsed);
|
|
|
- }
|
|
|
- }
|
|
|
+ panelState.RightPanel =
|
|
|
+ ((sender as ToggleButton).IsChecked == true) ?
|
|
|
+ PanelState.RightPanelState.PropertyPanel : PanelState.RightPanelState.None;
|
|
|
}
|
|
|
- private void RightPanelButton_Click(object sender, RoutedEventArgs e)
|
|
|
+
|
|
|
+ private void ClearPanelState()
|
|
|
{
|
|
|
- ControlRightPanel();
|
|
|
+ LeftToolPanelButtonIsChecked = false;
|
|
|
+ ViewSettingBtnIsChecked = false;
|
|
|
+ RightToolPanelButtonIsChecked = false;
|
|
|
}
|
|
|
|
|
|
private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- contentEditControl.ExpandLeftPanel(true);
|
|
|
+ LeftToolPanelButton.IsChecked = true;
|
|
|
+ LeftToolPanelButtonIsChecked = true;
|
|
|
botaBarControl.SelectBotaTool(BOTATools.Search);
|
|
|
}
|
|
|
-
|
|
|
- private void ControlRightPanel()
|
|
|
- {
|
|
|
- if (RightPanelButton != null)
|
|
|
- {
|
|
|
- if (RightPanelButton.IsChecked == true)
|
|
|
- {
|
|
|
- if (contentEditControl.pdfContentEditControl != null)
|
|
|
- {
|
|
|
- contentEditControl.ExpandRightPropertyPanel(contentEditControl.pdfContentEditControl, Visibility.Visible);
|
|
|
- if ((bool)ViewSettingBtn.IsChecked)
|
|
|
- {
|
|
|
- ViewSettingBtn.IsChecked = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- contentEditControl.ExpandRightPropertyPanel(null, Visibility.Collapsed);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
#region Save file
|
|
|
/// <summary>
|