Get way further

This commit is contained in:
2025-10-22 17:31:32 -05:00
parent 7c4f85ec21
commit 27f301fe48
39 changed files with 2028 additions and 123 deletions

View File

@@ -29,7 +29,7 @@ public partial class ProjectConfigurationViewModel : ViewModelBase, ISavable
TabItemViewModel tab;
public string FilePath { get; }
bool _modified = false;
private bool Modified
public bool Modified
{
get => _modified;
set
@@ -56,8 +56,8 @@ public partial class ProjectConfigurationViewModel : ViewModelBase, ISavable
string _license;
string _templatename;
string _templatenamepretty;
string _shortname;
string _shortnamepretty;
string _description;
@@ -130,22 +130,22 @@ public partial class ProjectConfigurationViewModel : ViewModelBase, ISavable
}
}
public string TemplateName
public string ShortName
{
get => _templatename;
get => _shortname;
set
{
Modified = true;
SetProperty(ref _templatename, value, nameof(TemplateName));
SetProperty(ref _shortname, value, nameof(ShortName));
}
}
public string TemplateNamePretty
public string ShortNamePretty
{
get => _templatenamepretty;
get => _shortnamepretty;
set
{
Modified = true;
SetProperty(ref _templatenamepretty, value, nameof(TemplateNamePretty));
SetProperty(ref _shortnamepretty, value, nameof(ShortNamePretty));
}
}
public string Description
@@ -183,8 +183,8 @@ public partial class ProjectConfigurationViewModel : ViewModelBase, ISavable
_homepage = config?.Info?.HomePage ?? "";
_maintainer = config?.Info?.Maintainer ?? "";
_license = config?.Info?.License ?? "";
_templatename = config?.Info?.TemplateName ?? "";
_templatenamepretty = config?.Info?.TemplateNamePretty ?? "";
_shortname = config?.Info?.ShortName ?? "";
_shortnamepretty = config?.Info?.ShortNamePretty ?? "";
_type = Array.IndexOf(CrossLangShell.ProjectTypes, config?.Info?.Type ?? "console");
_type = _type == -1 ? 0 : _type;
_description = config?.Info?.Description ?? "";
@@ -193,6 +193,12 @@ public partial class ProjectConfigurationViewModel : ViewModelBase, ISavable
[RelayCommand]
public void Save()
{
SaveRecovery(FilePath);
Modified = false;
}
public void SaveRecovery(string path)
{
var config = JsonConvert.DeserializeObject<CrossLangConfig>(File.ReadAllText(FilePath)) ?? new CrossLangConfig();
config.Name = Name;
@@ -207,13 +213,12 @@ public partial class ProjectConfigurationViewModel : ViewModelBase, ISavable
config.Info.License = string.IsNullOrWhiteSpace(License) ? null : License;
config.Info.Maintainer = string.IsNullOrWhiteSpace(Maintainer) ? null : Maintainer;
config.Info.Repoository = string.IsNullOrWhiteSpace(Repository) ? null : Repository;
config.Info.TemplateName = string.IsNullOrWhiteSpace(TemplateName) ? null : TemplateName;
config.Info.TemplateNamePretty = string.IsNullOrWhiteSpace(TemplateNamePretty) ? null : TemplateNamePretty;
config.Info.ShortName = string.IsNullOrWhiteSpace(ShortName) ? null : ShortName;
config.Info.ShortNamePretty = string.IsNullOrWhiteSpace(ShortNamePretty) ? null : ShortNamePretty;
config.Info.Type = CrossLangShell.ProjectTypes[Type];
File.WriteAllText(FilePath, JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings()
File.WriteAllText(path, JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
}));
Modified = false;
}
}