123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Avalonia;
- using Avalonia.Controls;
- using Avalonia.Controls.Shapes;
- using Avalonia.Media;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace InABox.Avalonia.Components.ImageEditing;
- internal class EllipseObject : IImageEditorObject
- {
- public IBrush? PrimaryBrush { get; set; }
- public IBrush? SecondaryBrush { get; set; }
- public double Thickness { get; set; } = 1.0;
- public Point Point1 { get; set; }
- public Point Point2 { get; set; }
- private Ellipse Control = new();
- public Control GetControl() => Control;
- public void Update()
- {
- Control.Stroke = PrimaryBrush;
- Control.Fill = SecondaryBrush;
- Control.StrokeThickness = Thickness;
- var topLeft = new Point(
- Math.Min(Point1.X, Point2.X),
- Math.Min(Point1.Y, Point2.Y));
- Canvas.SetLeft(Control, topLeft.X);
- Canvas.SetTop(Control, topLeft.Y);
- Control.Width = Math.Abs(Point2.X - Point1.X);
- Control.Height = Math.Abs(Point2.Y - Point1.Y);
- }
- public void SetActive(bool active)
- {
- }
- }
|