private void MergeVisual(Label label, params VisualCollector[] styles) { label.TextColor = ValueSelector.GetTextColor(styles); label.FontAttributes = ValueSelector.FontAttribute(styles); label.FontFamily = ValueSelector.FontFamily(styles); label.FontSize = ValueSelector.FontSize(styles); label.LineBreakMode = ValueSelector.GetLineBreakMode(styles); label.VerticalTextAlignment = ValueSelector.GetVerticalAlignment(styles); label.HorizontalTextAlignment = ValueSelector.GetHorizontalAlignment(styles); }
internal void OnUpdateStyle(Style style) { BackgroundColor = null; TextColor = null; FontAttribute = null; FontFamily = null; FontSize = 0; LineBreakMode = null; HorizontalTextAlignment = null; VerticalTextAlignment = null; if (style == null) { return; } foreach (var item in style.Setters) { if (item.Property == Label.BackgroundColorProperty) { BackgroundColor = ValueSelector.GetValueFromStyle <Color>(item); BackgroundColor.Value.MultiplyAlpha(0.5); } else if (item.Property == Label.TextColorProperty) { TextColor = ValueSelector.GetValueFromStyle <Color>(item); } else if (item.Property == Label.FontAttributesProperty) { FontAttribute = ValueSelector.GetValueFromStyle <FontAttributes>(item); } else if (item.Property == Label.FontFamilyProperty) { FontFamily = ValueSelector.GetValueFromStyle <string>(item); } else if (item.Property == Label.FontSizeProperty) { FontSize = ValueSelector.GetValueFromStyle <double>(item); } else if (item.Property == Label.VerticalTextAlignmentProperty) { VerticalTextAlignment = ValueSelector.GetValueFromStyle <TextAlignment>(item); } else if (item.Property == Label.HorizontalTextAlignmentProperty) { HorizontalTextAlignment = ValueSelector.GetValueFromStyle <TextAlignment>(item); } } }
internal void UpdateStyle() { // Priority: // 1) selected // 2) trigger // 3) column // 4) default foreach (var cell in cells) { if (isSelected) { // SELECT if (enableTrigger == null) { // row background cell.Wrapper.BackgroundColor = ValueSelector.GetBackgroundColor( DataGrid.VisualSelectedRowFromStyle.BackgroundColor, DataGrid.VisualSelectedRow.BackgroundColor, cell.Column.VisualCellFromStyle.BackgroundColor, cell.Column.VisualCell.BackgroundColor, DataGrid.VisualRowsFromStyle.BackgroundColor, DataGrid.VisualRows.BackgroundColor); if (!cell.IsCustomTemplate) { MergeVisual(cell.Label, DataGrid.VisualSelectedRowFromStyle, DataGrid.VisualSelectedRow, cell.Column.VisualCellFromStyle, cell.Column.VisualCell, DataGrid.VisualRowsFromStyle, DataGrid.VisualRows); } } // SELECT with TRIGGER else { // row background cell.Wrapper.BackgroundColor = ValueSelector.GetBackgroundColor( DataGrid.VisualSelectedRowFromStyle.BackgroundColor, DataGrid.VisualSelectedRow.BackgroundColor, enableTrigger.VisualContainerStyle.BackgroundColor, enableTrigger.VisualContainer.BackgroundColor, cell.Column.VisualCellFromStyle.BackgroundColor, cell.Column.VisualCell.BackgroundColor, DataGrid.VisualRowsFromStyle.BackgroundColor, DataGrid.VisualRows.BackgroundColor); if (!cell.IsCustomTemplate) { MergeVisual(cell.Label, DataGrid.VisualSelectedRowFromStyle, DataGrid.VisualSelectedRow, enableTrigger.VisualContainerStyle, enableTrigger.VisualContainer, cell.Column.VisualCellFromStyle, cell.Column.VisualCell, DataGrid.VisualRowsFromStyle, DataGrid.VisualRows); } } } // TRIGGER else if (enableTrigger != null) { // row background cell.Wrapper.BackgroundColor = ValueSelector.GetBackgroundColor( enableTrigger.VisualContainerStyle.BackgroundColor, enableTrigger.VisualContainer.BackgroundColor, cell.Column.VisualCellFromStyle.BackgroundColor, cell.Column.VisualCell.BackgroundColor, DataGrid.VisualRowsFromStyle.BackgroundColor, DataGrid.VisualRows.BackgroundColor); if (!cell.IsCustomTemplate) { MergeVisual(cell.Label, enableTrigger.VisualContainerStyle, enableTrigger.VisualContainer, cell.Column.VisualCellFromStyle, cell.Column.VisualCell, DataGrid.VisualRowsFromStyle, DataGrid.VisualRows); } } // DEFAULT else { // row background cell.Wrapper.BackgroundColor = ValueSelector.GetBackgroundColor( cell.Column.VisualCellFromStyle.BackgroundColor, cell.Column.VisualCell.BackgroundColor, DataGrid.VisualRowsFromStyle.BackgroundColor, DataGrid.VisualRows.BackgroundColor); if (!cell.IsCustomTemplate) { MergeVisual(cell.Label, cell.Column.VisualCellFromStyle, cell.Column.VisualCell, DataGrid.VisualRowsFromStyle, DataGrid.VisualRows); } } } }