using Microsoft.AspNetCore.Components;
using System.Drawing;
namespace GPW.CORE.Comp
{
public partial class CalWeekColumn
{
#region Public Enums
public enum ColType
{
///
/// Tipo etichetta Start (SX)
///
labelStart,
///
/// Tipo etichetta End (DX)
///
labelEnd,
///
/// Colonna dati
///
dataContainer
}
#endregion Public Enums
#region Public Properties
///
/// Lista etichette da mostrare (richiede tipo label...)
///
[Parameter]
public List EventList { get; set; } = new List();
///
/// Modalità di disegno
///
[Parameter]
public ColType ItemMode { get; set; } = ColType.dataContainer;
[Parameter]
public int ValMax { get; set; } = 19;
[Parameter]
public int ValMin { get; set; } = 9;
///
/// Dimensioni viewbox
///
[Parameter]
public Size vBox { get; set; } = new Size(1200, 3600);
#endregion Public Properties
#region Protected Methods
protected string getLabel(labelData currData)
{
return $"{currData.value}";
}
protected string getRect(boxData currData)
{
return $"";
}
protected string getBoxTitle(boxData currData)
{
return $"{currData.title}";
}
protected string getBoxDesc(boxData currData)
{
return $"{currData.value}";
}
protected int mFO
{
get => vBox.Width * 2 / 100;
}
protected int wFO
{
get => vBox.Width * 98 / 100;
}
protected int hFO
{
get => 100;// EventList.Count > 0 ? vBox.Height / EventList.Count : vBox.Height;
}
///
/// Converte la stringa in formato markup valido
///
///
///
protected MarkupString getMarkup(string rawData)
{
return new MarkupString(rawData);
}
private int numEv
{
get => EventList.Count > 0 ? EventList.Count : 1;
}
///
/// Genera una lista di etichette con corrdinate
///
///
protected List LabelItems()
{
int step = vBox.Height / numEv;// (ValMax - ValMin);
int offset = 0;// step / 2;
List answ = EventList
.OrderBy(x => x.Inizio)
.Select(x => new labelData()
{
pX = vBox.Width / 10,
pY = offset + (x.Inizio.Hour - ValMin) * step,
//pY = (x.Inizio.Hour - ValMin) * vBox.Height / (ValMax - ValMin),
value = x.Title
})
.ToList();
return answ;
}
protected List BoxItems()
{
List answ = new List();
int step = vBox.Height / (ValMax - ValMin);
int numEv = EventList.Count;
int evWidth = numEv > 1 ? (int)(1.2 * vBox.Width / numEv) : (int)(0.9 * vBox.Width);
int offsetX = 1;
int offsetY = 0;// step / 2;
if (numEv > 0)
{
int xStep = evWidth / EventList.Count;
int deltaX = 0;
answ = EventList
.OrderBy(x => x.Inizio)
.Select(x => new boxData()
{
pX = offsetX + xStep * (deltaX++),
pY = offsetY + (x.Inizio.Hour - ValMin) * step,
width = evWidth,
height = offsetY + (x.Fine.Hour - ValMin) * step,
title = x.Title,
value = x.Description,
start = x.Inizio,
end = x.Fine,
})
.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 DateTime start { get; set; } = DateTime.Today;
public DateTime end { get; set; } = DateTime.Today;
public string title { get; set; } = "";
public string value { get; set; } = "";
#endregion Public Properties
}
#endregion Protected Classes
}
}