|
@@ -58,6 +58,7 @@ namespace Viewer
|
|
LoadDefaultDocument();
|
|
LoadDefaultDocument();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #region Load Document
|
|
private void LoadDocument()
|
|
private void LoadDocument()
|
|
{
|
|
{
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
|
|
pdfViewControl.PDFView?.SetMouseMode(MouseModes.Viewer);
|
|
@@ -89,150 +90,18 @@ namespace Viewer
|
|
PropertyContainer.Child = null;
|
|
PropertyContainer.Child = null;
|
|
PropertyContainer.Visibility = Visibility.Collapsed;
|
|
PropertyContainer.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
-
|
|
|
|
- private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
|
|
|
|
|
|
+ private void LoadDefaultDocument()
|
|
{
|
|
{
|
|
- if (e != null && e.CommandType == CommandType.Context)
|
|
|
|
- {
|
|
|
|
- if (e.PressOnSelectedText)
|
|
|
|
- {
|
|
|
|
- e.Handle = true;
|
|
|
|
- e.PopupMenu = new ContextMenu();
|
|
|
|
- e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
|
- }
|
|
|
|
- else if (e.CommandTarget == TargetType.ImageSelection)
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.GetSelectImageCount() > 0)
|
|
|
|
- {
|
|
|
|
- e.Handle = true;
|
|
|
|
- e.PopupMenu = new ContextMenu();
|
|
|
|
-
|
|
|
|
- MenuItem imageCopyMenu = new MenuItem();
|
|
|
|
- imageCopyMenu = new MenuItem();
|
|
|
|
- imageCopyMenu.Header = "Copy Images";
|
|
|
|
- WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageCopyMenu, "Click", CopyImage_Click);
|
|
|
|
- imageCopyMenu.CommandParameter = e;
|
|
|
|
- e.PopupMenu.Items.Add(imageCopyMenu);
|
|
|
|
-
|
|
|
|
- MenuItem imageExtraMenu = new MenuItem();
|
|
|
|
- imageExtraMenu = new MenuItem();
|
|
|
|
- imageExtraMenu.Header = "Extract Images";
|
|
|
|
- WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageExtraMenu, "Click", ExtraImage_Click);
|
|
|
|
- imageExtraMenu.CommandParameter = e;
|
|
|
|
- e.PopupMenu.Items.Add(imageExtraMenu);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- e.Handle = true;
|
|
|
|
- e.PopupMenu = new ContextMenu();
|
|
|
|
-
|
|
|
|
- MenuItem fitWidthMenu = new MenuItem();
|
|
|
|
- fitWidthMenu.Header = "Automatically Resize";
|
|
|
|
- fitWidthMenu.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- e.PopupMenu.Items.Add(fitWidthMenu);
|
|
|
|
-
|
|
|
|
- MenuItem fitSizeMenu = new MenuItem();
|
|
|
|
- fitSizeMenu.Header = "Actual Size";
|
|
|
|
- fitSizeMenu.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- e.PopupMenu.Items.Add(fitSizeMenu);
|
|
|
|
-
|
|
|
|
- MenuItem zoomInMenu = new MenuItem();
|
|
|
|
- zoomInMenu.Header = "Zoom In";
|
|
|
|
- zoomInMenu.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
|
|
|
|
- pdfViewControl.PDFView?.Zoom(newZoom);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- e.PopupMenu.Items.Add(zoomInMenu);
|
|
|
|
-
|
|
|
|
- MenuItem zoomOutMenu = new MenuItem();
|
|
|
|
- zoomOutMenu.Header = "Zoom Out";
|
|
|
|
- zoomOutMenu.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
|
|
|
|
- pdfViewControl.PDFView?.Zoom(newZoom);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- e.PopupMenu.Items.Add(zoomOutMenu);
|
|
|
|
- e.PopupMenu.Items.Add(new Separator());
|
|
|
|
-
|
|
|
|
- MenuItem singleView = new MenuItem();
|
|
|
|
- singleView.Header = "Single Page";
|
|
|
|
- singleView.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- e.PopupMenu.Items.Add(singleView);
|
|
|
|
-
|
|
|
|
- MenuItem singleContinuousView = new MenuItem();
|
|
|
|
- singleContinuousView.Header = "Single Page Continuous";
|
|
|
|
- singleContinuousView.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- e.PopupMenu.Items.Add(singleContinuousView);
|
|
|
|
-
|
|
|
|
- MenuItem doubleView = new MenuItem();
|
|
|
|
- doubleView.Header = "Two Pages";
|
|
|
|
- doubleView.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+ string defaultFilePath = "developer_guide_windows.pdf";
|
|
|
|
+ pdfViewControl = new PDFViewControl();
|
|
|
|
+ pdfViewControl.PDFView.InitDocument(defaultFilePath);
|
|
|
|
+ LoadDocument();
|
|
|
|
+ }
|
|
|
|
+ #endregion
|
|
|
|
|
|
- e.PopupMenu.Items.Add(doubleView);
|
|
|
|
|
|
|
|
- MenuItem doubleContinuousView = new MenuItem();
|
|
|
|
- doubleContinuousView.Header = "Two Pages Continuous";
|
|
|
|
- doubleContinuousView.Click += (o, p) =>
|
|
|
|
- {
|
|
|
|
- if (pdfViewControl != null)
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- e.PopupMenu.Items.Add(doubleContinuousView);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (e != null && e.CommandType == CommandType.Copy)
|
|
|
|
- {
|
|
|
|
- e.DoCommand();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ #region Password
|
|
private void PasswordUI_Confirmed(object sender, string e)
|
|
private void PasswordUI_Confirmed(object sender, string e)
|
|
{
|
|
{
|
|
if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
|
|
if (passwordViewer != null && passwordViewer.PDFView != null && passwordViewer.PDFView.Document != null)
|
|
@@ -265,6 +134,7 @@ namespace Viewer
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
PasswordUI.Visibility = Visibility.Collapsed;
|
|
PasswordUI.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
+ #endregion
|
|
|
|
|
|
private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
|
|
private void PdfViewer_InfoChanged(object sender, KeyValuePair<string, object> e)
|
|
{
|
|
{
|
|
@@ -275,13 +145,50 @@ namespace Viewer
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 撤销重做状态更新事件通知
|
|
|
|
|
|
+ /// Undo Redo Event Noitfy
|
|
/// </summary>
|
|
/// </summary>
|
|
private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
private void UndoManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
OnPropertyChanged(e.PropertyName);
|
|
OnPropertyChanged(e.PropertyName);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ #region Expand or Hide Panel
|
|
|
|
+
|
|
|
|
+ private void ExpandLeftPanel(bool isExpand)
|
|
|
|
+ {
|
|
|
|
+ BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
+ Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
+ if (isExpand)
|
|
|
|
+ {
|
|
|
|
+ BodyGrid.ColumnDefinitions[0].Width = new GridLength(260);
|
|
|
|
+ BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
|
|
|
|
+ BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ ExpandLeftPanel(true);
|
|
|
|
+ BotaSideTool.SelectBotaTool(BOTATools.Search);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void ToolExpand_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ ToggleButton expandBtn = sender as ToggleButton;
|
|
|
|
+ if (expandBtn != null)
|
|
|
|
+ {
|
|
|
|
+ bool isExpand = expandBtn.IsChecked == true;
|
|
|
|
+ ExpandLeftPanel(isExpand);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
private double CheckZoomLevel(double zoom, bool IsGrowth)
|
|
private double CheckZoomLevel(double zoom, bool IsGrowth)
|
|
{
|
|
{
|
|
double standardZoom = 100;
|
|
double standardZoom = 100;
|
|
@@ -311,46 +218,6 @@ namespace Viewer
|
|
return standardZoom / 100;
|
|
return standardZoom / 100;
|
|
}
|
|
}
|
|
|
|
|
|
- private void LoadDefaultDocument()
|
|
|
|
- {
|
|
|
|
- string defaultFilePath = "developer_guide_windows.pdf";
|
|
|
|
- pdfViewControl = new PDFViewControl();
|
|
|
|
- pdfViewControl.PDFView.InitDocument(defaultFilePath);
|
|
|
|
- LoadDocument();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ToolExpand_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
- ToggleButton expandBtn = sender as ToggleButton;
|
|
|
|
- if (expandBtn != null)
|
|
|
|
- {
|
|
|
|
- bool isExpand = expandBtn.IsChecked == true;
|
|
|
|
- ExpandLeftPanel(isExpand);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ExpandSearchBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
- ExpandLeftPanel(true);
|
|
|
|
- BotaSideTool.SelectBotaTool(BOTATools.Search);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void ExpandLeftPanel(bool isExpand)
|
|
|
|
- {
|
|
|
|
- BotaSideTool.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
- Splitter.Visibility = isExpand ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
- if (isExpand)
|
|
|
|
- {
|
|
|
|
- BodyGrid.ColumnDefinitions[0].Width = new GridLength(260);
|
|
|
|
- BodyGrid.ColumnDefinitions[1].Width = new GridLength(15);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- BodyGrid.ColumnDefinitions[0].Width = new GridLength(0);
|
|
|
|
- BodyGrid.ColumnDefinitions[1].Width = new GridLength(0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
|
|
private void ViewSettingBtn_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
ToggleButton toggleButton = sender as ToggleButton;
|
|
ToggleButton toggleButton = sender as ToggleButton;
|
|
@@ -412,6 +279,41 @@ namespace Viewer
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
PopupBorder.Visibility = Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #region Open and save file
|
|
|
|
+
|
|
|
|
+ private void SaveFile()
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
|
|
|
|
+ if (pdfDoc.WriteToLoadedPath())
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView.UndoManager.CanSave = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SaveFileDialog saveDialog = new SaveFileDialog();
|
|
|
|
+ saveDialog.Filter = "(*.pdf)|*.pdf";
|
|
|
|
+ saveDialog.DefaultExt = ".pdf";
|
|
|
|
+ saveDialog.OverwritePrompt = true;
|
|
|
|
+
|
|
|
|
+ if (saveDialog.ShowDialog() == true)
|
|
|
|
+ {
|
|
|
|
+ if (pdfDoc.WriteToFilePath(saveDialog.FileName))
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView.UndoManager.CanSave = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine(ex.ToString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
private void OpenFile_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -451,48 +353,53 @@ namespace Viewer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine(ex.ToString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ SaveFile();
|
|
}
|
|
}
|
|
|
|
|
|
- private void SaveFile()
|
|
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ #region Context Menu
|
|
|
|
+
|
|
|
|
+ private void ExtraImage_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
- if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.Document != null)
|
|
|
|
|
|
+ System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
|
|
+ if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
{
|
|
|
|
+ string choosePath = folderDialog.SelectedPath;
|
|
|
|
+ string openPath = choosePath;
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- CPDFDocument pdfDoc = pdfViewControl.PDFView.Document;
|
|
|
|
- if (pdfDoc.WriteToLoadedPath())
|
|
|
|
- {
|
|
|
|
- pdfViewControl.PDFView.UndoManager.CanSave = false;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- SaveFileDialog saveDialog = new SaveFileDialog();
|
|
|
|
- saveDialog.Filter = "(*.pdf)|*.pdf";
|
|
|
|
- saveDialog.DefaultExt = ".pdf";
|
|
|
|
- saveDialog.OverwritePrompt = true;
|
|
|
|
|
|
+ Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
|
|
|
|
|
|
- if (saveDialog.ShowDialog() == true)
|
|
|
|
|
|
+ if (imageDict != null && imageDict.Count > 0)
|
|
{
|
|
{
|
|
- if (pdfDoc.WriteToFilePath(saveDialog.FileName))
|
|
|
|
|
|
+ foreach (int pageIndex in imageDict.Keys)
|
|
{
|
|
{
|
|
- pdfViewControl.PDFView.UndoManager.CanSave = false;
|
|
|
|
|
|
+ List<Bitmap> imageList = imageDict[pageIndex];
|
|
|
|
+ foreach (Bitmap image in imageList)
|
|
|
|
+ {
|
|
|
|
+ string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
|
|
|
|
+ image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
+ openPath = savePath;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ Process.Start("explorer", "/select,\"" + openPath + "\"");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- private void SaveFileBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
- {
|
|
|
|
- SaveFile();
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void CopyImage_Click(object sender, RoutedEventArgs e)
|
|
private void CopyImage_Click(object sender, RoutedEventArgs e)
|
|
@@ -528,40 +435,153 @@ namespace Viewer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void ExtraImage_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
+ private void PDFView_AnnotCommandHandler(object sender, AnnotCommandArgs e)
|
|
{
|
|
{
|
|
- System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
|
|
- if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
|
+ if (e != null && e.CommandType == CommandType.Context)
|
|
{
|
|
{
|
|
- string choosePath = folderDialog.SelectedPath;
|
|
|
|
- string openPath = choosePath;
|
|
|
|
- try
|
|
|
|
|
|
+ if (e.PressOnSelectedText)
|
|
{
|
|
{
|
|
- Dictionary<int, List<Bitmap>> imageDict = pdfViewControl.PDFView?.GetSelectedImages();
|
|
|
|
-
|
|
|
|
- if (imageDict != null && imageDict.Count > 0)
|
|
|
|
|
|
+ e.Handle = true;
|
|
|
|
+ e.PopupMenu = new ContextMenu();
|
|
|
|
+ e.PopupMenu.Items.Add(new MenuItem() { Header = "Copy", Command = ApplicationCommands.Copy, CommandTarget = (UIElement)sender });
|
|
|
|
+ }
|
|
|
|
+ else if (e.CommandTarget == TargetType.ImageSelection)
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null && pdfViewControl.PDFView != null && pdfViewControl.PDFView.GetSelectImageCount() > 0)
|
|
{
|
|
{
|
|
- foreach (int pageIndex in imageDict.Keys)
|
|
|
|
- {
|
|
|
|
- List<Bitmap> imageList = imageDict[pageIndex];
|
|
|
|
- foreach (Bitmap image in imageList)
|
|
|
|
- {
|
|
|
|
- string savePath = Path.Combine(choosePath, Guid.NewGuid() + ".jpg");
|
|
|
|
- image.Save(savePath, System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
- openPath = savePath;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ e.Handle = true;
|
|
|
|
+ e.PopupMenu = new ContextMenu();
|
|
|
|
+
|
|
|
|
+ MenuItem imageCopyMenu = new MenuItem();
|
|
|
|
+ imageCopyMenu = new MenuItem();
|
|
|
|
+ imageCopyMenu.Header = "Copy Images";
|
|
|
|
+ WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageCopyMenu, "Click", CopyImage_Click);
|
|
|
|
+ imageCopyMenu.CommandParameter = e;
|
|
|
|
+ e.PopupMenu.Items.Add(imageCopyMenu);
|
|
|
|
+
|
|
|
|
+ MenuItem imageExtraMenu = new MenuItem();
|
|
|
|
+ imageExtraMenu = new MenuItem();
|
|
|
|
+ imageExtraMenu.Header = "Extract Images";
|
|
|
|
+ WeakEventManager<MenuItem, RoutedEventArgs>.AddHandler(imageExtraMenu, "Click", ExtraImage_Click);
|
|
|
|
+ imageExtraMenu.CommandParameter = e;
|
|
|
|
+ e.PopupMenu.Items.Add(imageExtraMenu);
|
|
}
|
|
}
|
|
- Process.Start("explorer", "/select,\"" + openPath + "\"");
|
|
|
|
}
|
|
}
|
|
- catch (Exception ex)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
|
|
+ e.Handle = true;
|
|
|
|
+ e.PopupMenu = new ContextMenu();
|
|
|
|
|
|
|
|
+ MenuItem fitWidthMenu = new MenuItem();
|
|
|
|
+ fitWidthMenu.Header = "Automatically Resize";
|
|
|
|
+ fitWidthMenu.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitWidth);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(fitWidthMenu);
|
|
|
|
+
|
|
|
|
+ MenuItem fitSizeMenu = new MenuItem();
|
|
|
|
+ fitSizeMenu.Header = "Actual Size";
|
|
|
|
+ fitSizeMenu.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView?.ChangeFitMode(FitMode.FitSize);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(fitSizeMenu);
|
|
|
|
+
|
|
|
|
+ MenuItem zoomInMenu = new MenuItem();
|
|
|
|
+ zoomInMenu.Header = "Zoom In";
|
|
|
|
+ zoomInMenu.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor + 0.01, true);
|
|
|
|
+ pdfViewControl.PDFView?.Zoom(newZoom);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(zoomInMenu);
|
|
|
|
+
|
|
|
|
+ MenuItem zoomOutMenu = new MenuItem();
|
|
|
|
+ zoomOutMenu.Header = "Zoom Out";
|
|
|
|
+ zoomOutMenu.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ double newZoom = CheckZoomLevel(pdfViewControl.PDFView.ZoomFactor - 0.01, false);
|
|
|
|
+ pdfViewControl.PDFView?.Zoom(newZoom);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(zoomOutMenu);
|
|
|
|
+ e.PopupMenu.Items.Add(new Separator());
|
|
|
|
+
|
|
|
|
+ MenuItem singleView = new MenuItem();
|
|
|
|
+ singleView.Header = "Single Page";
|
|
|
|
+ singleView.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Single);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(singleView);
|
|
|
|
+
|
|
|
|
+ MenuItem singleContinuousView = new MenuItem();
|
|
|
|
+ singleContinuousView.Header = "Single Page Continuous";
|
|
|
|
+ singleContinuousView.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView?.ChangeViewMode(ViewMode.SingleContinuous);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(singleContinuousView);
|
|
|
|
+
|
|
|
|
+ MenuItem doubleView = new MenuItem();
|
|
|
|
+ doubleView.Header = "Two Pages";
|
|
|
|
+ doubleView.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView?.ChangeViewMode(ViewMode.Double);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ e.PopupMenu.Items.Add(doubleView);
|
|
|
|
+
|
|
|
|
+ MenuItem doubleContinuousView = new MenuItem();
|
|
|
|
+ doubleContinuousView.Header = "Two Pages Continuous";
|
|
|
|
+ doubleContinuousView.Click += (o, p) =>
|
|
|
|
+ {
|
|
|
|
+ if (pdfViewControl != null)
|
|
|
|
+ {
|
|
|
|
+ pdfViewControl.PDFView?.ChangeViewMode(ViewMode.DoubleContinuous);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ e.PopupMenu.Items.Add(doubleContinuousView);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if (e != null && e.CommandType == CommandType.Copy)
|
|
|
|
+ {
|
|
|
|
+ e.DoCommand();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
|
|
+ #region Close Window
|
|
|
|
+
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
{
|
|
{
|
|
if (pdfViewControl.PDFView.UndoManager.CanSave)
|
|
if (pdfViewControl.PDFView.UndoManager.CanSave)
|
|
@@ -582,6 +602,8 @@ namespace Viewer
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
|
+
|
|
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
|
protected void OnPropertyChanged([CallerMemberName] string name = null)
|
|
{
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|