@@ -6,6 +6,12 @@ | |||
<Nullable>enable</Nullable> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.0" /> | |||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.3.0" /> | |||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\BPASmartClient.MessageName\BPASmartClient.MessageName.csproj" /> | |||
</ItemGroup> | |||
@@ -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 | |||
{ | |||
/// <summary> | |||
/// C#编译器 | |||
/// </summary> | |||
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<string,string>(); | |||
//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; | |||
} | |||
} | |||
} |
@@ -22,9 +22,9 @@ namespace BPASmartClient.Compiler | |||
/// 控件类型 | |||
/// </summary> | |||
string ControlType { get; } | |||
///// <summary> | |||
///// 消息名称 | |||
///// </summary> | |||
//ObservableCollection<EventReceiveMessage> EventNameList { get; } | |||
/// <summary> | |||
/// 属性改变 | |||
/// </summary> | |||
event EventHandler PropertyChange; //声明一个事件 | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmartClient.MessageName.EnumHelp | |||
{ | |||
/// <summary> | |||
/// 数据来源类型 | |||
/// </summary> | |||
public enum DataTypeEnum | |||
{ | |||
/// <summary> | |||
/// POST接口,GET接口 | |||
/// </summary> | |||
API接口, | |||
/// <summary> | |||
/// 接收主题MQTT数据 | |||
/// </summary> | |||
MQTT, | |||
/// <summary> | |||
/// 本地数据推送 | |||
/// </summary> | |||
本地源, | |||
/// <summary> | |||
/// 特定服务推送数据 | |||
/// </summary> | |||
服务推送, | |||
/// <summary> | |||
/// 静态数据 | |||
/// </summary> | |||
静态数据 | |||
} | |||
} |
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public class ArcGauge : Control, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public ArcGauge() | |||
{ | |||
Width = 300; | |||
@@ -14,6 +14,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public class DigitalNumber :Control, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public DigitalNumber() | |||
{ | |||
Width = 80; | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class GraphArrow : UserControl, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public GraphArrow() | |||
{ | |||
InitializeComponent(); | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class GraphStar : UserControl, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public GraphStar() | |||
{ | |||
InitializeComponent(); | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public class KnobButton : Slider, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
static KnobButton() | |||
{ | |||
DefaultStyleKeyProperty.OverrideMetadata(typeof(KnobButton), new FrameworkPropertyMetadata(typeof(KnobButton))); | |||
@@ -41,6 +41,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
Storyboard storyboard1 = new Storyboard(); | |||
#endregion | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public NewConveyorBelt() | |||
{ | |||
@@ -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))); | |||
@@ -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<EventSendMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),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 发送事件名称集合 | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public class StatusLight : Control, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public StatusLight() | |||
{ | |||
Width = 80; | |||
@@ -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); | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheButton : Button, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheButton() | |||
{ | |||
InitializeComponent(); | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheCheckBox : CheckBox, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheCheckBox() | |||
{ | |||
InitializeComponent(); | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheComboBox : ComboBox, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheComboBox() | |||
{ | |||
InitializeComponent(); | |||
@@ -25,12 +25,15 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
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"}, | |||
@@ -22,6 +22,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheGroupBox : GroupBox, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheGroupBox() | |||
{ | |||
InitializeComponent(); | |||
@@ -22,6 +22,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheImage : Image, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheImage() | |||
{ | |||
InitializeComponent(); | |||
@@ -0,0 +1,11 @@ | |||
<ListBox x:Class="BPASmartClient.SCADAControl.CustomerControls.TheListBox" | |||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||
xmlns:local="clr-namespace:BPASmartClient.SCADAControl.CustomerControls" | |||
mc:Ignorable="d" | |||
BorderBrush="Transparent" | |||
Background="Transparent" | |||
d:DesignHeight="450" d:DesignWidth="800"> | |||
</ListBox> |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// TheListBox.xaml 的交互逻辑 | |||
/// </summary> | |||
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(); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 注册需要处理的事件 | |||
/// </summary> | |||
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) | |||
{ | |||
} | |||
} | |||
} |
@@ -19,6 +19,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
public class TheRadioButton : RadioButton, IExecutable, IDisposable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheRadioButton() | |||
{ | |||
SetCurrentValue(ContentProperty, "单选按钮"); | |||
@@ -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))); | |||
@@ -22,6 +22,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheTextBlock : TextBlock, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheTextBlock() | |||
{ | |||
InitializeComponent(); | |||
@@ -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))); | |||
@@ -21,6 +21,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
public class TheTimer : Control, IExecutable, IDisposable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
public TheTimer() | |||
{ | |||
Width = 40; | |||
@@ -23,6 +23,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public partial class TheToggleButton : ToggleButton, IExecutable | |||
{ | |||
public event EventHandler PropertyChange; //声明一个事件 | |||
/// <summary> | |||
/// 开关按钮 | |||
/// </summary> | |||
@@ -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"; | |||
@@ -635,4 +635,19 @@ | |||
</Style.Triggers> | |||
</Style> | |||
<SolidColorBrush x:Key="ListBorder" Color="#828790" /> | |||
<Style x:Key="DesignTheListBox" TargetType="{x:Type ListBox}"> | |||
<Setter Property="Background" Value="Transparent" /> | |||
<Setter Property="BorderBrush" Value="{StaticResource ListBorder}" /> | |||
<Setter Property="BorderThickness" Value="0" /> | |||
<Setter Property="Padding" Value="10" /> | |||
<Setter Property="Foreground" Value="White" /> | |||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> | |||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> | |||
<Setter Property="ScrollViewer.PanningMode" Value="Both" /> | |||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" /> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
</Style> | |||
</ResourceDictionary> |
@@ -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 | |||
/// <summary> | |||
/// Interaction logic for MainWindow.xaml | |||
/// </summary> | |||
public partial class MainWindow : Window | |||
public partial class MainWindow :Window | |||
{ | |||
/// <summary> | |||
/// 控件集合 | |||
@@ -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<RunEnum>(xx.Text); | |||
runEnumModel.MessageID = hm.Text; | |||
Class_InnerMessageBus.GetInstance().PostMessage(this, mlname.Text, runEnumModel); | |||
Class_InnerMessageBus.GetInstance().PostMessage(this,mlname.Text,runEnumModel); | |||
} | |||
/// <summary> | |||
@@ -135,10 +142,10 @@ namespace SCADA.Test | |||
/// </summary> | |||
public T ToEnumValue<T>(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); | |||
} | |||