wpf 实现全屏与取消全屏
2015-07-25 09:50
513 查看
/// <summary>
/// 全屏
/// </summary>
public void ToFullscreen()
{
//存储窗体信息
m_WindowState = this.WindowState;
m_WindowStyle = this.WindowStyle;
m_WindowTopMost = this.Topmost;
m_WindowResizeMode = this.ResizeMode;
m_WindowRect.X = this.Left;
m_WindowRect.Y = this.Top;
m_WindowRect.Width = this.Width;
m_WindowRect.Height = this.Height;
//变成无边窗体
this.WindowState = WindowState.Normal;//假如已经是Maximized,就不能进入全屏,所以这里先调整状态
this.WindowStyle = WindowStyle.None;
this.ResizeMode = ResizeMode.NoResize;
this.Topmost = true;//最大化后总是在最上面
// 调整窗口最大化。
this.Width = m_DisplayBounds.width;
this.Height = m_DisplayBounds.height;
this.WindowState = WindowState.Maximized;
}
/// <summary>
/// 取消全屏
/// </summary>
public void ExitFullscreen()
{
//恢复窗口先前信息,这样就退出了全屏
this.Topmost = m_WindowTopMost;
this.WindowStyle = m_WindowStyle;
this.ResizeMode = ResizeMode.CanResize;//设置为可调整窗体大小
this.Left = m_WindowRect.Left;
this.Width = m_WindowRect.Width;
this.Top = m_WindowRect.Top;
this.Height = m_WindowRect.Height;
this.WindowState = m_WindowState;//恢复窗口状态信息
this.ResizeMode = m_WindowResizeMode;//恢复窗口可调整信息
}
/// 全屏
/// </summary>
public void ToFullscreen()
{
//存储窗体信息
m_WindowState = this.WindowState;
m_WindowStyle = this.WindowStyle;
m_WindowTopMost = this.Topmost;
m_WindowResizeMode = this.ResizeMode;
m_WindowRect.X = this.Left;
m_WindowRect.Y = this.Top;
m_WindowRect.Width = this.Width;
m_WindowRect.Height = this.Height;
//变成无边窗体
this.WindowState = WindowState.Normal;//假如已经是Maximized,就不能进入全屏,所以这里先调整状态
this.WindowStyle = WindowStyle.None;
this.ResizeMode = ResizeMode.NoResize;
this.Topmost = true;//最大化后总是在最上面
// 调整窗口最大化。
this.Width = m_DisplayBounds.width;
this.Height = m_DisplayBounds.height;
this.WindowState = WindowState.Maximized;
}
/// <summary>
/// 取消全屏
/// </summary>
public void ExitFullscreen()
{
//恢复窗口先前信息,这样就退出了全屏
this.Topmost = m_WindowTopMost;
this.WindowStyle = m_WindowStyle;
this.ResizeMode = ResizeMode.CanResize;//设置为可调整窗体大小
this.Left = m_WindowRect.Left;
this.Width = m_WindowRect.Width;
this.Top = m_WindowRect.Top;
this.Height = m_WindowRect.Height;
this.WindowState = m_WindowState;//恢复窗口状态信息
this.ResizeMode = m_WindowResizeMode;//恢复窗口可调整信息
}
相关文章推荐
- poj 2236 Wireless Network 并查集
- 写给自己的话
- 深入解读Quartz的原理
- leetCode 89.Gray Code (格雷码) 解题思路和方法
- exchange2003备份与恢复
- jQuery.noConflict() 解决冲突 原理深入
- Nginx.conf 配置文件详解
- guava (一)--简介
- Exchange服务器快速关机
- Xamarin Android 绑定jar库同时将so库打包进去
- memset()函数及其作用
- Web开发者不可不知的15条编码原则
- JavaScript学习要点(九)
- Xamarin.Android开发实践(十三)
- 将博客搬至CSDN
- leetCode 88.Merge Sorted Array (合并排序数组) 解题思路和方法
- Log4j中配置日志文件相对路径
- Storm伪分布式安装
- make && make install 这是什么意思啊
- DHCP情况下,Linux如何查看当前网关