From a2d34d8e14993c268b2b5ff66a153bb9099bdfe6 Mon Sep 17 00:00:00 2001
From: fyf <11621@LAPTOP-04QQU0AO>
Date: Fri, 9 Sep 2022 11:29:45 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E7=BB=91=E5=AE=9A=E6=A8=A1=E5=9D=97=EF=BC=8C=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E7=BB=91=E5=AE=9A=E7=A4=BA=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BPASmartClient.Compiler.csproj | 6 +
BPASmartClient.Compiler/CSharpConfig.cs | 137 ++++++++++++++++++
BPASmartClient.Compiler/IExecutable.cs | 8 +-
.../EnumHelp/DataTypeEnum.cs | 35 +++++
.../CustomerControls/ArcGauge.cs | 2 +
.../CustomerControls/DigitalNumber.cs | 2 +
.../CustomerControls/GraphArrow.xaml.cs | 2 +
.../CustomerControls/GraphStar.xaml.cs | 2 +
.../CustomerControls/KnobButton.cs | 2 +
.../CustomerControls/NewConveyorBelt.xaml.cs | 1 +
.../CustomerControls/NumberBox.cs | 2 +
.../CustomerControls/Silos.xaml.cs | 76 ++++++++++
.../CustomerControls/StatusLight.cs | 2 +
.../CustomerControls/SwitchButton.cs | 2 +
.../CustomerControls/TheButton.xaml.cs | 2 +
.../CustomerControls/TheCheckBox.xaml.cs | 2 +
.../CustomerControls/TheComboBox.xaml.cs | 2 +
.../CustomerControls/TheDataGrid.xaml.cs | 7 +-
.../CustomerControls/TheGroupBox.xaml.cs | 2 +
.../CustomerControls/TheImage.xaml.cs | 2 +
.../CustomerControls/TheListBox.xaml | 11 ++
.../CustomerControls/TheListBox.xaml.cs | 97 +++++++++++++
.../CustomerControls/TheRadioButton.cs | 2 +
.../CustomerControls/TheSlider.cs | 2 +
.../CustomerControls/TheTextBlock.xaml.cs | 2 +
.../CustomerControls/TheTextBox.cs | 2 +
.../CustomerControls/TheTimer.cs | 2 +
.../CustomerControls/TheToggleButton.xaml.cs | 2 +
.../CustomerControls/WaveProgressBar.cs | 2 +
.../Themes/Generic.xaml | 15 ++
SCADA.Test/MainWindow.xaml.cs | 33 +++--
31 files changed, 447 insertions(+), 19 deletions(-)
create mode 100644 BPASmartClient.Compiler/CSharpConfig.cs
create mode 100644 BPASmartClient.MessageName/EnumHelp/DataTypeEnum.cs
create mode 100644 BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml
create mode 100644 BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs
diff --git a/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj b/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj
index 60f4f992..1acfacc7 100644
--- a/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj
+++ b/BPASmartClient.Compiler/BPASmartClient.Compiler.csproj
@@ -6,6 +6,12 @@
enable
+
+
+
+
+
+
diff --git a/BPASmartClient.Compiler/CSharpConfig.cs b/BPASmartClient.Compiler/CSharpConfig.cs
new file mode 100644
index 00000000..16cca283
--- /dev/null
+++ b/BPASmartClient.Compiler/CSharpConfig.cs
@@ -0,0 +1,137 @@
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.Emit;
+using Microsoft.CSharp;
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.Compiler
+{
+ ///
+ /// C#编译器
+ ///
+ public class CSharpConfig
+ {
+ #region 单例模式
+ public static CSharpConfig Instance = null;
+
+ public static CSharpConfig GetInstance()
+ {
+ if (Instance == null)
+ {
+ Instance = new CSharpConfig();
+ }
+ return Instance;
+ }
+ #endregion
+
+ public CSharpConfig()
+ {
+
+
+ }
+
+ public object RunCSharp(string code,object[] objValue,string error = "")
+ {
+ object strretu = string.Empty;
+ try
+ {
+ string funName = "main";
+ StringBuilder builder = new StringBuilder();
+ builder.Append("namespace YF \n{\n class CSharpConfigRun\n");
+ builder.Append(" {\n");
+ builder.Append(code);
+ builder.Append(" }\n}\n");
+
+
+
+ SyntaxTree tree = CSharpSyntaxTree.ParseText(builder.ToString());
+ var compilation =
+ CSharpCompilation.Create("YF")
+ .AddReferences(
+ MetadataReference.CreateFromFile(
+ typeof(object).Assembly.Location)
+ )
+ .AddSyntaxTrees(tree)
+ .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
+
+ EmitResult emitResult;
+ byte[] dllBytes;
+ using (var stream = new MemoryStream())
+ {
+ emitResult = compilation.Emit(stream);
+ dllBytes = stream.ToArray();
+ }
+ if (emitResult.Success)
+ {
+
+ // Assembly assembly = Assembly.LoadFrom("d:\\test.dll");
+ Assembly assembly = Assembly.Load(dllBytes);
+ var obj = assembly.CreateInstance("YF.CSharpConfigRun");
+ var method = obj.GetType().GetMethod("main",new Type[] { typeof(string) });
+ strretu = method.Invoke(obj,objValue);
+
+ }
+
+
+ //var providerOptions = new Dictionary();
+ //providerOptions.Add("CompilerVersion","v4.0");
+ //CSharpCodeProvider compiler = new CSharpCodeProvider(providerOptions);
+ //string output = Path.GetTempFileName();
+ //var cp = new CompilerParameters() { GenerateInMemory = true,OutputAssembly = output };
+ //cp.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
+ //cp.ReferencedAssemblies.Add("Microsoft.CSharp.dll");
+ //cp.ReferencedAssemblies.Add("System.Core.dll");
+ //cp.ReferencedAssemblies.Add("Newtonsoft.Json.dll"); //添加引用
+ //cp.ReferencedAssemblies.Add("System.dll");
+ //cp.GenerateExecutable = false;
+ //cp.EmbeddedResources.Clear();
+ //cp.LinkedResources.Clear();
+ //cp.Win32Resource = null;
+ //cp.TreatWarningsAsErrors = false;
+ //cp.WarningLevel = 4;
+ //cp.TempFiles.KeepFiles = false;
+ //CompilerResults cr = compiler.CompileAssemblyFromSource(cp,builder.ToString());
+
+
+
+
+ // 1.ICodeComplier
+ // CSharpCodeProvider complier = new CSharpCodeProvider();
+ // // 2.CompilerParameters
+ // CompilerParameters cp = new CompilerParameters();
+ // cp.ReferencedAssemblies.Add("System.dll"); //添加引用
+ //// cp.ReferencedAssemblies.Add("Newtonsoft.Json.dll"); //添加引用
+ // cp.GenerateExecutable = false;
+ // cp.GenerateInMemory = true;
+ // // 3.CompilerResults
+ // CompilerResults cr = complier.CompileAssemblyFromSource(cp,builder.ToString());
+ //if (cr.Errors.HasErrors)
+ //{
+ // foreach (CompilerError err in cr.Errors)
+ // {
+ // error += err.ErrorText + "\r\n";
+ // }
+ //}
+ //else
+ //{
+ // // 通过反射,调用HelloWorld的实例
+ // Assembly objAssembly = cr.CompiledAssembly;
+ // object objClass = objAssembly.CreateInstance("CSharpConfigRun");
+ // MethodInfo objFun = objClass.GetType().GetMethod(funName);
+ // strretu = objFun.Invoke(objClass,objValue);
+ //}
+ }
+ catch (Exception ex)
+ {
+ error += ex.Message;
+ }
+ return strretu;
+ }
+ }
+}
diff --git a/BPASmartClient.Compiler/IExecutable.cs b/BPASmartClient.Compiler/IExecutable.cs
index 063f0540..bc656d23 100644
--- a/BPASmartClient.Compiler/IExecutable.cs
+++ b/BPASmartClient.Compiler/IExecutable.cs
@@ -22,9 +22,9 @@ namespace BPASmartClient.Compiler
/// 控件类型
///
string ControlType { get; }
- /////
- ///// 消息名称
- /////
- //ObservableCollection EventNameList { get; }
+ ///
+ /// 属性改变
+ ///
+ event EventHandler PropertyChange; //声明一个事件
}
}
diff --git a/BPASmartClient.MessageName/EnumHelp/DataTypeEnum.cs b/BPASmartClient.MessageName/EnumHelp/DataTypeEnum.cs
new file mode 100644
index 00000000..e8f1a187
--- /dev/null
+++ b/BPASmartClient.MessageName/EnumHelp/DataTypeEnum.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPASmartClient.MessageName.EnumHelp
+{
+ ///
+ /// 数据来源类型
+ ///
+ public enum DataTypeEnum
+ {
+ ///
+ /// POST接口,GET接口
+ ///
+ API接口,
+ ///
+ /// 接收主题MQTT数据
+ ///
+ MQTT,
+ ///
+ /// 本地数据推送
+ ///
+ 本地源,
+ ///
+ /// 特定服务推送数据
+ ///
+ 服务推送,
+ ///
+ /// 静态数据
+ ///
+ 静态数据
+ }
+}
diff --git a/BPASmartClient.SCADAControl/CustomerControls/ArcGauge.cs b/BPASmartClient.SCADAControl/CustomerControls/ArcGauge.cs
index 145842bf..d2aef4a3 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/ArcGauge.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/ArcGauge.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public class ArcGauge : Control, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public ArcGauge()
{
Width = 300;
diff --git a/BPASmartClient.SCADAControl/CustomerControls/DigitalNumber.cs b/BPASmartClient.SCADAControl/CustomerControls/DigitalNumber.cs
index 376333cf..aee3277f 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/DigitalNumber.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/DigitalNumber.cs
@@ -14,6 +14,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public class DigitalNumber :Control, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public DigitalNumber()
{
Width = 80;
diff --git a/BPASmartClient.SCADAControl/CustomerControls/GraphArrow.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/GraphArrow.xaml.cs
index 77e7d0d4..7de4de7a 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/GraphArrow.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/GraphArrow.xaml.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class GraphArrow : UserControl, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public GraphArrow()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/GraphStar.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/GraphStar.xaml.cs
index b354c5c4..67c377e1 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/GraphStar.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/GraphStar.xaml.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class GraphStar : UserControl, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public GraphStar()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/KnobButton.cs b/BPASmartClient.SCADAControl/CustomerControls/KnobButton.cs
index 26de890f..be3a6b72 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/KnobButton.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/KnobButton.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public class KnobButton : Slider, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
static KnobButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(KnobButton), new FrameworkPropertyMetadata(typeof(KnobButton)));
diff --git a/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs
index f21eb9f3..3901eca6 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/NewConveyorBelt.xaml.cs
@@ -41,6 +41,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
Storyboard storyboard1 = new Storyboard();
#endregion
+ public event EventHandler PropertyChange; //声明一个事件
public NewConveyorBelt()
{
diff --git a/BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs b/BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs
index bbde7726..75d78c2f 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/NumberBox.cs
@@ -19,6 +19,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
public class NumberBox : TextBox, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
static NumberBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(NumberBox), new FrameworkPropertyMetadata(typeof(NumberBox)));
diff --git a/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
index eb04a495..f1561c32 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/Silos.xaml.cs
@@ -80,6 +80,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls
}
}
}
+
private void EventNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (EventReceiveNameList.Count > 0)
@@ -310,6 +311,81 @@ namespace BPASmartClient.SCADAControl.CustomerControls
private static readonly DependencyProperty EventSendNameListProperty =
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection),typeof(Silos),new PropertyMetadata(new ObservableCollection(),new PropertyChangedCallback(onEventNameListChanged)));
private static void onEventNameListChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataNameRefresh();
+
+
+ #endregion
+
+ #region 数据绑定模块
+ public event EventHandler PropertyChange; //声明一个事件
+ [Category("数据绑定-数据来源")]
+ public DataTypeEnum DataSouceType
+ {
+ get { return (DataTypeEnum)GetValue(DataSouceTypeProperty); }
+ set { SetValue(DataSouceTypeProperty,value); }
+ }
+ public static readonly DependencyProperty DataSouceTypeProperty =
+ DependencyProperty.Register("DataSouceType",typeof(DataTypeEnum),typeof(Silos),new PropertyMetadata(DataTypeEnum.静态数据));
+ [Category("数据绑定-数据来源")]
+ public int TimeCount
+ {
+ get { return (int)GetValue(TimeCountProperty); }
+ set { SetValue(TimeCountProperty,value); }
+ }
+ public static readonly DependencyProperty TimeCountProperty =
+ DependencyProperty.Register("TimeCount",typeof(int),typeof(Silos),new PropertyMetadata(5));
+ [Category("数据绑定-数据来源")]
+ public string DataSouceInformation
+ {
+ get { return (string)GetValue(DataSouceInformationProperty); }
+ set { SetValue(DataSouceInformationProperty,value); }
+ }
+ public static readonly DependencyProperty DataSouceInformationProperty =
+ DependencyProperty.Register("DataSouceInformation",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
+
+ [Category("数据绑定")]
+ public string FDataSouce
+ {
+ get { return (string)GetValue(FDataSouceProperty); }
+ set { SetValue(FDataSouceProperty,value); }
+ }
+ public static readonly DependencyProperty FDataSouceProperty =
+ DependencyProperty.Register("FDataSouce",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty,new PropertyChangedCallback(onFDataSouceChanged)));
+ private static void onFDataSouceChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.DataSouceRefresh();
+ public void DataSouceRefresh()
+ {
+ try
+ {
+ if (!string.IsNullOrEmpty(FDataSouce))
+ {
+ GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(Code,new object[] { FDataSouce });
+ if (PropertyChange != null)
+ {
+ PropertyChange(this,null);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ }
+ public static string _code = " public string main(string message) \n { \n //请在此填写你的代码\n\n return message; \n }\n";
+ [Category("数据绑定")]
+ public string Code
+ {
+ get { return (string)GetValue(CodeProperty); }
+ set { SetValue(CodeProperty,value); }
+ }
+ public static readonly DependencyProperty CodeProperty =
+ DependencyProperty.Register("Code",typeof(string),typeof(Silos),new PropertyMetadata(_code));
+ [Category("数据绑定")]
+ public string GenerateData
+ {
+ get { return (string)GetValue(GenerateDataProperty); }
+ set { SetValue(GenerateDataProperty,value); }
+ }
+ public static readonly DependencyProperty GenerateDataProperty =
+ DependencyProperty.Register("GenerateData",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty));
#endregion
#region 发送事件名称集合
diff --git a/BPASmartClient.SCADAControl/CustomerControls/StatusLight.cs b/BPASmartClient.SCADAControl/CustomerControls/StatusLight.cs
index a23c6541..05637421 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/StatusLight.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/StatusLight.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public class StatusLight : Control, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public StatusLight()
{
Width = 80;
diff --git a/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs b/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
index 679f53f6..6586c29d 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/SwitchButton.cs
@@ -26,6 +26,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
[TemplatePart(Name = TranslateX, Type = typeof(TranslateTransform))]
public class SwitchButton : ToggleButton, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public SwitchButton()
{
SetCurrentValue(WidthProperty, 120d);
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs
index f6d55d88..a7d24e1d 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheButton.xaml.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheButton : Button, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheButton()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml.cs
index 069aa682..80dd5cc6 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheCheckBox.xaml.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheCheckBox : CheckBox, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheCheckBox()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs
index a0743dab..47a1c06b 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheComboBox.xaml.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheComboBox : ComboBox, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheComboBox()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
index 9efb1557..6709e0dd 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheDataGrid.xaml.cs
@@ -25,12 +25,15 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheDataGrid :DataGrid, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheDataGrid()
{
InitializeComponent();
Style = Application.Current.Resources["DesignTheDataGrid"] as Style;
-
- ItemsString=new ItemsListObj()
+ MinWidth = 100;
+ MinHeight = 100;
+ ItemsString =new ItemsListObj()
{
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs
index d87f052c..2d767d1d 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheGroupBox.xaml.cs
@@ -22,6 +22,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheGroupBox : GroupBox, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheGroupBox()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs
index 991ac2f2..4a09eb29 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheImage.xaml.cs
@@ -22,6 +22,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheImage : Image, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheImage()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml b/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml
new file mode 100644
index 00000000..080529a3
--- /dev/null
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml
@@ -0,0 +1,11 @@
+
+
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs
new file mode 100644
index 00000000..53e6e2c6
--- /dev/null
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheListBox.xaml.cs
@@ -0,0 +1,97 @@
+using BPASmartClient.Compiler;
+using BPASmartClient.MessageName.接收消息Model.物料仓;
+using BPASmartClient.SCADAControl.Converters;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace BPASmartClient.SCADAControl.CustomerControls
+{
+ ///
+ /// TheListBox.xaml 的交互逻辑
+ ///
+ public partial class TheListBox :ListBox, IExecutable
+ {
+ public event EventHandler PropertyChange; //声明一个事件
+
+ public TheListBox()
+ {
+ InitializeComponent();
+ Style = Application.Current.Resources["DesignTheListBox"] as Style;
+ MinWidth = 100;
+ MinHeight = 100;
+ ItemsString = new ItemsListObj()
+ {
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ new datalist { Name="23232",Description="wwewewew",Messgae="564654645"},
+ };
+ }
+
+ public ItemsListObj ItemsString
+ {
+ get { return (ItemsListObj)GetValue(ItemsStringProperty); }
+ set { SetValue(ItemsStringProperty,value); }
+ }
+
+ public static readonly DependencyProperty ItemsStringProperty =
+ DependencyProperty.Register("ItemsString",typeof(ItemsListObj),typeof(TheListBox),new PropertyMetadata(null));
+
+
+
+
+ public string ControlType => "控件";
+
+ private bool isExecuteState;
+ public bool IsExecuteState
+ {
+ get { return isExecuteState; }
+ set
+ {
+ isExecuteState = value;
+ if (IsExecuteState)
+ {
+ Style = null;
+ Register();
+ }
+ }
+ }
+
+ ///
+ /// 注册需要处理的事件
+ ///
+ public void Register()
+ {
+ // 运行时进行项目绑定
+ Binding binding = new Binding();
+ binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
+ binding.Path = new PropertyPath("ItemsString");
+
+ SetBinding(ItemsSourceProperty,binding);
+ }
+
+ private void MyButton_Click(object sender,RoutedEventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs b/BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs
index c01781d5..51397261 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheRadioButton.cs
@@ -19,6 +19,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheRadioButton : RadioButton, IExecutable, IDisposable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheRadioButton()
{
SetCurrentValue(ContentProperty, "单选按钮");
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheSlider.cs b/BPASmartClient.SCADAControl/CustomerControls/TheSlider.cs
index 4e21de42..37f8dfa0 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheSlider.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheSlider.cs
@@ -19,6 +19,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheSlider : Slider, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
static TheSlider()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheSlider), new FrameworkPropertyMetadata(typeof(TheSlider)));
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml.cs
index eaadbc76..d25881e1 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.xaml.cs
@@ -22,6 +22,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheTextBlock : TextBlock, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheTextBlock()
{
InitializeComponent();
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
index f82a65f9..33230d51 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBox.cs
@@ -19,6 +19,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheTextBox : TextBox, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
static TheTextBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TheTextBox), new FrameworkPropertyMetadata(typeof(TheTextBox)));
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTimer.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTimer.cs
index 1b05bee7..491e14fc 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheTimer.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheTimer.cs
@@ -21,6 +21,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
{
public class TheTimer : Control, IExecutable, IDisposable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
public TheTimer()
{
Width = 40;
diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs b/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs
index 89443463..cad19f56 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheToggleButton.xaml.cs
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
public partial class TheToggleButton : ToggleButton, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
///
/// 开关按钮
///
diff --git a/BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs b/BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs
index b9448150..21f78609 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/WaveProgressBar.cs
@@ -14,6 +14,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls
[TemplatePart(Name = ElementClip, Type = typeof(FrameworkElement))]
public class WaveProgressBar : RangeBase, IExecutable
{
+ public event EventHandler PropertyChange; //声明一个事件
+
private const string ElementWave = "PART_Wave";
private const string ElementClip = "PART_Clip";
diff --git a/BPASmartClient.SCADAControl/Themes/Generic.xaml b/BPASmartClient.SCADAControl/Themes/Generic.xaml
index ee1a803f..9104bb27 100644
--- a/BPASmartClient.SCADAControl/Themes/Generic.xaml
+++ b/BPASmartClient.SCADAControl/Themes/Generic.xaml
@@ -635,4 +635,19 @@
+
+
+
diff --git a/SCADA.Test/MainWindow.xaml.cs b/SCADA.Test/MainWindow.xaml.cs
index e7579cdd..c560398d 100644
--- a/SCADA.Test/MainWindow.xaml.cs
+++ b/SCADA.Test/MainWindow.xaml.cs
@@ -1,4 +1,5 @@
-using BPASmartClient.MessageCommunication;
+using BPASmartClient.Compiler;
+using BPASmartClient.MessageCommunication;
using BPASmartClient.MessageCommunication.MsgControl;
using BPASmartClient.MessageName;
using BPASmartClient.MessageName.EnumHelp;
@@ -29,7 +30,7 @@ namespace SCADA.Test
///
/// Interaction logic for MainWindow.xaml
///
- public partial class MainWindow : Window
+ public partial class MainWindow :Window
{
///
/// 控件集合
@@ -43,6 +44,12 @@ namespace SCADA.Test
public MainWindow()
{
InitializeComponent();
+
+
+
+ string _code = " public string main(string message) \n { \n //请在此填写你的代码\n\n return message; \n }\n";
+ string GenerateData = (string)CSharpConfig.GetInstance().RunCSharp(_code,new object[] { "ERERERERE" });
+
xxnc.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList();
mlname.ItemsSource = System.Enum.GetNames(typeof(MessageNameEnum))?.ToList();
xx.ItemsSource = System.Enum.GetNames(typeof(RunEnum))?.ToList();
@@ -79,8 +86,8 @@ namespace SCADA.Test
{
//加载控件
Children.Clear();
- FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
- using (StreamReader sr = new StreamReader(fs, System.Text.Encoding.Unicode))
+ FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Read,FileShare.ReadWrite);
+ using (StreamReader sr = new StreamReader(fs,System.Text.Encoding.Unicode))
{
while (sr.Peek() > -1)
{
@@ -97,22 +104,22 @@ namespace SCADA.Test
{
eventReceiveMessages = runCanvas.Run(Children);
}
-
+
}
#endregion
- private void Button_Click(object sender, RoutedEventArgs e)
+ private void Button_Click(object sender,RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "布局文件|*.lay";
- if (ofd.ShowDialog() ==true)
+ if (ofd.ShowDialog() == true)
{
LoadingData(ofd.FileName);
}
}
- private void Button_Click_1(object sender, RoutedEventArgs e)
+ private void Button_Click_1(object sender,RoutedEventArgs e)
{
if (string.IsNullOrEmpty(mlname.Text))
{
@@ -127,7 +134,7 @@ namespace SCADA.Test
RunEnumModel runEnumModel = new RunEnumModel();
runEnumModel.Run = ToEnumValue(xx.Text);
runEnumModel.MessageID = hm.Text;
- Class_InnerMessageBus.GetInstance().PostMessage(this, mlname.Text, runEnumModel);
+ Class_InnerMessageBus.GetInstance().PostMessage(this,mlname.Text,runEnumModel);
}
///
@@ -135,10 +142,10 @@ namespace SCADA.Test
///
public T ToEnumValue(string name)
{
- return (T)Enum.Parse(typeof(T), name);
+ return (T)Enum.Parse(typeof(T),name);
}
- private void Button_Click_2(object sender, RoutedEventArgs e)
+ private void Button_Click_2(object sender,RoutedEventArgs e)
{
if (string.IsNullOrEmpty(xxnc.Text))
{
@@ -164,8 +171,8 @@ namespace SCADA.Test
silosMessage.MessageID = ch.Text;
silosMessage.Value = zl.Text;
silosMessage.Title = bt.Text;
- silosMessage.Text= cgs.Text;
- Class_InnerMessageBus.GetInstance().PostMessage(this, xxnc.Text, silosMessage);
+ silosMessage.Text = cgs.Text;
+ Class_InnerMessageBus.GetInstance().PostMessage(this,xxnc.Text,silosMessage);
}