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(100, 100); #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}"; } /// /// Converte la stringa in formato markup valido /// /// /// protected MarkupString getMarkup(string rawData) { return new MarkupString(rawData); } /// /// Genera una lista di etichette con corrdinate /// /// protected List LabelItems() { int step = vBox.Height / (ValMax - ValMin); int offset = step / 2; List 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 BoxItems() { List answ = new List(); 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 } }