Files
egwcorelib/EgwCoreLib.Razor/StepArrow.razor.cs
T
Samuele Locatelli 545cc592ea Update display arrow
2023-05-10 08:54:35 +02:00

151 lines
4.2 KiB
C#

using Microsoft.AspNetCore.Components;
namespace EgwCoreLib.Razor
{
public partial class StepArrow
{
#region Public Properties
/// <summary>
/// Style del blocco
/// </summary>
[Parameter]
public string BlockStyle { get; set; } = "fill:rgb(0,0,255);";
/// <summary>
/// Altezza oggetto
/// </summary>
[Parameter]
public int ObjH { get; set; } = 100;
/// <summary>
/// Id univoco oggetto
/// </summary>
[Parameter]
public int ObjId { get; set; } = 0;
/// <summary>
/// Larghezza oggetto
/// </summary>
[Parameter]
public int ObjW { get; set; } = 500;
/// <summary>
/// Angolo della freccia
/// </summary>
[Parameter]
public int TipAngle { get; set; } = 108;
/// <summary>
/// Testo da mostrare
/// </summary>
[Parameter]
public string StepText { get; set; } = "Arrow Stepped";
/// <summary>
/// Style delle likee di contorno:
/// formato: Top-Right-Bottom-Left
/// </summary>
[Parameter]
public List<string> StrokeColors { get; set; } = new List<string>();
/// <summary>
/// Testo da mostrare
/// </summary>
[Parameter]
public int StrokeWidth { get; set; } = 0;
/// <summary>
/// Stile testo
/// </summary>
[Parameter]
public string TextStyle { get; set; } = "font-size: 2.5em; font-weight:bold; fill: white;";
#endregion Public Properties
#region Protected Properties
/// <summary>
/// Angolo in radianti
/// </summary>
protected double radAngle
{
get => TipAngle * (Math.PI / 180);
}
protected int deltaX
{
get => (int)Math.Round((rectH / 2) / Math.Tan(radAngle / 2), 0);
}
/// <summary>
/// Elenco linee da disegnare da lista stroke conf:
/// nb: mi aspetto 4 valori configurati in StokeColors
/// </summary>
protected Dictionary<string, string> line2Draw
{
get
{
Dictionary<string, string> lineList = new Dictionary<string, string>();
if (StrokeColors.Count == 4)
{
var pList = pointList;
if (!string.IsNullOrEmpty(StrokeColors[0]))
lineList.Add($"{pList[0]} {pList[1]}", StrokeColors[0]);
if (!string.IsNullOrEmpty(StrokeColors[1]))
lineList.Add($"{pList[1]} {pList[2]} {pList[3]}", StrokeColors[1]);
if (!string.IsNullOrEmpty(StrokeColors[2]))
lineList.Add($"{pList[3]} {pList[4]}", StrokeColors[2]);
if (!string.IsNullOrEmpty(StrokeColors[3]))
lineList.Add($"{pList[4]} {pList[5]} {pList[0]}", StrokeColors[3]);
}
return lineList;
}
}
/// <summary>
/// Elenco punti calcolati (6) x la sagoma a freccia
/// </summary>
/// <returns></returns>
protected string[] pointList
{
get
{
string[] pList = new string[6];
// aggiungo 1:1 i punti
pList[0] = $"{StrokeWidth},{StrokeWidth}";
pList[1] = $"{rectW - deltaX},{StrokeWidth}";
pList[2] = $"{rectW},{rectH / 2}";
pList[3] = $"{rectW - deltaX},{rectH}";
pList[4] = $"{StrokeWidth},{rectH}";
pList[5] = $"{deltaX},{rectH / 2}";
return pList;
}
}
protected string poliPoints
{
get
{
return string.Join(" ", pointList);
}
}
protected int rectH
{
get => ObjH - (StrokeWidth * 2);
}
protected int rectW
{
get => ObjW - (StrokeWidth * 2);
}
protected bool showLines
{
get => StrokeWidth > 0 && StrokeColors.Count > 0;
}
#endregion Protected Properties
}
}