public void Save() { // General settings ConfigSection GeneralSection = ConfigFile.FindOrAddSection("General"); GeneralSection.Clear(); GeneralSection.SetValue("Version", (int)Version); GeneralSection.SetValue("BuildAfterSync", bBuildAfterSync); GeneralSection.SetValue("RunAfterSync", bRunAfterSync); GeneralSection.SetValue("SyncPrecompiledEditor", bSyncPrecompiledEditor); GeneralSection.SetValue("OpenSolutionAfterSync", bOpenSolutionAfterSync); GeneralSection.SetValue("ShowLogWindow", bShowLogWindow); GeneralSection.SetValue("AutoResolveConflicts", bAutoResolveConflicts); GeneralSection.SetValue("IncrementalBuilds", bUseIncrementalBuilds); GeneralSection.SetValue("ShowUnreviewed", bShowUnreviewedChanges); GeneralSection.SetValue("ShowAutomated", bShowAutomatedChanges); GeneralSection.SetValue("ShowLocalTimes", bShowLocalTimes); if (LastProject != null) { GeneralSection.SetValue("LastProject", LastProject.ToConfigEntry()); } GeneralSection.SetValues("OpenProjects", OpenProjects.Select(x => x.ToConfigEntry()).ToArray()); GeneralSection.SetValue("KeepInTray", bKeepInTray); GeneralSection.SetValue("FilterIndex", FilterIndex); GeneralSection.SetValues("RecentProjects", RecentProjects.Select(x => x.ToConfigEntry()).ToArray()); GeneralSection.SetValues("SyncFilter", SyncView); GeneralSection.SetValues("SyncExcludedCategories", SyncExcludedCategories); GeneralSection.SetValue("SyncAllProjects", bSyncAllProjects); GeneralSection.SetValue("IncludeAllProjectsInSolution", bIncludeAllProjectsInSolution); GeneralSection.SetValue("SyncType", SyncType.ToString()); // Build configuration GeneralSection.SetValue("BuildConfig", CompiledEditorBuildConfig.ToString()); // Tab labels GeneralSection.SetValue("TabLabels", TabLabels.ToString()); // Editor arguments List <string> EditorArgumentList = new List <string>(); foreach (Tuple <string, bool> EditorArgument in EditorArguments) { EditorArgumentList.Add(String.Format("{0}:{1}", EditorArgument.Item2? 1 : 0, EditorArgument.Item1)); } GeneralSection.SetValues("EditorArguments", EditorArgumentList.ToArray()); GeneralSection.SetValue("EditorArgumentsPrompt", bEditorArgumentsPrompt); // Schedule settings ConfigSection ScheduleSection = ConfigFile.FindOrAddSection("Schedule"); ScheduleSection.Clear(); ScheduleSection.SetValue("Enabled", bScheduleEnabled); ScheduleSection.SetValue("Time", ScheduleTime.ToString()); ScheduleSection.SetValue("Change", ScheduleChange.ToString()); ScheduleSection.SetValue("AnyOpenProject", ScheduleAnyOpenProject); ScheduleSection.SetValues("Projects", ScheduleProjects.Select(x => x.ToConfigEntry()).ToArray()); // Window settings ConfigSection WindowSection = ConfigFile.FindOrAddSection("Window"); WindowSection.Clear(); WindowSection.SetValue("Visible", bWindowVisible); WindowSection.SetValue("State", WindowState.ToString()); if (WindowBounds != null) { WindowSection.SetValue("Bounds", FormatRectangleValue(WindowBounds.Value)); } // Notification settings ConfigSection NotificationSection = ConfigFile.FindOrAddSection("Notifications"); NotificationSection.Clear(); if (NotifyUnassignedMinutes != -1) { NotificationSection.SetValue("NotifyUnassignedMinutes", NotifyUnassignedMinutes); } if (NotifyUnacknowledgedMinutes != -1) { NotificationSection.SetValue("NotifyUnacknowledgedMinutes", NotifyUnacknowledgedMinutes); } if (NotifyUnresolvedMinutes != -1) { NotificationSection.SetValue("NotifyUnresolvedMinutes", NotifyUnresolvedMinutes); } // Current workspace settings foreach (KeyValuePair <string, UserWorkspaceSettings> Pair in WorkspaceKeyToSettings) { string CurrentWorkspaceKey = Pair.Key; UserWorkspaceSettings CurrentWorkspace = Pair.Value; ConfigSection WorkspaceSection = ConfigFile.FindOrAddSection(CurrentWorkspaceKey); WorkspaceSection.Clear(); WorkspaceSection.SetValue("CurrentProjectPath", CurrentWorkspace.CurrentProjectIdentifier); WorkspaceSection.SetValue("CurrentChangeNumber", CurrentWorkspace.CurrentChangeNumber); if (CurrentWorkspace.CurrentSyncFilterHash != null) { WorkspaceSection.SetValue("CurrentSyncFilterHash", CurrentWorkspace.CurrentSyncFilterHash); } WorkspaceSection.SetValues("AdditionalChangeNumbers", CurrentWorkspace.AdditionalChangeNumbers.Select(x => x.ToString()).ToArray()); WorkspaceSection.SetValue("LastSyncResult", CurrentWorkspace.LastSyncResult.ToString()); WorkspaceSection.SetValue("LastSyncResultMessage", EscapeText(CurrentWorkspace.LastSyncResultMessage)); WorkspaceSection.SetValue("LastSyncChangeNumber", CurrentWorkspace.LastSyncChangeNumber); if (CurrentWorkspace.LastSyncTime.HasValue) { WorkspaceSection.SetValue("LastSyncTime", CurrentWorkspace.LastSyncTime.ToString()); } if (CurrentWorkspace.LastSyncDurationSeconds > 0) { WorkspaceSection.SetValue("LastSyncDuration", CurrentWorkspace.LastSyncDurationSeconds); } WorkspaceSection.SetValue("LastBuiltChangeNumber", CurrentWorkspace.LastBuiltChangeNumber); WorkspaceSection.SetValues("ExpandedArchiveName", CurrentWorkspace.ExpandedArchiveTypes); WorkspaceSection.SetValues("SyncFilter", CurrentWorkspace.SyncView); WorkspaceSection.SetValues("SyncIncludedCategories", CurrentWorkspace.SyncIncludedCategories); WorkspaceSection.SetValues("SyncExcludedCategories", CurrentWorkspace.SyncExcludedCategories); if (CurrentWorkspace.bSyncAllProjects.HasValue) { WorkspaceSection.SetValue("SyncAllProjects", CurrentWorkspace.bSyncAllProjects.Value); } if (CurrentWorkspace.bIncludeAllProjectsInSolution.HasValue) { WorkspaceSection.SetValue("IncludeAllProjectsInSolution", CurrentWorkspace.bIncludeAllProjectsInSolution.Value); } List <ConfigObject> BisectEntryObjects = new List <ConfigObject>(); foreach (KeyValuePair <int, BisectState> BisectPair in CurrentWorkspace.ChangeNumberToBisectState) { ConfigObject BisectEntryObject = new ConfigObject(); BisectEntryObject.SetValue("Change", BisectPair.Key); BisectEntryObject.SetValue("State", BisectPair.Value.ToString()); BisectEntryObjects.Add(BisectEntryObject); } WorkspaceSection.SetValues("Bisect", BisectEntryObjects.Select(x => x.ToString()).ToArray()); } // Current project settings foreach (KeyValuePair <string, UserProjectSettings> Pair in ProjectKeyToSettings) { string CurrentProjectKey = Pair.Key; UserProjectSettings CurrentProject = Pair.Value; ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); ProjectSection.Clear(); ProjectSection.SetValues("BuildStep", CurrentProject.BuildSteps.Select(x => x.ToString()).ToArray()); if (CurrentProject.FilterType != FilterType.None) { ProjectSection.SetValue("FilterType", CurrentProject.FilterType.ToString()); } ProjectSection.SetValues("FilterBadges", CurrentProject.FilterBadges.ToArray()); } // Perforce settings ConfigSection PerforceSection = ConfigFile.FindOrAddSection("Perforce"); PerforceSection.Clear(); if (SyncOptions.NumRetries > 0) { PerforceSection.SetValue("NumRetries", SyncOptions.NumRetries); } if (SyncOptions.NumThreads > 0) { PerforceSection.SetValue("NumThreads", SyncOptions.NumThreads); } if (SyncOptions.TcpBufferSize > 0) { PerforceSection.SetValue("TcpBufferSize", SyncOptions.TcpBufferSize); } // Save the file ConfigFile.Save(FileName); }
public void Save() { // General settings ConfigSection GeneralSection = ConfigFile.FindOrAddSection("General"); GeneralSection.Clear(); GeneralSection.SetValue("BuildAfterSync", bBuildAfterSync); GeneralSection.SetValue("RunAfterSync", bRunAfterSync); GeneralSection.SetValue("SyncPrecompiledEditor", bSyncPrecompiledEditor); GeneralSection.SetValue("OpenSolutionAfterSync", bOpenSolutionAfterSync); GeneralSection.SetValue("ShowLogWindow", bShowLogWindow); GeneralSection.SetValue("AutoResolveConflicts", bAutoResolveConflicts); GeneralSection.SetValue("IncrementalBuilds", bUseIncrementalBuilds); GeneralSection.SetValue("ShowLocalTimes", bShowLocalTimes); GeneralSection.SetValue("ShowAllStreams", bShowAllStreams); GeneralSection.SetValue("LastProjectFileName", LastProjectFileName); GeneralSection.SetValues("OpenProjectFileNames", OpenProjectFileNames); GeneralSection.SetValue("KeepInTray", bKeepInTray); GeneralSection.SetValue("FilterIndex", FilterIndex); GeneralSection.SetValues("OtherProjectFileNames", OtherProjectFileNames); GeneralSection.SetValues("SyncFilter", SyncView); GeneralSection.SetValues("SyncExcludedCategories", SyncExcludedCategories); GeneralSection.SetValue("SyncType", SyncType.ToString()); // Build configuration GeneralSection.SetValue("BuildConfig", CompiledEditorBuildConfig.ToString()); // Tab names GeneralSection.SetValue("TabNames", TabLabels.ToString()); // Editor arguments List <string> EditorArgumentList = new List <string>(); foreach (Tuple <string, bool> EditorArgument in EditorArguments) { EditorArgumentList.Add(String.Format("{0}:{1}", EditorArgument.Item2? 1 : 0, EditorArgument.Item1)); } GeneralSection.SetValues("EditorArguments", EditorArgumentList.ToArray()); // Schedule settings ConfigSection ScheduleSection = ConfigFile.FindOrAddSection("Schedule"); ScheduleSection.Clear(); ScheduleSection.SetValue("Enabled", bScheduleEnabled); ScheduleSection.SetValue("Time", ScheduleTime.ToString()); ScheduleSection.SetValue("Change", ScheduleChange.ToString()); // Window settings if (bHasWindowSettings) { ConfigSection WindowSection = ConfigFile.FindOrAddSection("Window"); WindowSection.Clear(); WindowSection.SetValue("X", WindowRectangle.X); WindowSection.SetValue("Y", WindowRectangle.Y); WindowSection.SetValue("Width", WindowRectangle.Width); WindowSection.SetValue("Height", WindowRectangle.Height); ConfigObject ColumnWidthsObject = new ConfigObject(); foreach (KeyValuePair <string, int> ColumnWidthPair in ColumnWidths) { ColumnWidthsObject.SetValue(ColumnWidthPair.Key, ColumnWidthPair.Value.ToString()); } WindowSection.SetValue("ColumnWidths", ColumnWidthsObject.ToString()); WindowSection.SetValue("Visible", bWindowVisible); } // Current workspace settings foreach (KeyValuePair <string, UserWorkspaceSettings> Pair in WorkspaceKeyToSettings) { string CurrentWorkspaceKey = Pair.Key; UserWorkspaceSettings CurrentWorkspace = Pair.Value; ConfigSection WorkspaceSection = ConfigFile.FindOrAddSection(CurrentWorkspaceKey); WorkspaceSection.Clear(); WorkspaceSection.SetValue("CurrentProjectPath", CurrentWorkspace.CurrentProjectIdentifier); WorkspaceSection.SetValue("CurrentChangeNumber", CurrentWorkspace.CurrentChangeNumber); WorkspaceSection.SetValues("AdditionalChangeNumbers", CurrentWorkspace.AdditionalChangeNumbers.Select(x => x.ToString()).ToArray()); WorkspaceSection.SetValue("LastSyncResult", CurrentWorkspace.LastSyncResult.ToString()); WorkspaceSection.SetValue("LastSyncResultMessage", EscapeText(CurrentWorkspace.LastSyncResultMessage)); WorkspaceSection.SetValue("LastSyncChangeNumber", CurrentWorkspace.LastSyncChangeNumber); if (CurrentWorkspace.LastSyncTime.HasValue) { WorkspaceSection.SetValue("LastSyncTime", CurrentWorkspace.LastSyncTime.ToString()); } if (CurrentWorkspace.LastSyncDurationSeconds > 0) { WorkspaceSection.SetValue("LastSyncDuration", CurrentWorkspace.LastSyncDurationSeconds); } WorkspaceSection.SetValue("LastBuiltChangeNumber", CurrentWorkspace.LastBuiltChangeNumber); WorkspaceSection.SetValues("ExpandedArchiveName", CurrentWorkspace.ExpandedArchiveTypes); WorkspaceSection.SetValues("SyncFilter", CurrentWorkspace.SyncView); WorkspaceSection.SetValues("SyncExcludedCategories", CurrentWorkspace.SyncExcludedCategories); } // Current project settings foreach (KeyValuePair <string, UserProjectSettings> Pair in ProjectKeyToSettings) { string CurrentProjectKey = Pair.Key; UserProjectSettings CurrentProject = Pair.Value; ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); ProjectSection.Clear(); ProjectSection.SetValues("BuildStep", CurrentProject.BuildSteps.Select(x => x.ToString()).ToArray()); } // Perforce settings ConfigSection PerforceSection = ConfigFile.FindOrAddSection("Perforce"); PerforceSection.Clear(); if (SyncOptions.NumRetries > 0) { PerforceSection.SetValue("NumRetries", SyncOptions.NumRetries); } if (SyncOptions.NumThreads > 0) { PerforceSection.SetValue("NumThreads", SyncOptions.NumThreads); } if (SyncOptions.TcpBufferSize > 0) { PerforceSection.SetValue("TcpBufferSize", SyncOptions.TcpBufferSize); } // Save the file ConfigFile.Save(FileName); }