当前位置: 首页>>代码示例>>C#>>正文


C# MaskedTextBox.ResumeLayout方法代码示例

本文整理汇总了C#中System.Windows.Forms.MaskedTextBox.ResumeLayout方法的典型用法代码示例。如果您正苦于以下问题:C# MaskedTextBox.ResumeLayout方法的具体用法?C# MaskedTextBox.ResumeLayout怎么用?C# MaskedTextBox.ResumeLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.MaskedTextBox的用法示例。


在下文中一共展示了MaskedTextBox.ResumeLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Password

        /// <summary>
        /// force means ignore any cache and require the user to enter a password
        /// </summary>
        /// <param name="prompt"></param>
        /// <param name="force"></param>
        /// <returns></returns>
        public static string Password(string prompt, bool requireEntry)
        {
            string passwordFileName;
            if (!string.IsNullOrWhiteSpace(prompt))
            {
                if (ProcessFunctions.KeplerProcess != null)
                {
                    passwordFileName = SwishFunctions.GeneratePasswordFileName(prompt, ProcessFunctions.KeplerProcess);
                    passwordFileName = Path.Combine(Path.GetTempPath(), passwordFileName);

                    if (!requireEntry && FileFunctions.FileExists(passwordFileName))
                    {
                        string _encodedPassword = File.ReadAllText(passwordFileName);
                        string _password = SwishFunctions.DecodePassword(_encodedPassword, ProcessFunctions.KeplerProcess);
                        return _password;
                    }
                } else
                {
                    passwordFileName = string.Empty;
                }
            } else
            {
                prompt = "Please enter password";
                passwordFileName = string.Empty;
            }

            string password;

            using (MaskedTextBox textBox = new MaskedTextBox())
            using (Panel panel = new Panel())
            using (Button buton = new Button())
            using (Form form = new Form())
            {
                textBox.SuspendLayout();
                buton.SuspendLayout();
                panel.SuspendLayout();
                form.SuspendLayout();

                textBox.UseSystemPasswordChar = true;
                textBox.Multiline = true;
                textBox.SelectionStart = 0;
                textBox.SelectionLength = 0;
                textBox.Size = new Size(300, textBox.Height);
                textBox.Dock = DockStyle.Top;
                textBox.Font = new Font(textBox.Font, FontStyle.Bold);
                textBox.TabIndex = 0;

                buton.Click += new EventHandler(buton_Click);
                buton.Dock = DockStyle.Left;
                buton.Text = "Ok";
                buton.Size = new Size(75, 23);
                buton.TabIndex = 0;

                panel.Height = 23;
                panel.Controls.Add(buton);
                panel.Dock = DockStyle.Fill;
                panel.TabIndex = 1;

                form.ControlBox = false;
                form.Text = prompt;
                form.ClientSize = new Size(300, 43);
                form.Controls.Add(panel);
                form.Controls.Add(textBox);
                form.AcceptButton = buton;

                textBox.ResumeLayout();
                buton.ResumeLayout();
                panel.ResumeLayout();
                form.ResumeLayout();

                textBox.Focus();
                form.ShowDialog();

                password = textBox.Text;
            }

            if (string.IsNullOrWhiteSpace(password))
            {
                return string.Empty;
            }

            if (string.IsNullOrWhiteSpace(passwordFileName))
            {
                return password;
            }

            string encodedPassword = SwishFunctions.EncodePassword(password, ProcessFunctions.KeplerProcess);
            if (File.Exists(passwordFileName))
            {
                FileFunctions.DeleteFile(passwordFileName, null);
            }
            File.WriteAllText(passwordFileName, encodedPassword);

            return password;
//.........这里部分代码省略.........
开发者ID:swish-climate-impact-assessment,项目名称:swish-kepler-actors,代码行数:101,代码来源:AdapterFunctions.cs


注:本文中的System.Windows.Forms.MaskedTextBox.ResumeLayout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。