114 lines
3.6 KiB
C#
114 lines
3.6 KiB
C#
/*
|
|
* 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 LinePattern : IPattern
|
|
{
|
|
public ObservableCollection<Line> Entities { get => _Entities; set => SetProperty(ref _Entities, value); }
|
|
private ObservableCollection<Line> _Entities = new ObservableCollection<Line>();
|
|
|
|
public LinePattern()
|
|
{
|
|
Entities = new ObservableCollection<Line>();
|
|
//Entities.Add(new Line());
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
Entities.Clear();
|
|
//Entities.Add(new Line());
|
|
}
|
|
|
|
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].START_X;
|
|
minY = maxY = Entities[0].START_Y;
|
|
foreach (var item in Entities) {
|
|
if (minX > item.START_X) minX = item.START_X;
|
|
if (minY > item.START_Y) minY = item.START_Y;
|
|
if (maxX < item.START_X) maxX = item.START_X;
|
|
if (maxY < item.START_Y) maxY = item.START_Y;
|
|
if (minX > item.END_X) minX = item.END_X;
|
|
if (minY > item.END_Y) minY = item.END_Y;
|
|
if (maxX < item.END_X) maxX = item.END_X;
|
|
if (maxY < item.END_Y) maxY = item.END_Y;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public class Line : NotifyPropertyChangedBase
|
|
{
|
|
public double START_X { get => _START_X; set => SetProperty(ref _START_X, value); }
|
|
private double _START_X;
|
|
public double START_Y { get => _START_Y; set => SetProperty(ref _START_Y, value); }
|
|
private double _START_Y;
|
|
public double END_X { get => _END_X; set => SetProperty(ref _END_X, value); }
|
|
private double _END_X;
|
|
public double END_Y { get => _END_Y; set => SetProperty(ref _END_Y, value); }
|
|
private double _END_Y;
|
|
|
|
public Brush CustomBrush = null;
|
|
|
|
public Line(double x1, double y1, double x2, double y2, string brush = null)
|
|
{
|
|
START_X = x1;
|
|
START_Y = y1;
|
|
END_X = x2;
|
|
END_Y = y2;
|
|
|
|
if (brush != null) {
|
|
CustomBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(brush));
|
|
}
|
|
}
|
|
|
|
public Line() : this(0, 0, 0, 0)
|
|
{
|
|
|
|
}
|
|
|
|
public void Copy(Line copyPattern)
|
|
{
|
|
if (copyPattern != null) {
|
|
START_X = copyPattern.START_X;
|
|
START_Y = copyPattern.START_Y;
|
|
END_X = copyPattern.END_X;
|
|
END_Y = copyPattern.END_Y;
|
|
|
|
CustomBrush = copyPattern.CustomBrush;
|
|
}
|
|
}
|
|
|
|
public void Shift(double x, double y)
|
|
{
|
|
START_X += x;
|
|
START_Y += y;
|
|
END_X += x;
|
|
END_Y += y;
|
|
}
|
|
}
|
|
}
|
|
}
|