我多次使用完全相同的代码,我认为只复制/粘贴所有内容会非常低效。有没有办法让我们说 button2 使用与 button1 完全相同的代码而不复制/粘贴所有内容?
我的一些代码非常大,这就是我问的原因。
例如,我知道这一点:
private TabPage T
{
get { return (t.SelectedTab); }
}
但是我不知道如何使它起作用:(是的,有多种方法可以在我的应用程序中启用全屏模式)
if (FormBorderStyle != FormBorderStyle.None)
{
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Normal;
WindowState = FormWindowState.Maximized;
p1.BackColor = Color.White;
p2.BackColor = Color.White;
TopMost = true;
c2.Visible = false;
Wi.Visible = false;
t1.Visible = false;
F.Text = "Exit Full Screen";
t2.Text = "Exit Full Screen";
}
else
{
FormBorderStyle = FormBorderStyle.Sizable;
if (Environment.OSVersion.Version.Build >= 7000)
{
if (DWM.DwmIsCompositionEnabled())
{
Color c = Color.FromArgb(255, 221, 220, 220);
TransparencyKey = c;
p1.BackColor = c;
p2.BackColor = c;
MARGINS mr = new MARGINS();
mr.T = 1800;
IntPtr h = Handle;
int result = DwmExtendFrameIntoClientArea(h, ref mr);
}
}
TopMost = false;
Wi.Visible = true;
t1.Visible = true;
F.Text = "Full Screen";
t2.Text = "Full Screen";
}