예제 #1
0
        protected virtual void LoadWindowState()
        {
            if (_settings == null)
            {
                return;
            }
            _settings.Reload();

            if (_settings.Placement == null)
            {
                return;
            }

            try
            {
                var wp = _settings.Placement;

                wp.length  = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
                wp.flags   = 0;
                wp.showCmd = (wp.showCmd == Constants.SW_SHOWMINIMIZED ? Constants.SW_SHOWNORMAL : wp.showCmd);
                var hwnd = new WindowInteropHelper(_window).Handle;
                NativeMethods.SetWindowPlacement(hwnd, wp);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to load window state:\r\n{0}", ex);
            }
        }
예제 #2
0
        protected virtual void LoadWindowState()
        {
            if (_settings == null)
            {
                return;
            }
            _settings.Reload();

            // check for existing placement and prevent empty bounds
            if (_settings.Placement == null || _settings.Placement.Value.normalPosition.IsEmpty)
            {
                return;
            }

            try
            {
                var wp = _settings.Placement.Value;

                wp.length  = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
                wp.flags   = 0;
                wp.showCmd = (wp.showCmd == (int)Constants.ShowWindowCommands.SW_SHOWMINIMIZED ? (int)Constants.ShowWindowCommands.SW_SHOWNORMAL : wp.showCmd);
                var hwnd = new WindowInteropHelper(_window).Handle;
                UnsafeNativeMethods.SetWindowPlacement(hwnd, ref wp);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to load window state:\r\n{0}", ex);
            }
        }
예제 #3
0
#pragma warning disable 618
        protected virtual void LoadWindowState()
        {
            if (_settings == null)
            {
                return;
            }
            _settings.Reload();

            // check for existing placement and prevent empty bounds
            if (_settings.Placement == null || _settings.Placement.normalPosition.IsEmpty)
            {
                return;
            }

            try
            {
                var wp = _settings.Placement;
                wp.flags   = 0;
                wp.showCmd = (wp.showCmd == SW.SHOWMINIMIZED ? SW.SHOWNORMAL : wp.showCmd);
                var hwnd = new WindowInteropHelper(_window).Handle;
                NativeMethods.SetWindowPlacement(hwnd, wp);
            }
            catch (Exception ex)
            {
                throw new MahAppsException("Failed to set the window state from the settings file", ex);
            }
        }