コード例 #1
0
        /// <summary>
        /// Loads the initial configuration.
        /// </summary>
        public void Load()
        {
            var tabControl = UIHelper.FindChild <TabControl>(Application.Current.MainWindow, "RepositoryTabs");

            Config = Configuration.LoadConfiguration();

            // We need to temporarily disable notifications to avoid collection modification within a loop.
            RepositoryViewModels.DisableNotifications();

            // Fill the "RecentRepositories" collection and load them.
            foreach (var recent in Config.RecentRepositories)
            {
                var repo = new RepositoryViewModel {
                    Name = recent.Name, RepositoryFullPath = recent.RepositoryFullPath
                };

                RecentRepositories.Add(repo);

                // If this repository was opened previously, re-open it again.
                if (Config.OpenedRepositories.Any(r => r.RepositoryFullPath == recent.RepositoryFullPath))
                {
                    repo.Init();
                    RepositoryViewModels.Add(repo);
                }
            }

            RepositoryViewModels.EnableNotifications(true);

            // Create the dashboard tab if there are no tabs opened.
            if (tabControl.Items.Count == 1) // The "+" tab is counted as one.
            {
                CreateTab(new object());     // Create "Dashboard".
            }
            // Select the first tab.
            tabControl.SelectedIndex = 0;
        }