1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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 RectangleObject : 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 Rectangle 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);
- }
- }
|