Parcourir la source

1

样式分支
fyf il y a 2 ans
Parent
révision
e55f637d1c
2 fichiers modifiés avec 7 ajouts et 44 suppressions
  1. +1
    -43
      BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
  2. +6
    -1
      BeDesignerSCADA/ViewModel/MainViewModelNew.cs

+ 1
- 43
BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs Voir le fichier

@@ -90,38 +90,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls
/// </summary>
DispatcherTimer timer = new DispatcherTimer();
/// <summary>
/// 属性绑定变量集合
/// </summary>
Dictionary<string,string> propertyBing = new Dictionary<string,string>();
/// <summary>
/// 运行事件
/// </summary>
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.Tick += Timer_Tick; ;
@@ -138,21 +111,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
try
{
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)
{


+ 6
- 1
BeDesignerSCADA/ViewModel/MainViewModelNew.cs Voir le fichier

@@ -271,7 +271,12 @@ namespace BeDesignerSCADA.ViewModel
string _binding = PropertyBindingWindow.ShowEdit(dependencyProperty, (selectControl as FrameworkElement), VariablePath);
if (!string.IsNullOrEmpty(_binding))
{
Binding bindingText = new Binding() { Mode = BindingMode.TwoWay, Path = new PropertyPath(_binding) };
Binding bindingText = new Binding()
{
Mode = BindingMode.TwoWay,
RelativeSource=new RelativeSource { Mode=RelativeSourceMode.Self},
Path = new PropertyPath(_binding)
};
(selectControl as FrameworkElement).SetBinding(dependencyProperty, bindingText);
}
else


Chargement…
Annuler
Enregistrer