📄 centeredform.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace NonFullscreenDemo
{
public partial class CenteredForm : NonFullscreenForm
{
private SizeF MyAutoScaleFactor;
public CenteredForm()
{
InitializeComponent();
MyAutoScaleFactor = new SizeF(
this.AutoScaleDimensions.Width / 96F,
this.AutoScaleDimensions.Height / 96F);
this.Height = (int)(MyAutoScaleFactor.Height * 80 - SystemInformation.MenuHeight);
}
private void btnExpand_Click(object sender, EventArgs e)
{
if (btnExpand.Text == "Expand")
{
btnExpand.Text = "Collapse";
this.Height = (int)(MyAutoScaleFactor.Height * 146);
}
else
{
btnExpand.Text = "Expand";
this.Height = (int)(MyAutoScaleFactor.Height * 80);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -