diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
index 10176eec..3456a376 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
@@ -1,6 +1,7 @@
using BPASmartClient.Compiler;
using BPASmartClient.DATABUS;
using BPASmartClient.SCADAControl;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -72,6 +73,17 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
public static readonly DependencyProperty TimeCountProperty =
DependencyProperty.Register("TimeCount",typeof(int),typeof(TheTextBlock),new PropertyMetadata(50));
+ ///
+ /// 数据模板
+ ///
+ private Dictionary DataModel
+ {
+ get { return (Dictionary)GetValue(DataModelProperty); }
+ set { SetValue(DataModelProperty, value); }
+ }
+ private static readonly DependencyProperty DataModelProperty =
+ DependencyProperty.Register("DataModel", typeof(Dictionary), typeof(TheTextBlock), new PropertyMetadata(new Dictionary()));
+
public event EventHandler PropertyChange; //声明一个事件
///
/// 属性刷新器
@@ -86,6 +98,16 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
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)
{
@@ -99,7 +121,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}
- if (propertyBing.Count > 0)
+ //if (propertyBing.Count > 0)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
@@ -115,12 +137,15 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
try
{
+ DataModel = JsonConvert.DeserializeObject>(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>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
{
Dictionary b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
diff --git a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs
index fb03bd99..0abfb00a 100644
--- a/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs
+++ b/BeDesignerSCADA/Controls/MainCanvasPanel.xaml.cs
@@ -553,9 +553,6 @@ namespace BeDesignerSCADA.Controls
}
}
-
-
-
///
/// 设备名称下拉框打开事件
///
diff --git a/BeDesignerSCADA/View/PropertyBindingWindow.xaml b/BeDesignerSCADA/View/PropertyBindingWindow.xaml
index b1c76621..e67a6736 100644
--- a/BeDesignerSCADA/View/PropertyBindingWindow.xaml
+++ b/BeDesignerSCADA/View/PropertyBindingWindow.xaml
@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BeDesignerSCADA.View"
mc:Ignorable="d"
- Title="PropertyBindingWindow" Height="160" Width="400"
+ Title="PropertyBindingWindow" Height="220" Width="400"
Background="White"
BorderBrush="#FFDEDEDE"
BorderThickness="1"
@@ -25,7 +25,21 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BeDesignerSCADA/View/PropertyBindingWindow.xaml.cs b/BeDesignerSCADA/View/PropertyBindingWindow.xaml.cs
index 3f30a259..013bcea3 100644
--- a/BeDesignerSCADA/View/PropertyBindingWindow.xaml.cs
+++ b/BeDesignerSCADA/View/PropertyBindingWindow.xaml.cs
@@ -1,6 +1,9 @@
using BeDesignerSCADA.Common;
+using BeDesignerSCADA.ViewModel;
+using BPASmart.Model;
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -29,11 +32,45 @@ namespace BeDesignerSCADA.View
public static PropertyBindingWindow Instance { get; } = new PropertyBindingWindow();
+ ///
+ /// 设备名称集合
+ ///
+ private ObservableCollection _DevNameList;
+ public ObservableCollection DevNameList
+ {
+ get
+ {
+ return _DevNameList;
+ }
+ set
+ {
+ _DevNameList = value;
+ }
+ }
- public static string ShowEdit(DependencyProperty selectproperty, FrameworkElement control)
+ ///
+ /// 设备变量集合
+ ///
+ private ObservableCollection _DevValueList;
+ public ObservableCollection DevValueList
+ {
+ get
+ {
+ return _DevValueList;
+ }
+ set
+ {
+ _DevValueList = value;
+ }
+ }
+
+ public string VariablePath = string.Empty;
+
+ public static string ShowEdit(DependencyProperty selectproperty, FrameworkElement control, string _VariablePath)
{
// 获取所有控件的可用属性
var pros = PropertyHelper.GetBindString(selectproperty, control);
+ Instance.VariablePath = _VariablePath;
Instance.ProperpName.Text = selectproperty.Name;
Instance.BindingName.Text = pros;
Instance.ShowDialog();
@@ -67,5 +104,105 @@ namespace BeDesignerSCADA.View
IsOk = true;
Close();
}
+
+ ///
+ /// 变量选择
+ ///
+ ///
+ ///
+ private void ComboBoxValue_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ try
+ {
+
+ if (sender is System.Windows.Controls.ComboBox)
+ {
+ System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
+ if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text))
+ {
+ Instance.BindingName.Text = string.Format("DataModel[{0}].{1}", toggle.Tag, toggle.Text);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+ ///
+ /// 变量下拉框打开事件
+ ///
+ ///
+ ///
+ private void valuebox_DropDownOpened(object sender, EventArgs e)
+ {
+ try
+ {
+ Instance.DevValueList = new System.Collections.ObjectModel.ObservableCollection();
+ if (sender is System.Windows.Controls.ComboBox)
+ {
+ System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
+ if (toggle.Tag == null) return;
+
+ CommunicationPar communication = null;
+ if (DataBusModel.GetInstance().KeyValues.ContainsKey(Instance.VariablePath))
+ {
+ communication = DataBusModel.GetInstance().KeyValues[Instance.VariablePath];
+ }
+ CommunicationModel mode = communication?.CommunicationDevices?.ToList().Find(par => par.DeviceName == toggle.Tag.ToString());
+ if (mode != null)
+ {
+ mode?.VarTableModels?.ToList().ForEach(par => { Instance.DevValueList.Add(par.VarName); });
+ }
+ }
+ valuebox.ItemsSource = Instance.DevValueList;
+
+ }
+ catch (Exception ex)
+ {
+
+ }
+
+ }
+ ///
+ /// 设备名称选择
+ ///
+ ///
+ ///
+ private void ComboBoxName_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ try
+ {
+ if (sender is System.Windows.Controls.ComboBox)
+ {
+ System.Windows.Controls.ComboBox toggle = (System.Windows.Controls.ComboBox)sender;
+ if (toggle.Tag != null && !string.IsNullOrEmpty(toggle.Text))
+ {
+ Instance.BindingName.Text = string.Format("DataModel[{0}].{1}", toggle.Text, toggle.Tag);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+ ///
+ /// 设备名称下拉框打开事件
+ ///
+ ///
+ ///
+ private void namebox_DropDownOpened(object sender, EventArgs e)
+ {
+
+ Instance.DevNameList = new System.Collections.ObjectModel.ObservableCollection();
+ CommunicationPar communication = null;
+ if (DataBusModel.GetInstance().KeyValues.ContainsKey(Instance.VariablePath))
+ {
+ communication = DataBusModel.GetInstance().KeyValues[Instance.VariablePath];
+ }
+ communication?.CommunicationDevices?.ToList().ForEach(x => { Instance.DevNameList.Add(x.DeviceName); });
+ namebox.ItemsSource = Instance.DevNameList;
+ }
}
}
diff --git a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
index 4d136b91..f26905a8 100644
--- a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
+++ b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
@@ -268,7 +268,7 @@ namespace BeDesignerSCADA.ViewModel
DependencyProperty dependencyProperty = PropertyHelper.GetDependencyProperties(selectControl)?.ToList().Find(x => x.Name == selectProName);
if (dependencyProperty != null)
{
- string _binding = PropertyBindingWindow.ShowEdit(dependencyProperty, (selectControl as FrameworkElement));
+ string _binding = PropertyBindingWindow.ShowEdit(dependencyProperty, (selectControl as FrameworkElement), VariablePath);
if (!string.IsNullOrEmpty(_binding))
{
Binding bindingText = new Binding() { Mode = BindingMode.TwoWay, Path = new PropertyPath(_binding) };