private void fullScreenHandler(bool isFullScreen)
{
if (isFullScreen)
{
this.WindowState = (WindowState)FormWindowState.Maximized;
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
this.Height = System.Windows.SystemParameters.PrimaryScreenHeight;
this.Topmost = true;
this.ResizeMode = System.Windows.ResizeMode.NoResize;
this.WindowStyle = System.Windows.WindowStyle.None;
}
else
{
this.WindowState = (WindowState)FormWindowState.Normal;
this.Width = 1920;
this.Height = 1080;
this.Topmost = false;
this.ResizeMode = System.Windows.ResizeMode.CanResizeWithGrip;
this.WindowStyle = System.Windows.WindowStyle.SingleBorderWindow;
}
this.Left = 0.0f;
this.Top = 0.0f;
}
protected override void OnKeyUp(System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
fullScreenHandler(false);
}
if (e.Key == Key.Enter)
{
fullScreenHandler(true);
}
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = false;
}
C# 全屏控制
最新推荐文章于 2024-03-30 18:04:57 发布