FirstFloor.ModernUI.Windows.Controls.DpiAwareWindow.DpiAwareWindow C# (CSharp) Method

DpiAwareWindow() protected method

Initializes a new instance of the DpiAwareWindow class.
protected DpiAwareWindow ( ) : System
return System
        protected DpiAwareWindow() {
            SourceInitialized += OnSourceInitialized;
            LocationChanged += OnLocationChanged;
            SizeChanged += OnSizeChanged;
            StateChanged += OnStateChanged;

            // WM_DPICHANGED is not send when window is minimized, do listen to global display setting changes
            SystemEvents.DisplaySettingsChanged += OnSystemEventsDisplaySettingsChanged;

            // try to set per-monitor dpi awareness, before the window is displayed
            _isPerMonitorDpiAware = ModernUiHelper.TrySetPerMonitorDpiAware();

            // set the default owner
            if (Application.Current != null && !ReferenceEquals(Application.Current.MainWindow, this)) {
                Owner = Application.Current.Windows.OfType<DpiAwareWindow>().FirstOrDefault(x => x.IsActive)
                        ?? (Application.Current.MainWindow.IsVisible ? Application.Current.MainWindow : null);
            }

            foreach (var gesture in NavigationCommands.BrowseBack.InputGestures.OfType<KeyGesture>()
                                                      .Where(x => x?.Key == Key.Back && x.Modifiers == ModifierKeys.None)
                                                      .ToList()) {
                NavigationCommands.BrowseBack.InputGestures.Remove(gesture);
            }
        }