public string ToConfigEntry()
        {
            ConfigObject Object = new ConfigObject();

            if (ServerAndPort != null)
            {
                Object.SetValue("ServerAndPort", ServerAndPort);
            }
            if (UserName != null)
            {
                Object.SetValue("UserName", UserName);
            }

            Object.SetValue("Type", Type.ToString());

            if (ClientPath != null)
            {
                Object.SetValue("ClientPath", ClientPath);
            }
            if (LocalPath != null)
            {
                Object.SetValue("LocalPath", LocalPath);
            }

            return(Object.ToString());
        }
        public string ToConfigEntry()
        {
            ConfigObject Object = new ConfigObject();

            Object.SetValue("Enabled", bEnabled ? 1 : 0);
            Object.SetValue("Type", Type);
            Object.SetValue("Order", String.Join(";", Order));

            return(Object.ToString());
        }
        static string FormatRectangleValue(Rectangle Value)
        {
            ConfigObject Object = new ConfigObject();

            Object.SetValue("X", Value.X);
            Object.SetValue("Y", Value.Y);
            Object.SetValue("W", Value.Width);
            Object.SetValue("H", Value.Height);

            return(Object.ToString());
        }
		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("LastProjectFileName", LastProjectFileName);
			GeneralSection.SetValue("KeepInTray", bKeepInTray);
			GeneralSection.SetValues("OtherProjectFileNames", OtherProjectFileNames);
			GeneralSection.SetValues("SyncFilter", SyncFilter);
			GeneralSection.SetValue("SyncType", SyncType.ToString());

			// Build configuration
			GeneralSection.SetValue("BuildConfig", CompiledEditorBuildConfig.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
			if(CurrentWorkspace != null)
			{
				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);
			}

			// Current project settings
			if(CurrentProject != null)
			{
				ConfigSection ProjectSection = ConfigFile.FindOrAddSection(CurrentProjectKey);
				ProjectSection.Clear();
				ProjectSection.SetValues("BuildStep", CurrentProject.BuildSteps.Select(x => x.ToString()).ToArray());
			}

			// 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);
        }