home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / vbasic / Data / Utils / XZipNet.msi / Data1.cab / Password.cs < prev    next >
Encoding:
Text File  |  2002-02-04  |  6.6 KB  |  186 lines

  1. /*
  2.  * Xceed Zip for .NET - MiniExplorer Sample Application
  3.  * Copyright (c) 2000-2002 - Xceed Software Inc.
  4.  * 
  5.  * [Password.cs]
  6.  * 
  7.  * This application demonstrates how to use the Xceed FileSystem object model
  8.  * in a generic way.
  9.  * 
  10.  * This file is part of Xceed Zip for .NET. The source code in this file 
  11.  * is only intended as a supplement to the documentation, and is provided 
  12.  * "as is", without warranty of any kind, either expressed or implied.
  13.  */
  14.  
  15. using System;
  16. using System.Drawing;
  17. using System.Collections;
  18. using System.ComponentModel;
  19. using System.Windows.Forms;
  20.  
  21. namespace Xceed.FileSystem.Samples.MiniExplorer
  22. {
  23.     /// <summary>
  24.     /// Summary description for Password.
  25.     /// </summary>
  26.     public class PasswordForm : System.Windows.Forms.Form
  27.     {
  28.     private System.Windows.Forms.Label label1;
  29.     private System.Windows.Forms.Label FilenameLabel;
  30.     private System.Windows.Forms.Label label3;
  31.     private System.Windows.Forms.TextBox PasswordText;
  32.     private System.Windows.Forms.CheckBox HideCheckBox;
  33.     private System.Windows.Forms.Button OKPushButton;
  34.     private System.Windows.Forms.Button CancelPushButton;
  35.         /// <summary>
  36.         /// Required designer variable.
  37.         /// </summary>
  38.         private System.ComponentModel.Container components = null;
  39.  
  40.         public PasswordForm()
  41.         {
  42.             //
  43.             // Required for Windows Form Designer support
  44.             //
  45.             InitializeComponent();
  46.         }
  47.  
  48.  
  49.     public DialogResult ShowDialog( IWin32Window owner, string filename, ref string password )
  50.     {
  51.       FilenameLabel.Text = filename;
  52.       PasswordText.Text = password;
  53.       HideCheckBox.Checked = true;
  54.  
  55.       this.DialogResult = DialogResult.Cancel;
  56.  
  57.       if( base.ShowDialog( owner ) == DialogResult.OK )
  58.       {
  59.         password = PasswordText.Text;
  60.         return DialogResult.OK;
  61.       }
  62.  
  63.       return DialogResult.Cancel;
  64.     }
  65.  
  66.         /// <summary>
  67.         /// Clean up any resources being used.
  68.         /// </summary>
  69.         protected override void Dispose( bool disposing )
  70.         {
  71.             if( disposing )
  72.             {
  73.                 if(components != null)
  74.                 {
  75.                     components.Dispose();
  76.                 }
  77.             }
  78.             base.Dispose( disposing );
  79.         }
  80.  
  81.         #region Windows Form Designer generated code
  82.         /// <summary>
  83.         /// Required method for Designer support - do not modify
  84.         /// the contents of this method with the code editor.
  85.         /// </summary>
  86.         private void InitializeComponent()
  87.         {
  88.       this.OKPushButton = new System.Windows.Forms.Button();
  89.       this.CancelPushButton = new System.Windows.Forms.Button();
  90.       this.label1 = new System.Windows.Forms.Label();
  91.       this.FilenameLabel = new System.Windows.Forms.Label();
  92.       this.label3 = new System.Windows.Forms.Label();
  93.       this.PasswordText = new System.Windows.Forms.TextBox();
  94.       this.HideCheckBox = new System.Windows.Forms.CheckBox();
  95.       this.SuspendLayout();
  96.       // 
  97.       // OKPushButton
  98.       // 
  99.       this.OKPushButton.DialogResult = System.Windows.Forms.DialogResult.OK;
  100.       this.OKPushButton.Location = new System.Drawing.Point(200, 112);
  101.       this.OKPushButton.Name = "OKPushButton";
  102.       this.OKPushButton.TabIndex = 5;
  103.       this.OKPushButton.Text = "&OK";
  104.       // 
  105.       // CancelPushButton
  106.       // 
  107.       this.CancelPushButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
  108.       this.CancelPushButton.Location = new System.Drawing.Point(280, 112);
  109.       this.CancelPushButton.Name = "CancelPushButton";
  110.       this.CancelPushButton.TabIndex = 6;
  111.       this.CancelPushButton.Text = "&Cancel";
  112.       // 
  113.       // label1
  114.       // 
  115.       this.label1.Location = new System.Drawing.Point(8, 8);
  116.       this.label1.Name = "label1";
  117.       this.label1.Size = new System.Drawing.Size(192, 16);
  118.       this.label1.TabIndex = 0;
  119.       this.label1.Text = "Decryption password required for file:";
  120.       // 
  121.       // FilenameLabel
  122.       // 
  123.       this.FilenameLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  124.       this.FilenameLabel.Location = new System.Drawing.Point(8, 24);
  125.       this.FilenameLabel.Name = "FilenameLabel";
  126.       this.FilenameLabel.Size = new System.Drawing.Size(352, 16);
  127.       this.FilenameLabel.TabIndex = 1;
  128.       this.FilenameLabel.Text = "label2";
  129.       // 
  130.       // label3
  131.       // 
  132.       this.label3.Location = new System.Drawing.Point(8, 56);
  133.       this.label3.Name = "label3";
  134.       this.label3.Size = new System.Drawing.Size(240, 16);
  135.       this.label3.TabIndex = 2;
  136.       this.label3.Text = "Please provide a valid decryption password:";
  137.       // 
  138.       // PasswordText
  139.       // 
  140.       this.PasswordText.Location = new System.Drawing.Point(8, 72);
  141.       this.PasswordText.Name = "PasswordText";
  142.       this.PasswordText.Size = new System.Drawing.Size(352, 20);
  143.       this.PasswordText.TabIndex = 3;
  144.       this.PasswordText.Text = "";
  145.       // 
  146.       // HideCheckBox
  147.       // 
  148.       this.HideCheckBox.Location = new System.Drawing.Point(8, 96);
  149.       this.HideCheckBox.Name = "HideCheckBox";
  150.       this.HideCheckBox.Size = new System.Drawing.Size(136, 16);
  151.       this.HideCheckBox.TabIndex = 4;
  152.       this.HideCheckBox.Text = "Hide password chars";
  153.       this.HideCheckBox.CheckedChanged += new System.EventHandler(this.HideCheckBox_CheckedChanged);
  154.       // 
  155.       // PasswordForm
  156.       // 
  157.       this.AcceptButton = this.OKPushButton;
  158.       this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  159.       this.CancelButton = this.CancelPushButton;
  160.       this.ClientSize = new System.Drawing.Size(368, 143);
  161.       this.Controls.AddRange(new System.Windows.Forms.Control[] {
  162.                                                                   this.HideCheckBox,
  163.                                                                   this.PasswordText,
  164.                                                                   this.label3,
  165.                                                                   this.FilenameLabel,
  166.                                                                   this.label1,
  167.                                                                   this.CancelPushButton,
  168.                                                                   this.OKPushButton});
  169.       this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  170.       this.MaximizeBox = false;
  171.       this.MinimizeBox = false;
  172.       this.Name = "PasswordForm";
  173.       this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
  174.       this.Text = "Password";
  175.       this.ResumeLayout(false);
  176.  
  177.     }
  178.         #endregion
  179.  
  180.     private void HideCheckBox_CheckedChanged(object sender, System.EventArgs e)
  181.     {
  182.       PasswordText.PasswordChar = ( HideCheckBox.Checked ? '*' : '\0' );
  183.     }
  184.     }
  185. }
  186.