Ionite
1 year ago
4 changed files with 243 additions and 44 deletions
@ -0,0 +1,32 @@
|
||||
using System; |
||||
using System.Globalization; |
||||
using System.Windows; |
||||
using System.Windows.Data; |
||||
|
||||
namespace StabilityMatrix.Converters; |
||||
|
||||
public class BooleanToHiddenVisibleConverter : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
var bValue = false; |
||||
if (value is bool b) |
||||
{ |
||||
bValue = b; |
||||
} |
||||
else if (value is bool) |
||||
{ |
||||
var tmp = (bool?) value; |
||||
bValue = tmp.Value; |
||||
} |
||||
return bValue ? Visibility.Visible : Visibility.Hidden; |
||||
} |
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
{ |
||||
if (value is Visibility visibility) |
||||
{ |
||||
return visibility == Visibility.Visible; |
||||
} |
||||
return false; |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
using System; |
||||
using System.Text.Json; |
||||
using StabilityMatrix.Extensions; |
||||
using StabilityMatrix.Models.Api; |
||||
|
||||
namespace StabilityMatrix.Models; |
||||
|
||||
public class ConnectedModelInfo |
||||
{ |
||||
public int ModelId { get; set; } |
||||
public string ModelName { get; set; } |
||||
public string ModelDescription { get; set; } |
||||
public bool Nsfw { get; set; } |
||||
public string[] Tags { get; set; } |
||||
public CivitModelType ModelType { get; set; } |
||||
public int VersionId { get; set; } |
||||
public string VersionName { get; set; } |
||||
public string VersionDescription { get; set; } |
||||
public string? BaseModel { get; set; } |
||||
public CivitFileMetadata FileMetadata { get; set; } |
||||
public DateTime ImportedAt { get; set; } |
||||
public CivitFileHashes Hashes { get; set; } |
||||
|
||||
// User settings |
||||
public string? UserTitle { get; set; } |
||||
public string? ThumbnailImageUrl { get; set; } |
||||
|
||||
public ConnectedModelInfo(CivitModel civitModel, CivitModelVersion civitModelVersion, CivitFile civitFile, DateTime importedAt) |
||||
{ |
||||
ModelId = civitModel.Id; |
||||
ModelName = civitModel.Name; |
||||
ModelDescription = civitModel.Description; |
||||
Nsfw = civitModel.Nsfw; |
||||
Tags = civitModel.Tags; |
||||
ModelType = civitModel.Type; |
||||
VersionId = civitModelVersion.Id; |
||||
VersionName = civitModelVersion.Name; |
||||
VersionDescription = civitModelVersion.Description; |
||||
ImportedAt = importedAt; |
||||
BaseModel = civitModelVersion.BaseModel; |
||||
FileMetadata = civitFile.Metadata; |
||||
Hashes = civitFile.Hashes; |
||||
} |
||||
|
||||
public static ConnectedModelInfo? FromJson(string json) |
||||
{ |
||||
return JsonSerializer.Deserialize<ConnectedModelInfo>(json); |
||||
} |
||||
} |
Loading…
Reference in new issue