feature(BuildCalc) Added reset button, can change micro delay, and can alter timing interval again

This commit is contained in:
2022-04-14 22:28:14 -04:00
parent 4cef578cd0
commit 04c1718259
115 changed files with 1561 additions and 1308 deletions
+47 -42
View File
@@ -10,57 +10,73 @@ using Microsoft.EntityFrameworkCore;
namespace Services.Development;
public class NoteService : INoteService {
public class NoteService : INoteService
{
private readonly HttpClient httpClient;
private bool isLoaded;
private event Action OnChange = default!;
private void NotifyDataChanged() {
OnChange?.Invoke();
}
public NoteService(HttpClient httpClient) {
public NoteService(HttpClient httpClient)
{
this.httpClient = httpClient;
}
public List<NoteContentModel> NoteContentModelsByPageOrder { get; set; } = new();
public List<NoteContentModel> NoteContentModels { get; set; } = default!;
public List<NoteConnectionModel> NoteConnectionModels { get; set; } = null!;
public List<NoteSectionModel> NoteSectionModels { get; set; } = null!;
public List<NoteContentModel> NoteContentModelsByPageOrder { get; set; } = new();
public void Subscribe(Action action) {
public void Subscribe(Action action)
{
OnChange += action;
}
public void Unsubscribe(Action action) {
public void Unsubscribe(Action action)
{
OnChange -= action;
}
public bool IsLoaded() {
public bool IsLoaded()
{
return isLoaded;
}
public async Task Load() {
if (isLoaded) {
return;
}
NoteContentModels = (await httpClient.GetFromJsonAsync<NoteContentModel[]>("generated/NoteContentModels.json") ?? Array.Empty<NoteContentModel>()).ToList();
NoteConnectionModels = (await httpClient.GetFromJsonAsync<NoteConnectionModel[]>("generated/NoteConnectionModels.json") ?? Array.Empty<NoteConnectionModel>()).ToList();
NoteSectionModels = (await httpClient.GetFromJsonAsync<NoteSectionModel[]>("generated/NoteSectionModels.json") ?? Array.Empty<NoteSectionModel>()).ToList();
public async Task Load()
{
if (isLoaded) return;
NoteContentModels =
(await httpClient.GetFromJsonAsync<NoteContentModel[]>("generated/NoteContentModels.json") ??
Array.Empty<NoteContentModel>()).ToList();
NoteConnectionModels =
(await httpClient.GetFromJsonAsync<NoteConnectionModel[]>("generated/NoteConnectionModels.json") ??
Array.Empty<NoteConnectionModel>()).ToList();
NoteSectionModels =
(await httpClient.GetFromJsonAsync<NoteSectionModel[]>("generated/NoteSectionModels.json") ??
Array.Empty<NoteSectionModel>()).ToList();
isLoaded = true;
SortSQL();
NotifyDataChanged();
}
public void Update()
{
NotifyDataChanged();
}
private event Action OnChange = default!;
private void NotifyDataChanged()
{
OnChange?.Invoke();
}
private NoteContentModel? ContentById(int id)
{
foreach (var data in NoteContentModels!)
@@ -69,7 +85,7 @@ public class NoteService : INoteService {
return null;
}
private void SortSQL()
{
foreach (var connection in NoteConnectionModels)
@@ -79,27 +95,19 @@ public class NoteService : INoteService {
}
foreach (var content in NoteContentModels)
{
if (content.NoteSectionModelId != null)
{
foreach (var section in NoteSectionModels)
{
if (section.Id == content.NoteSectionModelId)
{
section.NoteContentModels.Add(content);
}
}
}
}
ByPageOrder();
}
private void ByPageOrder()
{
NoteContentModelsByPageOrder = new List<NoteContentModel>();
int order = 1;
var order = 1;
foreach (var note in NoteContentModels)
{
if (note.Parent != null) continue;
@@ -121,10 +129,7 @@ public class NoteService : INoteService {
GetAllChildren(note);
}
NoteContentModelsByPageOrder = NoteContentModelsByPageOrder.OrderBy(noteContent => noteContent.PageOrder).ToList();
}
public void Update() {
NotifyDataChanged();
NoteContentModelsByPageOrder =
NoteContentModelsByPageOrder.OrderBy(noteContent => noteContent.PageOrder).ToList();
}
}