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