Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ContextMenu/CustomContextMenu/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="CustomContextMenu.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CustomContextMenu"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
14 changes: 14 additions & 0 deletions ContextMenu/CustomContextMenu/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;

namespace CustomContextMenu
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}

}
10 changes: 10 additions & 0 deletions ContextMenu/CustomContextMenu/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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)
)]
12 changes: 12 additions & 0 deletions ContextMenu/CustomContextMenu/CustomContextMenu.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
<PackageReference Include="System.Drawing.Common" Version="9.0.8" />
</ItemGroup>
<Import Project="targets\MultiTargeting.targets" />
</Project>
25 changes: 25 additions & 0 deletions ContextMenu/CustomContextMenu/CustomContextMenu.sln
Original file line number Diff line number Diff line change
@@ -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
Binary file added ContextMenu/CustomContextMenu/Data/Input.pdf
Binary file not shown.
13 changes: 13 additions & 0 deletions ContextMenu/CustomContextMenu/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Window x:Class="CustomContextMenu.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CustomContextMenu" xmlns:PdfViewer="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF"
mc:Ignorable="d"
Title="MainWindow"
WindowState="Maximized">
<Grid>
<PdfViewer:PdfViewerControl x:Name="pdfViewer" />
</Grid>
</Window>
67 changes: 67 additions & 0 deletions ContextMenu/CustomContextMenu/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
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;
}
}
}
}
10 changes: 10 additions & 0 deletions ContextMenu/CustomContextMenu/targets/MultiTargeting.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net462;net8.0-windows;net9.0-windows</TargetFrameworks>
<UseWPF>true</UseWPF>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<EnableDefaultItems>True</EnableDefaultItems>
<EnableDefaultEmbeddedResourceItems>True</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
</Project>