コード例 #1
0
        private static void OnClosing(object sender, CancelEventArgs e)
        {
            Form form = sender as Form;

            if (form == null)
            {
                return;
            }

            // the window is being closed, update the WindowState setting
            if (form.WindowState != FormWindowState.Minimized)
            {
                Properties.Settings.Default.WindowState = form.WindowState;
            }

            TabbedXmlExplorerWindow window = SingleInstanceApplication.Instance.MainWindow;

            Properties.Settings.Default.Font                  = window.TreeFont;
            Properties.Settings.Default.ForeColor             = window.TreeForeColor;
            Properties.Settings.Default.AutoCompleteMode      = window.AutoCompleteMode;
            Properties.Settings.Default.UseSyntaxHighlighting = window.UseSyntaxHighlighting;
            Properties.Settings.Default.Expressions           = window.Expressions;
            Properties.Settings.Default.RecentlyUsedFiles     = window.RecentlyUsedFiles;
            Properties.Settings.Default.ChildNodeDefinitions  = window.ChildNodeDefinitions;
            Properties.Settings.Default.ShowNodeToolTips      = window.ShowNodeToolTips;
        }
コード例 #2
0
        private static void OnWindowShown(object sender, EventArgs e)
        {
            try
            {
                TabbedXmlExplorerWindow window = sender as TabbedXmlExplorerWindow;
                if (window == null)
                {
                    return;
                }

                var settings = Properties.Settings.Default;

                if (settings.CheckForUpdates)
                {
                    window.CheckForUpdates(false);
                }

                if (settings.CheckDefaultProgram)
                {
                    settings.CheckDefaultProgram = false;
                    settings.Save();

                    if (System.Windows.DefaultApplications.IsAssociationsWindowSupported)
                    {
                        using (DefaultProgramPrompt prompt = new DefaultProgramPrompt())
                        {
                            DialogResult result = prompt.ShowDialog(window);

                            if (result == DialogResult.Yes)
                            {
                                System.Windows.DefaultApplications.ShowAssociationsWindow("XML Explorer");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                ExceptionDialog.ShowDialog(ex);
            }
        }
コード例 #3
0
        private static void OnStartup(object sender, StartupEventArgs e)
        {
            try
            {
                TabbedXmlExplorerWindow window = SingleInstanceApplication.Instance.MainWindow;

                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                Debug.WriteLine(string.Format("Local user config path: {0}", config.FilePath));

                string dockFilename = Path.GetDirectoryName(config.FilePath);
                dockFilename = Path.Combine(dockFilename, "user.dock.config");
                Debug.WriteLine(string.Format("Local user dock config path: {0}", dockFilename));
                window.DockSettingsFilename = dockFilename;

                if (dockFilename != null && File.Exists(dockFilename))
                {
                    window.DockPanel.LoadFromXml(dockFilename, window.DeserializeDockContent);
                }

                // upgrade settings from a previous version, if needed
                if (Properties.Settings.Default.UpgradeNeeded)
                {
                    Properties.Settings.Default.Upgrade();
                    Properties.Settings.Default.UpgradeNeeded = false;
                    Properties.Settings.Default.Save();
                }

                // open it
                window.Open(e.CommandLine);

                // read any options saved from a previous instance of the application
                // (window size and position, font, etc)
                ReadOptions(window);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                ExceptionDialog.ShowDialog(ex);
            }
        }
コード例 #4
0
        /// <summary>
        /// Applies any saved settings to a TabbedXmlExplorerWindow.
        /// </summary>
        private static void ReadOptions(TabbedXmlExplorerWindow window)
        {
            try
            {
                window.Settings = Properties.Settings.Default;

                // AutoCompleteMode
                window.AutoCompleteMode = Properties.Settings.Default.AutoCompleteMode;

                window.TreeFont      = Properties.Settings.Default.Font;
                window.TreeForeColor = Properties.Settings.Default.ForeColor;

                // Size
                if (!Properties.Settings.Default.ClientSize.IsEmpty)
                {
                    window.Size = Properties.Settings.Default.ClientSize;
                }
                window.ResizeEnd += OnResizeEnd;

                // Location
                Point location = Properties.Settings.Default.Location;
                if (IsValidLocation(location))
                {
                    window.StartPosition = FormStartPosition.Manual;
                    window.Location      = location;
                }
                window.LocationChanged += OnLocationChanged;

                // WindowState
                if (Properties.Settings.Default.WindowState != FormWindowState.Minimized)
                {
                    window.WindowState = Properties.Settings.Default.WindowState;
                }
                window.FormClosing += OnClosing;

                // UseSyntaxHighlighting
                window.UseSyntaxHighlighting = Properties.Settings.Default.UseSyntaxHighlighting;
                window.ShowNodeToolTips      = Properties.Settings.Default.ShowNodeToolTips;

                // XPath Expression Library
                window.Expressions = Properties.Settings.Default.Expressions;
                if (window.Expressions == null)
                {
                    window.Expressions = new XPathExpressionLibrary();
                }

                // Recently Used Files
                window.RecentlyUsedFiles = Properties.Settings.Default.RecentlyUsedFiles;
                if (window.RecentlyUsedFiles == null)
                {
                    window.RecentlyUsedFiles = new RecentlyUsedFilesStack();
                }
                else
                {
                    // not sure why, but the list gets reversed when persisted
                    window.RecentlyUsedFiles.Reverse();
                }

                window.AutoUpdateUrl        = Properties.Settings.Default.UpdateUrl;
                window.MinimumReleaseStatus = Properties.Settings.Default.UpdateReleaseStatus;

                // ChildNodeDefinitions
                window.ChildNodeDefinitions = Properties.Settings.Default.ChildNodeDefinitions;
                if (window.ChildNodeDefinitions == null)
                {
                    window.ChildNodeDefinitions = new ChildNodeDefinitionCollection();
                    Properties.Settings.Default.ChildNodeDefinitions = window.ChildNodeDefinitions;
                }

                window.Shown += new EventHandler(OnWindowShown);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }