using InABox.Core; using Xamarin.Forms; namespace PRS.Mobile { public class DigitalFormLabel : Label, IDigitalFormControl { private DFLayoutLabel _definition; public DFLayoutLabel Definition { get => _definition; set { _definition = value; Initialize(value ?? new DFLayoutLabel()); } } public DigitalFormLabel() { MinimumHeightRequest = 60; VerticalOptions = LayoutOptions.FillAndExpand; HorizontalOptions = LayoutOptions.FillAndExpand; } private void Initialize(DFLayoutLabel label) { Text = label.Caption; LineBreakMode = label.Style.TextWrapping ? LineBreakMode.WordWrap : LineBreakMode.NoWrap; BackgroundColor = label.Style.BackgroundColour.IsEmpty ? Color.Transparent : label.Style.BackgroundColour; FontAttributes = label.Style.IsBold ? FontAttributes.Bold : label.Style.IsItalic ? FontAttributes.Italic : FontAttributes.None; TextDecorations = label.Style.Underline == UnderlineType.Single || label.Style.Underline == UnderlineType.Double ? TextDecorations.Underline : TextDecorations.None; FontSize = label.Style.FontSize > 5 && label.Style.FontSize < 37 ? label.Style.FontSize : Device.GetNamedSize(NamedSize.Small, this); TextColor = label.Style.ForegroundColour.IsEmpty ? Color.Black : label.Style.ForegroundColour; HorizontalTextAlignment = label.Style.HorizontalTextAlignment == DFLayoutAlignment.Start ? TextAlignment.Start : label.Style.HorizontalTextAlignment == DFLayoutAlignment.Middle ? TextAlignment.Center : label.Style.HorizontalTextAlignment == DFLayoutAlignment.End ? TextAlignment.End : HorizontalTextAlignment; VerticalTextAlignment = label.Style.VerticalTextAlignment == DFLayoutAlignment.Start ? TextAlignment.Start : label.Style.HorizontalTextAlignment == DFLayoutAlignment.Middle ? TextAlignment.Center : label.Style.HorizontalTextAlignment == DFLayoutAlignment.End ? TextAlignment.End : TextAlignment.Center; } } }