Converting to EF, need to work on TS

This commit is contained in:
Lani Aung
2021-11-19 23:04:15 -07:00
parent 1fd14ebafd
commit 744fc6bc57
43 changed files with 2159 additions and 542 deletions
+13 -17
View File
@@ -1,25 +1,21 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using System;
using fxl.codes.kisekae.Entities;
namespace fxl.codes.kisekae.Models
{
public class CelModel
{
public Dictionary<int, string> ImageByPalette = new();
public readonly int Fix;
public readonly string Image;
public readonly int Mark;
public readonly int ZIndex;
public int Id { get; init; }
public int Fix { get; init; }
public string FileName { get; init; }
public int PaletteId { get; init; }
public bool[] Sets { get; } = new bool[10];
public string Comment { get; init; }
[JsonIgnore] public int Transparency { get; set; }
public double Opacity { get; internal set; } = 1.0;
public Coordinate[] InitialPositions { get; } = new Coordinate[10];
[JsonIgnore] public string DefaultImage => ImageByPalette.ContainsKey(PaletteId) ? ImageByPalette[PaletteId] : null;
public Coordinate Offset { get; set; }
[JsonIgnore] public int Height { get; internal set; }
[JsonIgnore] public int Width { get; internal set; }
[JsonIgnore] public int ZIndex { get; internal set; }
internal CelModel(CelConfig celConfig, Render render, int zIndex)
{
Mark = celConfig.Mark;
Fix = celConfig.Fix;
ZIndex = zIndex;
Image = Convert.ToBase64String(render.Image);
}
}
}
-21
View File
@@ -1,21 +0,0 @@
using System.Collections.Generic;
using fxl.codes.kisekae.Entities;
namespace fxl.codes.kisekae.Models
{
public class ConfigurationModel
{
public ConfigurationModel(KisekaeDto dto)
{
Id = dto.Id;
Name = dto.Name;
Configurations = new Dictionary<int, string>();
foreach (var config in dto.Configurations) Configurations.Add(config.Id, config.Filename);
}
public int Id { get; }
public string Name { get; }
public IDictionary<int, string> Configurations { get; }
}
}
-14
View File
@@ -1,14 +0,0 @@
namespace fxl.codes.kisekae.Models
{
public class Coordinate
{
public Coordinate(int x = 0, int y = 0)
{
X = x;
Y = y;
}
public int X { get; }
public int Y { get; }
}
}
-2
View File
@@ -1,5 +1,3 @@
using System;
namespace fxl.codes.kisekae.Models
{
public class ErrorViewModel
+18
View File
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.Linq;
using fxl.codes.kisekae.Entities;
namespace fxl.codes.kisekae.Models
{
public class KisekaeModel
{
public readonly IEnumerable<KeyValuePair<int, string>> Configurations;
public readonly string Name;
internal KisekaeModel(Kisekae kisekae)
{
Name = kisekae.FileName;
Configurations = kisekae.Configurations.Select(x => new KeyValuePair<int, string>(x.Id, x.Name)).ToArray();
}
}
}
-12
View File
@@ -1,12 +0,0 @@
using System;
using SixLabors.ImageSharp;
namespace fxl.codes.kisekae.Models
{
public class PaletteModel
{
public string FileName { get; internal set; }
public string Comment { get; internal set; }
public Color[] Colors { get; internal set; } = Array.Empty<Color>();
}
}
+14 -6
View File
@@ -1,17 +1,25 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using SixLabors.ImageSharp;
using Configuration = fxl.codes.kisekae.Entities.Configuration;
namespace fxl.codes.kisekae.Models
{
public class PlaysetModel
{
public readonly int Height;
public readonly string Name;
public readonly int Width;
public readonly CelModel[] Cels;
[JsonIgnore] public Color BorderColor = Color.Black;
public string Name { get; set; }
public int Height { get; set; }
public int Width { get; set; }
[JsonIgnore] public List<PaletteModel> Palettes { get; } = new();
public List<CelModel> Cels { get; } = new();
public bool[] EnabledSets { get; } = new bool[10];
internal PlaysetModel(Configuration configuration)
{
Name = configuration.Name;
Height = configuration.Height;
Width = configuration.Width;
Cels = new CelModel[0];
}
}
}