ui(manager)+manager: improve display version
This commit is contained in:
@@ -1,18 +1,30 @@
|
||||
using System.ComponentModel;
|
||||
using ModpackUpdater.Manager;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui.Models.UpdatesCollectorViewMode;
|
||||
|
||||
public record ModUpdateInfo(KeyValuePair<string, string>[] AvailableVersions, InstallAction Origin) : INotifyPropertyChanged
|
||||
public record ModUpdateInfo(ModVersionInfo[] AvailableVersions, InstallAction Origin) : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public int NewVersion { get; set; }
|
||||
public bool Visible { get; set; } = true;
|
||||
|
||||
public string? OldVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
if (AvailableVersions.FirstOrDefault(n => n.Tag.Equals(Origin.SourceTag)) is { } old
|
||||
&& !old.Name.Equals(old.Tag, StringComparison.InvariantCulture))
|
||||
return $"{old.Name} ({old.Tag})";
|
||||
return Origin.SourceTag;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> DisplayVersions { get; } = AvailableVersions.Select(n =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(n.Value) || n.Value.Equals(n.Key, StringComparison.InvariantCulture))
|
||||
return n.Key;
|
||||
return $"{n.Value} ({n.Value})";
|
||||
if (string.IsNullOrWhiteSpace(n.Tag) || n.Tag.Equals(n.Name, StringComparison.InvariantCulture))
|
||||
return n.Name;
|
||||
return $"{n.Name} ({n.Tag})";
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user