Files
webdoorcreator/WebDoorCreator.UI/Components/SvgComp/HwSvgObj.razor.cs
T
2023-05-17 09:31:21 +02:00

202 lines
5.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using WebDoorCreator.UI;
using WebDoorCreator.UI.Components;
using WebDoorCreator.UI.Components.Buttons;
using WebDoorCreator.UI.Components.CompMan;
using WebDoorCreator.UI.Components.DoorMan;
using WebDoorCreator.UI.Components.DoorDef;
using WebDoorCreator.UI.Components.Gen;
using WebDoorCreator.UI.Components.Order;
using WebDoorCreator.UI.Components.Users;
using WebDoorCreator.UI.Components.Hardware;
using WebDoorCreator.UI.Components.SvgComp;
using WebDoorCreator.UI.Components.Filters;
using WebDoorCreator.UI.Components.Report;
using WebDoorCreator.UI.Shared;
using WebDoorCreator.Data.DbModels;
using EgwCoreLib.Razor;
namespace WebDoorCreator.UI.Components.SvgComp
{
public partial class HwSvgObj
{
#region Public Properties
[Parameter]
public EventCallback<bool> EC_ExeFunct { get; set; }
[Parameter]
public EventCallback<bool> EC_ExePlus { get; set; }
[Parameter]
public string ImagePath { get; set; } = "images/LogoEgw.png";
[Parameter]
public string LineColor { get; set; } = "#00838F";
[Parameter]
public int LineWidth { get; set; } = 8;
[Parameter]
public string ItemName { get; set; } = "";
[Parameter]
public int ItemCount { get; set; } = 0;
[Parameter]
public string PlusColor { get; set; } = "green";
[Parameter]
public int ObjH { get; set; } = 204;
[Parameter]
public int ObjId { get; set; } = 0;
[Parameter]
public int ObjW { get; set; } = 450;
[Parameter]
public bool ShowPlus { get; set; } = false;
[Parameter]
public string TextStyle { get; set; } = "font-size: 2.5em;";
#endregion Public Properties
#region Protected Properties
protected CircleData CircleImg { get; set; } = null!;
protected CircleData CircleLine { get; set; } = null!;
protected int LineDist { get; set; } = 20;
protected int TextAreaHeight
{
get => (ObjH / 2 * 110 / 100);
}
protected int TextAreaWidth
{
get => ObjW - (ObjH * 90 / 100);
}
protected string cardClass
{
get => ItemCount > 0 ? "bg-primary text-light" : "bg-inactive text-dark";
}
#endregion Protected Properties
#region Protected Methods
protected void execFunc()
{
EC_ExeFunct.InvokeAsync(true);
}
protected void execPlus()
{
EC_ExePlus.InvokeAsync(true);
}
protected override void OnParametersSet()
{
setupGraphParams();
}
#endregion Protected Methods
#region Protected Classes
protected class CircleData
{
#region Public Constructors
public CircleData(int px, int py, int radius)
{
cx = px;
cy = py;
rad = radius;
}
#endregion Public Constructors
#region Public Properties
public int cx { get; set; } = 0;
public int cy { get; set; } = 0;
public int rad { get; set; } = 100;
#endregion Public Properties
}
protected class LineData
{
#region Public Constructors
public LineData(PointData pA, PointData pB)
{
p1 = pA;
p2 = pB;
}
#endregion Public Constructors
#region Public Properties
public PointData p1 { get; set; }
public PointData p2 { get; set; }
#endregion Public Properties
}
protected class PointData
{
#region Public Constructors
public PointData(int valx, int valy)
{
px = valx;
py = valy;
}
#endregion Public Constructors
#region Public Properties
public int px { get; set; } = 0;
public int py { get; set; } = 0;
#endregion Public Properties
}
#endregion Protected Classes
#region Private Methods
private void setupGraphParams()
{
// calcolo i dati del cerchi...
CircleLine = new CircleData(ObjW - LineWidth - (ObjH / 2), ObjH / 2, (ObjH - LineWidth) / 2);
CircleImg = new CircleData(ObjW - LineWidth - (ObjH / 2), ObjH / 2, (ObjH - 2 * LineWidth) / 2);
LineDist = ObjH / 4;
}
#endregion Private Methods
}
}