Example #1
0
 /// <summary>
 /// Load general settings from the session persistence store.
 /// </summary>
 public void LoadSettings()
 {
     AllwaysBuildOnCompile = _persistenceManager.ReadBoolean(
         Constants.KEY_ALWAYS_BUILD_ON_COMPILE, false);
     AllwaysBuildOnRun = _persistenceManager.ReadBoolean(
         Constants.KEY_ALWAYS_BUILD_ON_RUN, false);
 }
Example #2
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);
            }
        }
Example #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);
        }
Example #4
0
 public void Update()
 {
     ColorizeTypes = _persistenceManager.ReadBoolean(
         Constants.KEY_COLORIZE_TYPES, false);
     ColorizeVariables = _persistenceManager.ReadBoolean(
         Constants.KEY_COLORIZE_VARIABLES, false);
     ColorizeOnActivate = _persistenceManager.ReadBoolean(
         Constants.KEY_COLORIZE_ON_ACTIVATE, false);
     ColorizeOnLookup = _persistenceManager.ReadBoolean(
         Constants.KEY_COLORIZE_ON_LOOKUP, false);
 }
Example #5
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);
        }
Example #6
0
        private void ActivatePlugin()
        {
            _applicationManager = ApplicationManager.GetInstance();

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

            bool haveTools = persistenceManager.ReadBoolean(
                Constants.KEY_HAVE_MONO_TOOLS, false);

            if (!haveTools && CreateDefaultTools())
            {
                persistenceManager.WriteBoolean(
                    Constants.KEY_HAVE_MONO_TOOLS, true);
            }
        }
Example #7
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;
        }
Example #8
0
        /// <summary>
        /// Copy the files in the named content folder to the user data folder.
        /// </summary>
        /// <param name="contentName">The name of the content folder to deploy.
        /// </param>
        public static void DeployContent(string contentName)
        {
            ApplicationManager applicationManager =
                ApplicationManager.GetInstance();

            /*
             * Check content hasn't been deployed already.
             */

            IPersistenceManager persistenceManager =
                applicationManager.GetPersistenceManager(contentName);

            bool contentDeployed = persistenceManager.ReadBoolean(
                Constants.KEY_USER_CONTENT_DEPLOYED, false);

            if (contentDeployed)
            {
                return;
            }

            /*
             * Check we have content to deploy.
             */

            string contentRoot = Path.Combine(
                Constants.USER_CONTENT_FOLDER, contentName);

            contentRoot = Path.Combine(
                applicationManager.QuickSharpHome, contentRoot);

            if (!Directory.Exists(contentRoot))
            {
                return;
            }

            int contentRootLength = contentRoot.Length;

            /*
             * Copy the content to the user home directory.
             * Just ignore any errors - there's nothing the end user
             * can do and any message is likely to be confusing.
             */

            string targetRoot = applicationManager.QuickSharpUserHome;

            string[] folders = Directory.GetDirectories(
                contentRoot, "*.*", SearchOption.AllDirectories);

            foreach (string folder in folders)
            {
                try
                {
                    string targetPath = Path.Combine(targetRoot,
                                                     folder.Substring(contentRootLength + 1));

                    Directory.CreateDirectory(targetPath);
                }
                catch
                {
                }
            }

            string[] files = Directory.GetFiles(
                contentRoot, "*.*", SearchOption.AllDirectories);

            foreach (string file in files)
            {
                try
                {
                    string targetPath = Path.Combine(targetRoot,
                                                     file.Substring(contentRootLength + 1));

                    File.Copy(file, targetPath);
                }
                catch
                {
                }
            }

            /*
             * Register that we've done it.
             */

            persistenceManager.WriteBoolean(
                Constants.KEY_USER_CONTENT_DEPLOYED, true);
        }
Example #9
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();
            };
        }
Example #10
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;
                }
            }
        }