public void CloseProject() { if (CurrentWorkspace != null || CurrentProject != null) { Save(); CurrentWorkspace = null; CurrentWorkspaceKey = null; CurrentProject = null; CurrentProjectKey = null; } }
public UserProjectSettings FindOrAddProject(string ClientProjectFileName) { // Read the project settings UserProjectSettings CurrentProject; if (!ProjectKeyToSettings.TryGetValue(ClientProjectFileName, out CurrentProject)) { CurrentProject = new UserProjectSettings(); ProjectKeyToSettings.Add(ClientProjectFileName, CurrentProject); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(ClientProjectFileName); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); } return(CurrentProject); }
public UserProjectSettings FindOrAddProject(string ClientProjectFileName) { // Read the project settings UserProjectSettings CurrentProject; if (!ProjectKeyToSettings.TryGetValue(ClientProjectFileName, out CurrentProject)) { CurrentProject = new UserProjectSettings(); ProjectKeyToSettings.Add(ClientProjectFileName, CurrentProject); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(ClientProjectFileName); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); if (!Enum.TryParse(ProjectSection.GetValue("FilterType", ""), true, out CurrentProject.FilterType)) { CurrentProject.FilterType = FilterType.None; } CurrentProject.FilterBadges.UnionWith(ProjectSection.GetValues("FilterBadges", new string[0])); } return(CurrentProject); }
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 CloseProject() { if(CurrentWorkspace != null || CurrentProject != null) { Save(); CurrentWorkspace = null; CurrentWorkspaceKey = null; CurrentProject = null; CurrentProjectKey = null; } }
public void OpenProject(string ClientBranchPath, string ClientProjectFileName) { CloseProject(); // Update the current workspace CurrentWorkspaceKey = ClientBranchPath.Trim('/'); CurrentWorkspace = new UserWorkspaceSettings(); // Read the workspace settings ConfigSection WorkspaceSection = ConfigFile.FindSection(CurrentWorkspaceKey); if(WorkspaceSection == null) { string LegacyBranchAndClientKey = ClientBranchPath.Trim('/'); int SlashIdx = LegacyBranchAndClientKey.IndexOf('/'); if(SlashIdx != -1) { LegacyBranchAndClientKey = LegacyBranchAndClientKey.Substring(0, SlashIdx) + "$" + LegacyBranchAndClientKey.Substring(SlashIdx + 1); } string CurrentSync = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey, null); if(CurrentSync != null) { int AtIdx = CurrentSync.LastIndexOf('@'); if(AtIdx != -1) { int ChangeNumber; if(int.TryParse(CurrentSync.Substring(AtIdx + 1), out ChangeNumber)) { CurrentWorkspace.CurrentProjectIdentifier = CurrentSync.Substring(0, AtIdx); CurrentWorkspace.CurrentChangeNumber = ChangeNumber; } } } string LastUpdateResultText = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey + "$LastUpdate", null); if(LastUpdateResultText != null) { int ColonIdx = LastUpdateResultText.LastIndexOf(':'); if(ColonIdx != -1) { int ChangeNumber; if(int.TryParse(LastUpdateResultText.Substring(0, ColonIdx), out ChangeNumber)) { WorkspaceUpdateResult Result; if(Enum.TryParse(LastUpdateResultText.Substring(ColonIdx + 1), out Result)) { CurrentWorkspace.LastSyncChangeNumber = ChangeNumber; CurrentWorkspace.LastSyncResult = Result; } } } } } else { CurrentWorkspace.CurrentProjectIdentifier = WorkspaceSection.GetValue("CurrentProjectPath"); CurrentWorkspace.CurrentChangeNumber = WorkspaceSection.GetValue("CurrentChangeNumber", -1); foreach(string AdditionalChangeNumberString in WorkspaceSection.GetValues("AdditionalChangeNumbers", new string[0])) { int AdditionalChangeNumber; if(int.TryParse(AdditionalChangeNumberString, out AdditionalChangeNumber)) { CurrentWorkspace.AdditionalChangeNumbers.Add(AdditionalChangeNumber); } } Enum.TryParse(WorkspaceSection.GetValue("LastSyncResult", ""), out CurrentWorkspace.LastSyncResult); CurrentWorkspace.LastSyncResultMessage = UnescapeText(WorkspaceSection.GetValue("LastSyncResultMessage")); CurrentWorkspace.LastSyncChangeNumber = WorkspaceSection.GetValue("LastSyncChangeNumber", -1); DateTime LastSyncTime; if(DateTime.TryParse(WorkspaceSection.GetValue("LastSyncTime", ""), out LastSyncTime)) { CurrentWorkspace.LastSyncTime = LastSyncTime; } CurrentWorkspace.LastSyncDurationSeconds = WorkspaceSection.GetValue("LastSyncDuration", 0); CurrentWorkspace.LastBuiltChangeNumber = WorkspaceSection.GetValue("LastBuiltChangeNumber", 0); CurrentWorkspace.ExpandedArchiveTypes = WorkspaceSection.GetValues("ExpandedArchiveName", new string[0]); } // Read the project settings CurrentProjectKey = ClientProjectFileName; CurrentProject = new UserProjectSettings(); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); }
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); }
public void OpenProject(string ClientBranchPath, string ClientProjectFileName) { CloseProject(); // Update the current workspace CurrentWorkspaceKey = ClientBranchPath.Trim('/'); CurrentWorkspace = new UserWorkspaceSettings(); // Read the workspace settings ConfigSection WorkspaceSection = ConfigFile.FindSection(CurrentWorkspaceKey); if (WorkspaceSection == null) { string LegacyBranchAndClientKey = ClientBranchPath.Trim('/'); int SlashIdx = LegacyBranchAndClientKey.IndexOf('/'); if (SlashIdx != -1) { LegacyBranchAndClientKey = LegacyBranchAndClientKey.Substring(0, SlashIdx) + "$" + LegacyBranchAndClientKey.Substring(SlashIdx + 1); } string CurrentSync = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey, null); if (CurrentSync != null) { int AtIdx = CurrentSync.LastIndexOf('@'); if (AtIdx != -1) { int ChangeNumber; if (int.TryParse(CurrentSync.Substring(AtIdx + 1), out ChangeNumber)) { CurrentWorkspace.CurrentProjectIdentifier = CurrentSync.Substring(0, AtIdx); CurrentWorkspace.CurrentChangeNumber = ChangeNumber; } } } string LastUpdateResultText = ConfigFile.GetValue("Clients." + LegacyBranchAndClientKey + "$LastUpdate", null); if (LastUpdateResultText != null) { int ColonIdx = LastUpdateResultText.LastIndexOf(':'); if (ColonIdx != -1) { int ChangeNumber; if (int.TryParse(LastUpdateResultText.Substring(0, ColonIdx), out ChangeNumber)) { WorkspaceUpdateResult Result; if (Enum.TryParse(LastUpdateResultText.Substring(ColonIdx + 1), out Result)) { CurrentWorkspace.LastSyncChangeNumber = ChangeNumber; CurrentWorkspace.LastSyncResult = Result; } } } } } else { CurrentWorkspace.CurrentProjectIdentifier = WorkspaceSection.GetValue("CurrentProjectPath"); CurrentWorkspace.CurrentChangeNumber = WorkspaceSection.GetValue("CurrentChangeNumber", -1); foreach (string AdditionalChangeNumberString in WorkspaceSection.GetValues("AdditionalChangeNumbers", new string[0])) { int AdditionalChangeNumber; if (int.TryParse(AdditionalChangeNumberString, out AdditionalChangeNumber)) { CurrentWorkspace.AdditionalChangeNumbers.Add(AdditionalChangeNumber); } } Enum.TryParse(WorkspaceSection.GetValue("LastSyncResult", ""), out CurrentWorkspace.LastSyncResult); CurrentWorkspace.LastSyncResultMessage = UnescapeText(WorkspaceSection.GetValue("LastSyncResultMessage")); CurrentWorkspace.LastSyncChangeNumber = WorkspaceSection.GetValue("LastSyncChangeNumber", -1); DateTime LastSyncTime; if (DateTime.TryParse(WorkspaceSection.GetValue("LastSyncTime", ""), out LastSyncTime)) { CurrentWorkspace.LastSyncTime = LastSyncTime; } CurrentWorkspace.LastSyncDurationSeconds = WorkspaceSection.GetValue("LastSyncDuration", 0); CurrentWorkspace.LastBuiltChangeNumber = WorkspaceSection.GetValue("LastBuiltChangeNumber", 0); CurrentWorkspace.ExpandedArchiveTypes = WorkspaceSection.GetValues("ExpandedArchiveName", new string[0]); } // Read the project settings CurrentProjectKey = ClientProjectFileName; CurrentProject = new UserProjectSettings(); ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey); CurrentProject.BuildSteps.AddRange(ProjectSection.GetValues("BuildStep", new string[0]).Select(x => new ConfigObject(x))); }