public SavedWindowStateRestorer(MetroWindow window, SavedWindowState settings, Rect defaultWindowLocation) {
			this.window = window;
			this.settings = settings;
			this.defaultWindowLocation = defaultWindowLocation;
			window.SourceInitialized += Window_SourceInitialized;
			window.ContentRendered += Window_ContentRendered;
		}
		public SavedWindowState(MetroWindow window) {
			this.Bounds = window.RestoreBounds;
			var source = PresentationSource.FromVisual(window);
			Debug.Assert(source != null);
			if (source != null) {
				var t = this.Bounds;
				t = Rect.Transform(Bounds, source.CompositionTarget.TransformToDevice);
				this.Bounds = new Rect(t.TopLeft, this.Bounds.Size);
			}
			this.IsFullScreen = window.IsFullScreen;
			this.WindowState = window.WindowState;
		}
Exemple #3
0
 public FullScreenCommand(IAppWindow appWindow)
     : base(MetroWindow.FullScreenCommand)
 {
     this.window = (MetroWindow)appWindow.MainWindow;
 }
Exemple #4
0
        public static void UpdateWin32Style(MetroWindow window)
        {
            const int GWL_STYLE = -16;
            const int WS_SYSMENU = 0x00080000;

            IntPtr hWnd = new WindowInteropHelper(window).Handle;

            // The whole title bar is restyled. We must hide the system menu or Windows
            // will sometimes paint the title bar for us.
            SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_SYSMENU);
        }
Exemple #5
0
            void UpdatePadding(MetroWindow window)
            {
                Debug.Assert(window != null);

                var state = window.IsFullScreen ? WindowState.Maximized : window.WindowState;
                switch (state) {
                default:
                case WindowState.Normal:
                    border.ClearValue(Border.PaddingProperty);
                    border.BorderThickness = oldThickness;
                    break;

                case WindowState.Minimized:
                case WindowState.Maximized:
                    double magicx, magicy;

                    magicx = magicy = 10;//TODO: Figure out how this value is calculated (it's not ResizeBorderThickness.Left/Top)

                    double deltax = magicx - SystemParameters.ResizeFrameVerticalBorderWidth;
                    double deltay = magicy - SystemParameters.ResizeFrameHorizontalBorderHeight;
                    Debug.Assert(deltax >= 0 && deltay >= 0);
                    if (deltax < 0)
                        deltax = 0;
                    if (deltay < 0)
                        deltay = 0;

                    border.Padding = new Thickness(
                        SystemParameters.BorderWidth + border.BorderThickness.Left + deltax,
                        SystemParameters.BorderWidth + border.BorderThickness.Top + deltay,
                        SystemParameters.BorderWidth + border.BorderThickness.Right + deltax,
                        SystemParameters.BorderWidth + border.BorderThickness.Bottom + deltay);
                    border.BorderThickness = new Thickness(0);
                    break;
                }
            }
Exemple #6
0
 public MaximizedWindowFixer(MetroWindow metroWindow, Border border)
 {
     this.border = border;
     this.oldThickness = border.BorderThickness;
     this.metroWindow = metroWindow;
     metroWindow.StateChanged += MetroWindow_StateChanged;
     border.Loaded += border_Loaded;
 }
Exemple #7
0
		MetroWindow GetWindow() {
			Debug.Assert(scaleElement != null);
			if (metroWindow != null)
				return metroWindow;
			if (scaleElement == null)
				return null;

			var win = Window.GetWindow(scaleElement);
			metroWindow = win as MetroWindow;
			if (metroWindow != null) {
				metroWindow.WindowDPIChanged += MetroWindow_WindowDPIChanged;
				return metroWindow;
			}

			// scaleElement.IsLoaded can be true if we've moved a tool window, so always hook the
			// loaded event.
			scaleElement.Loaded -= ScaleElement_Loaded;
			scaleElement.Loaded += ScaleElement_Loaded;

			return null;
		}
Exemple #8
0
 public SavedWindowState(MetroWindow window)
 {
     this.Bounds = window.RestoreBounds;
     this.IsFullScreen = window.IsFullScreen;
     this.WindowState = window.WindowState;
 }