Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5465 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
6 changed files with 97 additions and 13 deletions
@ -0,0 +1,76 @@
@@ -0,0 +1,76 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows; |
||||
using System.Windows.Forms; |
||||
using System.Windows.Interop; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
using WindowState = System.Windows.WindowState; |
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
class FullScreenEnabledWindow : Window |
||||
{ |
||||
public static readonly DependencyProperty FullScreenProperty = |
||||
DependencyProperty.Register("FullScreen", typeof(bool), typeof(FullScreenEnabledWindow)); |
||||
|
||||
public bool FullScreen { |
||||
get { return (bool)GetValue(FullScreenProperty); } |
||||
set { SetValue(FullScreenProperty, value); } |
||||
} |
||||
|
||||
System.Windows.WindowState previousWindowState = WindowState.Maximized; |
||||
double oldLeft, oldTop, oldWidth, oldHeight; |
||||
|
||||
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
base.OnPropertyChanged(e); |
||||
if (e.Property == FullScreenProperty) { |
||||
if ((bool)e.NewValue) { |
||||
// enable fullscreen mode
|
||||
// remember previous window state
|
||||
if (this.WindowState == WindowState.Normal || this.WindowState == WindowState.Maximized) |
||||
previousWindowState = this.WindowState; |
||||
oldLeft = this.Left; |
||||
oldTop = this.Top; |
||||
oldWidth = this.Width; |
||||
oldHeight = this.Height; |
||||
|
||||
WindowInteropHelper interop = new WindowInteropHelper(this); |
||||
interop.EnsureHandle(); |
||||
Screen screen = Screen.FromHandle(interop.Handle); |
||||
|
||||
Rect bounds = screen.Bounds.ToWpf().TransformFromDevice(this); |
||||
|
||||
this.ResizeMode = ResizeMode.NoResize; |
||||
this.Left = bounds.Left; |
||||
this.Top = bounds.Top; |
||||
this.Width = bounds.Width; |
||||
this.Height = bounds.Height; |
||||
this.WindowState = WindowState.Normal; |
||||
this.WindowStyle = WindowStyle.None; |
||||
|
||||
} else { |
||||
ClearValue(WindowStyleProperty); |
||||
ClearValue(ResizeModeProperty); |
||||
ClearValue(MaxWidthProperty); |
||||
ClearValue(MaxHeightProperty); |
||||
this.WindowState = previousWindowState; |
||||
|
||||
this.Left = oldLeft; |
||||
this.Top = oldTop; |
||||
this.Width = oldWidth; |
||||
this.Height = oldHeight; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue