Parse 12 vs 24 bit colors eventually
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.IsolatedStorage;
|
||||
using fxl.codes.kisekae.Models;
|
||||
using fxl.codes.kisekae.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@@ -12,27 +15,56 @@ namespace fxl.codes.kisekae.Controllers
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly ConfigurationReaderService _readerService;
|
||||
private readonly IsolatedStorageFile _storage;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, ConfigurationReaderService readerService)
|
||||
{
|
||||
_logger = logger;
|
||||
_readerService = readerService;
|
||||
|
||||
_storage = IsolatedStorageFile.GetUserStoreForApplication();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
var directories = _storage.GetDirectoryNames();
|
||||
var model = new List<DirectoryModel>();
|
||||
|
||||
foreach (var directory in directories)
|
||||
{
|
||||
var files = _storage.GetFileNames(Path.Combine(directory, "*.cnf"));
|
||||
if (files.Length <= 0) continue;
|
||||
|
||||
var doll = new DirectoryModel(directory);
|
||||
foreach (var file in files)
|
||||
{
|
||||
doll.Configurations.Add(new ConfigurationModel(file));
|
||||
}
|
||||
|
||||
model.Add(doll);
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult LoadConfiguration(IFormFile file)
|
||||
public IActionResult Upload(IFormFile file)
|
||||
{
|
||||
_logger.LogTrace($"File uploaded: {file?.FileName}");
|
||||
if (!(file?.FileName.EndsWith("cnf", StringComparison.InvariantCultureIgnoreCase) ?? false))
|
||||
throw new Exception("Please select a *.cnf file");
|
||||
|
||||
var model = _readerService.ReadCnf(file);
|
||||
return View("Index");
|
||||
return View("Play", model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Select(string directory, string file)
|
||||
{
|
||||
var stream = _storage.OpenFile(Path.Combine(directory, file), FileMode.Open);
|
||||
var model = _readerService.ParseStream(stream, directory);
|
||||
return View("Play", model);
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
|
||||
Reference in New Issue
Block a user