ancora nuova modifica HwSvgObj x nuova modalità

This commit is contained in:
Samuele Locatelli
2023-05-18 10:40:14 +02:00
parent 9e65f9dce1
commit 6eed928af5
6 changed files with 94 additions and 77 deletions
Binary file not shown.
@@ -8,11 +8,11 @@ else
{
<div class="row">
<div class="col-4">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@(()=> backToList())" ObjId="@HwCode" ItemName="Back to List" ItemCount="0" ShowPlus="false" ImagePath=""></HwSvgObj>
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="exeFun" ObjId="@HwCode" ItemName="Back to List" ItemCount="0" ShowPlus="false" IconTag="fa-solid fa-right-from-bracket text-light"></HwSvgObj>
</div>
<div class="col-4"></div>
<div class="col-4">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExePlus="@(()=> hwToAdd(""))" ObjId="@HwCode" ItemName="@(translate(HwLabel))" ItemCount="@HwInst" ShowPlus="true" ImagePath=""></HwSvgObj>
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="exeFun" ObjId="@HwCode" ItemName="@(translate(HwLabel))" ItemCount="@HwInst" ShowPlus="true" IconTag="fa-solid fa-plus"></HwSvgObj>
</div>
</div>
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components;
using Newtonsoft.Json;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.UI.Components.SvgComp;
using WebDoorCreator.UI.Data;
using static WebDoorCreator.UI.Data.WDCRefreshService;
@@ -100,10 +101,24 @@ namespace WebDoorCreator.UI.Components.Hardware
#region Protected Methods
protected async Task backToList()
protected async Task exeFun(HwSvgObj.ActionReq action)
{
await Task.Delay(1);
await E_act2Rel.InvokeAsync(true);
switch (action)
{
case HwSvgObj.ActionReq.Minus:
// nulla (x ora)
break;
case HwSvgObj.ActionReq.Plus:
await hwToAdd("");
break;
case HwSvgObj.ActionReq.Select:
default:
await E_act2Rel.InvokeAsync(true);
break;
}
}
protected int getDoorOpInstNum(int doorOpId)
@@ -285,7 +300,6 @@ namespace WebDoorCreator.UI.Components.Hardware
DoorOpList = null;
await Task.Delay(1);
ListRecord = await WDCService.DoorOpGetByDoorId(DoorId);
var tempListVal = await WDCService.ListValuesGetAll(HwCode, "Folder");
if (ListRecord != null)
{
DoorOpList = ListRecord.Where(x => (x.DoorId == DoorId) && (x.ObjectId == HwCode)).ToList();
@@ -1,7 +1,7 @@
<svg viewBox="0 0 @ObjW @ObjH" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0,@LineDist)">
<foreignObject width="@TextAreaWidth" height="100%">
<div class="d-flex justify-content-between rectangle p-3 @cardClass" style="@TextStyle" @onclick="()=>execFunc(false)">
<div class="d-flex justify-content-between rectangle p-3 @cardClass" style="@TextStyle;" @onclick="() => doExecFunc(ActionReq.Select, false)">
<div>
@ItemName
</div>
@@ -26,19 +26,30 @@
<stop offset="100%" stop-color="#92B2C4" />
</linearGradient>
<rect fill="url(#BckGrad)" x="0" y="0" height="100%" width="100%" style="opacity: 100%;"></rect>
<image x="@(CircleImg.rad/2)" y="0" href="@ImagePath" width="@CircleImg.rad" height="100%"></image>
@if (!string.IsNullOrEmpty(ImagePath))
{
<image x="@(CircleImg.rad/2)" y="0" href="@ImagePath" width="@CircleImg.rad" height="100%"></image>
}
@if (ShowPlus)
{
<rect x="0" y="0" width="100%" height="100%" fill="@PlusColor" style="opacity: 20%;" />
<rect x="0" y="0" width="100%" height="100%" fill="@PlusColor" style="opacity: 20%;" />
}
</pattern>
</defs>
@if (ShowPlus)
{
<circle id="circleCont" cx="@CircleImg.cx" cy="@CircleImg.cy" r="@CircleImg.rad" fill="url(#@($"contImg_{ObjId}"))" style="cursor: pointer;" @onclick="()=>execPlus()" />
<circle id="circleCont" cx="@CircleImg.cx" cy="@CircleImg.cy" r="@CircleImg.rad" fill="url(#@($"contImg_{ObjId}"))" style="cursor: pointer;" @onclick="() => doExecFunc(ActionReq.Plus, true)" />
}
else
{
<circle id="circleCont" cx="@CircleImg.cx" cy="@CircleImg.cy" r="@CircleImg.rad" fill="url(#@($"contImg_{ObjId}"))" style="cursor: pointer;" @onclick="()=>execFunc(true)" />
<circle id="circleCont" cx="@CircleImg.cx" cy="@CircleImg.cy" r="@CircleImg.rad" fill="url(#@($"contImg_{ObjId}"))" style="cursor: pointer;" @onclick="() => doExecFunc(ActionReq.Select, true)" />
}
@if (string.IsNullOrEmpty(ImagePath))
{
<g transform="translate(@(CircleImg.cx - CircleImg.rad/2.5),@(CircleImg.cy-CircleImg.rad/2.5))">
<foreignObject width="100%" height="100%">
<i class="@IconTag fa-5x"></i>
</foreignObject>
</g>
}
</svg>
@@ -1,47 +1,45 @@
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 Enums
/// <summary>
/// Enum delle azioni associate al controllo
/// </summary>
public enum ActionReq
{
Minus,
Plus,
Select
}
#endregion Public Enums
#region Public Properties
[Parameter]
public EventCallback<bool> EC_ExeFunct { get; set; }
public EventCallback<ActionReq> EC_ExeFunct { get; set; }
/// <summary>
/// Tag icona da mostrare (secondario se img != null)
/// </summary>
[Parameter]
public string IconTag { get; set; } = "";
/// <summary>
/// Path img da mostrare (prioritario su icona)
/// </summary>
[Parameter]
public string ImagePath { get; set; } = "";
[Parameter]
public EventCallback<bool> EC_ExePlus { get; set; }
public int ItemCount { get; set; } = 0;
[Parameter]
public string ImagePath { get; set; } = "images/LogoEgw.png";
public string ItemName { get; set; } = "";
[Parameter]
public string LineColor { get; set; } = "#00838F";
@@ -49,16 +47,6 @@ namespace WebDoorCreator.UI.Components.SvgComp
[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;
@@ -68,6 +56,9 @@ namespace WebDoorCreator.UI.Components.SvgComp
[Parameter]
public int ObjW { get; set; } = 450;
[Parameter]
public string PlusColor { get; set; } = "green";
[Parameter]
public bool ShowPlus { get; set; } = false;
@@ -78,6 +69,10 @@ namespace WebDoorCreator.UI.Components.SvgComp
#region Protected Properties
protected string cardClass
{
get => ItemCount > 0 ? "bg-primary text-light" : "bg-inactive text-dark";
}
protected CircleData CircleImg { get; set; } = null!;
@@ -95,11 +90,6 @@ namespace WebDoorCreator.UI.Components.SvgComp
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
@@ -107,20 +97,19 @@ namespace WebDoorCreator.UI.Components.SvgComp
/// <summary>
/// Invia evento principale
/// </summary>
/// <param name="forceSend">se true manda sempre EC_ExeFunct, altrimenti NON invia se showPlus attivo...</param>
protected void execFunc(bool forceSend)
/// <param name="action">Azione richiesta</param>
/// <param name="forceSend">
/// se true manda sempre EC_ExeFunct, altrimenti NON invia se showPlus attivo...
/// </param>
protected void doExecFunc(ActionReq action, bool forceSend)
{
// invia la chiamata richiesta secondo configurazione...
if (forceSend || !ShowPlus)
{
EC_ExeFunct.InvokeAsync(true);
EC_ExeFunct.InvokeAsync(action);
}
}
protected void execPlus()
{
EC_ExePlus.InvokeAsync(true);
}
protected override void OnParametersSet()
{
setupGraphParams();
+16 -13
View File
@@ -21,23 +21,27 @@
<div class="col-3">
</div>
<div class="col-3">
<DoorSvgObj LineColor="#8E44AD" LineWidth="8" ObjH="200" ObjW="900" LeftTextClass="col-10 fs-1 fw-bold" RightTextClass="col-2" EC_ExeFunct="@(()=> exeFun())" ObjId="1" TextData="@msgList" Message1="messaggio 1" Message2="messaggio 2" ImagePath="@svgUrl(196)"></DoorSvgObj>
<DoorSvgObj LineColor="#8E44AD" LineWidth="8" ObjH="200" ObjW="900" LeftTextClass="col-10 fs-1 fw-bold" RightTextClass="col-2" EC_ExeFunct="@(()=> exeDoor())" ObjId="1" TextData="@msgList" Message1="messaggio 1" Message2="messaggio 2" ImagePath="@svgUrl(196)"></DoorSvgObj>
</div>
<div class="col-3">
<DoorSvgObj LineColor="#8E44AD" LineWidth="8" ObjH="200" ObjW="900" LeftTextClass="col-10 fs-1 fw-bold" RightTextClass="col-2" EC_ExeFunct="@(()=> exeFun())" ObjId="2" TextData="@msgList" Message1="messaggio 1" Message2="messaggio 2" ShowPlusMinus="true" ImagePath="@svgUrl(186)"></DoorSvgObj>
<DoorSvgObj LineColor="#8E44AD" LineWidth="8" ObjH="200" ObjW="900" LeftTextClass="col-10 fs-1 fw-bold" RightTextClass="col-2" EC_ExeFunct="@(()=> exeDoor())" ObjId="2" TextData="@msgList" Message1="messaggio 1" Message2="messaggio 2" ShowPlusMinus="true" ImagePath="@svgUrl(186)"></DoorSvgObj>
</div>
<div class="col-3">
</div>
</div>
<div class="row my-2">
<div class="col-4">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@(()=> exeFun())" ObjId="21" ItemName="Flush Pull" ItemCount="2" ImagePath="@svgUrl(196)"></HwSvgObj>
<div class="col-3">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@exeFun" ObjId="21" ItemName="Flush Pull" ItemCount="2" ImagePath="@svgUrl(196)"></HwSvgObj>
</div>
<div class="col-4">
<div class="col-3">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@exeFun" ObjId="22" ItemName="Hinge" ItemCount="0" IconTag="fa-solid fa-right-from-bracket text-light"></HwSvgObj>
</div>
<div class="col-4">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@(()=> exeFun())" ObjId="22" ItemName="Hinge" ItemCount="0" ShowPlus="true" ImagePath="@svgUrl(186)"></HwSvgObj>
<div class="col-3">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@exeFun" ObjId="23" ItemName="Hinge" ItemCount="0" IconTag="fa-solid fa-plus text-light" ShowPlus="true"></HwSvgObj>
</div>
<div class="col-3">
<HwSvgObj LineColor="#CFD8DC" LineWidth="8" ObjH="200" ObjW="700" EC_ExeFunct="@exeFun" ObjId="24" ItemName="Hinge" ItemCount="0" ShowPlus="true" ImagePath="@svgUrl(186)"></HwSvgObj>
</div>
</div>
@@ -96,11 +100,6 @@
protected override async Task OnInitializedAsync()
{
//return base.OnInitializedAsync();
//}
//protected override void OnInitialized()
//{
msgList = new Dictionary<string, string>();
msgList.Add("T1", "Titolo");
msgList.Add("M1", "Messaggio 1");
@@ -110,7 +109,11 @@
protected List<DoorModel>? DoorsList { get; set; } = null;
protected async Task exeFun()
protected async Task exeDoor()
{
await Task.Delay(1);
}
protected async Task exeFun(HwSvgObj.ActionReq action)
{
await Task.Delay(1);
}