Skip to content

Commit 22dda7d

Browse files
committed
899019 - Added sample to show custom password dialog box
1 parent 1051165 commit 22dda7d

21 files changed

+1091
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>CustomPassswordDialog</RootNamespace>
10+
<AssemblyName>CustomPassswordDialog</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
<TargetFrameworkProfile />
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="PresentationCore" />
38+
<Reference Include="PresentationFramework" />
39+
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
40+
<Reference Include="System" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Xaml" />
43+
<Reference Include="System.Xml.Linq" />
44+
<Reference Include="System.Data.DataSetExtensions" />
45+
<Reference Include="Microsoft.CSharp" />
46+
<Reference Include="System.Data" />
47+
<Reference Include="System.Deployment" />
48+
<Reference Include="System.Drawing" />
49+
<Reference Include="System.Net.Http" />
50+
<Reference Include="System.Windows.Forms" />
51+
<Reference Include="System.Xml" />
52+
<Reference Include="WindowsBase" />
53+
<Reference Include="WindowsFormsIntegration" />
54+
</ItemGroup>
55+
<ItemGroup>
56+
<Compile Include="Form1.cs">
57+
<SubType>Form</SubType>
58+
</Compile>
59+
<Compile Include="Form1.Designer.cs">
60+
<DependentUpon>Form1.cs</DependentUpon>
61+
</Compile>
62+
<Compile Include="passwordBox.cs">
63+
<SubType>Form</SubType>
64+
</Compile>
65+
<Compile Include="passwordBox.Designer.cs">
66+
<DependentUpon>passwordBox.cs</DependentUpon>
67+
</Compile>
68+
<Compile Include="Program.cs" />
69+
<Compile Include="Properties\AssemblyInfo.cs" />
70+
<Compile Include="WPFuserControl.xaml.cs">
71+
<DependentUpon>WPFuserControl.xaml</DependentUpon>
72+
</Compile>
73+
<EmbeddedResource Include="Form1.resx">
74+
<DependentUpon>Form1.cs</DependentUpon>
75+
</EmbeddedResource>
76+
<EmbeddedResource Include="passwordBox.resx">
77+
<DependentUpon>passwordBox.cs</DependentUpon>
78+
</EmbeddedResource>
79+
<EmbeddedResource Include="Properties\Resources.resx">
80+
<Generator>ResXFileCodeGenerator</Generator>
81+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
82+
<SubType>Designer</SubType>
83+
</EmbeddedResource>
84+
<Compile Include="Properties\Resources.Designer.cs">
85+
<AutoGen>True</AutoGen>
86+
<DependentUpon>Resources.resx</DependentUpon>
87+
<DesignTime>True</DesignTime>
88+
</Compile>
89+
<None Include="packages.config" />
90+
<None Include="Properties\Settings.settings">
91+
<Generator>SettingsSingleFileGenerator</Generator>
92+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
93+
</None>
94+
<Compile Include="Properties\Settings.Designer.cs">
95+
<AutoGen>True</AutoGen>
96+
<DependentUpon>Settings.settings</DependentUpon>
97+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
98+
</Compile>
99+
</ItemGroup>
100+
<ItemGroup>
101+
<None Include="App.config" />
102+
</ItemGroup>
103+
<ItemGroup>
104+
<Page Include="WPFuserControl.xaml">
105+
<SubType>Designer</SubType>
106+
<Generator>MSBuild:Compile</Generator>
107+
</Page>
108+
</ItemGroup>
109+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
110+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomPassswordDialog", "CustomPassswordDialog.csproj", "{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net8.0-windows</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<UseWPF>true</UseWPF>
8+
<UseWindowsForms>true</UseWindowsForms>
9+
<ImplicitUsings>enable</ImplicitUsings>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Syncfusion.PdfViewer.WPF" Version="*" />
14+
</ItemGroup>
15+
16+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
<ItemGroup>
5+
<Compile Update="Form1.cs">
6+
<SubType>Form</SubType>
7+
</Compile>
8+
<Compile Update="passwordBox.cs">
9+
<SubType>Form</SubType>
10+
</Compile>
11+
</ItemGroup>
12+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35707.178 d17.12
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomPassswordDialog_NET", "CustomPassswordDialog_NET.csproj", "{2782E349-BEF7-4485-A7D4-60DAEDBF53ED}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.Designer.cs

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
using Syncfusion.Windows.PdfViewer;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.ComponentModel;
5+
using System.Data;
6+
using System.Drawing;
7+
using System.IO;
8+
using System.Linq;
9+
using System.Text;
10+
using System.Threading.Tasks;
11+
using System.Windows.Forms;
12+
using System.Windows.Forms.Integration;
13+
14+
namespace CustomPassswordDialog
15+
{
16+
public partial class Form1 : Form
17+
{
18+
ElementHost elementHost;
19+
WPFuserControl userControl;
20+
public static string PreLoadPdf;
21+
public Form1()
22+
{
23+
InitializeComponent();
24+
this.Load += Form1_Load;
25+
}
26+
27+
private void Form1_Load(object sender, EventArgs e)
28+
{
29+
30+
elementHost = new ElementHost();
31+
{
32+
elementHost.AutoSize = true;
33+
elementHost.Dock = DockStyle.Fill;
34+
elementHost.Margin = new Padding(0, 0, 0, 0);
35+
elementHost.Region = new Region();
36+
elementHost.BackColor = Color.White;
37+
}
38+
this.WindowState = FormWindowState.Maximized;
39+
}
40+
41+
private void CreatePdf()
42+
{
43+
userControl = new WPFuserControl();
44+
elementHost.Child = userControl;
45+
46+
userControl.pdfViewer.IsBookmarkEnabled = false;
47+
userControl.pdfViewer.ToolbarSettings.ShowFileTools = true;
48+
userControl.pdfViewer.ToolbarSettings.ShowPageNavigationTools = true;
49+
userControl.pdfViewer.ToolbarSettings.ShowAnnotationTools = false;
50+
userControl.pdfViewer.ToolbarSettings.ShowZoomTools = true;
51+
userControl.pdfViewer.ThumbnailSettings.IsVisible = false;
52+
userControl.pdfViewer.EnableRedactionTool = false;
53+
userControl.pdfViewer.PageOrganizerSettings.IsIconVisible = false;
54+
userControl.pdfViewer.EnableLayers = false;
55+
userControl.pdfViewer.EnableRedactionTool = false;
56+
userControl.pdfViewer.FormSettings.IsIconVisible = false;
57+
userControl.pdfViewer.CursorMode = PdfViewerCursorMode.SelectTool;
58+
userControl.pdfViewer.EnableNotificationBar = false;
59+
userControl.pdfViewer.ShowToolbar = true;
60+
61+
userControl.pdfViewer.ZoomMode = ZoomMode.FitWidth;
62+
splitContainer1.Panel2.Controls.Clear();
63+
splitContainer1.Panel2.Controls.Add(elementHost);
64+
}
65+
66+
private void getPDF()
67+
{
68+
try
69+
{
70+
var OFD = new OpenFileDialog()
71+
{
72+
DefaultExt = "pdf",
73+
Filter = "Pdf files|*.pdf",
74+
Title = "Search a PDF",
75+
FilterIndex = 1,
76+
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
77+
};
78+
if (OFD.ShowDialog() == DialogResult.OK && File.Exists(OFD.FileName))
79+
{
80+
PreLoadPdf = OFD.FileName;
81+
82+
userControl.pdfViewer.ReferencePath = Application.StartupPath;
83+
userControl.pdfViewer.Load(PreLoadPdf);
84+
}
85+
}
86+
catch(System.Exception ex)
87+
{
88+
Console.WriteLine("Unexpected error"+ ex.Message);
89+
}
90+
}
91+
92+
private void Open_Click(object sender, EventArgs e)
93+
{
94+
CreatePdf();
95+
getPDF();
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)