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.DataViewer/CustomSortColumn.cs |  108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)

diff --git a/Plugin.DataViewer/CustomSortColumn.cs b/Plugin.DataViewer/CustomSortColumn.cs
new file mode 100644
index 0000000..793d2f1
--- /dev/null
+++ b/Plugin.DataViewer/CustomSortColumn.cs
@@ -0,0 +1,108 @@
+锘縰sing System.ComponentModel;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace Plugin.DataViewer
+{
+    public class CustomSortColumnConverter : IValueConverter
+    {
+        public static CustomSortColumnConverter Instance = new CustomSortColumnConverter();
+        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            if (value as ListSortDirection? == ListSortDirection.Ascending)
+            {
+                return true;
+            }
+
+            if (value as ListSortDirection? == ListSortDirection.Descending)
+            {
+                return false;
+            }
+            return null;
+        }
+
+        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+        {
+            return value;
+        }
+    }
+
+    public interface ICustomSortColumn
+    {
+        public bool? IsAsc { get; set; }
+
+        void UpdateOther(bool? value);
+        DataGrid GetOwner();
+    }
+
+    public class CustomSortTemplateColumn : DataGridTemplateColumn, ICustomSortColumn
+    {
+        public static DependencyProperty IsAscProperty = DependencyProperty.Register(
+                            "IsAsc",
+                            typeof(bool?),
+                            typeof(DataGridTemplateColumn),
+                            new FrameworkPropertyMetadata(null));
+
+        public bool? IsAsc
+        {
+            get => (bool?)GetValue(IsAscProperty);
+            set
+            {
+                SetValue(IsAscProperty, value);
+            }
+        }
+
+        public void UpdateOther(bool? value)
+        {
+            foreach (var col in DataGridOwner.Columns)
+            {
+                if (col == this) continue;
+                if (col is ICustomSortColumn csc)
+                {
+                    csc.IsAsc = value;
+                }
+            }
+        }
+
+        public DataGrid GetOwner()
+        {
+            return this.DataGridOwner;
+        }
+    }
+
+    public class CustomSortTextColumn : DataGridTextColumn, ICustomSortColumn
+    {
+        public static DependencyProperty IsAscProperty = DependencyProperty.Register(
+                            "IsAsc",
+                            typeof(bool?),
+                            typeof(DataGridTextColumn),
+                            new FrameworkPropertyMetadata(null));
+
+        public bool? IsAsc
+        {
+            get => (bool?)GetValue(IsAscProperty);
+            set
+            {
+                SetValue(IsAscProperty, value);
+            }
+        }
+        public void UpdateOther(bool? value)
+        {
+            foreach (var col in DataGridOwner.Columns)
+            {
+                if (col == this) continue;
+                if (col is ICustomSortColumn csc)
+                {
+                    csc.IsAsc = value;
+                }
+            }
+        }
+
+        public DataGrid GetOwner()
+        {
+            return this.DataGridOwner;
+        }
+    }
+}

--
Gitblit v1.9.1