167 lines
4.9 KiB
C#
167 lines
4.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using System.Drawing;
|
|
|
|
namespace GPW.CORE.Comp
|
|
{
|
|
public partial class CalWeekColumn
|
|
{
|
|
#region Public Enums
|
|
|
|
public enum ColType
|
|
{
|
|
/// <summary>
|
|
/// Tipo etichetta Start (SX)
|
|
/// </summary>
|
|
labelStart,
|
|
|
|
/// <summary>
|
|
/// Tipo etichetta End (DX)
|
|
/// </summary>
|
|
labelEnd,
|
|
|
|
/// <summary>
|
|
/// Colonna dati
|
|
/// </summary>
|
|
dataContainer
|
|
}
|
|
|
|
#endregion Public Enums
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Lista etichette da mostrare (richiede tipo label...)
|
|
/// </summary>
|
|
[Parameter]
|
|
public List<CalendarEvent> EventList { get; set; } = new List<CalendarEvent>();
|
|
|
|
/// <summary>
|
|
/// Modalità di disegno
|
|
/// </summary>
|
|
[Parameter]
|
|
public ColType ItemMode { get; set; } = ColType.dataContainer;
|
|
|
|
[Parameter]
|
|
public int ValMax { get; set; } = 19;
|
|
|
|
[Parameter]
|
|
public int ValMin { get; set; } = 9;
|
|
|
|
/// <summary>
|
|
/// Dimensioni viewbox
|
|
/// </summary>
|
|
[Parameter]
|
|
public Size vBox { get; set; } = new Size(100, 100);
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string getLabel(labelData currData)
|
|
{
|
|
return $"<text class=\"lblText\">{currData.value}</text>";
|
|
}
|
|
|
|
protected string getRect(boxData currData)
|
|
{
|
|
return $"<rect x=\"0\" y=\"0\" width=\"{currData.width}\" height=\"{currData.height}\" fill=\"rgba(120,120,120,0.5)\" rx=\"3\" ry=\"3\" />";
|
|
}
|
|
protected string getBoxTitle(boxData currData)
|
|
{
|
|
return $"<text class=\"lblBoxTitle\" x=\"2\" y=\"4\">{currData.title}</text>";
|
|
}
|
|
protected string getBoxDesc(boxData currData)
|
|
{
|
|
return $"<text class=\"lblBoxText\" x=\"2\" y=\"8\">{currData.value}</text>";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converte la stringa in formato markup valido
|
|
/// </summary>
|
|
/// <param name="rawData"></param>
|
|
/// <returns></returns>
|
|
protected MarkupString getMarkup(string rawData)
|
|
{
|
|
return new MarkupString(rawData);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Genera una lista di etichette con corrdinate
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected List<labelData> LabelItems()
|
|
{
|
|
int step = vBox.Height / (ValMax - ValMin);
|
|
int offset = step / 2;
|
|
|
|
List<labelData> answ = EventList
|
|
.OrderBy(x => x.Inizio)
|
|
.Select(x => new labelData()
|
|
{
|
|
pX = vBox.Width / 2,
|
|
pY = offset + (x.Inizio.Hour - ValMin) * step,
|
|
//pY = (x.Inizio.Hour - ValMin) * vBox.Height / (ValMax - ValMin),
|
|
value = x.Title
|
|
})
|
|
.ToList();
|
|
return answ;
|
|
}
|
|
|
|
protected List<boxData> BoxItems()
|
|
{
|
|
List<boxData> answ = new List<boxData>();
|
|
int step = vBox.Height / (ValMax - ValMin);
|
|
int offset = 0;// step / 2;
|
|
int numEv = EventList.Count;
|
|
if (numEv > 0)
|
|
{
|
|
int xStep = vBox.Width / EventList.Count;
|
|
int deltaX = 0;
|
|
answ = EventList
|
|
.OrderBy(x => x.Inizio)
|
|
.Select(x => new boxData()
|
|
{
|
|
pX = xStep * (deltaX++),
|
|
pY = offset + (x.Inizio.Hour - ValMin) * step,
|
|
width = vBox.Width / numEv,
|
|
height = offset + (x.Fine.Hour - ValMin) * step,
|
|
title = x.Title,
|
|
value = x.Description
|
|
})
|
|
.ToList();
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Protected Classes
|
|
|
|
protected class labelData
|
|
{
|
|
#region Public Properties
|
|
|
|
public int pX { get; set; } = 0;
|
|
public int pY { get; set; } = 0;
|
|
public string value { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
protected class boxData
|
|
{
|
|
#region Public Properties
|
|
|
|
public int pX { get; set; } = 0;
|
|
public int pY { get; set; } = 0;
|
|
public int width { get; set; } = 0;
|
|
public int height { get; set; } = 0;
|
|
public string title { get; set; } = "";
|
|
public string value { get; set; } = "";
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Protected Classes
|
|
}
|
|
} |