diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/App.config b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog.csproj b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog.csproj new file mode 100644 index 0000000..c70da03 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44} + WinExe + CustomPassswordDialog + CustomPassswordDialog + v4.8 + 512 + true + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + Form + + + passwordBox.cs + + + + + WPFuserControl.xaml + + + Form1.cs + + + passwordBox.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + Designer + MSBuild:Compile + + + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog.sln b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog.sln new file mode 100644 index 0000000..23d4c89 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomPassswordDialog", "CustomPassswordDialog.csproj", "{9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9E7928EB-CF2C-4D27-9E26-C4FACD2B2D44}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.csproj b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.csproj new file mode 100644 index 0000000..83cb700 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + enable + true + true + enable + + + + + + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.csproj.user b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.csproj.user new file mode 100644 index 0000000..76617a3 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.csproj.user @@ -0,0 +1,12 @@ + + + + + + Form + + + Form + + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.sln b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.sln new file mode 100644 index 0000000..9337e46 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/CustomPassswordDialog_NET.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35707.178 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomPassswordDialog_NET", "CustomPassswordDialog_NET.csproj", "{2782E349-BEF7-4485-A7D4-60DAEDBF53ED}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2782E349-BEF7-4485-A7D4-60DAEDBF53ED}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.Designer.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.Designer.cs new file mode 100644 index 0000000..ec37a36 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.Designer.cs @@ -0,0 +1,83 @@ +namespace CustomPassswordDialog +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.Open = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 0); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.Open); + this.splitContainer1.Size = new System.Drawing.Size(800, 450); + this.splitContainer1.SplitterDistance = 44; + this.splitContainer1.TabIndex = 0; + // + // Open + // + this.Open.Location = new System.Drawing.Point(12, 12); + this.Open.Name = "Open"; + this.Open.Size = new System.Drawing.Size(133, 69); + this.Open.TabIndex = 0; + this.Open.Text = "OpenPDF"; + this.Open.UseVisualStyleBackColor = true; + this.Open.Click += new System.EventHandler(this.Open_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.splitContainer1); + this.Name = "Form1"; + this.Text = "Form1"; + this.splitContainer1.Panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.Button Open; + } +} + diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.cs new file mode 100644 index 0000000..4b5b1d8 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.cs @@ -0,0 +1,98 @@ +using Syncfusion.Windows.PdfViewer; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Windows.Forms.Integration; + +namespace CustomPassswordDialog +{ + public partial class Form1 : Form + { + ElementHost elementHost; + WPFuserControl userControl; + public static string PreLoadPdf; + public Form1() + { + InitializeComponent(); + this.Load += Form1_Load; + } + + private void Form1_Load(object sender, EventArgs e) + { + + elementHost = new ElementHost(); + { + elementHost.AutoSize = true; + elementHost.Dock = DockStyle.Fill; + elementHost.Margin = new Padding(0, 0, 0, 0); + elementHost.Region = new Region(); + elementHost.BackColor = Color.White; + } + this.WindowState = FormWindowState.Maximized; + } + + private void CreatePdf() + { + userControl = new WPFuserControl(); + elementHost.Child = userControl; + + userControl.pdfViewer.IsBookmarkEnabled = false; + userControl.pdfViewer.ToolbarSettings.ShowFileTools = true; + userControl.pdfViewer.ToolbarSettings.ShowPageNavigationTools = true; + userControl.pdfViewer.ToolbarSettings.ShowAnnotationTools = false; + userControl.pdfViewer.ToolbarSettings.ShowZoomTools = true; + userControl.pdfViewer.ThumbnailSettings.IsVisible = false; + userControl.pdfViewer.EnableRedactionTool = false; + userControl.pdfViewer.PageOrganizerSettings.IsIconVisible = false; + userControl.pdfViewer.EnableLayers = false; + userControl.pdfViewer.EnableRedactionTool = false; + userControl.pdfViewer.FormSettings.IsIconVisible = false; + userControl.pdfViewer.CursorMode = PdfViewerCursorMode.SelectTool; + userControl.pdfViewer.EnableNotificationBar = false; + userControl.pdfViewer.ShowToolbar = true; + + userControl.pdfViewer.ZoomMode = ZoomMode.FitWidth; + splitContainer1.Panel2.Controls.Clear(); + splitContainer1.Panel2.Controls.Add(elementHost); + } + + private void getPDF() + { + try + { + var OFD = new OpenFileDialog() + { + DefaultExt = "pdf", + Filter = "Pdf files|*.pdf", + Title = "Search a PDF", + FilterIndex = 1, + InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop), + }; + if (OFD.ShowDialog() == DialogResult.OK && File.Exists(OFD.FileName)) + { + PreLoadPdf = OFD.FileName; + + userControl.pdfViewer.ReferencePath = Application.StartupPath; + userControl.pdfViewer.Load(PreLoadPdf); + } + } + catch(System.Exception ex) + { + Console.WriteLine("Unexpected error"+ ex.Message); + } + } + + private void Open_Click(object sender, EventArgs e) + { + CreatePdf(); + getPDF(); + } + } +} diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.resx b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Program.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Program.cs new file mode 100644 index 0000000..44d064b --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CustomPassswordDialog +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/AssemblyInfo.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..736ed27 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/AssemblyInfo.cs @@ -0,0 +1,27 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 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: AssemblyDescription("")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[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)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9e7928eb-cf2c-4d27-9e26-c4facd2b2d44")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Resources.Designer.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Resources.Designer.cs new file mode 100644 index 0000000..24fcdd8 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace CustomPassswordDialog.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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", "17.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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CustomPassswordDialog.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [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/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Resources.resx b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Settings.Designer.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Settings.Designer.cs new file mode 100644 index 0000000..81187f3 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace CustomPassswordDialog.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/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Settings.settings b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/WPFuserControl.xaml b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/WPFuserControl.xaml new file mode 100644 index 0000000..12e3a51 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/WPFuserControl.xaml @@ -0,0 +1,15 @@ + + + + + diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/WPFuserControl.xaml.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/WPFuserControl.xaml.cs new file mode 100644 index 0000000..1f7e2e0 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/WPFuserControl.xaml.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security; +using System.Text; +using System.Threading.Tasks; +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; +using UserControl = System.Windows.Controls.UserControl; + +namespace CustomPassswordDialog +{ + /// + /// Interaction logic for WPFuserControl.xaml + /// + public partial class WPFuserControl : UserControl + { + private passwordBox passwordDialogBox; + public WPFuserControl() + { + InitializeComponent(); + } + + private void pdfViewer_GetDocumentPassword(object sender, Syncfusion.Windows.PdfViewer.GetDocumentPasswordEventArgs e) + { + passwordDialogBox = new passwordBox(); + passwordDialogBox.ShowDialog(); + if(passwordDialogBox.DialogResult == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(passwordDialogBox.password)) + { + SecureString secureString = ConvertToSecureString(passwordDialogBox.password); + e.Password = secureString; + } + e.Handled = true; + } + + private SecureString ConvertToSecureString( string secureString) + { + SecureString passsword = new SecureString(); + foreach(char c in secureString) + { + passsword.AppendChar(c); + } + passsword.MakeReadOnly(); + return passsword; + } + + private void pdfViewer_ErrorOccurred(object sender, Syncfusion.Windows.PdfViewer.ErrorOccurredEventArgs args) + { + if(passwordDialogBox.DialogResult == System.Windows.Forms.DialogResult.OK && args.Message == "Can't open an encrypted document. The password is invalid.") + { + System.Windows.Forms.MessageBox.Show(args.Message); + pdfViewer.Load(Form1.PreLoadPdf); + } + } + } +} diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/packages.config b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/packages.config new file mode 100644 index 0000000..d6e73f2 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.Designer.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.Designer.cs new file mode 100644 index 0000000..c7047b5 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.Designer.cs @@ -0,0 +1,97 @@ +namespace CustomPassswordDialog +{ + partial class passwordBox + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.PasswordTextBox = new System.Windows.Forms.TextBox(); + this.Ok_Button = new System.Windows.Forms.Button(); + this.Cancel_button = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(35, 47); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 16); + this.label1.TabIndex = 0; + this.label1.Text = "Enter password"; + // + // PasswordTextBox + // + this.PasswordTextBox.Location = new System.Drawing.Point(176, 47); + this.PasswordTextBox.Name = "PasswordTextBox"; + this.PasswordTextBox.Size = new System.Drawing.Size(177, 22); + this.PasswordTextBox.TabIndex = 1; + this.PasswordTextBox.UseSystemPasswordChar = true; + // + // Ok_Button + // + this.Ok_Button.Location = new System.Drawing.Point(330, 200); + this.Ok_Button.Name = "Ok_Button"; + this.Ok_Button.Size = new System.Drawing.Size(110, 31); + this.Ok_Button.TabIndex = 2; + this.Ok_Button.Text = "OK"; + this.Ok_Button.UseVisualStyleBackColor = true; + this.Ok_Button.Click += new System.EventHandler(this.Ok_Button_Click); + // + // Cancel_button + // + this.Cancel_button.Location = new System.Drawing.Point(450,200); + this.Cancel_button.Name = "Cancel_button"; + this.Cancel_button.Size = new System.Drawing.Size(105, 31); + this.Cancel_button.TabIndex = 3; + this.Cancel_button.Text = "Cancel"; + this.Cancel_button.UseVisualStyleBackColor = true; + this.Cancel_button.Click += new System.EventHandler(this.Cancel_button_Click); + // + // passwordBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(600, 250); + this.Controls.Add(this.Cancel_button); + this.Controls.Add(this.Ok_Button); + this.Controls.Add(this.PasswordTextBox); + this.Controls.Add(this.label1); + this.Name = "passwordBox"; + this.Text = "passwordBox"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox PasswordTextBox; + private System.Windows.Forms.Button Ok_Button; + private System.Windows.Forms.Button Cancel_button; + } +} \ No newline at end of file diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.cs b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.cs new file mode 100644 index 0000000..05620fc --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CustomPassswordDialog +{ + public partial class passwordBox : Form + { + public string password; + public passwordBox() + { + InitializeComponent(); + password = string.Empty; + PasswordTextBox.Text = string.Empty; + } + + private void Ok_Button_Click(object sender, EventArgs e) + { + password = PasswordTextBox.Text; + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void Cancel_button_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + } +} diff --git a/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.resx b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/How-to/Show-Custom-Password-Dialog/CustomPassswordDialog/passwordBox.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file