diff --git a/ContextMenu/CustomContextMenu/App.xaml b/ContextMenu/CustomContextMenu/App.xaml new file mode 100644 index 0000000..0e1d8d2 --- /dev/null +++ b/ContextMenu/CustomContextMenu/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/ContextMenu/CustomContextMenu/App.xaml.cs b/ContextMenu/CustomContextMenu/App.xaml.cs new file mode 100644 index 0000000..216f7be --- /dev/null +++ b/ContextMenu/CustomContextMenu/App.xaml.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace CustomContextMenu +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } + +} diff --git a/ContextMenu/CustomContextMenu/AssemblyInfo.cs b/ContextMenu/CustomContextMenu/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/ContextMenu/CustomContextMenu/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/ContextMenu/CustomContextMenu/CustomContextMenu.csproj b/ContextMenu/CustomContextMenu/CustomContextMenu.csproj new file mode 100644 index 0000000..2a6a268 --- /dev/null +++ b/ContextMenu/CustomContextMenu/CustomContextMenu.csproj @@ -0,0 +1,12 @@ + + + + WinExe + + + + + + + + diff --git a/ContextMenu/CustomContextMenu/CustomContextMenu.sln b/ContextMenu/CustomContextMenu/CustomContextMenu.sln new file mode 100644 index 0000000..63d1b19 --- /dev/null +++ b/ContextMenu/CustomContextMenu/CustomContextMenu.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.14.36401.2 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomContextMenu", "CustomContextMenu.csproj", "{0FAA7523-B034-4EA9-860A-A8936DFFD40E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0FAA7523-B034-4EA9-860A-A8936DFFD40E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BAAD6341-6945-42C7-8438-919E9DB8EB03} + EndGlobalSection +EndGlobal diff --git a/ContextMenu/CustomContextMenu/Data/Input.pdf b/ContextMenu/CustomContextMenu/Data/Input.pdf new file mode 100644 index 0000000..8773442 Binary files /dev/null and b/ContextMenu/CustomContextMenu/Data/Input.pdf differ diff --git a/ContextMenu/CustomContextMenu/MainWindow.xaml b/ContextMenu/CustomContextMenu/MainWindow.xaml new file mode 100644 index 0000000..f07e857 --- /dev/null +++ b/ContextMenu/CustomContextMenu/MainWindow.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/ContextMenu/CustomContextMenu/MainWindow.xaml.cs b/ContextMenu/CustomContextMenu/MainWindow.xaml.cs new file mode 100644 index 0000000..400822e --- /dev/null +++ b/ContextMenu/CustomContextMenu/MainWindow.xaml.cs @@ -0,0 +1,67 @@ +using Syncfusion.Windows.PdfViewer; +using System; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace CustomContextMenu +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + pdfViewer.Load("../../../Data/Input.pdf"); + pdfViewer.ContextMenuOpening += PdfViewer_ContextMenuOpening; + } + + private void Pan_Click(object sender, RoutedEventArgs e) + { + pdfViewer.CursorMode = PdfViewerCursorMode.HandTool; + } + + private void SelectZoomArea_Click(object sender, RoutedEventArgs e) + { + pdfViewer.CursorMode = PdfViewerCursorMode.MarqueeZoom; + } + + private void FitToPageMenuItem_Click(object sender, RoutedEventArgs e) + { + pdfViewer.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitPage; + } + private void PdfViewer_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) + { + if (e.Source == "Text Selection") + { + ContextMenu contextmenu = new ContextMenu(); + contextmenu.FlowDirection = FlowDirection.LeftToRight; + contextmenu.HorizontalAlignment = HorizontalAlignment.Center; + MenuItem selectZoomArea = new MenuItem(); + selectZoomArea.Header = "Select Zoom Area"; + selectZoomArea.Click += SelectZoomArea_Click; + contextmenu.Items.Add(selectZoomArea); + MenuItem fitToPageMenuItem = new MenuItem(); + fitToPageMenuItem.Header = "Fit to Page"; + fitToPageMenuItem.Click += FitToPageMenuItem_Click; + contextmenu.Items.Add(fitToPageMenuItem); + MenuItem pan = new MenuItem(); + pan.Header = "Pan"; + pan.Click += Pan_Click; + contextmenu.Items.Add(pan); + contextmenu.IsOpen = true; + contextmenu.StaysOpen = true; + e.Handled = true; + } + } + } +} \ No newline at end of file diff --git a/ContextMenu/CustomContextMenu/targets/MultiTargeting.targets b/ContextMenu/CustomContextMenu/targets/MultiTargeting.targets new file mode 100644 index 0000000..4a85629 --- /dev/null +++ b/ContextMenu/CustomContextMenu/targets/MultiTargeting.targets @@ -0,0 +1,10 @@ + + + net462;net8.0-windows;net9.0-windows + true + False + True + True + True + + \ No newline at end of file