private void setSearchByAuthorEnabled(bool isEnabled, string hostname) { checkBoxSearchByAuthor.Enabled = isEnabled; linkLabelFindMe.Enabled = isEnabled; bool wasEnabled = comboBoxUser.Enabled; comboBoxUser.Enabled = isEnabled; if (!wasEnabled && isEnabled) { DataCache dataCache = getDataCache(EDataCacheType.Live); User[] users = dataCache?.UserCache?.GetUsers() .OrderBy(user => user.Name).ToArray() ?? Array.Empty <User>(); if (!users.Any()) { WinFormsHelpers.FillComboBox(comboBoxUser, users, _ => false); } else { User selectedUser = (User)comboBoxUser.SelectedItem; string previousSelection = selectedUser == null ? String.Empty : selectedUser.Name; bool hasPreviousSelection = users.SingleOrDefault(user => user.Name == previousSelection) != null; User defaultUser = getCurrentUser(hostname) ?? users.First(); string defaultUserFullName = hasPreviousSelection ? previousSelection : defaultUser.Name; WinFormsHelpers.FillComboBox(comboBoxUser, users, user => user.Name == defaultUserFullName); } } updateSearchButtonState(); }
/////////////////////////////////////////////////////////////////////////////////////////////////// private void setSearchByProjectEnabled(bool isEnabled) { checkBoxSearchByProject.Enabled = isEnabled; bool wasEnabled = comboBoxProjectName.Enabled; comboBoxProjectName.Enabled = isEnabled; if (!wasEnabled && isEnabled) { DataCache dataCache = getDataCache(EDataCacheType.Live); string[] projectNames = dataCache?.ProjectCache?.GetProjects() .OrderBy(project => project.Path_With_Namespace) .Select(project => project.Path_With_Namespace) .ToArray() ?? Array.Empty <string>(); string selectedProject = (string)comboBoxProjectName.SelectedItem; string previousSelection = selectedProject ?? String.Empty; string defaultProjectName = projectNames.SingleOrDefault(name => name == previousSelection) == null ? getDefaultProjectName() : previousSelection; WinFormsHelpers.FillComboBox(comboBoxProjectName, projectNames, projectName => projectName == defaultProjectName); } updateSearchButtonState(); }
public DiscussionFontSelectionPanel(Action <string> onFontSelectionChanged) { _onFontSelectionChanged = onFontSelectionChanged; InitializeComponent(); WinFormsHelpers.FillComboBox(comboBoxFonts, Constants.DiscussionsWindowFontSizeChoices, Program.Settings.MainWindowFontSizeName); }
private void setFontFromSettings() { WinFormsHelpers.FillComboBox(comboBoxFonts, Constants.MainWindowFontSizeChoices, name => name == Program.Settings.MainWindowFontSizeName); applyFont(Program.Settings.MainWindowFontSizeName); }
private void setThemeFromSettings() { WinFormsHelpers.FillComboBox(comboBoxThemes, Constants.ThemeNames, name => name == Program.Settings.VisualThemeName); applyTheme(Program.Settings.VisualThemeName); }
private void loadConfiguration() { _loadingConfiguration = true; Trace.TraceInformation("[MainForm] Loading configuration"); Program.Settings.PropertyChanged += onSettingsPropertyChanged; Debug.Assert(Program.Settings.KnownHosts.Count() == Program.Settings.KnownAccessTokens.Count()); // Remove all items except header for (int iListViewItem = 1; iListViewItem < listViewKnownHosts.Items.Count; ++iListViewItem) { listViewKnownHosts.Items.RemoveAt(iListViewItem); } List <string> newKnownHosts = new List <string>(); List <string> newAccessTokens = new List <string>(); for (int iKnownHost = 0; iKnownHost < Program.Settings.KnownHosts.Count(); ++iKnownHost) { // Upgrade from old versions which did not have prefix string host = StringUtils.GetHostWithPrefix(Program.Settings.KnownHosts[iKnownHost]); string accessToken = Program.Settings.KnownAccessTokens.Length > iKnownHost ? Program.Settings.KnownAccessTokens[iKnownHost] : String.Empty; if (addKnownHost(host, accessToken)) { newKnownHosts.Add(host); newAccessTokens.Add(accessToken); } } Program.Settings.KnownHosts = newKnownHosts.ToArray(); Program.Settings.KnownAccessTokens = newAccessTokens.ToArray(); if (Program.Settings.ColorSchemeFileName == String.Empty) { // Upgrade from old versions which did not have a separate file for Default color scheme Program.Settings.ColorSchemeFileName = getDefaultColorSchemeFileName(); } textBoxStorageFolder.Text = Program.Settings.LocalGitFolder; checkBoxDisplayFilter.Checked = Program.Settings.DisplayFilterEnabled; textBoxDisplayFilter.Text = Program.Settings.DisplayFilter; checkBoxMinimizeOnClose.Checked = Program.Settings.MinimizeOnClose; checkBoxRunWhenWindowsStarts.Checked = Program.Settings.RunWhenWindowsStarts; applyAutostartSetting(Program.Settings.RunWhenWindowsStarts); checkBoxDisableSplitterRestrictions.Checked = Program.Settings.DisableSplitterRestrictions; checkBoxNewDiscussionIsTopMostForm.Checked = Program.Settings.NewDiscussionIsTopMostForm; var showWarningsOnFileMismatchMode = ConfigurationHelper.GetShowWarningsOnFileMismatchMode(Program.Settings); switch (showWarningsOnFileMismatchMode) { case ConfigurationHelper.ShowWarningsOnFileMismatchMode.Always: radioButtonShowWarningsAlways.Checked = true; break; case ConfigurationHelper.ShowWarningsOnFileMismatchMode.Never: radioButtonShowWarningsNever.Checked = true; break; case ConfigurationHelper.ShowWarningsOnFileMismatchMode.UntilUserIgnoresFile: radioButtonShowWarningsOnce.Checked = true; break; } RevisionType defaultRevisionType = ConfigurationHelper.GetDefaultRevisionType(Program.Settings); switch (defaultRevisionType) { case RevisionType.Commit: radioButtonCommits.Checked = true; break; case RevisionType.Version: radioButtonVersions.Checked = true; break; } _mergeRequestFilter = new MergeRequestFilter(createMergeRequestFilterState()); _mergeRequestFilter.FilterChanged += updateVisibleMergeRequests; checkBoxShowNewMergeRequests.Checked = Program.Settings.Notifications_NewMergeRequests; checkBoxShowMergedMergeRequests.Checked = Program.Settings.Notifications_MergedMergeRequests; checkBoxShowUpdatedMergeRequests.Checked = Program.Settings.Notifications_UpdatedMergeRequests; checkBoxShowResolvedAll.Checked = Program.Settings.Notifications_AllThreadsResolved; checkBoxShowOnMention.Checked = Program.Settings.Notifications_OnMention; checkBoxShowKeywords.Checked = Program.Settings.Notifications_Keywords; checkBoxShowMyActivity.Checked = Program.Settings.Notifications_MyActivity; checkBoxShowServiceNotifications.Checked = Program.Settings.Notifications_Service; if (ConfigurationHelper.IsProjectBasedWorkflowSelected(Program.Settings)) { radioButtonSelectByProjects.Checked = true; } else { radioButtonSelectByUsernames.Checked = true; } LocalCommitStorageType type = ConfigurationHelper.GetPreferredStorageType(Program.Settings); switch (type) { case LocalCommitStorageType.FileStorage: radioButtonDontUseGit.Checked = true; break; case LocalCommitStorageType.FullGitRepository: radioButtonUseGitFullClone.Checked = true; break; case LocalCommitStorageType.ShallowGitRepository: radioButtonUseGitShallowClone.Checked = true; break; } if (comboBoxDCDepth.Items.Contains(Program.Settings.DiffContextDepth)) { comboBoxDCDepth.Text = Program.Settings.DiffContextDepth; } else { comboBoxDCDepth.SelectedIndex = 0; } loadColumnWidths(listViewMergeRequests, Program.Settings.ListViewMergeRequestsColumnWidths); loadColumnWidths(listViewFoundMergeRequests, Program.Settings.ListViewFoundMergeRequestsColumnWidths); loadColumnIndices(listViewMergeRequests, Program.Settings.ListViewMergeRequestsDisplayIndices, x => Program.Settings.ListViewMergeRequestsDisplayIndices = x); loadColumnIndices(listViewFoundMergeRequests, Program.Settings.ListViewFoundMergeRequestsDisplayIndices, x => Program.Settings.ListViewFoundMergeRequestsDisplayIndices = x); WinFormsHelpers.FillComboBox(comboBoxFonts, Constants.MainWindowFontSizeChoices, Program.Settings.MainWindowFontSizeName); applyFont(Program.Settings.MainWindowFontSizeName); WinFormsHelpers.FillComboBox(comboBoxThemes, Constants.ThemeNames, Program.Settings.VisualThemeName); applyTheme(Program.Settings.VisualThemeName); Trace.TraceInformation("[MainForm] Configuration loaded"); _loadingConfiguration = false; }