/
jhayphal
/
CitReportDesigner
Обзор
Документация
Войти
/
jhayphal
/
CitReportDesigner
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ControlsSandbox/ViewModels/CellViewModel.cs
97 строк
2 KB
Oleg Nazarenko
Пофиксил фон текста.
27 мар 2023, 23:42
27 мар 2023, 23:42
e59abcd
Код
Авторство
О чём код?
using Avalonia.Layout; using Avalonia.Media; using ReactiveUI; namespace ControlsSandbox.ViewModels; public class CellViewModel : ViewModelBase, IBounds { private readonly CitReport.Cell cell; /// <summary> /// Конструктор для дизайнера. /// </summary> public CellViewModel() { var table = new CitReport.Table( new double[] { 0f, 50f, 100f }, new double[] { 0f, 5f, 10f }); cell = table.GetCell(0, 0); cell.Properties.DisplayValue.Add(string.Empty, "Text for designer"); } public CellViewModel(CitReport.Cell cell) { this.cell = cell; } public string Text { get { cell.Properties.DisplayValue.TryGetValue(DesignerEnvironment.Current.Language, out string text); return text ?? string.Empty; } set { cell.Properties.DisplayValue.TryGetValue(DesignerEnvironment.Current.Language, out string text); text ??= string.Empty; if (text != value) { cell.Properties.DisplayValue[DesignerEnvironment.Current.Language] = value; this.RaisePropertyChanged(nameof(Text)); } } } public int Column => cell.Column; public bool LastColumn => Column == cell.Table.ColumnsCount - 1; public int Row => cell.Row; public bool LastRow => Row == cell.Table.RowsCount - 1; public double X { get => cell.X; set => cell.X = value; } public double Y { get => cell.Y; set => cell.Y = value; } public double Width { get => cell.Width; set => cell.Width = value; } public double Height { get => cell.Height; set => cell.Height = value; } public ReportSizeUnit SizeUnit => ReportSizeUnit.Millimeter; public HorizontalAlignment HorizontalAlignment => AlignmentConverter.ConvertHorizontal(cell.Style.HorizontalAlignment); public VerticalAlignment VerticalAlignment => AlignmentConverter.ConvertVertical(cell.Style.VerticalAlignment); public IBrush ForegroundColor { get; set; } = Brushes.Black; public IBrush BackgroundColor { get; set; } = Brushes.Transparent; public bool Equals(CitReport.Cell cell) => cell == this.cell; public override bool Equals(object obj) => obj is CellViewModel viewModel && Equals(viewModel.cell); public override int GetHashCode() => cell.GetHashCode(); public override string ToString() => cell.ToString(); }