diff --git a/Toolbar/CustomToolbar/App.config b/Toolbar/CustomToolbar/App.config new file mode 100644 index 0000000..c365e08 --- /dev/null +++ b/Toolbar/CustomToolbar/App.config @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> + </startup> + +</configuration> diff --git a/Toolbar/CustomToolbar/App.xaml b/Toolbar/CustomToolbar/App.xaml new file mode 100644 index 0000000..7e9e14c --- /dev/null +++ b/Toolbar/CustomToolbar/App.xaml @@ -0,0 +1,9 @@ +<Application x:Class="CustomToolBar.App" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="clr-namespace:CustomToolBar" + StartupUri="MainWindow.xaml"> + <Application.Resources> + + </Application.Resources> +</Application> diff --git a/Toolbar/CustomToolbar/App.xaml.cs b/Toolbar/CustomToolbar/App.xaml.cs new file mode 100644 index 0000000..15bc31b --- /dev/null +++ b/Toolbar/CustomToolbar/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace CustomToolBar +{ + /// <summary> + /// Interaction logic for App.xaml + /// </summary> + public partial class App : Application + { + } +} diff --git a/Toolbar/CustomToolbar/CustomToolbar.csproj b/Toolbar/CustomToolbar/CustomToolbar.csproj new file mode 100644 index 0000000..769e813 --- /dev/null +++ b/Toolbar/CustomToolbar/CustomToolbar.csproj @@ -0,0 +1,110 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{6AC69A74-7539-4C2C-BDFD-F436674A7FBD}</ProjectGuid> + <OutputType>WinExe</OutputType> + <RootNamespace>CustomToolbar</RootNamespace> + <AssemblyName>CustomToolbar</AssemblyName> + <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <WarningLevel>4</WarningLevel> + <Deterministic>true</Deterministic> + <TargetFrameworkProfile /> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE;FRAMEWORK</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <Prefer32Bit>false</Prefer32Bit> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE;FRAMEWORK</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" /> + <PackageReference Include="Syncfusion.SfSkinManager.WPF" Version="*"/> + <PackageReference Include="Syncfusion.Themes.Office2019Colorful.WPF" Version="*"/> + <PackageReference Include="Syncfusion.Tools.WPF" Version="*"/> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Windows.Controls.Ribbon" /> + <Reference Include="System.Xml" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xaml"> + <RequiredTargetFramework>4.0</RequiredTargetFramework> + </Reference> + <Reference Include="WindowsBase" /> + <Reference Include="PresentationCore" /> + <Reference Include="PresentationFramework" /> + </ItemGroup> + <ItemGroup> + <ApplicationDefinition Include="App.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </ApplicationDefinition> + <Compile Include="ViewModel\ViewModel.cs" /> + <Page Include="MainWindow.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Compile Include="App.xaml.cs"> + <DependentUpon>App.xaml</DependentUpon> + <SubType>Code</SubType> + </Compile> + <Compile Include="Helper\PdfViewerEventAttachUtil.cs" /> + <Compile Include="MainWindow.xaml.cs"> + <DependentUpon>MainWindow.xaml</DependentUpon> + <SubType>Code</SubType> + </Compile> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> + <Compile Include="Properties\Settings.Designer.cs"> + <AutoGen>True</AutoGen> + <DependentUpon>Settings.settings</DependentUpon> + <DesignTimeSharedInput>True</DesignTimeSharedInput> + </Compile> + <EmbeddedResource Include="Properties\Resources.resx"> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> + <None Include="Data\F# Succinctly.pdf" /> + <None Include="Properties\Settings.settings"> + <Generator>SettingsSingleFileGenerator</Generator> + <LastGenOutput>Settings.Designer.cs</LastGenOutput> + </None> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <Resource Include="Data\PdfViewer\Approved.png" /> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project> \ No newline at end of file diff --git a/Toolbar/CustomToolbar/CustomToolbar.sln b/Toolbar/CustomToolbar/CustomToolbar.sln new file mode 100644 index 0000000..cf96a8e --- /dev/null +++ b/Toolbar/CustomToolbar/CustomToolbar.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomToolbar", "CustomToolbar.csproj", "{BDB4645E-EC1F-6D00-4FE7-2C6AB5166375}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BDB4645E-EC1F-6D00-4FE7-2C6AB5166375}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BDB4645E-EC1F-6D00-4FE7-2C6AB5166375}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BDB4645E-EC1F-6D00-4FE7-2C6AB5166375}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BDB4645E-EC1F-6D00-4FE7-2C6AB5166375}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E4AE6383-1A5C-46C2-93BE-A60C75360BC0} + EndGlobalSection +EndGlobal diff --git a/Toolbar/CustomToolbar/CustomToolbar_NET.csproj b/Toolbar/CustomToolbar/CustomToolbar_NET.csproj new file mode 100644 index 0000000..717e54c --- /dev/null +++ b/Toolbar/CustomToolbar/CustomToolbar_NET.csproj @@ -0,0 +1,14 @@ +<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> + <PropertyGroup> + <OutputType>WinExe</OutputType> + <TargetFramework>net8.0-windows</TargetFramework> + <UseWPF>true</UseWPF> + </PropertyGroup> + + <ItemGroup> + <PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" /> + <PackageReference Include="Syncfusion.SfSkinManager.WPF" Version="*" /> + <PackageReference Include="Syncfusion.Themes.Office2019Colorful.WPF" Version="*" /> + <PackageReference Include="Syncfusion.Tools.WPF" Version="*" /> + </ItemGroup> +</Project> diff --git a/Toolbar/CustomToolbar/CustomToolbar_NET.sln b/Toolbar/CustomToolbar/CustomToolbar_NET.sln new file mode 100644 index 0000000..8f7d9f0 --- /dev/null +++ b/Toolbar/CustomToolbar/CustomToolbar_NET.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.226.21692 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomToolbar_NET", "CustomToolbar_NET.csproj", "{A9693914-16B8-4605-BAF9-69C6FFE4ABB0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A9693914-16B8-4605-BAF9-69C6FFE4ABB0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A9693914-16B8-4605-BAF9-69C6FFE4ABB0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A9693914-16B8-4605-BAF9-69C6FFE4ABB0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A9693914-16B8-4605-BAF9-69C6FFE4ABB0}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CBF28B5B-1546-4921-BF24-226CA1F9ED89} + EndGlobalSection +EndGlobal diff --git a/Toolbar/CustomToolbar/Data/F# Succinctly.pdf b/Toolbar/CustomToolbar/Data/F# Succinctly.pdf new file mode 100644 index 0000000..8773442 Binary files /dev/null and b/Toolbar/CustomToolbar/Data/F# Succinctly.pdf differ diff --git a/Toolbar/CustomToolbar/Data/PdfViewer/Approved.png b/Toolbar/CustomToolbar/Data/PdfViewer/Approved.png new file mode 100644 index 0000000..79d6257 Binary files /dev/null and b/Toolbar/CustomToolbar/Data/PdfViewer/Approved.png differ diff --git a/Toolbar/CustomToolbar/Helper/PdfViewerEventAttachUtil.cs b/Toolbar/CustomToolbar/Helper/PdfViewerEventAttachUtil.cs new file mode 100644 index 0000000..aae45f2 --- /dev/null +++ b/Toolbar/CustomToolbar/Helper/PdfViewerEventAttachUtil.cs @@ -0,0 +1,43 @@ +#region Copyright Syncfusion Inc. 2001-2021. +// Copyright Syncfusion Inc. 2001-2021. All rights reserved. +// Use of this code is subject to the terms of our license. +// A copy of the current license can be obtained at any time by e-mailing +// licensing@syncfusion.com. Any infringement will be prosecuted under +// applicable laws. +#endregion +using System; +using System.Windows; +using System.Windows.Controls; + +namespace syncfusion.pdfviewerdemos.wpf +{ + public class PdfViewerEventAttachUtil + { + public static DependencyProperty WindowLoaded = DependencyProperty.RegisterAttached("WindowLoaded", typeof(bool), typeof(PdfViewerEventAttachUtil), new PropertyMetadata(new PropertyChangedCallback(WindowLoadedChanged))); + + public static void SetWindowLoaded(DependencyObject sender, bool command) + { + sender.SetValue(WindowLoaded, command); + } + /// <summary> + /// Retrieves the parent Window from the given Grid and assigns handlers from the ViewModel. + /// </summary> + public static void WindowLoadedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) + { + Grid grid = sender as Grid; + if (grid != null) + { + Window view = grid.Parent as Window; + if (view != null) + { + CustomToolbarViewModel viewModel = view.DataContext as CustomToolbarViewModel; + if (viewModel != null) + { + view.Loaded += new RoutedEventHandler(viewModel.Loaded); + view.Closed += new EventHandler(viewModel.Closed); + } + } + } + } + } +} diff --git a/Toolbar/CustomToolbar/MainWindow.xaml b/Toolbar/CustomToolbar/MainWindow.xaml new file mode 100644 index 0000000..573c6cd --- /dev/null +++ b/Toolbar/CustomToolbar/MainWindow.xaml @@ -0,0 +1,591 @@ +<syncfusion:RibbonWindow + x:Class="syncfusion.pdfviewerdemos.wpf.CustomToolBar" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:cc="clr-namespace:Syncfusion.Windows.PdfViewer;assembly=Syncfusion.PdfViewer.WPF" + xmlns:local="clr-namespace:syncfusion.pdfviewerdemos.wpf" + xmlns:syncfusion="http://schemas.syncfusion.com/wpf" + x:Name="ribbonwindow" + Title="CustomToolBar" + MinWidth="940" + ShowHelpButton="False" + SnapsToDevicePixels="True" + WindowStartupLocation="CenterScreen" + WindowState="Maximized"> + <Window.DataContext> + <local:CustomToolbarViewModel /> + </Window.DataContext> + + <Grid Name="grid1" local:PdfViewerEventAttachUtil.WindowLoaded="True"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto" /> + <RowDefinition Height="*" /> + </Grid.RowDefinitions> + <Grid + x:Name="ribbonGrid" + Grid.Row="0" + VerticalAlignment="Top"> + <syncfusion:Ribbon + Name="MyRibbon" + BackStageColor="#D24726" + BackStageHeader="FILE" + EnableMoreCommands="False"> + <syncfusion:RibbonTab + syncfusion:Ribbon.KeyTip="H" + Caption="Home" + IsChecked="True"> + <syncfusion:RibbonBar + Name="file_tab" + syncfusion:Ribbon.KeyTip="FN" + syncfusion:Ribbon.ShowInMoreCommands="False" + Header="File" + IsEnabled="True"> + <DockPanel> + <syncfusion:RibbonButton + Name="Btnopen" + Width="60" + syncfusion:Ribbon.KeyTip="O" + Background="Transparent" + Foreground="#666666" + Label="Open" + SizeForm="Large"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M5.1229254,6 C4.9319264,6 4.7599241,6.1059875 4.6749264,6.2759857 L1.3099782,13 12.185817,13 14.935776,6.7459869 C15.058775,6.4989929 14.967774,6.3089905 14.923776,6.2369995 14.879777,6.1660004 14.750781,6 14.497787,6 z M1.5009773,1.0000001 C1.2249804,0.99999999 0.99998522,1.223999 0.99998528,1.5 L0.99998528,11.383987 3.7799429,5.8289947 C4.035936,5.3179932 4.5499283,5 5.1229254,5 L12.011824,5 12.011824,3.5 C12.011824,3.223999 11.786821,3 11.510823,3 L7.2768928,3 C6.938893,3 6.606897,2.8839874 6.3429009,2.673996 L4.3739358,1.1089935 C4.2859322,1.0389862 4.1749336,0.99999999 4.0619365,1.0000001 z M1.4999778,4.4408921E-16 L4.0619365,4.4408921E-16 C4.4009358,-6.475124E-09 4.7299258,0.11499023 4.9959208,0.3259887 L6.9648935,1.8909911 C7.0538965,1.9609985 7.1638881,2 7.2768928,1.9999999 L11.510823,1.9999999 C12.338815,2 13.011809,2.6719971 13.011809,3.5009918 L13.011809,5 14.497787,5 C15.021773,5 15.499771,5.2659912 15.77476,5.7119903 16.049759,6.1569977 16.074759,6.7029877 15.839762,7.17099 L13.100804,13.401993 C12.940803,13.764999 12.581815,14 12.184817,14 L0.99998528,14 C0.44799143,14 0,13.551987 0,13 L0,1.5 C0,0.67098998 0.67098773,-6.475124E-09 1.4999778,4.4408921E-16 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Open"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to open the PDF document" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonButton + Name="Save" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="S" + Foreground="#666666" + Label="Save" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M3.9989982,9.9999962 L3.9989982,14.999996 4.9989982,14.999996 4.9989982,10.999996 5.9989984,10.999996 5.9989984,14.999996 9.9989984,14.999996 9.9989984,9.9999962 z M2.9989938,1.0009929 L2.9989938,6 10.998994,6 10.998994,1.0009929 z M1.5,1.0009929 C1.2239999,1.0009929 0.99999988,1.2249929 0.99999988,1.500993 L0.99999988,12.843993 2.51,15.000993 2.9989983,15.000993 2.9989983,8.9999962 10.998998,8.9999962 10.998998,15.000993 12.5,15.000993 C12.776,15.000993 13,14.775993 13,14.500993 L13,1.500993 C13,1.2249929 12.776,1.0009929 12.5,1.0009929 L11.998994,1.0009929 11.998994,7 1.9989936,7 1.9989936,1.0009929 z M1.9989936,0 L11.998994,0 11.998994,0.00099283666 13,0.00099283666 C13.552,0.0009929199 14,0.44899291 14,1.0009929 L14,14.500993 C14,15.328993 13.328,16.000994 12.5,16.000994 L1.9889999,16.000994 0,13.157993 0,1.0009929 C-1.1920929E-07,0.44899291 0.44699991,0.0009929199 0.99999988,0.00099283666 L1.9989936,0.00099283666 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Save"> + <TextBlock + HorizontalAlignment="Left" + Text="Click to save the document in the local disk" + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonButton + Name="Print1" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="R" + Command="{Binding ElementName=pdfviewer, Path=PrintCommand, Mode=OneWay}" + Foreground="#666666" + Label="Print" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M3.9999731,11 L3.9999731,15 9.9999733,15 9.9999733,11 z M2.5000291,7.9999914 C2.7760291,7.9999913 3.0000291,8.2239914 3.0000291,8.4999914 3.0000291,8.7759914 2.7760291,8.9999914 2.5000291,8.9999914 2.2240291,8.9999914 2.0000291,8.7759914 2.0000291,8.4999914 2.0000291,8.2239914 2.2240291,7.9999913 2.5000291,7.9999914 z M1,6.9999933 L1,11.999993 2.9999731,11.999993 2.9999731,10 10.999973,10 10.999973,11.999993 13,11.999993 13,6.9999933 10.999973,6.9999933 2.9999731,6.9999998 z M3.9999731,1 L3.9999731,5.9999933 9.9999733,5.9999933 9.9999733,1 z M2.9999731,0 L10.999973,0 10.999973,5.9999933 14,5.9999933 14,12.999993 10.999973,12.999993 10.999973,16 2.9999731,16 2.9999731,12.999993 0,12.999993 0,5.9999933 2.9999731,5.9999933 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Print"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to Print this PDF file or pages from it" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + </DockPanel> + </syncfusion:RibbonBar> + + <!-- Page Navigation --> + <syncfusion:RibbonBar + Name="Navigation" + syncfusion:Ribbon.KeyTip="HF" + Header="Navigation" + KeyTipOnCollapsed="N"> + <DockPanel> + <syncfusion:RibbonButton + Name="First" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="F" + Command="{Binding ElementName=pdfviewer, Path=FirstPageCommand, Mode=OneWay}" + Foreground="#666666" + Label="First" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M17.999989,0.0030003171 L17.999989,15.389999 7.6660047,7.6969998 z M0,0 L3.85,0 3.85,15.453 0,15.453 z" + Fill="#666666" + Stretch="Uniform" + StrokeThickness="1" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="First"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to go to first Page in the document" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonButton + Name="Previous" + Width="60" + Padding="0,0,5,0" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="P" + Command="{Binding ElementName=pdfviewer, Path=PreviousPageCommand, Mode=OneWay}" + Foreground="#666666" + Label="Previous" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="F1M309.352,82.7328L309.352,100.7328L297.263,91.7328z" + Fill="#666666" + Stretch="Uniform" + StrokeThickness="1" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Previous"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to go to previous page in the document" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonTextBox + Name="txtCurrentPageIndex" + Width="35" + Height="25" + Margin="1,-27,2,0" + RenderTransformOrigin="0.505,0.5" + TextAlignment="Center"> + <TextBox.InputBindings> + <KeyBinding + Key="Enter" + Command="{Binding ElementName=pdfviewer, Path=GoToPageCommand, Mode=OneWay}" + CommandParameter="{Binding Text, ElementName=txtCurrentPageIndex}" /> + </TextBox.InputBindings> + <syncfusion:RibbonTextBox.ToolTip> + <syncfusion:ScreenTip Description="GoTo Page"> + <TextBlock + Width="130" + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Go to specified page in the document" + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonTextBox.ToolTip> + </syncfusion:RibbonTextBox> + <TextBlock + Name="pageSeparator" + Margin="3,-27,0,0" + VerticalAlignment="Center" + FontFamily="Segoe UI" + FontSize="9pt" + Foreground="Black" + Text="/"> + <TextBlock.Style> + <Style TargetType="{x:Type TextBlock}"> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" /> + <Setter Property="Opacity" Value="0.2" /> + </Trigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + <TextBlock + Name="lblTotalPageCount" + Margin="3,-27,3,0" + VerticalAlignment="Center" + FontFamily="Segoe UI" + FontSize="9pt" + Foreground="Black" + Text="{Binding ElementName=pdfviewer, Path=PageCount}" + ToolTip="Total page count"> + <TextBlock.Style> + <Style TargetType="{x:Type TextBlock}"> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" /> + <Setter Property="Opacity" Value="0.2" /> + </Trigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + + <syncfusion:RibbonButton + Name="Next" + AutomationProperties.AutomationId="Hello" + Width="60" + Padding="5,0,0,0" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="N" + Command="{Binding ElementName=pdfviewer, Path=NextPageCommand, Mode=OneWay}" + Foreground="#666666" + Label="Next" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="F1M332.7717,100.7773L332.7717,82.7773L344.8607,91.7773z" + Fill="#666666" + Stretch="Uniform" + StrokeThickness="1" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Next"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to go to next page in the document" + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + + + <syncfusion:RibbonButton + Name="Last" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="L" + Command="{Binding ElementName=pdfviewer, Path=LastPageCommand, Mode=OneWay}" + Foreground="#666666" + Label="Last" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M0,0.062001844 L10.334001,7.7550024 0,15.449002 z M14.15099,0 L18.000983,0 18.000983,15.452997 14.15099,15.452997 z" + Fill="#666666" + Stretch="Uniform" + StrokeThickness="1" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Last"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to go to last page of the document" + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + </DockPanel> + </syncfusion:RibbonBar> + + <!-- Zoom --> + <syncfusion:RibbonBar + Name="Zoom" + syncfusion:Ribbon.KeyTip="Z" + Header="Zoom"> + <DockPanel> + <syncfusion:RibbonButton + Name="ZoomIn" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="Y" + Foreground="#666666" + Label="Zoom In" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M7.5350111,4.500005 L8.5350113,4.500005 8.5350113,7.5000053 11.534998,7.5000053 11.534998,8.5000052 8.5350113,8.5000052 8.5350113,11.500005 7.5350111,11.500005 7.5350111,8.5000052 4.5349984,8.5000052 4.5349984,7.5000053 7.5350111,7.5000053 z M8.0360043,1 C4.1570021,1 1.0000002,4.1399999 1.0000002,7.9999998 1.0000002,11.86 4.1570021,15 8.0360043,15 11.915007,15 15.072009,11.86 15.072009,7.9999998 15.072009,4.1399999 11.915007,1 8.0360043,1 z M8.0360043,0 C12.467007,0 16.072009,3.5889997 16.072009,7.9999998 16.072009,12.411 12.467007,16 8.0360043,16 3.6050018,16 0,12.411 0,7.9999998 0,3.5889997 3.6050018,0 8.0360043,0 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Zoom In"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to increase the magnification of the entire page" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonButton + Name="ZoomOut" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="X" + Foreground="#666666" + Label="Zoom Out" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M4.5349984,7.5000053 L11.534998,7.5000053 11.534998,8.5000052 4.5349984,8.5000052 z M8.0360043,1 C4.1570021,1 1.0000002,4.1399999 1.0000002,7.9999998 1.0000002,11.86 4.1570021,15 8.0360043,15 11.915007,15 15.072009,11.86 15.072009,7.9999998 15.072009,4.1399999 11.915007,1 8.0360043,1 z M8.0360043,0 C12.467007,0 16.072009,3.5889997 16.072009,7.9999998 16.072009,12.411 12.467007,16 8.0360043,16 3.6050018,16 0,12.411 0,7.9999998 0,3.5889997 3.6050018,0 8.0360043,0 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Zoom Out"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to decrease the magnification of the entire page." /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonComboBox + Name="ZoomComboBox" + Width="50" + Height="25" + Margin="9,-24,10,2" + HorizontalAlignment="Center" + syncfusion:Ribbon.KeyTip="C" + SelectedIndex="2" + IsEditable="True" + SelectedItem="{Binding ElementName=pdfviewer, Path=DataContext.SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" + TextBlock.TextAlignment="Center"> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">50</syncfusion:RibbonComboBoxItem> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">75</syncfusion:RibbonComboBoxItem> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">100</syncfusion:RibbonComboBoxItem> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">125</syncfusion:RibbonComboBoxItem> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">150</syncfusion:RibbonComboBoxItem> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">200</syncfusion:RibbonComboBoxItem> + <syncfusion:RibbonComboBoxItem HorizontalAlignment="Center">400</syncfusion:RibbonComboBoxItem> + </syncfusion:RibbonComboBox> + + <TextBlock + Name="ZoomPercentage" + Width="60" + Margin="-69,40,0,0" + LineHeight=".1" + Text="Zoom Percentage" + TextAlignment="Center" + TextWrapping="Wrap"> + <TextBlock.Style> + <Style TargetType="{x:Type TextBlock}"> + <Style.Triggers> + <Trigger Property="IsEnabled" Value="False"> + <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}" /> + <Setter Property="Opacity" Value="0.2" /> + </Trigger> + </Style.Triggers> + </Style> + </TextBlock.Style> + </TextBlock> + </DockPanel> + </syncfusion:RibbonBar> + + <syncfusion:RibbonBar + Name="Size" + syncfusion:Ribbon.KeyTip="FN" + syncfusion:Ribbon.ShowInMoreCommands="False" + Header="View"> + <DockPanel> + <syncfusion:RibbonButton + Name="FitPage" + Width="60" + syncfusion:Ribbon.KeyTip="V" + Foreground="#666666" + Label="Fit Page" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M9.000203,9.5003757 L14.000204,9.5003757 14.000204,10.500376 10.000203,10.500376 10.000203,14.500377 9.000203,14.500377 z M7.1302061E-06,9.5003757 L5.0000072,9.5003757 5.0000072,14.500377 4.0000072,14.500377 4.0000072,10.500376 7.1302061E-06,10.500376 z M4.0000001,0.50001849 L5.0000001,0.50001849 5.0000001,5.5000185 0,5.5000185 0,4.5000185 4.0000001,4.5000185 z M9.000203,0.4999966 L10.000203,0.4999966 10.000203,4.4999965 14.000204,4.4999965 14.000204,5.4999965 9.000203,5.4999965 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="FitPage"> + <TextBlock + HorizontalAlignment="Left" + Foreground="#FF4C4C4C" + Text="Click to show one page at a time." /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + <syncfusion:RibbonButton + Name="FitWidth" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="W" + Foreground="#666666" + Label="Fit Width" + SizeForm="Large" + ToolTipService.ShowOnDisabled="True"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M13.000494,11.000022 L14.000494,11.000022 14.000494,16.000022 9.0004942,16.000022 9.0004942,15.000022 13.000494,15.000022 z M0,11 L1,11 1,15 5.0000005,15 5.0000005,16 0,16 z M9.0005012,1.9995017 L14.000501,1.9995017 14.000501,6.9995017 13.000501,6.9995017 13.000501,2.9995017 9.0005012,2.9995017 z M0,1.9995017 L5.0000005,1.9995017 5.0000005,2.9995017 1,2.9995017 1,6.9995017 0,6.9995017 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="FitWidth"> + <TextBlock + HorizontalAlignment="Left" + Text="Click to fill the window with each page and scroll through pages continuously." + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + + </DockPanel> + + </syncfusion:RibbonBar> + + <syncfusion:RibbonBar + Name="find_text" + syncfusion:Ribbon.KeyTip="" + syncfusion:Ribbon.ShowInMoreCommands="False" + Header="Search" + IsEnabled="True"> + <syncfusion:RibbonButton + Name="FindText" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="T" + Foreground="#666666" + Label="Find Text" + SizeForm="Large"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M10.502988,1.0000001 C8.0220308,0.99999996 6.0029879,3.0189972 6.0029879,5.5 6.0029879,7.9809875 8.0220308,10 10.502988,10 12.984006,10 15.002988,7.9809875 15.002988,5.5 15.002988,3.0189972 12.984006,0.99999996 10.502988,1.0000001 z M10.502988,0 C13.536008,-4.1227921E-08 16.002988,2.4669952 16.002988,5.5 16.002988,8.5329895 13.536008,11 10.502988,11 9.1760683,11 7.957469,10.527799 7.0063903,9.742589 L6.9818491,9.7213249 0.85414124,15.853991 C0.75615358,15.950992 0.62817001,15.999992 0.50018644,15.999992 0.3722024,15.999992 0.24421883,15.950992 0.14623165,15.853991 -0.048743725,15.657988 -0.048743725,15.341982 0.14623165,15.145979 L6.2744442,9.0128088 6.2604085,8.9966106 C5.4751949,8.0455341 5.0029879,6.8269329 5.0029878,5.5 5.0029879,2.4669952 7.4700289,-4.1227921E-08 10.502988,0 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Find Text"> + <TextBlock + HorizontalAlignment="Left" + Text="Search Text in Document" + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + </syncfusion:RibbonButton> + </syncfusion:RibbonBar> + + <syncfusion:RibbonBar + Name="Stamp" + syncfusion:Ribbon.KeyTip="FN" + syncfusion:Ribbon.ShowInMoreCommands="False" + Header="Stamp" + IsEnabled="True"> + <syncfusion:RibbonButton + Name="Stamps" + Width="60" + HorizontalAlignment="Left" + syncfusion:Ribbon.KeyTip="Q" + Foreground="#666666" + Label="Stamp" + SizeForm="Large" + ContextMenuService.Placement="Bottom"> + <syncfusion:RibbonButton.IconTemplate> + <DataTemplate> + <Path + Width="30" + Height="30" + Data="M2.0000045,14.999986 L13.000005,14.999986 13.000005,15.999986 2.0000045,15.999986 z M7.5002503,1 C6.6682982,1 6.0333347,1.2659998 5.5613617,1.8119993 4.854402,2.6300001 4.8124046,4.0339999 5.4613671,5.1499996 6.8902854,7.6089997 6.9062843,10.419 6.9062843,10.538 L6.9062843,11.999992 8.0942163,11.999992 8.0942163,10.538 C8.0942163,10.419 8.1112155,7.6089997 9.539133,5.1509995 10.188096,4.0349998 10.146099,2.6309996 9.4391393,1.8119993 8.9671659,1.2659998 8.3322029,1 7.5002503,1 z M7.5002503,0 C8.6241855,0 9.5311336,0.38999939 10.196095,1.1589994 11.189039,2.3079996 11.274034,4.1559997 10.404084,5.6529999 9.1141576,7.8729997 9.0941591,10.512 9.0941591,10.539 L9.0941591,11.999992 15,11.999992 15,12.999993 0,12.999993 0,11.999992 5.906342,11.999992 5.906342,10.538 C5.906342,10.512 5.886343,7.8729997 4.5974168,5.6529999 3.7264668,4.1559997 3.8124618,2.3079996 4.8044052,1.1589994 5.469367,0.38999939 6.3763146,0 7.5002503,0 z" + Fill="#666666" + Stretch="Uniform" /> + </DataTemplate> + </syncfusion:RibbonButton.IconTemplate> + <syncfusion:RibbonButton.ToolTip> + <syncfusion:ScreenTip Description="Stamp"> + <TextBlock + HorizontalAlignment="Left" + Text="Add custom stamp in document" + TextWrapping="Wrap" /> + </syncfusion:ScreenTip> + </syncfusion:RibbonButton.ToolTip> + <syncfusion:RibbonButton.ContextMenu> + <ContextMenu> + <syncfusion:RibbonMenuItem + Name="CustomStampContextMenu" + Header="Custom Stamp" + ItemsSource="{Binding CustomStamps, Mode=TwoWay}" /> + <syncfusion:RibbonMenuItem Name="BrowseStamp" Header="Browse" /> + </ContextMenu> + </syncfusion:RibbonButton.ContextMenu> + </syncfusion:RibbonButton> + </syncfusion:RibbonBar> + </syncfusion:RibbonTab> + </syncfusion:Ribbon> + </Grid> + <cc:PdfViewerControl + Name="pdfviewer" + Grid.Row="1" + ItemSource="{Binding Path=FilePath}" + ShowToolbar="False" /> + </Grid> +</syncfusion:RibbonWindow> diff --git a/Toolbar/CustomToolbar/MainWindow.xaml.cs b/Toolbar/CustomToolbar/MainWindow.xaml.cs new file mode 100644 index 0000000..4386edd --- /dev/null +++ b/Toolbar/CustomToolbar/MainWindow.xaml.cs @@ -0,0 +1,26 @@ +#region Copyright Syncfusion Inc. 2001 - 2015 +// Copyright Syncfusion Inc. 2001 - 2015. All rights reserved. +// Use of this code is subject to the terms of our license. +// A copy of the current license can be obtained at any time by e-mailing +// licensing@syncfusion.com. Any infringement will be prosecuted under +// applicable laws. +#endregion +using Syncfusion.SfSkinManager; +using Syncfusion.Windows.Tools.Controls; +using System.Windows; + +namespace syncfusion.pdfviewerdemos.wpf +{ + /// <summary> + /// Interaction logic for Window1.xaml + /// </summary> + public partial class CustomToolBar : RibbonWindow + { + public CustomToolBar() + { + SfSkinManager.SetTheme(this, new Theme() { ThemeName = "Office2019Colorful" }); + InitializeComponent(); + } + + } +} \ No newline at end of file diff --git a/Toolbar/CustomToolbar/Properties/AssemblyInfo.cs b/Toolbar/CustomToolbar/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dbab445 --- /dev/null +++ b/Toolbar/CustomToolbar/Properties/AssemblyInfo.cs @@ -0,0 +1,57 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +//[assembly: AssemblyTitle("CustomToolBar")] +//[assembly: AssemblyDescription("")] +//[assembly: AssemblyConfiguration("")] +//[assembly: AssemblyCompany("")] +//[assembly: AssemblyProduct("CustomToolBar")] +//[assembly: AssemblyCopyright("Copyright © 2021")] +//[assembly: AssemblyTrademark("")] +//[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file +//inside a <PropertyGroup>. For example, if you are using US english +//in your source files, set the <UICulture> to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[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) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +//[assembly: AssemblyVersion("1.0.0.0")] +//[assembly: AssemblyFileVersion("1.0.0.0")] + + diff --git a/Toolbar/CustomToolbar/Properties/Resources.Designer.cs b/Toolbar/CustomToolbar/Properties/Resources.Designer.cs new file mode 100644 index 0000000..11087ab --- /dev/null +++ b/Toolbar/CustomToolbar/Properties/Resources.Designer.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + + +namespace CustomToolBar.Properties +{ + /// <summary> + /// A strongly-typed resource class, for looking up localized strings, etc. + /// </summary> + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// <summary> + /// Returns the cached ResourceManager instance used by this class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CustomToolBar.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// <summary> + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// </summary> + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Toolbar/CustomToolbar/Properties/Resources.resx b/Toolbar/CustomToolbar/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Toolbar/CustomToolbar/Properties/Resources.resx @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/Toolbar/CustomToolbar/Properties/Settings.Designer.cs b/Toolbar/CustomToolbar/Properties/Settings.Designer.cs new file mode 100644 index 0000000..3e1ae99 --- /dev/null +++ b/Toolbar/CustomToolbar/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// <auto-generated> +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </auto-generated> +//------------------------------------------------------------------------------ + +namespace CustomToolbar_NET.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Toolbar/CustomToolbar/Properties/Settings.settings b/Toolbar/CustomToolbar/Properties/Settings.settings new file mode 100644 index 0000000..033d7a5 --- /dev/null +++ b/Toolbar/CustomToolbar/Properties/Settings.settings @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> + <Profiles> + <Profile Name="(Default)" /> + </Profiles> + <Settings /> +</SettingsFile> \ No newline at end of file diff --git a/Toolbar/CustomToolbar/ViewModel/ViewModel.cs b/Toolbar/CustomToolbar/ViewModel/ViewModel.cs new file mode 100644 index 0000000..cdaede5 --- /dev/null +++ b/Toolbar/CustomToolbar/ViewModel/ViewModel.cs @@ -0,0 +1,653 @@ +#region Copyright Syncfusion Inc. 2001-2021. +// Copyright Syncfusion Inc. 2001-2021. All rights reserved. +// Use of this code is subject to the terms of our license. +// A copy of the current license can be obtained at any time by e-mailing +// licensing@syncfusion.com. Any infringement will be prosecuted under +// applicable laws. +#endregion +using Microsoft.Win32; +using Syncfusion.Pdf.Parsing; +using Syncfusion.Windows.PdfViewer; +using Syncfusion.Windows.Shared; +using System; +using System.Collections.Generic; +using System.IO; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Ribbon; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; + + +namespace syncfusion.pdfviewerdemos.wpf +{ + /// <summary> + /// Represents the view model class + /// </summary> + public class CustomToolbarViewModel : NotificationObject + { + #region Private Members + private String m_filePath; + private RibbonButton m_customStampButton = null; + private List<Image> m_imageList = new List<Image>(); + CustomToolBar m_customToolbarWindow = null; + private string m_fileName; + private string m_selectedItem; + private int[] zoomLevels = { 50, 75, 100, 125, 150, 200, 400 }; + #endregion + + #region Constructor + /// <summary> + /// Initializes a new instance of the <see cref="CustomToolbarViewModel"/> class. + /// </summary> + public CustomToolbarViewModel() + { +#if FRAMEWORK + m_filePath = "../../Data/F# Succinctly.pdf"; +#else + m_filePath = "../../../Data/F# Succinctly.pdf"; +#endif + } + /// <summary> + /// Opens and returns a file stream for the specified file from the Data directory, + /// </summary> + /// <param name="fileName">The name of the file to open.</param> + /// <returns>A FileStream for the specified file.</returns> + + private Stream GetFileStream(string fileName) + { +#if FRAMEWORK + FileStream stream = new FileStream("../../Data/" + fileName, FileMode.Open); +#else + FileStream stream = new FileStream("../../../Data/" + fileName, FileMode.Open); +#endif + return stream; + } + +#endregion + + #region Properties + + /// <summary> + /// Gets or sets the file path. + /// </summary> + public String FilePath + { + get + { + return m_filePath; + } + set + { + m_filePath = value; + } + } + /// <summary> + /// Gets or sets the Zoom combo box selected item. + /// </summary> + public string SelectedItem + { + get + { + return m_selectedItem; + } + set + { + if (m_selectedItem != value) + { + m_selectedItem = value; + RaisePropertyChanged("SelectedItem"); + OnItemSelect(m_selectedItem); + } + } + } + #endregion + + /// <summary> + /// Loads PDF on load and initializes controls in custom toolbar. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + public void Loaded(object sender, RoutedEventArgs e) + { + m_customToolbarWindow = (sender as CustomToolBar).FindName("ribbonwindow") as CustomToolBar; + m_customToolbarWindow.Btnopen.Click += new RoutedEventHandler(BtnOpen_Click); + UnWireEvents(); + WireUpEvents(); + InitializeStamp(); + if (m_customToolbarWindow.MyRibbon.BackStageButton != null) + m_customToolbarWindow.MyRibbon.BackStageButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.file_tab.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Navigation.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Zoom.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Size.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.find_text.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Stamp.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.pdfviewer.CurrentPageChanged += pdfviewer1_CurrentPageChanged; + + if (m_customToolbarWindow.pdfviewer.LoadedDocument == null) + { + m_customToolbarWindow.txtCurrentPageIndex.Text = "0"; + m_customToolbarWindow.FitWidth.IsEnabled = false; + m_customToolbarWindow.FitPage.IsEnabled = false; + m_customToolbarWindow.Last.IsEnabled = false; + m_customToolbarWindow.First.IsEnabled = false; + m_customToolbarWindow.Previous.IsEnabled = false; + m_customToolbarWindow.Next.IsEnabled = false; + m_customToolbarWindow.Save.IsEnabled = false; + m_customToolbarWindow.Print1.IsEnabled = false; + m_customToolbarWindow.ZoomIn.IsEnabled = false; + m_customToolbarWindow.ZoomOut.IsEnabled = false; + m_customToolbarWindow.txtCurrentPageIndex.IsEnabled = false; + m_customToolbarWindow.ZoomComboBox.IsEnabled = false; + m_customToolbarWindow.FindText.IsEnabled = false; + m_customToolbarWindow.pageSeparator.IsEnabled = false; + m_customToolbarWindow.lblTotalPageCount.IsEnabled = false; + m_customToolbarWindow.ZoomPercentage.IsEnabled = false; + m_customToolbarWindow.Stamps.IsEnabled = false; + } + else + { + m_customToolbarWindow.lblTotalPageCount.Text = m_customToolbarWindow.pdfviewer.PageCount.ToString(); + m_customToolbarWindow.ZoomComboBox.SelectedIndex = 2; + } + } + /// <summary> + /// Handles cleanup operations when the custom toolbar window is closed. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the EventArgs.</param> + public void Closed(object sender, EventArgs e) + { + m_customToolbarWindow.CustomStampContextMenu.PreviewMouseDown -= M_customStampMenu_PreviewMouseDown; + m_customToolbarWindow.BrowseStamp.Click -= CustomStampBrowse_Click; + UnWireEvents(); + m_customToolbarWindow.pdfviewer.ShowToolbar = true; + m_customToolbarWindow.pdfviewer.Unload(true); + } + + /// <summary> + /// Occurs when the window size changed. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the SizeChangedEventArgs.</param> + public void Window_SizeChanged(object sender, SizeChangedEventArgs e) + { + if (m_customToolbarWindow != null) + { + m_customToolbarWindow.MyRibbon.BackStageButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.file_tab.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Navigation.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Zoom.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Size.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.find_text.LauncherButton.Visibility = Visibility.Collapsed; + m_customToolbarWindow.Stamp.LauncherButton.Visibility = Visibility.Collapsed; + } + } + /// <summary> + /// Handles the open file dialog to load a PDF document into the viewer. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void BtnOpen_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog dialog = new OpenFileDialog(); + dialog.Filter = "Pdf Files (.pdf)|*.pdf"; + dialog.ShowDialog(); + if (!string.IsNullOrEmpty(dialog.FileName)) + { + LoadDocument(dialog.FileName); + m_customToolbarWindow.txtCurrentPageIndex.Text = "1"; + m_customToolbarWindow.ribbonwindow.Title = dialog.SafeFileName; + m_customToolbarWindow.ZoomComboBox.SelectedIndex = 2; + m_customToolbarWindow.FitWidth.IsEnabled = true; + m_customToolbarWindow.IsEnabled = true; + m_customToolbarWindow.Last.IsEnabled = true; + m_customToolbarWindow.First.IsEnabled = true; + m_customToolbarWindow.Previous.IsEnabled = true; + m_customToolbarWindow.Next.IsEnabled = true; + m_customToolbarWindow.Save.IsEnabled = true; + m_customToolbarWindow.Print1.IsEnabled = true; + m_customToolbarWindow.ZoomIn.IsEnabled = true; + m_customToolbarWindow.ZoomOut.IsEnabled = true; + m_customToolbarWindow.txtCurrentPageIndex.IsEnabled = true; + m_customToolbarWindow.ZoomComboBox.IsEnabled = true; + m_customToolbarWindow.FindText.IsEnabled = true; + m_customToolbarWindow.pageSeparator.IsEnabled = true; + m_customToolbarWindow.lblTotalPageCount.IsEnabled = true; + m_customToolbarWindow.ZoomPercentage.IsEnabled = true; + m_customToolbarWindow.Stamps.IsEnabled = true; + } + m_customToolbarWindow.pdfviewer.CurrentPageChanged += pdfviewer1_CurrentPageChanged; + } + /// <summary> + /// Saves the loaded PDF document to a user-selected location. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void Save_Click(object sender, RoutedEventArgs e) + { + if (m_customToolbarWindow.pdfviewer.LoadedDocument != null) + { + PdfLoadedDocument ldoc = m_customToolbarWindow.pdfviewer.LoadedDocument; + SaveFileDialog save = new SaveFileDialog(); + save.Filter = "PDF Files (*.pdf)|*.pdf"; + save.FileName = m_fileName; + if (save.ShowDialog() == true) + { + FileInfo saveFi = new FileInfo(save.FileName); + if (save.FileName != string.Empty) + { + + m_customToolbarWindow.pdfviewer.LoadedDocument.Save(save.FileName); + MessageBox.Show("File saved succesfully"); + } + } + } + } + /// <summary> + /// Adjusts the PDF viewer zoom level based on the selected zoom percentage + /// </summary> + /// <param name="selectedItem">The selected zoom level from the dropdown.</param> + private void OnItemSelect(string selectedItem) + { + if (selectedItem != null) + { + string[] zoomPercentage = selectedItem.ToString().Split(':'); + if (zoomPercentage.Length > 1) + { + string zoomValue = zoomPercentage[1].Trim(); + if (!string.IsNullOrEmpty(zoomValue) && m_customToolbarWindow.ZoomComboBox.IsDropDownOpen) + { + m_customToolbarWindow.pdfviewer.ZoomTo(int.Parse(zoomValue)); + m_customToolbarWindow.ZoomComboBox.Text = m_customToolbarWindow.pdfviewer.ZoomPercentage.ToString(); + m_customToolbarWindow.FitWidth.IsEnabled = true; + m_customToolbarWindow.FitPage.IsEnabled = true; + m_customToolbarWindow.ZoomOut.IsEnabled = true; + m_customToolbarWindow.ZoomIn.IsEnabled = true; + } + if (zoomValue.Equals(zoomLevels[0].ToString())) + { + m_customToolbarWindow.ZoomOut.IsEnabled = false; + m_customToolbarWindow.ZoomIn.IsEnabled = true; + } + if (zoomValue.Equals(zoomLevels[6].ToString())) + { + m_customToolbarWindow.ZoomOut.IsEnabled = true; + m_customToolbarWindow.ZoomIn.IsEnabled = false; + } + } + } + } + + /// <summary> + /// Sets the PDF viewer zoom mode to Fit Page and updates the toolbar controls accordingly. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void FitPage_Click(object sender, RoutedEventArgs e) + { + if (m_customToolbarWindow.pdfviewer.LoadedDocument != null) + { + m_customToolbarWindow.pdfviewer.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitPage; + m_customToolbarWindow.ZoomComboBox.Text= m_customToolbarWindow.pdfviewer.ZoomPercentage.ToString(); + m_customToolbarWindow.ZoomIn.IsEnabled = true; + if(m_customToolbarWindow.pdfviewer.ZoomPercentage <= m_customToolbarWindow.pdfviewer.MinimumZoomPercentage) + m_customToolbarWindow.ZoomOut.IsEnabled = false; + m_customToolbarWindow.FitWidth.IsEnabled = true; + m_customToolbarWindow.FitPage.IsEnabled = false; + } + } + /// <summary> + /// Sets the PDF viewer zoom mode to Fit Width and updates the toolbar controls accordingly. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void FitWidth_Click(object sender, RoutedEventArgs e) + { + if (m_customToolbarWindow.pdfviewer.LoadedDocument != null) + { + m_customToolbarWindow.pdfviewer.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.FitWidth; + m_customToolbarWindow.ZoomComboBox.Text = m_customToolbarWindow.pdfviewer.ZoomPercentage.ToString(); + m_customToolbarWindow.ZoomIn.IsEnabled = true; + m_customToolbarWindow.ZoomOut.IsEnabled = true; + if(m_customToolbarWindow.pdfviewer.ZoomPercentage >= m_customToolbarWindow.pdfviewer.MaximumZoomPercentage) + m_customToolbarWindow.ZoomIn.IsEnabled = false; + m_customToolbarWindow.FitWidth.IsEnabled = false; + m_customToolbarWindow.FitPage.IsEnabled = true; + } + } + /// <summary> + /// Increases the zoom level of the PDF viewer to the next predefined zoom level + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + + private void ZoomIn_Click(object sender, RoutedEventArgs e) + { + if (m_customToolbarWindow.pdfviewer.LoadedDocument != null) + { + int currentZoom = m_customToolbarWindow.pdfviewer.ZoomPercentage; + int nextZoom = -1; + int currentIndex = Array.IndexOf(zoomLevels, currentZoom); + if (currentIndex != -1) + { + if (currentIndex + 1 < zoomLevels.Length) + { + nextZoom = zoomLevels[currentIndex + 1]; + } + } + else + { + for (int i = 0; i < zoomLevels.Length; i++) + { + if (currentZoom < zoomLevels[i]) + { + nextZoom = zoomLevels[i]; + break; + } + } + } + if(nextZoom != -1) + { + m_customToolbarWindow.pdfviewer.ZoomTo(nextZoom); + m_customToolbarWindow.ZoomComboBox.Text = nextZoom.ToString(); + m_customToolbarWindow.pdfviewer.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.Default; + m_customToolbarWindow.FitWidth.IsEnabled = true; + m_customToolbarWindow.FitPage.IsEnabled = true; + if (currentZoom >= m_customToolbarWindow.pdfviewer.MinimumZoomPercentage) + m_customToolbarWindow.ZoomOut.IsEnabled = true; + } + } + } + /// <summary> + /// Decreases the zoom level of the PDF viewer to the previous predefined zoom level + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void ZoomOut_Click(object sender, RoutedEventArgs e) + { + if (m_customToolbarWindow.pdfviewer.LoadedDocument != null) + { + int currentZoom = m_customToolbarWindow.pdfviewer.ZoomPercentage; + int nextZoom = -1; + int currentIndex = Array.IndexOf(zoomLevels, currentZoom); + if (currentIndex != -1) + { + if (currentIndex - 1 >= 0) + { + nextZoom = zoomLevels[currentIndex - 1]; + } + } + else + { + for (int i = zoomLevels.Length - 1; i >= 0; i--) + { + if (currentZoom > zoomLevels[i]) + { + nextZoom = zoomLevels[i]; + break; + } + } + + } + if (nextZoom != -1) + { + m_customToolbarWindow.pdfviewer.ZoomTo(nextZoom); + m_customToolbarWindow.ZoomComboBox.Text = nextZoom.ToString(); + m_customToolbarWindow.pdfviewer.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.Default; + m_customToolbarWindow.FitWidth.IsEnabled = true; + if (currentZoom <= m_customToolbarWindow.pdfviewer.MaximumZoomPercentage) + m_customToolbarWindow.ZoomIn.IsEnabled = true; + } + } + } + /// <summary> + /// Opens the text search bar in the PDF viewer. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void FindText_Click(object sender, RoutedEventArgs e) + { + m_customToolbarWindow.pdfviewer.ShowTextSearchBar(); + } + /// <summary> + /// Opens the context menu for custom stamps in the PDF viewer. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + + private void CustomStamps_Click(object sender, RoutedEventArgs e) + { + m_customStampButton = sender as RibbonButton; + m_customStampButton.ContextMenu.IsOpen = true; + } + /// <summary> + /// Allows users to select and add image files as custom stamps in the PDF viewer. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the RoutedEventArgs.</param> + private void CustomStampBrowse_Click(object sender, RoutedEventArgs e) + { + OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); + openFileDialog.Multiselect = true; + openFileDialog.Filter = "PNG Files(*.png)|*.png|JPEG Files(*.jpeg)|*.jpeg"; + openFileDialog.Title = "Select Image File"; + if (openFileDialog.ShowDialog().Value) + { + foreach (string m_fileName in openFileDialog.FileNames) + { + string fileType = System.IO.Path.GetExtension(m_fileName); + fileType = fileType.ToLower(); + if (fileType == ".jpeg" || fileType == ".png") + { + if (m_customStampButton != null && m_customStampButton.ContextMenu != null && m_customToolbarWindow.CustomStampContextMenu != null) + m_customToolbarWindow.CustomStampContextMenu.Items.Add(GetImage(m_fileName)); + } + } + MessageBox.Show("Selected image(s) are added to the custom stamps collection.", "Message", MessageBoxButton.OK, MessageBoxImage.Information); + } + } + /// <summary> + /// Creates an Image control from the given file path. + /// </summary> + /// <param name="filePath">File path of the document </param> + private System.Windows.Controls.Image GetImage(string filePath) + { + System.Windows.Controls.Image image = new System.Windows.Controls.Image(); + image.Source = new BitmapImage(new Uri(filePath, UriKind.RelativeOrAbsolute)); + ValidateImage(image); + m_imageList.Add(image); + return image; + } + // <summary> + /// Creates an Image control from a file in the specified folder. + /// </summary> + /// <param name="filePath">File path of the document </param> + private Image GetImageFromFolder(string filePath) + { + System.Windows.Controls.Image image = new System.Windows.Controls.Image(); + BitmapImage bitmapImage = new BitmapImage(); + image.Source = bitmapImage; + bitmapImage.BeginInit(); + bitmapImage.CacheOption = BitmapCacheOption.OnLoad; + bitmapImage.StreamSource = GetFileStream(filePath); + bitmapImage.EndInit(); + ValidateImage(image); + m_imageList.Add(image); + return image; + } + /// <summary> + /// Validates and adjusts the size of the given image. + /// </summary> + /// <param name="image">The Image control to be validated and resized.</param> + + private void ValidateImage(Image image) + { + image.Margin = new Thickness(5); + if (image.Source.Width > 200f || image.Source.Height > 140f) + { + image.Stretch = Stretch.Fill; + if (image.Source.Width > image.Source.Height) + { + float widthPercentage = 200f / (float)image.Source.Width; + image.Width = image.Source.Width * widthPercentage; + image.Height = image.Source.Height * widthPercentage; + } + else + { + float heightPercentage = 140f / (float)image.Source.Height; + image.Width = image.Source.Width * heightPercentage; + image.Height = image.Source.Height * heightPercentage; + } + } + } + /// <summary> + /// Handles the selection of a custom stamp image. + /// </summary> + /// <param name="sender">The source of the event (custom stamp menu).</param> + /// <param name="e">Mouse button event arguments.</param> + + private void M_customStampMenu_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + System.Windows.Controls.Image image = e.OriginalSource as System.Windows.Controls.Image; + if (m_customToolbarWindow.pdfviewer != null && image != null) + { + m_customToolbarWindow.pdfviewer.AnnotationMode = PdfDocumentView.PdfViewerAnnotationMode.Stamp; + if (m_customToolbarWindow.pdfviewer.ToolbarSettings != null && m_customToolbarWindow.pdfviewer.ToolbarSettings.StampAnnotations != null) + { + m_customToolbarWindow.pdfviewer.ToolbarSettings.StampAnnotations.Clear(); + System.Windows.Controls.Image selectedImage = new System.Windows.Controls.Image(); + selectedImage.Source = image.Source; + if (selectedImage.Source.Width > selectedImage.Source.Height) + { + float widthPercentage = 200f / (float)selectedImage.Source.Width; + selectedImage.Width = selectedImage.Source.Width * widthPercentage; + selectedImage.Height = selectedImage.Source.Height * widthPercentage; + } + else + { + float heightPercentage = 50f / (float)selectedImage.Source.Height; + selectedImage.Width = selectedImage.Source.Width * heightPercentage; + selectedImage.Height = selectedImage.Source.Height * heightPercentage; + } + if (selectedImage != null && selectedImage.Source != null) + m_customToolbarWindow.pdfviewer.ToolbarSettings.StampAnnotations.Add(new PdfStampAnnotation(selectedImage)); + } + } + } + /// <summary> + /// Initializes custom stamp functionality by wiring event handlers for stamp selection + /// </summary> + private void InitializeStamp() + { + m_customToolbarWindow.CustomStampContextMenu.PreviewMouseDown += M_customStampMenu_PreviewMouseDown; + m_customToolbarWindow.BrowseStamp.Click += CustomStampBrowse_Click; + m_customToolbarWindow.CustomStampContextMenu.Items.Add(GetImageFromFolder("pdfviewer/Approved.png")); + } + /// <summary> + /// Loads the specified PDF document into the viewer and updates the total page count label. + /// </summary> + /// <param name="fileName">The name of the file to open.</param> + private void LoadDocument(string fileName) + { + FileInfo info = new FileInfo(fileName); + this.m_fileName = info.Name; + m_customToolbarWindow.pdfviewer.Load(fileName); + m_customToolbarWindow.lblTotalPageCount.Text = m_customToolbarWindow.pdfviewer.PageCount.ToString(); + } + /// <summary> + /// Updates the current page index display and enables or disables navigation buttons + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the EventArgs.</param> + private void pdfviewer1_CurrentPageChanged(object sender, EventArgs args) + { + m_customToolbarWindow.txtCurrentPageIndex.Text = m_customToolbarWindow.pdfviewer.CurrentPageIndex.ToString(); + if (m_customToolbarWindow.pdfviewer.CurrentPage == 1) + { + m_customToolbarWindow.First.IsEnabled = false; + m_customToolbarWindow.Previous.IsEnabled = false; + } + else + { + m_customToolbarWindow.First.IsEnabled = true; + m_customToolbarWindow.Previous.IsEnabled = true; + } + if (m_customToolbarWindow.pdfviewer.CurrentPage == m_customToolbarWindow.pdfviewer.LoadedDocument.Pages.Count) + { + m_customToolbarWindow.Last.IsEnabled = false; + m_customToolbarWindow.Next.IsEnabled = false; + } + else + { + m_customToolbarWindow.Last.IsEnabled = true; + m_customToolbarWindow.Next.IsEnabled = true; + } + } + /// <summary> + /// Handles the Enter key press in the ZoomComboBox to set the PDF viewer zoom level. + /// </summary> + /// <param name="sender">The button that triggered the event.</param> + /// <param name="e">Event data for the KeyEventArgs.</param> + private void ZoomComboBox_KeyDown(object sender, KeyEventArgs e) + { + ComboBox zoomBox = sender as ComboBox; + if (e.Key == Key.Enter) + { + string zoomEntered = zoomBox.Text; + int magnificationValue; + int.TryParse(zoomEntered, out magnificationValue); + if (magnificationValue != 0) + { + int minimumZoomPercentage = m_customToolbarWindow.pdfviewer.MinimumZoomPercentage; + int maximumZoomPercentage = m_customToolbarWindow.pdfviewer.MaximumZoomPercentage; + + if (magnificationValue < minimumZoomPercentage) + magnificationValue = minimumZoomPercentage; + if (magnificationValue > maximumZoomPercentage) + magnificationValue = maximumZoomPercentage; + if (magnificationValue > minimumZoomPercentage && !m_customToolbarWindow.ZoomOut.IsEnabled) + m_customToolbarWindow.ZoomOut.IsEnabled = true; + if (magnificationValue < maximumZoomPercentage && !m_customToolbarWindow.ZoomIn.IsEnabled) + m_customToolbarWindow.ZoomIn.IsEnabled = true; + m_customToolbarWindow.FitWidth.IsEnabled = true; + m_customToolbarWindow.FitPage.IsEnabled = true; + + m_customToolbarWindow.pdfviewer.ZoomMode = Syncfusion.Windows.PdfViewer.ZoomMode.Default; + m_customToolbarWindow.pdfviewer.ZoomTo(magnificationValue); + m_customToolbarWindow.ZoomComboBox.Text = magnificationValue.ToString(); + } + } + } + /// <summary> + /// Wires up event handlers for various UI elements in the custom toolbar, + /// </summary> + private void WireUpEvents() + { + m_customToolbarWindow.Save.Click += new RoutedEventHandler(Save_Click); + m_customToolbarWindow.FitPage.Click += new RoutedEventHandler(FitPage_Click); + m_customToolbarWindow.FitWidth.Click += new RoutedEventHandler(FitWidth_Click); + m_customToolbarWindow.FindText.Click += new RoutedEventHandler(FindText_Click); + m_customToolbarWindow.Stamps.Click += new RoutedEventHandler(CustomStamps_Click); + m_customToolbarWindow.ZoomIn.Click += new RoutedEventHandler(ZoomIn_Click); + m_customToolbarWindow.ZoomOut.Click += new RoutedEventHandler(ZoomOut_Click); + m_customToolbarWindow.ZoomComboBox.KeyDown += new KeyEventHandler(ZoomComboBox_KeyDown); + } + + /// <summary> + /// UnWire the event handlers from various UI elements in the custom toolbar + /// </summary> + private void UnWireEvents() + { + m_customToolbarWindow.Save.Click -= new RoutedEventHandler(Save_Click); + m_customToolbarWindow.FitPage.Click -= new RoutedEventHandler(FitPage_Click); + m_customToolbarWindow.FitWidth.Click -= new RoutedEventHandler(FitWidth_Click); + m_customToolbarWindow.Stamps.Click -= new RoutedEventHandler(CustomStamps_Click); + m_customToolbarWindow.ZoomIn.Click -= new RoutedEventHandler(ZoomIn_Click); + m_customToolbarWindow.ZoomOut.Click -= new RoutedEventHandler(ZoomOut_Click); + m_customToolbarWindow.ZoomComboBox.KeyDown -= new KeyEventHandler(ZoomComboBox_KeyDown); + } + } +}