From 559890c482f5973f06aafdfec9550fee5ba3c7f2 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 17:02:15 +0800
Subject: [PATCH] feat: CAN 模拟器 TCP 化 + 多设备并发调试 + 后台生命周期管理
---
HMI.UI/DpUtil/StackPanelHelper.cs | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/HMI.UI/DpUtil/StackPanelHelper.cs b/HMI.UI/DpUtil/StackPanelHelper.cs
index 3c5c84a..ffe05eb 100644
--- a/HMI.UI/DpUtil/StackPanelHelper.cs
+++ b/HMI.UI/DpUtil/StackPanelHelper.cs
@@ -1,7 +1,7 @@
锘縰sing System.Windows;
using System.Windows.Controls;
-namespace HMI.UI
+namespace HMI.UI.DpUtil
{
public class StackPanelHelper
{
@@ -20,19 +20,35 @@
new PropertyMetadata(0d, (d, e) =>
{
if (!(d is StackPanel sp)) return;
- if (sp.Children == null) return;
- var children = sp.Children;
- double space = (double)e.NewValue;
- if (sp.Orientation == Orientation.Horizontal)
+ sp.Loaded += Sp_Loaded;
+ }));
+
+ private static void Sp_Loaded(object sender, RoutedEventArgs e)
+ {
+ var sp = sender as StackPanel;
+ var children = sp.Children;
+ if (sp.Children == null) return;
+ double space = GetChildSpace(sp);
+ if (sp.Orientation == Orientation.Horizontal)
+ {
+ for (int i = 0; i < children.Count; i++)
{
- for (int i = 0; i < children.Count; i++)
+ if (children[i] is FrameworkElement ui)
{
- if (children[i] is FrameworkElement ui)
- {
- ui.Margin = new Thickness(0, 0, (i == children.Count - 1) ? 0 : space, 0);
- }
+ ui.Margin = new Thickness(0, 0, (i == children.Count - 1) ? 0 : space, 0);
}
}
- }));
+ }
+ else
+ {
+ for (int i = 0; i < children.Count; i++)
+ {
+ if (children[i] is FrameworkElement ui)
+ {
+ ui.Margin = new Thickness(0, 0, 0, (i == children.Count - 1) ? 0 : space);
+ }
+ }
+ }
+ }
}
-}
+}
\ No newline at end of file
--
Gitblit v1.9.1