feature(BuildCalc) Added reset button, can change micro delay, and can alter timing interval again
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DataType = Model.Entity.Data.DataType;
|
||||
|
||||
namespace Services.Website;
|
||||
namespace Services.Website;
|
||||
|
||||
//TODO Move to a database folder, with EntityService, EntityFilterService
|
||||
public class EntityDialogService : IEntityDialogService
|
||||
{
|
||||
private string? entityId = null;
|
||||
private string? entityId;
|
||||
|
||||
private List<string> history = new List<string>();
|
||||
|
||||
private event Action OnChange = null!;
|
||||
private readonly List<string> history = new();
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
|
||||
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 void AddDialog(string id)
|
||||
{
|
||||
entityId = id;
|
||||
@@ -36,7 +29,7 @@ public class EntityDialogService : IEntityDialogService
|
||||
{
|
||||
entityId = null;
|
||||
history.Clear();
|
||||
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
@@ -45,20 +38,20 @@ public class EntityDialogService : IEntityDialogService
|
||||
if (history.Count > 1)
|
||||
{
|
||||
history.RemoveAt(history.Count - 1);
|
||||
|
||||
|
||||
if (history.Count == 0)
|
||||
{
|
||||
entityId = null;
|
||||
NotifyDataChanged();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
entityId = history.Last();
|
||||
NotifyDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool HasDialog()
|
||||
{
|
||||
@@ -74,6 +67,11 @@ public class EntityDialogService : IEntityDialogService
|
||||
{
|
||||
return entityId;
|
||||
}
|
||||
}
|
||||
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged()
|
||||
{
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -2,27 +2,26 @@
|
||||
|
||||
namespace Services.Website;
|
||||
|
||||
public class NavigationService : INavigationService {
|
||||
private string navigationStateType = NavigationStateType.Default;
|
||||
public class NavigationService : INavigationService
|
||||
{
|
||||
private int navigationStateId = -1;
|
||||
|
||||
private string navigationStateType = NavigationStateType.Default;
|
||||
|
||||
private NavSelectionType navSelectionType = NavSelectionType.None;
|
||||
|
||||
|
||||
|
||||
|
||||
private Type renderType = null!;
|
||||
private int webPageType;
|
||||
private int webSectionType;
|
||||
|
||||
private event Action OnChange = null!;
|
||||
|
||||
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
public void Subscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
public void Unsubscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
@@ -37,7 +36,8 @@ public class NavigationService : INavigationService {
|
||||
return navigationStateId;
|
||||
}
|
||||
|
||||
public void ChangeNavigationState(string newState) {
|
||||
public void ChangeNavigationState(string newState)
|
||||
{
|
||||
if (newState.Equals(navigationStateType))
|
||||
return;
|
||||
|
||||
@@ -46,12 +46,15 @@ public class NavigationService : INavigationService {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public string GetNavigationState() {
|
||||
public string GetNavigationState()
|
||||
{
|
||||
return navigationStateType;
|
||||
}
|
||||
|
||||
public void SelectPage(int pageType, Type page) {
|
||||
if (renderType != page) {
|
||||
public void SelectPage(int pageType, Type page)
|
||||
{
|
||||
if (renderType != page)
|
||||
{
|
||||
renderType = page;
|
||||
webPageType = pageType;
|
||||
navSelectionType = NavSelectionType.Page;
|
||||
@@ -60,7 +63,8 @@ public class NavigationService : INavigationService {
|
||||
}
|
||||
|
||||
|
||||
public void SelectSection(int section) {
|
||||
public void SelectSection(int section)
|
||||
{
|
||||
if (section == webSectionType) return;
|
||||
webSectionType = section;
|
||||
navSelectionType = NavSelectionType.Section;
|
||||
@@ -68,15 +72,18 @@ public class NavigationService : INavigationService {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
public void Back() {
|
||||
if (navSelectionType == NavSelectionType.Page) {
|
||||
public void Back()
|
||||
{
|
||||
if (navSelectionType == NavSelectionType.Page)
|
||||
{
|
||||
navSelectionType = NavSelectionType.Section;
|
||||
webPageType = 0;
|
||||
NotifyDataChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
if (navSelectionType == NavSelectionType.Section) {
|
||||
if (navSelectionType == NavSelectionType.Section)
|
||||
{
|
||||
navSelectionType = NavSelectionType.None;
|
||||
webSectionType = 0;
|
||||
webPageType = 0;
|
||||
@@ -84,23 +91,30 @@ public class NavigationService : INavigationService {
|
||||
}
|
||||
}
|
||||
|
||||
public NavSelectionType GetNavSelectionType() {
|
||||
public NavSelectionType GetNavSelectionType()
|
||||
{
|
||||
return navSelectionType;
|
||||
}
|
||||
|
||||
public int GetWebPageId() {
|
||||
public int GetWebPageId()
|
||||
{
|
||||
return webPageType;
|
||||
}
|
||||
|
||||
public int GetWebSectionId() {
|
||||
public int GetWebSectionId()
|
||||
{
|
||||
return webSectionType;
|
||||
}
|
||||
|
||||
public Type GetRenderType() {
|
||||
public Type GetRenderType()
|
||||
{
|
||||
return renderType;
|
||||
}
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged()
|
||||
{
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -5,36 +5,21 @@ namespace Services.Website;
|
||||
public class ToastService : IToastService
|
||||
{
|
||||
private readonly List<ToastModel> toasts = new();
|
||||
|
||||
private event Action OnChange = null!;
|
||||
|
||||
#if DEBUG
|
||||
public ToastService()
|
||||
public void Subscribe(Action action)
|
||||
{
|
||||
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Error, Title = "Example Error"});
|
||||
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Information, Title = "Example Information"});
|
||||
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Success, Title = "Example Success"});
|
||||
toasts.Add(new ToastModel(){Message = "Example message", SeverityType = SeverityType.Warning, Title = "Example Warning"});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
OnChange();
|
||||
}
|
||||
|
||||
public void Subscribe(Action action) {
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void Unsubscribe(Action action) {
|
||||
public void Unsubscribe(Action action)
|
||||
{
|
||||
OnChange += action;
|
||||
}
|
||||
|
||||
public void AddToast(ToastModel toast)
|
||||
{
|
||||
toasts.Insert(0, toast);
|
||||
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
@@ -55,11 +40,8 @@ public class ToastService : IToastService
|
||||
|
||||
public void AgeToasts()
|
||||
{
|
||||
foreach (var toast in toasts)
|
||||
{
|
||||
toast.Age++;
|
||||
}
|
||||
|
||||
foreach (var toast in toasts) toast.Age++;
|
||||
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
@@ -69,6 +51,10 @@ public class ToastService : IToastService
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private event Action OnChange = null!;
|
||||
|
||||
private void NotifyDataChanged()
|
||||
{
|
||||
OnChange();
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,47 @@
|
||||
using System.Net.Http.Json;
|
||||
|
||||
using Model.Website;
|
||||
|
||||
namespace Services.Development;
|
||||
|
||||
public class WebsiteService : IWebsiteService {
|
||||
public class WebsiteService : IWebsiteService
|
||||
{
|
||||
private readonly HttpClient httpClient;
|
||||
|
||||
private bool isLoaded;
|
||||
|
||||
|
||||
private event Action OnChange = default!;
|
||||
|
||||
|
||||
public WebsiteService(HttpClient httpClient) {
|
||||
public WebsiteService(HttpClient httpClient)
|
||||
{
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<WebSectionModel> WebSectionModels { get; set; } = default!;
|
||||
public List<WebPageModel> WebPageModels { get; set; } = default!;
|
||||
|
||||
|
||||
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;}
|
||||
|
||||
WebPageModels = ((await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"))!).ToList();
|
||||
WebSectionModels =((await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json"))!).ToList();
|
||||
|
||||
public async Task Load()
|
||||
{
|
||||
if (isLoaded) return;
|
||||
|
||||
WebPageModels = (await httpClient.GetFromJsonAsync<WebPageModel[]>("generated/WebPageModels.json"))!.ToList();
|
||||
WebSectionModels = (await httpClient.GetFromJsonAsync<WebSectionModel[]>("generated/WebSectionModels.json"))!
|
||||
.ToList();
|
||||
|
||||
isLoaded = true;
|
||||
|
||||
@@ -48,27 +50,28 @@ public class WebsiteService : IWebsiteService {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
void SortSql()
|
||||
public void Update()
|
||||
{
|
||||
foreach (var page in WebPageModels)
|
||||
{
|
||||
|
||||
if (page.WebSectionModelId != null)
|
||||
{
|
||||
WebSectionModel webSection =
|
||||
WebSectionModels.Find(webSection => webSection.Id == page.WebSectionModelId);
|
||||
|
||||
webSection.WebPageModels.Add(page);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Update() {
|
||||
NotifyDataChanged();
|
||||
}
|
||||
|
||||
private void NotifyDataChanged() {
|
||||
|
||||
private event Action OnChange = default!;
|
||||
|
||||
private void SortSql()
|
||||
{
|
||||
foreach (var page in WebPageModels)
|
||||
if (page.WebSectionModelId != null)
|
||||
{
|
||||
var webSection =
|
||||
WebSectionModels.Find(webSection => webSection.Id == page.WebSectionModelId);
|
||||
|
||||
webSection.WebPageModels.Add(page);
|
||||
}
|
||||
}
|
||||
|
||||
private void NotifyDataChanged()
|
||||
{
|
||||
OnChange?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user