Beispiel #1
0
        /// <summary>
        /// Create an instance of the application options editor.
        /// </summary>
        public OptionsForm()
        {
            ApplicationManager _applicationManager =
                ApplicationManager.GetInstance();

            InitializeComponent();

            /*
             * Get the form proxy so we can call any update events.
             */

            OptionsFormProxy formProxy = OptionsFormProxy.GetInstance();

            /*
             * Call each registered page factory to get the pages.
             */

            _pages = new Dictionary <String, OptionsPage>();

            foreach (OptionsPageFactoryHandler d in
                     _applicationManager.OptionsPageFactoryHandlers)
            {
                OptionsPage page = d();

                if (page != null)
                {
                    _pages[page.Name] = page;
                }
            }

            formProxy.UpdateOptionsFormPages(_pages);

            /*
             * Create the groups and assign the child pages.
             */

            _groups = new Dictionary <String, List <String> >();

            foreach (OptionsPage page in _pages.Values)
            {
                if (!_groups.ContainsKey(page.GroupText))
                {
                    _groups[page.GroupText] = new List <String>();
                }

                _groups[page.GroupText].Add(page.Name);
            }

            /*
             * Populate the tree.
             */

            optionsTreeView.SuspendLayout();

            foreach (string groupText in _groups.Keys)
            {
                /*
                 * Groups will be empty, have one page or several pages.
                 * If group has only one page, the group will access the
                 * page directly, otherwise it will be the parent of the
                 * sub pages.
                 */

                if (_groups[groupText].Count < 1)
                {
                    continue;
                }

                if (_groups[groupText].Count == 1)
                {
                    PageNode groupNode = new PageNode();
                    groupNode.Text = groupText;
                    groupNode.Name = _groups[groupText][0];

                    optionsTreeView.Nodes.Add(groupNode);
                }
                else if (_groups[groupText].Count > 1)
                {
                    TreeNode groupNode = new TreeNode();
                    groupNode.Text = groupText;

                    foreach (string pageName in _groups[groupText])
                    {
                        OptionsPage page = _pages[pageName];

                        PageNode pageNode = new PageNode();
                        pageNode.Text = page.PageText;
                        pageNode.Name = page.Name;

                        groupNode.Nodes.Add(pageNode);
                    }

                    optionsTreeView.Nodes.Add(groupNode);
                }

                optionsTreeView.ResumeLayout(true);
            }

            /*
             * Call the control update proxy.
             */

            formProxy.UpdateOptionsFormControls(Controls);

            /*
             * Sort the top level nodes.
             */

            if (optionsTreeView.Nodes.Count > 0)
            {
                optionsTreeView.TreeViewNodeSorter = new TreeNodeSorter();
                optionsTreeView.Sort();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initialize the theme base.
 /// </summary>
 public BaseTheme()
 {
     applicationManager = ApplicationManager.GetInstance();
     mainForm           = applicationManager.MainForm;
 }
Beispiel #3
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;
                }
            }
        }