|
@@ -90,38 +90,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
DispatcherTimer timer = new DispatcherTimer(); |
|
|
DispatcherTimer timer = new DispatcherTimer(); |
|
|
/// <summary> |
|
|
/// <summary> |
|
|
/// 属性绑定变量集合 |
|
|
|
|
|
/// </summary> |
|
|
|
|
|
Dictionary<string,string> propertyBing = new Dictionary<string,string>(); |
|
|
|
|
|
/// <summary> |
|
|
|
|
|
/// 运行事件 |
|
|
/// 运行事件 |
|
|
/// </summary> |
|
|
/// </summary> |
|
|
public void Register() |
|
|
public void Register() |
|
|
{ |
|
|
{ |
|
|
//Binding binding = new Binding(); |
|
|
|
|
|
//binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self }; |
|
|
|
|
|
//binding.Path = new PropertyPath(string.Format("DataModel[{0}].通道校准参数2", "小配料机")); |
|
|
|
|
|
//SetBinding(TextProperty, binding); |
|
|
|
|
|
|
|
|
|
|
|
//Binding binding = new Binding(); |
|
|
|
|
|
//binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self }; |
|
|
|
|
|
//binding.Path = new PropertyPath("this"); |
|
|
|
|
|
//SetBinding(DataContextProperty, binding); |
|
|
|
|
|
|
|
|
|
|
|
PropertyInfo[] propertyInfos = this.GetType().GetProperties(); |
|
|
|
|
|
foreach (PropertyInfo propertyInfo in propertyInfos) |
|
|
|
|
|
{ |
|
|
|
|
|
var propName = propertyInfo?.GetValue(this,null); |
|
|
|
|
|
if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains(".")) |
|
|
|
|
|
{ |
|
|
|
|
|
string va = string.Empty; |
|
|
|
|
|
if (propName.ToString().StartsWith("{}")) va = propName.ToString().Replace("{}",""); |
|
|
|
|
|
else va = propName.ToString(); |
|
|
|
|
|
propertyBing[propertyInfo.Name] = va; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//if (propertyBing.Count > 0) |
|
|
|
|
|
|
|
|
if (BindingOperations.GetBinding(this, TextProperty) != null) |
|
|
{ |
|
|
{ |
|
|
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); |
|
|
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); |
|
|
timer.Tick += Timer_Tick; ; |
|
|
timer.Tick += Timer_Tick; ; |
|
@@ -138,21 +111,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
DataModel = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData)); |
|
|
DataModel = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData)); |
|
|
|
|
|
|
|
|
foreach (var item in propertyBing) |
|
|
|
|
|
{ |
|
|
|
|
|
//{Binding 测试设备.VAR_A_2} |
|
|
|
|
|
string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split("."); |
|
|
|
|
|
if (str.Length > 1) |
|
|
|
|
|
{ |
|
|
|
|
|
DataModel = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData)); |
|
|
|
|
|
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0])) |
|
|
|
|
|
{ |
|
|
|
|
|
Dictionary<string, object> b = Class_DataBus.GetInstance().Dic_RedisData[str[0]]; |
|
|
|
|
|
if (b != null && b.ContainsKey(str[1])) this.GetType().GetProperty(item.Key).SetValue(this, b[str[1]]); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
catch (Exception ex) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
|