Example #1
0
File: app.cs Project: roytam1/fx3
        /// <summary>
        /// Saves the state of opened windows, urls, etc to preferences
        /// so that state can be restored when the app is restarted.
        /// </summary>
        private void SaveSession()
        {
            if (ServiceManager.Preferences.GetIntPref("browser.homepage.mode") == 2)
            {
                bool           isLastPageOnly = ServiceManager.Preferences.GetIntPref("browser.session.windowmode") == 0;
                WindowMediator wm             = ServiceManager.WindowMediator;
                IEnumerator    browsers       = wm.GetEnumeratorForType("BrowserWindow");
                int            count          = 0;
                while (browsers.MoveNext())
                {
                    if (isLastPageOnly && count > 0)
                    {
                        // XXX need to |getMostRecentWindow| instead of just taking the first.
                        break;
                    }

                    BrowserWindow currWindow = browsers.Current as BrowserWindow;
                    String        pref       = "browser.session.windows.";
                    pref += currWindow.Type + count++;
                    ServiceManager.Preferences.SetStringPref(pref, currWindow.URL);
                    ServiceManager.Preferences.SetIntPref(pref + ".left", currWindow.Left);
                    ServiceManager.Preferences.SetIntPref(pref + ".top", currWindow.Top);
                    ServiceManager.Preferences.SetIntPref(pref + ".width", currWindow.Width);
                    ServiceManager.Preferences.SetIntPref(pref + ".height", currWindow.Height);
                }
                // XXX need to save session histories.
            }
        }