PlotDirector/PlotLine/Models/MapAppearanceModels.cs

40 lines
1.5 KiB
C#

using System.Text.Json;
using System.Text.Json.Serialization;
namespace PlotLine.Models;
public sealed class MapCanvasAppearance
{
public string Preset { get; set; } = "light";
public string BackgroundColor { get; set; } = "#c9dfdf";
public string LandColor { get; set; } = "#e9e4c5";
}
public sealed class MapReferencePlacement
{
public Guid? ImageID { get; set; }
public double X { get; set; }
public double Y { get; set; }
public double Width { get; set; } = 800;
public double Height { get; set; } = 600;
public double Rotation { get; set; }
public double Opacity { get; set; } = .35;
public bool IsVisible { get; set; } = true;
public bool IsLocked { get; set; } = true;
}
public sealed class MapReferenceImage
{
public Guid ImageID { get; set; }
public int ProjectID { get; set; }
public string OriginalFileName { get; set; } = "Reference image";
public string ContentType { get; set; } = "image/webp";
public int Width { get; set; }
public int Height { get; set; }
public long FileSizeBytes { get; set; }
public int UseCount { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public byte[]? ImageData { get; set; }
}
public static class MapAppearanceJson
{
private static readonly JsonSerializerOptions Options = new() { PropertyNameCaseInsensitive = true };
public static T Read<T>(string value) where T : new() => JsonSerializer.Deserialize<T>(value, Options) ?? new T();
}