本文整理汇总了C#中System.Windows.Forms.MaskedTextBox.SuspendLayout方法的典型用法代码示例。如果您正苦于以下问题:C# MaskedTextBox.SuspendLayout方法的具体用法?C# MaskedTextBox.SuspendLayout怎么用?C# MaskedTextBox.SuspendLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MaskedTextBox
的用法示例。
在下文中一共展示了MaskedTextBox.SuspendLayout方法的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;
//.........这里部分代码省略.........