properly save project-specific settings from the ProjectType into the actual ProjectObjectModel

This commit is contained in:
Michael Becker 2022-09-06 00:43:52 -04:00
parent 328728fa32
commit e217c4769d
No known key found for this signature in database
GPG Key ID: DA394832305DA332
2 changed files with 34 additions and 0 deletions

View File

@ -115,5 +115,19 @@ namespace UniversalEditor.ObjectModels.Project
/// </summary>
/// <value>The relative path to the <see cref="ProjectObjectModel" />.</value>
public string RelativeFileName { get; set; } = String.Empty;
private System.Collections.Generic.Dictionary<Guid, object> _projectSettings = new System.Collections.Generic.Dictionary<Guid, object>();
public object GetProjectSetting(Guid id, object defaultValue = null)
{
if (_projectSettings.ContainsKey(id))
{
return _projectSettings[id];
}
return defaultValue;
}
public void SetProjectSetting(Guid id, object value)
{
_projectSettings[id] = value;
}
}
}

View File

@ -1428,6 +1428,13 @@ namespace UniversalEditor.UserInterface
{
if (projType.SettingsProvider != null)
{
for (int i = 0; i < projType.SettingsProvider.SettingsGroups.Count; i++)
{
for (int j = 0; j < projType.SettingsProvider.SettingsGroups[i].Settings.Count; j++)
{
projType.SettingsProvider.SettingsGroups[i].Settings[j].SetValue(project.GetProjectSetting(projType.SettingsProvider.SettingsGroups[i].Settings[j].ID, projType.SettingsProvider.SettingsGroups[i].Settings[j].DefaultValue));
}
}
list.Add(projType.SettingsProvider);
}
}
@ -1444,6 +1451,19 @@ namespace UniversalEditor.UserInterface
if (dlg.ShowDialog() == DialogResult.OK)
{
// TODO: apply properties to project
foreach (ProjectType projType in project.ProjectTypes)
{
if (projType.SettingsProvider != null)
{
for (int i = 0; i < projType.SettingsProvider.SettingsGroups.Count; i++)
{
for (int j = 0; j < projType.SettingsProvider.SettingsGroups[i].Settings.Count; j++)
{
project.SetProjectSetting(projType.SettingsProvider.SettingsGroups[i].Settings[j].ID, projType.SettingsProvider.SettingsGroups[i].Settings[j].GetValue());
}
}
}
}
}
return;
}