/* * Copyright (c) 2022 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using Aurora.View; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media; namespace AuroraUIComponent.UserControls { public class DotPattern : IPattern { public ObservableCollection Entities { get => _Entities; set => SetProperty(ref _Entities, value); } private ObservableCollection _Entities = new ObservableCollection(); public DotPattern() { Entities = new ObservableCollection(); //Entities.Add(new Dot()); } public void Clear() { Entities.Clear(); //Entities.Add(new Dot()); } public override void Shift(double x, double y) { foreach (var item in Entities) { item.Shift(x, y); } } public override bool GetMinMax(out double minX, out double maxX, out double minY, out double maxY) { if (Entities.Count == 0) { return base.GetMinMax(out minX, out maxX, out minY, out maxY); } minX = maxX = Entities[0].ORG_X; minY = maxY = Entities[0].ORG_Y; foreach (var item in Entities) { if (minX > item.ORG_X) minX = item.ORG_X; if (minY > item.ORG_Y) minY = item.ORG_Y; if (maxX < item.ORG_X) maxX = item.ORG_X; if (maxY < item.ORG_Y) maxY = item.ORG_Y; } return true; } public class Dot : NotifyPropertyChangedBase { public double ORG_X { get => _ORG_X; set => SetProperty(ref _ORG_X, value); } private double _ORG_X; public double ORG_Y { get => _ORG_Y; set => SetProperty(ref _ORG_Y, value); } private double _ORG_Y; public double RADIUS { get => _RADIUS; set => SetProperty(ref _RADIUS, value); } private double _RADIUS = 2; public Brush CustomBrush = null; public Dot(double x, double y, double r = 2, string brush = null) { ORG_X = x; ORG_Y = y; RADIUS = r; if (brush != null) { CustomBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(brush)); } } public Dot() : this(0, 0, 0) { } public void Copy(Dot copyPattern) { if (copyPattern != null) { ORG_X = copyPattern.ORG_X; ORG_Y = copyPattern.ORG_Y; RADIUS = copyPattern.RADIUS; CustomBrush = copyPattern.CustomBrush; } } public void Shift(double x, double y) { ORG_X += x; ORG_Y += y; } } } }