Beispiel #1
0
        /// <summary>
        /// Retrieve the settings from the session persistence store (e.g. registry).
        /// </summary>
        public void Update()
        {
            CurrentWorkspace = _persistenceManager.ReadString(
                Constants.KEY_CURRENT_WORKSPACE, Directory.GetCurrentDirectory());
            BackupDirectory = _persistenceManager.ReadString(
                Constants.KEY_BACKUP_DIRECTORY, String.Empty);
            VisitedFoldersList = _persistenceManager.ReadStrings(
                Constants.KEY_VISITED_FOLDERS_LIST);
            VisitedFoldersLimit = _persistenceManager.ReadInt(
                Constants.KEY_VISITED_FOLDERS_LIMIT, 10);
            ShowSourceOnly = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_SOURCE_ONLY, false);
            ShowHiddenFiles = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_HIDDEN_FILES, false);
            ShowSystemFiles = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_SYSTEM_FILES, false);
            ShowFullPath = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_FULL_PATH, false);

            // Trim the list if too big.
            while (VisitedFoldersList.Count > VisitedFoldersLimit)
            {
                VisitedFoldersList.RemoveAt(0);
            }
        }
Beispiel #2
0
        private void ActivatePlugin()
        {
            IPersistenceManager persistenceManager =
                ApplicationManager.GetInstance().GetPersistenceManager(
                    Constants.PLUGIN_NAME);

            /*
             * We support SCE 3.5 and 4.0. use the registry override keys to
             * use a different invariant name in place of the defaults.
             */

            string providerInvariantName35 = persistenceManager.ReadString(
                Constants.KEY_DATA_PROVIDER_INVARIANT_NAME_35,
                Constants.DATA_PROVIDER_INVARIANT_NAME_35);

            string providerInvariantName40 = persistenceManager.ReadString(
                Constants.KEY_DATA_PROVIDER_INVARIANT_NAME_40,
                Constants.DATA_PROVIDER_INVARIANT_NAME_40);

            SqlCodeAssistManager sqlCodeAssistManager =
                SqlCodeAssistManager.GetInstance();

            sqlCodeAssistManager.RegisterProviderFactoryHandlers(
                providerInvariantName35, GetMSSCECodeAssistProvider);

            sqlCodeAssistManager.RegisterProviderFactoryHandlers(
                providerInvariantName40, GetMSSCECodeAssistProvider);
        }
Beispiel #3
0
        /// <summary>
        /// Retrieve the settings from the session persistence store (e.g. registry).
        /// </summary>
        public void Update()
        {
            RootFolder = _persistenceManager.ReadString(
                Constants.KEY_ROOT_FOLDER, Directory.GetCurrentDirectory());

            bool defaultFiltersApplied = _persistenceManager.ReadBoolean(
                Constants.KEY_DEFAULT_FILTERS_APPLIED, false);

            List <string> filterList = _persistenceManager.ReadStrings(
                Constants.KEY_FILE_FILTERS);

            SelectedFilter = _persistenceManager.ReadString(
                Constants.KEY_SELECTED_FILE_FILTER, String.Empty);

            if (filterList.Count == 0 && !defaultFiltersApplied)
            {
                filterList.Add("55F01123-747C-423B-BDAB-3ED92B6A466D|Hide All Files|");
                filterList.Add("692BB91D-FA37-4826-9483-E4CD53AF9DAB|Web Files|(?i:\\.html$) (?i:\\.css$) (?i:\\.js$)");

                SelectedFilter = String.Empty;

                _persistenceManager.WriteBoolean(
                    Constants.KEY_DEFAULT_FILTERS_APPLIED, true);
            }

            FileFilters = FileFilter.GetFileFilters(filterList);

            ApplyFilter = _persistenceManager.ReadBoolean(
                Constants.KEY_APPLY_FILE_FILTER, false);

            if (SelectedFilter == String.Empty)
            {
                ApplyFilter = false;
            }

            VisitedFoldersList = _persistenceManager.ReadStrings(
                Constants.KEY_VISITED_FOLDERS_LIST);
            VisitedFoldersLimit = _persistenceManager.ReadInt(
                Constants.KEY_VISITED_FOLDERS_LIMIT, 10);

            // Trim the list if too big.
            while (VisitedFoldersList.Count > VisitedFoldersLimit)
            {
                VisitedFoldersList.RemoveAt(0);
            }

            BackupDirectory = _persistenceManager.ReadString(
                Constants.KEY_BACKUP_DIRECTORY, String.Empty);
            ShowHiddenFiles = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_HIDDEN_FILES, false);
            ShowSystemFiles = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_SYSTEM_FILES, false);
            ShowFullPath = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_FULL_PATH, false);
        }
Beispiel #4
0
        /// <summary>
        /// Retrieve the settings from the session persistence store (e.g. the registry).
        /// </summary>
        public void Update()
        {
            OverrideConfigFiles = _persistenceManager.ReadBoolean(
                Constants.KEY_OVERRIDE_CONFIG_FILES, true);
            TabSize = _persistenceManager.ReadInt(
                Constants.KEY_TAB_SIZE, 4);
            UseTabs = _persistenceManager.ReadBoolean(
                Constants.KEY_USE_TABS, false);
            BackspaceUnindents = _persistenceManager.ReadBoolean(
                Constants.KEY_BACKSPACE_UNINDENTS, true);
            ShowIndentationGuides = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_INDENTATION_GUIDES, false);
            LineNumberMarginSize = _persistenceManager.ReadInt(
                Constants.KEY_LINE_NUMBER_MARGIN_SIZE, 36);
            ShowFolding = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_FOLDING, true);
            FoldStyle = _persistenceManager.ReadInt(
                Constants.KEY_FOLD_STYLE, 2);
            FoldMarkerStyle = _persistenceManager.ReadInt(
                Constants.KEY_FOLD_MARKER_STYLE, 0);
            FontName = _persistenceManager.ReadString(
                Constants.KEY_FONT_NAME, Constants.DEFAULT_FONT_NAME);
            FontSize = (float)_persistenceManager.ReadDouble(
                Constants.KEY_FONT_SIZE, 10.0F);
            MatchBraces = _persistenceManager.ReadBoolean(
                Constants.KEY_MATCH_BRACES, true);
            WordWrap = _persistenceManager.ReadBoolean(
                Constants.KEY_WORD_WRAP, false);

            int colorMode = _persistenceManager.ReadInt(
                Constants.KEY_PRINTING_COLOR_MODE, 0);

            PrintingColorMode = GetPrintingColorMode(colorMode);
        }
Beispiel #5
0
        public void Load()
        {
            /*
             * Don't call this from the constructor -
             * loading the SqlConnections invokes an instance
             * of this class and if it's called from the
             * constructor we get an infinite loop.
             */

            List <string> list =
                _persistenceManager.ReadStrings(
                    Constants.KEY_SQL_CONNECTIONS);

            foreach (string s in list)
            {
                SqlConnection cnn = SqlConnection.Parse(s);

                if (cnn != null)
                {
                    _sqlConnections[cnn.ID] = cnn;
                }
            }

            SelectedConnectionId = _persistenceManager.ReadString(
                Constants.KEY_SQL_CONNECTION_SELECTED,
                String.Empty);
        }
Beispiel #6
0
        /*
         * In this sample options page a text value is presented for editing
         * and will be saved to the registry. A validate method prevents
         * an empty message from being saved.
         */

        public OptionsPage3()
        {
            Name      = Constants.UI_OPTIONS_PAGE3;
            PageText  = "Options Page 3";
            GroupText = "Options Group 2";

            /*
             * Create the form layout.
             */

            textMessage          = new TextBox();
            textMessage.Location = new Point(15, 30);
            textMessage.Size     = new Size(400, 20);

            GroupBox groupBox = new GroupBox();

            groupBox.Size = new Size(430, 250);
            groupBox.Text = PageText;
            groupBox.Controls.Add(textMessage);

            Controls.Add(groupBox);

            /*
             * Create a persistence manager instance and load the
             * stored settings.
             */

            persistenceManager = ApplicationManager.GetInstance().
                                 GetPersistenceManager(Constants.PLUGIN_NAME);

            textMessage.Text = persistenceManager.ReadString(
                Constants.KEY_OPTION_TEXT_MESSAGE,
                "Enter a message here");
        }
Beispiel #7
0
        public SqlMetalForm(SqlConnection selectedConnection)
        {
            InitializeComponent();

            _applicationManager =
                QuickSharp.Core.ApplicationManager.GetInstance();

            _persistenceManager = _applicationManager.
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            _sqlConnectionManager =
                SqlConnectionManager.GetInstance();

            _provider         = selectedConnection.Provider;
            _connectionString = selectedConnection.ConnectionString;

            _useCompactEdition = _sqlConnectionManager.
                                 ConnectionIsSqlServerCe(selectedConnection);

            _output = _applicationManager.GetDockedForm(
                QuickSharp.Output.Constants.DOCKED_FORM_KEY)
                      as OutputForm;

            /*
             * Get the tool path.
             */

            _sqlMetalPath = _persistenceManager.ReadString(
                Constants.KEY_SQL_METAL_PATH,
                Constants.SQL_METAL_DEFAULT_PATH);

            /*
             * Populate the filename with the database name.
             */

            _filenameTextBox.Text = GetOutputFilename();

            /*
             * Update the UI
             */

            Text = Resources.SqlMetalFormTitle;
            _filenameLabel.Text     = Resources.SqlMetalFormFilename;
            _includeGroupBox.Text   = Resources.SqlMetalFormIncludeGroup;
            _viewsCheckBox.Text     = Resources.SqlMetalFormViews;
            _functionsCheckBox.Text = Resources.SqlMetalFormFunctions;
            _sprocsCheckBox.Text    = Resources.SqlMetalFormSprocs;
            _okButton.Text          = Resources.SqlMetalFormOk;
            _cancelButton.Text      = Resources.SqlMetalFormCancel;

            CheckToolAvailable();

            /*
             * Allow client applications to modify form.
             */

            SqlMetalFormProxy.GetInstance().
            UpdateFormControls(Controls);
        }
        public void Update()
        {
            IldasmPath = _persistenceManager.ReadString(
                Constants.KEY_ILDASM_PATH,
                @"C:\Program Files\Microsoft.NET\SDK\v2.0\bin\ildasm.exe");

            DexplorePath = _persistenceManager.ReadString(
                Constants.KEY_DEXPLORE_PATH,
                @"C:\Program Files\Common Files\Microsoft Shared\Help 8\dexplore.exe");

            DexploreArgs = _persistenceManager.ReadString(
                Constants.KEY_DEXPLORE_ARGS,
                @"/helpcol ms-help://MS.NETFramework.v20.en /usehelpsettings NETFrameworkSDK.20 ");

            ClrDbgPath = _persistenceManager.ReadString(
                Constants.KEY_CLRDBG_PATH,
                @"C:\Program Files\Microsoft.NET\SDK\v2.0\GuiDebug\DbgCLR.exe");
        }
Beispiel #9
0
        public void Update()
        {
            /*
             * The default server path is not required: the plugin
             * will populate the key with the installed path on
             * first-time startup. First time use is determined by
             * the String.Empty value.
             */

            ServerPath = _persistenceManager.ReadString(
                Constants.KEY_WEB_SERVER_PATH, String.Empty);

            ServerPort = _persistenceManager.ReadString(
                Constants.KEY_WEB_SERVER_PORT,
                "8080");

            ServerRoot = _persistenceManager.ReadString(
                Constants.KEY_WEB_SERVER_ROOT,
                "/");
        }
Beispiel #10
0
        public SqlMetalOptionsPage()
        {
            Name      = Constants.UI_OPTIONS_PAGE_SQLMETAL;
            PageText  = Resources.OptionsPageTextSqlMetal;
            GroupText = Resources.OptionsGroupText;

            _sqlMetalPathLabel        = new Label();
            _sqlMetalPathTextBox      = new TextBox();
            _sqlMetalPathWarningLabel = new Label();

            Controls.Add(_sqlMetalPathLabel);
            Controls.Add(_sqlMetalPathTextBox);
            Controls.Add(_sqlMetalPathWarningLabel);

            #region Form Layout

            _sqlMetalPathLabel.AutoSize = true;
            _sqlMetalPathLabel.Location = new System.Drawing.Point(0, 0);
            _sqlMetalPathLabel.Name     = m_sqlMetalPathLabel;
            _sqlMetalPathLabel.TabIndex = 0;
            _sqlMetalPathLabel.Text     = Resources.SqlMetalToolPath;

            _sqlMetalPathTextBox.Location = new System.Drawing.Point(3, 16);
            _sqlMetalPathTextBox.Name     = m_sqlMetalPathTextBox;
            _sqlMetalPathTextBox.Size     = new System.Drawing.Size(424, 20);
            _sqlMetalPathTextBox.TabIndex = 1;

            _sqlMetalPathWarningLabel.AutoSize  = true;
            _sqlMetalPathWarningLabel.Location  = new System.Drawing.Point(0, 46);
            _sqlMetalPathWarningLabel.Name      = m_sqlMetalPathWarningLabel;
            _sqlMetalPathWarningLabel.TabIndex  = 2;
            _sqlMetalPathWarningLabel.ForeColor = Color.Red;
            _sqlMetalPathWarningLabel.Text      = Resources.SqlMetalToolPathWarning;
            _sqlMetalPathWarningLabel.Visible   = false;

            #endregion

            _persistenceManager = ApplicationManager.GetInstance().
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            // Update the form
            _sqlMetalPathTextBox.Text = _persistenceManager.ReadString(
                Constants.KEY_SQL_METAL_PATH,
                Constants.SQL_METAL_DEFAULT_PATH);

            if (!File.Exists(_sqlMetalPathTextBox.Text))
            {
                _sqlMetalPathWarningLabel.Visible = true;
            }
        }
Beispiel #11
0
        private void ActivatePlugin()
        {
            IPersistenceManager persistenceManager =
                ApplicationManager.GetInstance().GetPersistenceManager(
                    Constants.PLUGIN_NAME);

            string dataProviderInvariantName = persistenceManager.ReadString(
                Constants.KEY_DATA_PROVIDER_INVARIANT_NAME,
                Constants.DATA_PROVIDER_INVARIANT_NAME);

            SqlCodeAssistManager.GetInstance().
            RegisterProviderFactoryHandlers(
                dataProviderInvariantName,
                GetMSSqlCodeAssistProvider);
        }
Beispiel #12
0
        private IDockContent OpenSQLiteDocument(string path, bool readOnly)
        {
            string sqliteManagerPath = _persistenceManager.ReadString(
                Constants.KEY_SQLITE_MANAGER_PATH, String.Empty);

            if (File.Exists(sqliteManagerPath))
            {
                FileTools.LaunchApplication(true,
                                            sqliteManagerPath, String.Format("\"{0}\"", path));
            }

            /*
             * No document is created so return null.
             */

            return(null);
        }
        public SQLiteManagerOptionsPage()
        {
            Name      = Constants.UI_OPTIONS_PAGE_SQLITE_MANAGER;
            PageText  = Resources.OptionsPageText;
            GroupText = Resources.OptionsGroupText;

            _sqliteManagerPathLabel        = new Label();
            _sqliteMangerPathTextBox       = new TextBox();
            _sqliteManagerPathWarningLabel = new Label();

            Controls.Add(_sqliteManagerPathLabel);
            Controls.Add(_sqliteMangerPathTextBox);
            Controls.Add(_sqliteManagerPathWarningLabel);

            _sqliteManagerPathLabel.AutoSize = true;
            _sqliteManagerPathLabel.Location = new System.Drawing.Point(0, 0);
            _sqliteManagerPathLabel.Name     = m_sqliteManagerPathLabel;
            _sqliteManagerPathLabel.TabIndex = 0;
            _sqliteManagerPathLabel.Text     = Resources.SQLiteManagerPathLabel;

            _sqliteMangerPathTextBox.Location = new System.Drawing.Point(3, 16);
            _sqliteMangerPathTextBox.Name     = m_sqliteMangerPathTextBox;
            _sqliteMangerPathTextBox.Size     = new System.Drawing.Size(424, 20);
            _sqliteMangerPathTextBox.TabIndex = 1;

            _sqliteManagerPathWarningLabel.AutoSize  = true;
            _sqliteManagerPathWarningLabel.Location  = new System.Drawing.Point(0, 46);
            _sqliteManagerPathWarningLabel.Name      = m_sqliteManagerPathWarningLabel;
            _sqliteManagerPathWarningLabel.TabIndex  = 2;
            _sqliteManagerPathWarningLabel.ForeColor = Color.Red;
            _sqliteManagerPathWarningLabel.Text      = Resources.SQLiteManagerPathWarningLabel;
            _sqliteManagerPathWarningLabel.Visible   = false;

            _persistenceManager = ApplicationManager.GetInstance().
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            _sqliteMangerPathTextBox.Text = _persistenceManager.ReadString(
                Constants.KEY_SQLITE_MANAGER_PATH, String.Empty);

            if (!File.Exists(_sqliteMangerPathTextBox.Text))
            {
                _sqliteManagerPathWarningLabel.Visible = true;
            }
        }
Beispiel #14
0
        public void ActivatePlugin()
        {
            ApplicationManager applicationManager =
                ApplicationManager.GetInstance();

            /*
             * Get the path to the SQLite utility. The default value is
             * blank to signal that we need to create the default value
             * from the QuickSharp installation path.
             */

            _persistenceManager = applicationManager.
                                  GetPersistenceManager(Constants.PLUGIN_NAME);

            string sqliteManagerPath = _persistenceManager.ReadString(
                Constants.KEY_SQLITE_MANAGER_PATH, String.Empty);

            if (sqliteManagerPath == String.Empty)
            {
                sqliteManagerPath = Path.Combine(
                    applicationManager.QuickSharpHome,
                    Constants.SQLITE_MANAGER_EXE);

                _persistenceManager.WriteString(
                    Constants.KEY_SQLITE_MANAGER_PATH, sqliteManagerPath);
            }

            /*
             * Register the document open handler.
             */

            applicationManager.RegisterOpenDocumentHandler(
                Constants.DOCUMENT_TYPE_SQLITE, OpenSQLiteDocument);

            /*
             * Register the options page.
             */

            applicationManager.RegisterOptionsPageFactory(
                delegate { return(new SQLiteManagerOptionsPage()); });
        }
        private ReferenceManager()
        {
            _applicationManager = ApplicationManager.GetInstance();

            IPersistenceManager persistenceManager = _applicationManager.
                                                     GetPersistenceManager(Constants.PLUGIN_NAME);

            string databaseFilename = persistenceManager.ReadString(
                Constants.KEY_DATABASE_FILENAME,
                Constants.DEFAULT_DATABASE_FILENAME);

            if (FileTools.FilenameIsInvalid(databaseFilename))
            {
                databaseFilename = Constants.DEFAULT_DATABASE_FILENAME;
            }

            _referenceDatabasePath = Path.Combine(
                ApplicationManager.GetInstance().QuickSharpUserHome,
                databaseFilename);

            _fullNamespaceList = new List <string>();
            _rootNamespaceList = new List <string>();
        }
Beispiel #16
0
        private void SetMainFormState()
        {
            WindowState =
                (FormWindowState)Enum.Parse(typeof(FormWindowState),
                                            _persistenceManager.ReadString(
                                                Constants.KEY_WINDOW_STATE, "Normal"));

            Height = _persistenceManager.ReadInt(
                Constants.KEY_WINDOW_HEIGHT, 500);

            Width = _persistenceManager.ReadInt(
                Constants.KEY_WINDOW_WIDTH, 700);

            Location = new Point(
                _persistenceManager.ReadInt(Constants.KEY_WINDOW_X, 40),
                _persistenceManager.ReadInt(Constants.KEY_WINDOW_Y, 40));

            _mainStatusStrip.Visible = UI_VIEW_MENU_STATUSBAR.Checked =
                _persistenceManager.ReadBoolean(
                    Constants.KEY_STATUSBAR_VISIBLE, true);

            Text = _profile.ClientTitle;
            Icon = _profile.ClientIcon;
        }
Beispiel #17
0
        /// <summary>
        /// Initialize a new instance of the GeneralOptionsPage.
        /// </summary>
        public GeneralOptionsPage()
        {
            _applicationManager = ApplicationManager.GetInstance();
            _persistenceManager = _applicationManager.
                                  GetPersistenceManager(Constants.MODULE_NAME);

            Name      = Constants.UI_OPTIONS_PAGE_GENERAL;
            PageText  = Resources.OptionsPageTextGeneral;
            GroupText = Resources.OptionsGroupText;

            _documentsGroupBox          = new GroupBox();
            _restoreLastSessionCheckBox = new CheckBox();
            _showNoHandlerCheckBox      = new CheckBox();
            _allowShellOpenCheckBox     = new CheckBox();
            _showDocumentPathCheckBox   = new CheckBox();
            _themeGroupBox        = new GroupBox();
            _themeComboBox        = new ComboBox();
            _restartRequiredLabel = new Label();

            #region Form Layout

            _documentsGroupBox.Controls.Add(_restoreLastSessionCheckBox);
            _documentsGroupBox.Controls.Add(_showNoHandlerCheckBox);
            _documentsGroupBox.Controls.Add(_allowShellOpenCheckBox);
            _documentsGroupBox.Controls.Add(_showDocumentPathCheckBox);
            _documentsGroupBox.Location = new Point(0, 0);
            _documentsGroupBox.Name     = m_documentGroupBox;
            _documentsGroupBox.TabIndex = 0;
            _documentsGroupBox.TabStop  = false;
            _documentsGroupBox.Text     = Resources.OptionsDocumentsGroupBox;
            _documentsGroupBox.Size     = new Size(430, 137);

            _restoreLastSessionCheckBox.AutoSize = true;
            _restoreLastSessionCheckBox.Location = new Point(19, 22);
            _restoreLastSessionCheckBox.Name     = m_restoreLastSessionCheckBox;
            _restoreLastSessionCheckBox.TabIndex = 1;
            _restoreLastSessionCheckBox.Text     = Resources.OptionsRestoreLastSession;

            _showNoHandlerCheckBox.AutoSize = true;
            _showNoHandlerCheckBox.Location = new Point(19, 45);
            _showNoHandlerCheckBox.Name     = m_showNoHandlerCheckBox;
            _showNoHandlerCheckBox.TabIndex = 2;
            _showNoHandlerCheckBox.Text     = Resources.OptionsShowNoHandler;

            _allowShellOpenCheckBox.AutoSize = true;
            _allowShellOpenCheckBox.Location = new Point(19, 68);
            _allowShellOpenCheckBox.Name     = m_allowShellOpenCheckBox;
            _allowShellOpenCheckBox.TabIndex = 3;
            _allowShellOpenCheckBox.Text     = Resources.OptionsAllowShellOpen;

            _showDocumentPathCheckBox.AutoSize = true;
            _showDocumentPathCheckBox.Location = new Point(19, 91);
            _showDocumentPathCheckBox.Name     = m_showDocumentPathCheckBox;
            _showDocumentPathCheckBox.TabIndex = 4;
            _showDocumentPathCheckBox.Text     = Resources.OptionsShowDocumentPath;

            _themeGroupBox.Location = new Point(0, 144);
            _themeGroupBox.Name     = m_themeGroupBox;
            _themeGroupBox.TabIndex = 5;
            _themeGroupBox.TabStop  = false;
            _themeGroupBox.Text     = Resources.OptionsThemeGroupBox;
            _themeGroupBox.Size     = new Size(430, 78);
            _themeGroupBox.Controls.Add(_themeComboBox);

            _themeComboBox.Location      = new Point(19, 31);
            _themeComboBox.Name          = m_themeComboBox;
            _themeComboBox.TabIndex      = 6;
            _themeComboBox.Size          = new Size(392, 21);
            _themeComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            _themeComboBox.DisplayMember = "Name";

            _restartRequiredLabel.AutoSize = true;
            _restartRequiredLabel.Location = new System.Drawing.Point(0, 230);
            _restartRequiredLabel.Name     = m_restartRequiredLabel;
            _restartRequiredLabel.Text     = Resources.OptionsRestartRequired;
            _restartRequiredLabel.TabIndex = 7;

            Controls.Add(_documentsGroupBox);
            Controls.Add(_themeGroupBox);
            Controls.Add(_restartRequiredLabel);

            #endregion

            _restoreLastSessionCheckBox.Checked =
                _persistenceManager.ReadBoolean(
                    Constants.KEY_DOCUMENT_RESTORE_LAST_SESSION, false);

            _showNoHandlerCheckBox.Checked =
                _persistenceManager.ReadBoolean(
                    Constants.KEY_DOCUMENT_SHOW_NO_HANDLER_MESSAGE, true);

            _allowShellOpenCheckBox.Checked =
                _persistenceManager.ReadBoolean(
                    Constants.KEY_DOCUMENT_ALLOW_SHELL_OPEN, true);

            _showDocumentPathCheckBox.Checked =
                _persistenceManager.ReadBoolean(
                    Constants.KEY_SHOW_DOCUMENT_PATH, false);

            string savedTheme = _persistenceManager.ReadString(
                Constants.KEY_SELECTED_THEME,
                _applicationManager.SelectedTheme);

            // Is the theme still available?
            if (_applicationManager.GetThemeProvider(savedTheme) == null)
            {
                savedTheme = Constants.DEFAULT_THEME_ID;
            }

            List <StringMap> themes =
                _applicationManager.ThemeProviderMap;

            foreach (StringMap map in themes)
            {
                _themeComboBox.Items.Add(map);

                if (map.Value == savedTheme)
                {
                    _themeComboBox.SelectedItem = map;
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// Create the main form.
        /// </summary>
        public MainForm()
        {
            _applicationManager          = ApplicationManager.GetInstance();
            _applicationManager.MainForm = this;

            /*
             * Get the ClientProfile.
             */

            _profile = _applicationManager.ClientProfile;

            if (_profile == null)
            {
                throw new Exception(Resources.NullClientProfileMessage);
            }

            /*
             * Register the default persistence provider and
             * create the settings persistence manager.
             */

            _applicationManager.RegisterPersistenceProvider(
                Constants.REGISTRY_PERSISTENCE_PROVIDER,
                RegistryPersistenceManager.GetInstance);

            _persistenceManager = _applicationManager.
                                  GetPersistenceManager(Constants.MODULE_NAME);

            /*
             * Set default form providers.
             */

            if (_profile.UpdateCheckFormFactory == null)
            {
                _profile.UpdateCheckFormFactory = delegate
                { return(new UpdateCheckForm()); }
            }
            ;

            if (_profile.AboutBoxFactory == null)
            {
                _profile.AboutBoxFactory = delegate
                { return(new AboutForm()); }
            }
            ;

            /*
             * Get any command line flags and values.
             */

            foreach (string arg in _profile.CommandLineArgs)
            {
                if (arg[0] != '/' && arg[0] != '-')
                {
                    continue;
                }
                if (arg.Length < 2)
                {
                    continue;
                }
                _applicationManager.AddCommandLineSwitch(arg.Substring(1));
            }

            /*
             * Determine if documents should be opened by the Windows shell
             * and if "no handler" messages should be shown.
             */

            _allowShellOpen = _persistenceManager.ReadBoolean(
                Constants.KEY_DOCUMENT_ALLOW_SHELL_OPEN, true);

            _showNoHandlerMessage = _persistenceManager.ReadBoolean(
                Constants.KEY_DOCUMENT_SHOW_NO_HANDLER_MESSAGE, true);

            _showDocumentChangeStatusMessage = _persistenceManager.ReadBoolean(
                Constants.KEY_SHOW_DOCUMENT_PATH, false);

            /*
             * Set up the MRU documents list.
             */

            _recentlyUsedDocuments = _persistenceManager.ReadStrings(
                Constants.KEY_MRU_DOCUMENTS_LIST);

            // Trim down to size if too big
            while (_recentlyUsedDocuments.Count > _profile.MRUDocumentListMax)
            {
                _recentlyUsedDocuments.RemoveAt(0);
            }

            /*
             * Optionally allow the documents open at the end of the last
             * session to be restored.
             */

            if (_persistenceManager.ReadBoolean(
                    Constants.KEY_DOCUMENT_RESTORE_LAST_SESSION, false))
            {
                _restoreDocumentsFromLastSession = true;
            }

            /*
             * Optionally reset the window configuration.
             */

            if (_applicationManager.HaveCommandLineSwitch(Resources.SwitchClean) &&
                _applicationManager.HaveDockPanelConfig)
            {
                File.Delete(_applicationManager.DockPanelConfigFile);
            }

            /*
             * Initialize the form.
             */

            InitializeComponent();

            /*
             * Add the Help and UpdateCheck menu items if needed.
             * Do this here to avoid adding the menu items after the
             * plugins and confusing their menu placement strategies.
             */

            SetApplicationHelpState();
            SetUpdateCheckState();

            /*
             * Prepare the main toolbar. Create the main toolbar
             * before the plugins so items can be added if required.
             */

            CreateMainToolbar();

            /*
             * Load the available plugins.
             */

            _pluginManager = PluginManager.GetInstance();
            _pluginManager.LoadPlugins();
            _pluginManager.RegisterPlugins();
            _pluginManager.ActivatePlugins(this);

            /*
             * Load the toolbars and setup the menu.
             */

            LoadDockedToolStrips();

            /*
             * Enable the document management UI if documents and document
             * handlers have been registered.
             */

            UI_FILE_MENU_NEW.Enabled = UI_TOOLBAR_NEW.Enabled = false;

            if (_applicationManager.NewDocumentType != null &&
                _applicationManager.NewDocumentHandler != null)
            {
                UI_FILE_MENU_NEW.Enabled = UI_TOOLBAR_NEW.Enabled = true;
            }

            UI_FILE_MENU_OPEN.Enabled = UI_TOOLBAR_OPEN.Enabled = false;

            if (_applicationManager.OpenDocumentHandlers.Count > 0)
            {
                UI_FILE_MENU_OPEN.Enabled = UI_TOOLBAR_OPEN.Enabled = true;
            }

            /*
             * Optionally display the current document path on the status bar
             * for 3 seconds whenever the it changes.
             */

            if (_showDocumentChangeStatusMessage)
            {
                ClientWindow.ActiveDocumentChanged += delegate
                {
                    Document doc = ClientWindow.ActiveDocument as Document;

                    if (doc != null && doc.FilePath != null)
                    {
                        SetStatusBarMessage(doc.FilePath, 5);
                    }
                    else
                    {
                        SetStatusBarMessage(String.Empty);
                    }
                };
            }

            /*
             * Set the theme.
             */

            // Register the default 'do nothing' theme.
            _applicationManager.RegisterThemeProvider(
                new DefaultTheme());

            // Register the built in Visual Studio 2008 theme.
            if (!_profile.HaveFlag(ClientFlags.CoreDisableVisualStudio2008Theme))
            {
                _applicationManager.RegisterThemeProvider(
                    new VS2008Theme());
            }

            // Register the built in Visual Studio 2010 themes.
            if (!_profile.HaveFlag(ClientFlags.CoreDisableVisualStudio2010Theme))
            {
                _applicationManager.RegisterThemeProvider(
                    new VS2010ThemeBasic());
                _applicationManager.RegisterThemeProvider(
                    new VS2010ThemeEnhanced());
            }

            // Set the currently selected theme, use VS2010 for
            // initially selected theme. If this isn't available
            // SelectTheme will bump it down to the default.
            _applicationManager.SelectedTheme =
                _persistenceManager.ReadString(
                    Constants.KEY_SELECTED_THEME,
                    Constants.VS2010_ENHANCED_THEME_ID);

            IQuickSharpTheme provider =
                _applicationManager.GetSelectedThemeProvider();

            if (provider != null)
            {
                provider.ApplyTheme();
            }

            if (_profile.ThemeFlags != null &&
                _profile.ThemeFlags.MenuForeColor != Color.Empty)
            {
                MenuTools.MenuStripItemsSetForeColor(MainMenu,
                                                     _profile.ThemeFlags.MenuForeColor,
                                                     _profile.ThemeFlags.MenuHideImages);
            }

            // Send notification that the theme has been activated.
            if (ThemeActivated != null)
            {
                ThemeActivated();
            }

            /*
             * Set or restore the layout of the main form.
             */

            SetMainFormState();
            UpdateMenuItems();
            UpdateToolbarItems();

            /*
             * Register the option pages. (This needs to be after
             * the plugins and default themes are loaded/registered.)
             */

            _applicationManager.RegisterOptionsPageFactory(
                delegate { return(new GeneralOptionsPage()); });

            /*
             * Restore the document state after the window is loaded
             * otherwise the drop-down window list doesn't get shown.
             */

            Load += delegate
            {
                /*
                 * Restore the saved dockpanel state.
                 */

                SetDockPanelState();

                /*
                 * Allow plugins to set default window states
                 * if not restored from the saved config.
                 */

                if (DockPanelPostLoad != null)
                {
                    DockPanelPostLoad();
                }

                /*
                 * Load documents from the command line.
                 */

                LoadDocuments();
            };
        }