本文整理汇总了C#中System.Windows.Forms.Button.PerformLayout方法的典型用法代码示例。如果您正苦于以下问题:C# Button.PerformLayout方法的具体用法?C# Button.PerformLayout怎么用?C# Button.PerformLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Button
的用法示例。
在下文中一共展示了Button.PerformLayout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceMissingFiles
//.........这里部分代码省略.........
{
MessageBox.Show(
null,
"Paint.NET has detected that some important installation files are missing. Repairing " +
"this requires administrator privilege. Please run the 'PdnRepair.exe' program in the installation " +
"directory after logging in with a user that has administrator privilege." + Environment.NewLine +
Environment.NewLine +
"The missing files are: " + missingFilesSB.ToString(),
"Paint.NET",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
return false;
}
const int hMargin = 8;
const int vMargin = 8;
Form form = new Form();
form.Text = "Paint.NET";
form.ClientSize = new Size(400, 10);
form.StartPosition = FormStartPosition.CenterScreen;
Label infoLabel = new Label();
form.Controls.Add(infoLabel);
infoLabel.Text =
"Paint.NET has detected that some important installation files are missing. If you click " +
"the Repair button it will attempt to repair this and then continue loading." + Environment.NewLine +
Environment.NewLine +
"The missing files are: " + missingFilesSB.ToString();
#if DEBUG
infoLabel.Text += Environment.NewLine +
"Since this is a DEBUG build, you should probably add /skipRepairAttempt to the command-line.";
#endif
infoLabel.Location = new Point(hMargin, vMargin);
infoLabel.Width = form.ClientSize.Width - hMargin * 2;
infoLabel.Height = infoLabel.GetPreferredSize(new Size(infoLabel.Width, 1)).Height;
Button repairButton = new Button();
form.Controls.Add(repairButton);
repairButton.Text = "&Repair";
Exception exception = null;
repairButton.Click +=
delegate(object sender, EventArgs e)
{
form.DialogResult = DialogResult.Yes;
repairButton.Enabled = false;
try
{
Shell.Execute(form, "PdnRepair.exe", "/noPause", false, ExecuteWaitType.WaitForExit);
}
catch (Exception ex)
{
exception = ex;
}
};
repairButton.AutoSize = true;
repairButton.PerformLayout();
repairButton.Width += 20;
repairButton.Location = new Point((form.ClientSize.Width - repairButton.Width) / 2, infoLabel.Bottom + vMargin * 2);
repairButton.FlatStyle = FlatStyle.System;
UI.EnableShield(repairButton, true);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.ShowInTaskbar = true;
form.Icon = null;
form.ClientSize = new Size(form.ClientRectangle.Width, repairButton.Bottom + vMargin);
DialogResult result = form.ShowDialog(null);
form.Dispose();
form = null;
if (result == DialogResult.Yes)
{
return true;
}
else if (exception == null)
{
return false;
}
else
{
throw new Exception("Error while attempting to repair", exception);
}
}
catch (Exception ex)
{
throw new Exception("Could not repair installation after it was determined that the following files are missing: " +
missingFilesSB.ToString(), ex);
}
}