From 3a471ae651b228231bebb3a2d438baa1d4ac0261 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期五, 21 十一月 2025 08:57:52 +0800
Subject: [PATCH] 优化
---
Plugin.DODriverControl/SingleControl.xaml.cs | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/Plugin.DODriverControl/SingleControl.xaml.cs b/Plugin.DODriverControl/SingleControl.xaml.cs
index 0767cb0..2cea7ba 100644
--- a/Plugin.DODriverControl/SingleControl.xaml.cs
+++ b/Plugin.DODriverControl/SingleControl.xaml.cs
@@ -311,11 +311,21 @@
{
if (data.Dio == DIOType.DI)
{
- return new LightBall
+ if (data.ControlType == ControlType.BOOL)
{
- Size = 40,
- DataContext = data
- };
+ return new LightBall
+ {
+ Size = 40,
+ DataContext = data
+ };
+ }
+ else
+ {
+ return new TextBox
+ {
+ IsReadOnly = true
+ };
+ }
}
Style btnStyle = this.FindResource("PrimaryButton") as Style;
var btn = new Button
@@ -513,9 +523,10 @@
case ControlType.LREAL:
case ControlType.STRING:
case ControlType.WSTRING:
- ((Button)ui).Content = value;
+ ((TextBox)ui).Text = value;
break;
default:
+ ((TextBox)ui).Text = value;
break;
}
});
@@ -539,6 +550,7 @@
value = null;
return false;
}
+ string msg;
switch (data.ControlType)
{
case ControlType.BOOL:
@@ -546,11 +558,11 @@
bool res = false;
if (data.Dio == DIOType.DI)
{
- res = controller.ReadDIBool(data.Address, out val, out string msg);
+ res = controller.ReadDIBool(data.Address, out val, out msg);
}
else
{
- res = controller.ReadDOBool(data.Address, out val, out string msg);
+ res = controller.ReadDOBool(data.Address, out val, out msg);
}
if (res == true)
{
@@ -560,6 +572,10 @@
value = null;
return false;
default:
+ if (controller.ReadDIDouble(data.Address, out double? dVal, out msg))
+ {
+ value = dVal.ToString();
+ }
value = null;
return true;
}
--
Gitblit v1.9.1