⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btpassworddlg.cs

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 CS
字号:
//Filename    : BTPasswordDlg.cs
//Part of     : Phone Navigator C# example
//Description : Dialog for asking passkey for Bluetooth devices
//Version     : 3.2
//
//This example is only to be used with PC Connectivity API version 3.2.
//Compability ("as is") with future versions is not quaranteed.
//
//Copyright (c) 2005-2207 Nokia Corporation.
//
//This material, including but not limited to documentation and any related
//computer programs, is protected by intellectual property rights of Nokia
//Corporation and/or its licensors.
//All rights are reserved. Reproducing, modifying, translating, or
//distributing any or all of this material requires the prior written consent
//of Nokia Corporation. Nokia Corporation retains the right to make changes
//to this material at any time without notice. A copyright license is hereby
//granted to download and print a copy of this material for personal use only.
//No other license to any other intellectual property rights is granted. The
//material is provided "as is" without warranty of any kind, either express or
//implied, including without limitation, any warranty of non-infringement,
//merchantability and fitness for a particular purpose. In no event shall
//Nokia Corporation be liable for any direct, indirect, special, incidental,
//or consequential loss or damages, including but not limited to, lost profits
//or revenue,loss of use, cost of substitute program, or loss of data or
//equipment arising out of the use or inability to use the material, even if
//Nokia Corporation has been advised of the likelihood of such damages occurring.
using System.Windows.Forms;
namespace CSPhoneNavigator.NET
{
    public class FRM_Password : System.Windows.Forms.Form
    {

        #region " Windows Form Designer generated code "

        public FRM_Password()
            : base()
        {

            //This call is required by the Windows Form Designer.
            InitializeComponent();

            //Add any initialization after the InitializeComponent() call

        }

        //Form overrides dispose to clean up the component list.
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if ((components != null))
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        //Required by the Windows Form Designer
        private System.ComponentModel.IContainer components;

        //NOTE: The following procedure is required by the Windows Form Designer
        //It can be modified using the Windows Form Designer.  
        //Do not modify it using the code editor.
        internal System.Windows.Forms.Button BTN_Cancel;
        internal System.Windows.Forms.Button BTN_OK;
        internal System.Windows.Forms.Label LBL_Password;
        internal System.Windows.Forms.TextBox TXB_Password;
        [System.Diagnostics.DebuggerStepThrough()]
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FRM_Password));
            this.LBL_Password = new System.Windows.Forms.Label();
            this.TXB_Password = new System.Windows.Forms.TextBox();
            this.BTN_Cancel = new System.Windows.Forms.Button();
            this.BTN_OK = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // LBL_Password
            // 
            this.LBL_Password.Location = new System.Drawing.Point(8, 64);
            this.LBL_Password.Name = "LBL_Password";
            this.LBL_Password.Size = new System.Drawing.Size(128, 16);
            this.LBL_Password.TabIndex = 11;
            this.LBL_Password.Text = "Bluetooth passkey:";
            // 
            // TXB_Password
            // 
            this.TXB_Password.Location = new System.Drawing.Point(8, 88);
            this.TXB_Password.Name = "TXB_Password";
            this.TXB_Password.Size = new System.Drawing.Size(296, 20);
            this.TXB_Password.TabIndex = 8;
            this.TXB_Password.Text = "123";
            this.TXB_Password.TextChanged += new System.EventHandler(this.TXB_Password_TextChanged);
            // 
            // BTN_Cancel
            // 
            this.BTN_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.BTN_Cancel.Location = new System.Drawing.Point(232, 48);
            this.BTN_Cancel.Name = "BTN_Cancel";
            this.BTN_Cancel.Size = new System.Drawing.Size(72, 32);
            this.BTN_Cancel.TabIndex = 10;
            this.BTN_Cancel.Text = "Cancel";
            this.BTN_Cancel.Click += new System.EventHandler(this.BTN_Cancel_Click);
            // 
            // BTN_OK
            // 
            this.BTN_OK.Location = new System.Drawing.Point(232, 8);
            this.BTN_OK.Name = "BTN_OK";
            this.BTN_OK.Size = new System.Drawing.Size(72, 32);
            this.BTN_OK.TabIndex = 9;
            this.BTN_OK.Text = "OK";
            this.BTN_OK.Click += new System.EventHandler(this.BTN_OK_Click);
            // 
            // FRM_Password
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(312, 118);
            this.Controls.Add(this.LBL_Password);
            this.Controls.Add(this.TXB_Password);
            this.Controls.Add(this.BTN_Cancel);
            this.Controls.Add(this.BTN_OK);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "FRM_Password";
            this.Text = "Bluetooth Passkey";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private void BTN_OK_Click(object sender, System.EventArgs e)
        {
            if (TXB_Password.Text.Length <= 0)
            {
                MessageBox.Show("Empty passkey not allowed");
            }
            else
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }

        private void BTN_Cancel_Click(object sender, System.EventArgs e)
        {
            this.Close();
        }
        private bool IsNumeric(string strText)
        {
            return false;
        }

        private void TXB_Password_TextChanged(object sender, System.EventArgs e)
        {
            if (TXB_Password.Text.Length > 0 & !IsNumeric(TXB_Password.Text))
            {
                MessageBox.Show("Passkey can contain only numbers");
                int i;
                string strOut = "";
                for (i = 0; i < TXB_Password.Text.Length; i++)
                {
                    if (IsNumeric(TXB_Password.Text.Substring(i, 1)))
                    {
                        strOut += TXB_Password.Text.Substring(i, 1);
                    }
                }
                TXB_Password.Text = strOut;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -