Esempio n. 1
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (!CheckSave())
            {
                e.Cancel = true;
            }

            if (e.Cancel == false)
            {
                ConfigManager.UndoManager.ClearHistory();

                // Persist window placement details to application settings
                NativeMethods.WINDOWPLACEMENT wp = new NativeMethods.WINDOWPLACEMENT();
                IntPtr hwnd = new WindowInteropHelper(this).Handle;
                NativeMethods.GetWindowPlacement(hwnd, out wp);

                ConfigManager.SettingsManager.SaveSetting("ProfileEditor", "WindowLocation", wp.normalPosition);

                // Close all open documents so they can clean up
                while (_documents.Count > 0)
                {
                    _documents[0].document.Close();
                }
            }
            base.OnClosing(e);
        }
Esempio n. 2
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            // Load window placement details for previous application session from application settings
            // Note - if window was closed on a monitor that is now disconnected from the computer,
            //        SetWindowPlacement will place the window onto a visible monitor.

            if (ConfigManager.SettingsManager.IsSettingAvailable("ProfileEditor", "WindowLocation"))
            {
                NativeMethods.WINDOWPLACEMENT wp = new NativeMethods.WINDOWPLACEMENT();
                wp.normalPosition = ConfigManager.SettingsManager.LoadSetting("ProfileEditor", "WindowLocation", new NativeMethods.RECT(0, 0, (int)Width, (int)Height));
                wp.length         = Marshal.SizeOf(typeof(NativeMethods.WINDOWPLACEMENT));
                wp.flags          = 0;
                wp.showCmd        = (wp.showCmd == NativeMethods.SW_SHOWMINIMIZED ? NativeMethods.SW_SHOWNORMAL : wp.showCmd);
                IntPtr hwnd = new WindowInteropHelper(this).Handle;
                NativeMethods.SetWindowPlacement(hwnd, ref wp);
            }

            base.OnSourceInitialized(e);
        }
Esempio n. 3
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            // Load window placement details for previous application session from application settings
            // Note - if window was closed on a monitor that is now disconnected from the computer,
            //        SetWindowPlacement will place the window onto a visible monitor.

            if (ConfigManager.SettingsManager.IsSettingAvailable("ProfileEditor", "WindowLocation"))
            {
                NativeMethods.WINDOWPLACEMENT wp = new NativeMethods.WINDOWPLACEMENT();
                wp.normalPosition = ConfigManager.SettingsManager.LoadSetting("ProfileEditor", "WindowLocation", new NativeMethods.RECT(0, 0, (int)Width, (int)Height));
                wp.length = Marshal.SizeOf(typeof(NativeMethods.WINDOWPLACEMENT));
                wp.flags = 0;
                wp.showCmd = (wp.showCmd == NativeMethods.SW_SHOWMINIMIZED ? NativeMethods.SW_SHOWNORMAL : wp.showCmd);
                IntPtr hwnd = new WindowInteropHelper(this).Handle;
                NativeMethods.SetWindowPlacement(hwnd, ref wp);
            }

            base.OnSourceInitialized(e);
        }
Esempio n. 4
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (!CheckSave())
            {
                e.Cancel = true;
            }

            if (e.Cancel == false)
            {
                ConfigManager.UndoManager.ClearHistory();

                // Persist window placement details to application settings
                NativeMethods.WINDOWPLACEMENT wp = new NativeMethods.WINDOWPLACEMENT();
                IntPtr hwnd = new WindowInteropHelper(this).Handle;
                NativeMethods.GetWindowPlacement(hwnd, out wp);

                ConfigManager.SettingsManager.SaveSetting("ProfileEditor", "WindowLocation", wp.normalPosition);

                // Close all open documents so they can clean up
                while (_documents.Count > 0)
                {
                    _documents[0].document.Close();
                }
            }
            base.OnClosing(e);
        }