From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 Plugin.TsExecution/ScreenTouch.xaml.cs |  179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/Plugin.TsExecution/ScreenTouch.xaml.cs b/Plugin.TsExecution/ScreenTouch.xaml.cs
new file mode 100644
index 0000000..4cf1f19
--- /dev/null
+++ b/Plugin.TsExecution/ScreenTouch.xaml.cs
@@ -0,0 +1,179 @@
+锘縰sing HMI.Base;
+using HMI.UI.DpUtil;
+using System;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace Plugin.TsExecution
+{
+    public class ColorConverter : IMultiValueConverter
+    {
+        public static ColorConverter Instance = new ColorConverter();
+        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (values[0] is ObservableCollection<string> list && values[1] is string tag)
+            {
+                if (list?.Contains(tag) == true) return Brushes.Green;
+                return Brushes.White;
+            }
+            return values;
+        }
+
+        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+        {
+            return null;
+        }
+    }
+
+    /// <summary>
+    /// ScreenTouch.xaml 鐨勪氦浜掗�昏緫
+    /// </summary>
+    public partial class ScreenTouch : NotifyControl
+    {
+        public static readonly DependencyProperty ValuesProperty = DependencyProperty.Register(
+            nameof(Values),
+            typeof(ObservableCollection<bool>),
+            typeof(ScreenTouch),
+            new PropertyMetadata(null, OnValuesChanged));
+
+        private static void OnValuesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            if (d is ScreenTouch control)
+            {
+                // 濡傛灉鏈夋棫鐨勯泦鍚堬紝鍙栨秷璁㈤槄
+                if (e.OldValue is ObservableCollection<bool> oldCollection)
+                {
+                    oldCollection.CollectionChanged -= control.Value_CollectionChanged;
+                }
+
+                // 濡傛灉鏈夋柊鐨勯泦鍚堬紝璁㈤槄鍙樻洿浜嬩欢
+                if (e.NewValue is ObservableCollection<bool> newCollection)
+                {
+                    newCollection.CollectionChanged += control.Value_CollectionChanged;
+                }
+
+                // 鍒锋柊鎵�鏈夊崟鍏冩牸
+                control.PaintPoints();
+            }
+        }
+
+
+        public ScreenTouch(int rows, int columns)
+        {
+            this.rows = rows;
+            this.columns = columns;
+            InitializeComponent();
+            Refresh();
+            Values = new ObservableCollection<bool>(new bool[rows * columns]);
+        }
+
+        public ObservableCollection<bool> Values
+        {
+            get => (ObservableCollection<bool>)GetValue(ValuesProperty);
+            set
+            {
+                SetValue(ValuesProperty, value);
+            }
+        }
+
+        private void Value_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+        {
+            PaintPoints();
+        }
+
+        public int rows { get; private set; }
+        public int columns { get; private set; }
+
+        private Border[] children;
+
+        public void Refresh()
+        {
+            uniform.Children.Clear();
+            uniform.Rows = rows;
+            uniform.Columns = columns;
+
+            children = new Border[rows * columns];
+
+
+            for (int i = 0; i < children.Length; i++)
+            {
+                var border = new Border
+                {
+                    BorderThickness = new Thickness(0),
+                    Background = Brushes.White
+                };
+                children[i] = border;
+                uniform.Children.Add(border);
+            }
+            UniformGridHelper.RefreshGridInnerBorder(uniform);
+        }
+
+        public void Refresh(int rows, int columns)
+        {
+            this.rows = rows;
+            this.columns = columns;
+            Refresh();
+        }
+
+        public void Clear()
+        {
+            Values = new ObservableCollection<bool>(new bool[rows * columns]);
+        }
+
+        public void DrawPoint(int x, int y)
+        {
+            Values[y * columns + x] = true;
+        }
+
+        public void DrawPoints(int[][] points)
+        {
+            var temp = new ObservableCollection<bool>(new bool[rows * columns]);
+            for (int i = 0; i < points.Length; i++)
+            {
+                int[] point = points[i];
+                int index = point[1] * columns + point[0];
+                //children[point[0]][point[1]].Background = Brushes.Green;
+                temp[index] = true;
+            }
+            Values = temp;
+        }
+
+        public void DrawNewPoints(int[][] points)
+        {
+            var temp = Values == null ?
+                new ObservableCollection<bool>(new bool[rows * columns]) :
+                new ObservableCollection<bool>(Values);
+            for (int i = 0; i < points.Length; i++)
+            {
+                int[] point = points[i];
+                if (point == null)
+                {
+                    continue;
+                }
+                int index = point[1] * columns + point[0];
+                //children[point[0]][point[1]].Background = Brushes.Green;
+                temp[index] = true;
+            }
+            Values = temp;
+        }
+
+        private void PaintPoints()
+        {
+            for (int i = 0; i < Values.Count; i++)
+            {
+                if (Values[i])
+                {
+                    children[i].Background = Brushes.Green;
+                }
+                else
+                {
+                    children[i].Background = Brushes.White;
+                }
+            }
+        }
+    }
+}

--
Gitblit v1.9.1