ui/wpf/UIcore/DrawingArea.cs

changeset 108
77254bd6dccb
parent 107
b34bd1557c6c
child 109
c3dfcb8f0be7
--- a/ui/wpf/UIcore/DrawingArea.cs	Sat Apr 05 17:57:04 2025 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Shapes;
-using System.Diagnostics;
-
-namespace UI
-{
-    public class DrawingArea : System.Windows.Controls.Canvas
-    {
-        public Action<int,int> resizeCallback;
-
-        public Color Color;
-        private Brush Brush;
-
-        public DrawingArea(Container container) : base()
-        {
-            this.SizeChanged += UpdateSize;
-            ResetGraphics();
-
-            container.Add(this, true);
-        }
-
-        public void UpdateSize(object sender, SizeChangedEventArgs e)
-        {
-            if(resizeCallback != null)
-            {
-                Children.Clear();
-                ResetGraphics();
-
-                Size s = e.NewSize;
-                resizeCallback((int)s.Width, (int)s.Height);
-            }
-        }
-
-        public void Redraw()
-        {
-            if (resizeCallback != null)
-            {
-                Children.Clear();
-                ResetGraphics();
-
-                resizeCallback((int)ActualWidth, (int)ActualHeight);
-            }
-
-        }
-
-        private void ResetGraphics()
-        {
-            Color = Color.FromRgb(0, 0, 0);
-            Brush = System.Windows.Media.Brushes.Black;
-        }
-
-        public void SetColor(int r, int g, int b)
-        {
-            Color = Color.FromRgb((byte)r, (byte)g, (byte)b);
-            Brush = new SolidColorBrush(Color);
-        }
-
-        public void DrawLine(int x1, int y1, int x2, int y2)
-        {
-            Line line = new Line();
-            line.Stroke = Brush;
-            line.StrokeThickness = 1;
-            line.SnapsToDevicePixels = true;
-
-            line.X1 = x1;
-            line.Y1 = y1;
-            line.X2 = x2;
-            line.Y2 = y2;
-
-            Children.Add(line);
-        }
-
-        public void DrawRect(int x, int y, int w, int h, bool fill)
-        {
-            Rectangle rect = new Rectangle();
-            rect.Stroke = Brush;
-            rect.StrokeThickness = 1;
-            rect.SnapsToDevicePixels = true;
-            if(fill)
-            {
-                rect.Fill = Brush;
-            }
-
-            rect.Width = w;
-            rect.Height = h;
-            SetLeft(rect, x);
-            SetTop(rect, y);
-
-            Children.Add(rect);
-        }
-    }
-}

mercurial