Add grayscale resolutions.

This commit is contained in:
2019-05-19 15:56:12 +01:00
parent c0df1ed4b6
commit 20da3251f8
11 changed files with 1967 additions and 37 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Cicm.Database.Migrations
{
public partial class GrayscaleResolutions : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>("Grayscale", "resolutions", nullable: false, defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn("Grayscale", "resolutions");
}
}
}

View File

@@ -770,6 +770,8 @@ namespace Cicm.Database.Migrations
b.Property<long?>("Colors").HasColumnName("colors").HasColumnType("bigint(20)");
b.Property<bool>("Grayscale");
b.Property<int>("Height").ValueGeneratedOnAdd().HasColumnName("height").HasColumnType("int(11)")
.HasDefaultValueSql("'0'");

View File

@@ -47,6 +47,8 @@ namespace Cicm.Database.Models
public long? Palette { get; set; }
[DisplayName("Character based")]
public bool Chars { get; set; }
[DisplayName("Grayscale")]
public bool Grayscale { get; set; }
public virtual ICollection<ResolutionsByGpu> ResolutionsByGpu { get; set; }
@@ -59,17 +61,25 @@ namespace Cicm.Database.Models
if(Colors == null) return $"{Width}x{Height} characters";
if(Palette != null && Colors != Palette)
return $"{Width}x{Height} characters at {Colors} colors from a palette of {Palette}";
return Grayscale
? $"{Width}x{Height} characters at {Colors} grays from a palette of {Palette}"
: $"{Width}x{Height} characters at {Colors} colors from a palette of {Palette}";
return $"{Width}x{Height} characters at {Colors} colors";
return Colors == 2 && Grayscale
? $"{Width}x{Height} black and white characters"
: $"{Width}x{Height} characters at {Colors} colors";
}
if(Colors == null) return $"{Width}x{Height} pixels";
if(Palette != null && Colors != Palette)
return $"{Width}x{Height} pixels at {Colors} colors from a palette of {Palette}";
return Grayscale
? $"{Width}x{Height} pixels at {Colors} grays from a palette of {Palette}"
: $"{Width}x{Height} pixels at {Colors} colors from a palette of {Palette}";
return $"{Width}x{Height} pixels at {Colors} colors";
return Colors == 2 && Grayscale
? $"{Width}x{Height} black and white pixels"
: $"{Width}x{Height} pixels at {Colors} colors";
}
}
}

View File

@@ -51,7 +51,7 @@ namespace cicm_web.Areas.Admin.Controllers
// GET: Admin/Resolutions
public async Task<IActionResult> Index() =>
View(await _context.Resolutions.OrderBy(r => r.Chars).ThenBy(r => r.Width).ThenBy(r => r.Height)
.ThenBy(r => r.Colors).ToListAsync());
.ThenBy(r => r.Colors).ThenBy(r => r.Grayscale).ToListAsync());
// GET: Admin/Resolutions/Details/5
public async Task<IActionResult> Details(int? id)
@@ -72,7 +72,7 @@ namespace cicm_web.Areas.Admin.Controllers
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Id,Width,Height,Colors,Palette,Chars")]
public async Task<IActionResult> Create([Bind("Id,Width,Height,Colors,Palette,Chars,Grayscale")]
Resolution resolution)
{
if(ModelState.IsValid)
@@ -101,7 +101,7 @@ namespace cicm_web.Areas.Admin.Controllers
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Width,Height,Colors,Palette,Chars")]
public async Task<IActionResult> Edit(int id, [Bind("Id,Width,Height,Colors,Palette,Chars,Grayscale")]
Resolution resolution)
{
if(id != resolution.Id) return NotFound();

View File

@@ -92,6 +92,13 @@
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Grayscale" /> @Html.DisplayNameFor(model => model.Grayscale)
</label>
</div>
</div>
<div class="form-group">
<input class="btn btn-primary"
type="submit"

View File

@@ -72,6 +72,12 @@
<dd>
@Html.DisplayFor(model => model.Chars)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Grayscale)
</dt>
<dd>
@Html.DisplayFor(model => model.Grayscale)
</dd>
</dl>
<form asp-action="Delete">

View File

@@ -71,9 +71,22 @@
<dd>
@Html.DisplayFor(model => model.Chars)
</dd>
<dt>
@Html.DisplayNameFor(model => model.Grayscale)
</dt>
<dd>
@Html.DisplayFor(model => model.Grayscale)
</dd>
</dl>
</div>
<div>
<a asp-action="Edit" asp-route-id="@Model.Id" class="btn btn-primary">Edit</a>
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
<a asp-action="Edit"
asp-route-id="@Model.Id"
class="btn btn-primary">
Edit
</a>
<a asp-action="Index"
class="btn btn-secondary">
Back to List
</a>
</div>

View File

@@ -94,6 +94,13 @@
</label>
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input asp-for="Grayscale" /> @Html.DisplayNameFor(model => model.Grayscale)
</label>
</div>
</div>
<div class="form-group">
<input class="btn btn-primary"
type="submit"

View File

@@ -48,19 +48,7 @@
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Width)
</th>
<th>
@Html.DisplayNameFor(model => model.Height)
</th>
<th>
@Html.DisplayNameFor(model => model.Colors)
</th>
<th>
@Html.DisplayNameFor(model => model.Palette)
</th>
<th>
@Html.DisplayNameFor(model => model.Chars)
Resolution
</th>
<th></th>
</tr>
@@ -70,19 +58,7 @@
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Width)
</td>
<td>
@Html.DisplayFor(modelItem => item.Height)
</td>
<td>
@Html.DisplayFor(modelItem => item.Colors)
</td>
<td>
@Html.DisplayFor(modelItem => item.PaletteView)
</td>
<td>
@Html.DisplayFor(modelItem => item.Chars)
@item.ToString()
</td>
<td>
<a asp-action="Details"

View File

@@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>3.0.99.477</Version>
<Version>3.0.99.479</Version>
<Company>Canary Islands Computer Museum</Company>
<Copyright>Copyright © 2003-2018 Natalia Portillo</Copyright>
<Product>Canary Islands Computer Museum Website</Product>