public MessageBoxWindow(string message) { InitializeComponent(); WindowChrome windowChrome = new WindowChrome() { CaptionHeight = 51, CornerRadius = new CornerRadius(0), GlassFrameThickness = new Thickness(0), NonClientFrameEdges = NonClientFrameEdges.None, ResizeBorderThickness = new Thickness(0), UseAeroCaptionButtons = false }; WindowChrome.SetWindowChrome(this, windowChrome); Message = message; rowCaption.Visibility = Visibility.Collapsed; imgIcon.Visibility = Visibility.Collapsed; SetButtons(MessageBoxButton.OK); NativeDisplay display = NativeDisplay.GetDisplayFromWindow(new WindowInteropHelper(this).Handle); MaxWidth = display.WorkingArea.Width * 0.9; MaxHeight = display.WorkingArea.Height * 0.9; }
///Get all the displays, and choose whether to include monitors not attached to the desktop public static SystemDisplay[] GetAllDisplays(bool IncludeMonitorsNotAttachedToDesktop) { var allDisplays = NativeDisplay.GetAllDisplays(); if (!IncludeMonitorsNotAttachedToDesktop) { //Remove displays not attached to the desktop allDisplays.RemoveAll(display => !display.AttachedToDesktop); } if (allDisplays == null || allDisplays.Count == 0) { /*Failed to find the displays, so add the primary Screen as a display*/ var display = new SystemDisplay(); display.Bounds = new Rect(0, 0, Screen.currentResolution.width, Screen.currentResolution.height); display.PhysicalBounds = display.Bounds; display.PixelWidth = (int)display.PhysicalBounds.width; display.PixelHeight = (int)display.PhysicalBounds.height; display.WorkArea = display.Bounds; display.AttachedToDesktop = true; display.IsPrimary = true; allDisplays.Add(display); } return(allDisplays.ToArray()); }
/// Restores the style of a window to what it was before fullscreening. public static void RestoreWindowStyle(EditorWindow editorWindow, Rect origPosition) { UseIdentifierTitle(editorWindow, () => NativeDisplay.RestoreWindowStyle(editorWindow, origPosition)); }
/// Sets the position of a window using system calls. public static void SetWindowPosition(EditorWindow editorWindow, int x, int y, int width, int height) { UseIdentifierTitle(editorWindow, () => NativeDisplay.SetWindowPosition(editorWindow, x, y, width, height)); }