public FormSettings(GitUICommands aCommands, SettingsPageReference initalPage = null)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            _initalPage = initalPage;

            //if form is created for translation purpose
            if (aCommands == null)
                return;

            // NEW:

            _commonLogic = new CommonLogic(Module);

            _checkSettingsLogic = new CheckSettingsLogic(_commonLogic, Module);
            _checklistSettingsPage = new ChecklistSettingsPage(_commonLogic, _checkSettingsLogic, Module, this);
            _checkSettingsLogic.ChecklistSettingsPage = _checklistSettingsPage; // TODO
            _settingsPageRegistry.RegisterSettingsPage(_checklistSettingsPage);

            _gitSettingsPage = new GitSettingsPage(_checkSettingsLogic, this);
            _settingsPageRegistry.RegisterSettingsPage(_gitSettingsPage);

            _gitExtensionsSettingsPage = new GitExtensionsSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_gitExtensionsSettingsPage);

            _appearanceSettingsPage = new AppearanceSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_appearanceSettingsPage);

            _colorsSettingsPage = new ColorsSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_colorsSettingsPage);

            _startPageSettingsPage = new StartPageSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_startPageSettingsPage);

            _globalSettingsSettingsPage = new GlobalSettingsSettingsPage(_commonLogic, _checkSettingsLogic, Module);
            _settingsPageRegistry.RegisterSettingsPage(_globalSettingsSettingsPage);

            _localSettingsSettingsPage = new LocalSettingsSettingsPage(_commonLogic, _checkSettingsLogic, Module);
            _settingsPageRegistry.RegisterSettingsPage(_localSettingsSettingsPage);

            _sshSettingsPage = new SshSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_sshSettingsPage);
            _checklistSettingsPage.SshSettingsPage = _sshSettingsPage;

            _scriptsSettingsPage = new ScriptsSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_scriptsSettingsPage);

            _hotkeysSettingsPage = new HotkeysSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_hotkeysSettingsPage);

            _shellExtensionSettingsPage = new ShellExtensionSettingsPage();
            _settingsPageRegistry.RegisterSettingsPage(_shellExtensionSettingsPage);

            // register all plugin pages
            _settingsPageRegistry.RegisterPluginSettingsPages();

            settingsTreeViewUserControl1.SetSettingsPages(_settingsPageRegistry, _initalPage);
        }
        public void GotoPage(SettingsPageReference settingsPageReference)
        {
            foreach (var node in GetNodesWithSettingsPage())
            {
                var settingsPage = (ISettingsPage)node.Tag;

                if (settingsPage.GetType() == settingsPageReference.SettingsPageType)
                {
                    _isSelectionChangeTriggeredByGoto = true;
                    treeView1.SelectedNode = node;
                    FireSettingsPageSelectedEvent(node);
                    return;
                }
            }
        }
        public void GotoPage(SettingsPageReference settingsPageReference)
        {
            if (settingsPageReference.SettingsSection != null)
            {
                if (settingsPageReference.SettingsSection == SettingsPageReference.Section.GitExtensionsSettings)
                {
                    _geRootNode.Expand();
                    _pluginsRootNode.Collapse();

                    if (_geRootNode.Nodes.Count > 0)
                    {
                        treeView1.SelectedNode = _geRootNode.Nodes[0];
                    }
                }
                else if (settingsPageReference.SettingsSection == SettingsPageReference.Section.PluginsSettings)
                {
                    _geRootNode.Collapse();
                    _pluginsRootNode.Expand();

                    if (_pluginsRootNode.Nodes.Count > 0)
                    {
                        treeView1.SelectedNode = _pluginsRootNode.Nodes[0];
                    }
                }
                else
                {
                    // programming error: forgot to handle a case
                }
            }

            if (settingsPageReference.SettingsPageType != null)
            {
                foreach (var node in GetNodesWithSettingsPage())
                {
                    var settingsPage = (ISettingsPage)node.Tag;

                    if (settingsPage.GetType() == settingsPageReference.SettingsPageType)
                    {
                        _isSelectionChangeTriggeredByGoto = true;
                        treeView1.SelectedNode = node;
                        break;
                    }
                }
            }

            FireSettingsPageSelectedEvent(treeView1.SelectedNode);
        }
        public void AddSettingsPage(ISettingsPage page, SettingsPageReference parentPageReference)
        {
            TreeNode node;
            if (parentPageReference == null)
                node = treeView1.Nodes.Add(page.GetTitle());
            else
            {
                TreeNode parentNode;
                if (!_Pages2NodeMap.TryGetValue(parentPageReference, out parentNode))
                    throw new ArgumentException("You have to add parent page first: " + parentPageReference.ToString());

                node = parentNode.Nodes.Add(page.GetTitle());
            }

            node.Tag = page;
            _Pages2NodeMap.Add(page.PageReference, node);
            _SettingsPages.Add(page);
        }
        public void GotoPage(SettingsPageReference settingsPageReference)
        {
            TreeNode node;
            if (settingsPageReference == null)
                node = treeView1.Nodes.Count > 0 ? treeView1.Nodes[0] : null;
            else
                _Pages2NodeMap.TryGetValue(settingsPageReference, out node);

            if (node != null)
            {
                _isSelectionChangeTriggeredByGoto = true;
                treeView1.SelectedNode = node;
                FireSettingsPageSelectedEvent(treeView1.SelectedNode);
                _isSelectionChangeTriggeredByGoto = false;
            }
        }
        public bool StartSettingsDialog(IWin32Window owner, SettingsPageReference initalPage = null)
        {
            if (!InvokeEvent(owner, PreSettings))
                return true;

            using (var form = new FormSettings(this, initalPage))
            {
                form.ShowDialog(owner);
            }

            InvokeEvent(owner, PostSettings);

            return true;
        }
        public void SetSettingsPages(SettingsPageRegistry settingsPageRegistry, SettingsPageReference initalPage)
        {
            AddSettingsPages(settingsPageRegistry.GetSettingsPages(), _geRootNode);

            AddSettingsPages(settingsPageRegistry.GetPluginSettingsPages(), _pluginsRootNode);

            if (initalPage == null)
            {
                initalPage = new SettingsPageReference(SettingsPageReference.Section.GitExtensionsSettings);
            }
            GotoPage(initalPage);
        }
 public void GotoPage(SettingsPageReference settingsPageReference)
 {
     settingsTreeViewUserControl1.GotoPage(settingsPageReference);
 }
        public FormSettings(GitUICommands aCommands, SettingsPageReference initalPage = null)
            : base(aCommands)
        {
            InitializeComponent();
            Translate();

            //if form is created for translation purpose
            if (aCommands == null)
                return;

            // NEW:
            settingsTreeView.AddSettingsPage(new GitExtensionsSettingsGroup(), null);
            SettingsPageReference gitExtPageRef = GitExtensionsSettingsGroup.GetPageReference();

            _commonLogic = new CommonLogic(Module);

            _checkSettingsLogic = new CheckSettingsLogic(_commonLogic, Module);
            var checklistSettingsPage = new ChecklistSettingsPage(_commonLogic, _checkSettingsLogic, Module, this);
            _checkSettingsLogic.ChecklistSettingsPage = checklistSettingsPage; // TODO
            settingsTreeView.AddSettingsPage(checklistSettingsPage, gitExtPageRef);

            settingsTreeView.AddSettingsPage(new GitSettingsPage(_checkSettingsLogic, this), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new GitExtensionsSettingsPage(), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new AppearanceSettingsPage(), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new ColorsSettingsPage(), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new StartPageSettingsPage(), gitExtPageRef);

            var globalSettingsSettingsPage = new GlobalSettingsSettingsPage(_commonLogic, _checkSettingsLogic, Module);
            settingsTreeView.AddSettingsPage(globalSettingsSettingsPage, gitExtPageRef);

            var localSettingsSettingsPage = new LocalSettingsSettingsPage(_commonLogic, _checkSettingsLogic, Module);
            settingsTreeView.AddSettingsPage(localSettingsSettingsPage, gitExtPageRef);

            var _sshSettingsPage = new SshSettingsPage();
            settingsTreeView.AddSettingsPage(_sshSettingsPage, gitExtPageRef);
            checklistSettingsPage.SshSettingsPage = _sshSettingsPage;

            settingsTreeView.AddSettingsPage(new ScriptsSettingsPage(), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new HotkeysSettingsPage(), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new ShellExtensionSettingsPage(), gitExtPageRef);

            settingsTreeView.AddSettingsPage(new AdvancedSettingsPage(), gitExtPageRef);
            SettingsPageReference advancedPageRef = AdvancedSettingsPage.GetPageReference();

            settingsTreeView.AddSettingsPage(new ConfirmationsSettingsPage(), advancedPageRef);

            settingsTreeView.AddSettingsPage(new PluginsSettingsGroup(), null);
            SettingsPageReference pluginsPageRef = PluginsSettingsGroup.GetPageReference();
            foreach (var gitPlugin in LoadedPlugins.Plugins)
            {
                var settingsPage = PluginSettingsPage.CreateSettingsPageFromPlugin(gitPlugin);
                settingsTreeView.AddSettingsPage(settingsPage, pluginsPageRef);
            }

            settingsTreeView.GotoPage(initalPage);
        }
 public void GotoPage(SettingsPageReference settingsPageReference)
 {
     settingsTreeView.GotoPage(settingsPageReference);
 }