Show / Hide Table of Contents

Struct WndSavedRect

Helps to save and restore window rectangle and state. Ensures in screen, per-monitor-DPI-aware, etc.

public struct WndSavedRect
Examples

WPF window created with wpfBuilder.

const string c_rkey = @"HKEY_CURRENT_USER\Software\Au\Test", c_rvalue = @"Wpf7.Rect";
var b = new wpfBuilder("Window").WinSize(400).R.AddOkCancel().End();
	
WndSavedRect.Restore(b.Window, Registry.GetValue(c_rkey, c_rvalue, null) as string, s1 => Registry.SetValue(c_rkey, c_rvalue, s1));

//the same
//b.WinSaved(Registry.GetValue(c_rkey, c_rvalue, null) as string, s1 => Registry.SetValue(c_rkey, c_rvalue, s1));

if (!b.ShowDialog()) return;

Namespace: Au.More
Assembly: Au.dll

Constructors

Name Description
WndSavedRect(wnd)

Gets window rectangle and state for saving. Usually called when closing the window. See also WndSavedRect.ToString.

WndSavedRect(Form)

Gets window rectangle and state for saving. Usually called when closing the window. See also WndSavedRect.ToString.

WndSavedRect(Window)

Gets window rectangle and state for saving. Usually called when closing the window. See also WndSavedRect.ToString.

Properties

Name Description
Dpi

Dpi.OfWindow.

IsToolWindow

wnd.IsToolWindow. If false, WndSavedRect.RawRect may have an offset that depends on work area.

Maximize

The window should be maximized.

RawRect

Window rectangle in normal state (not maximized/minimized), as retrieved by API GetWindowPlacement.

Methods

Name Description
FromString(string, out WndSavedRect)

Creates WndSavedRect from string created by WndSavedRect.ToString.

NormalizeRect()

Gets real rectangle for restoring saved window rectangle.

Restore(Form, string, Action<string>)

Calls WndSavedRect.FromString. If it returns true, sets form bounds = WndSavedRect.NormalizeRect, maximizes if need, sets StartPosition = Manual, and returns true. Call this function before showing window.

Restore(Window, string, Action<string>)

Calls WndSavedRect.FromString. If it returns true, calls WndSavedRect.NormalizeRect, ExtWpf.SetRect, maximizes if need and returns true. Call this function before showing window.

ToString()

Converts this object to string for saving. The string is very simple, like "1 2 3 4 5 6".