@@ -61,22 +61,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
private void NewConveyorBelt_Loaded(object sender, RoutedEventArgs e) | |||
{ | |||
EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged; | |||
EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged; | |||
} | |||
private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | |||
{ | |||
if (EventSendNameList.Count > 0) | |||
{ | |||
try | |||
{ | |||
EventSendNameListStr = JsonConvert.SerializeObject(EventSendNameList); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
} | |||
private void EventNameList_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | |||
{ | |||
@@ -351,23 +335,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
public static readonly DependencyProperty EventReceiveNameListProperty = | |||
DependencyProperty.Register("EventReceiveNameList", typeof(ObservableCollection<EventReceiveMessage>), typeof(NewConveyorBelt), new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(), onEventNameListChanged)); | |||
private static void onEventNameListChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => (d as NewConveyorBelt)?.RunNameRefresh(); | |||
[Category("名称[自动生成]")] | |||
private string EventSendNameListStr | |||
{ | |||
get { return (string)GetValue(EventSendNameListStrProperty); } | |||
set { SetValue(EventSendNameListStrProperty,value); } | |||
} | |||
private static readonly DependencyProperty EventSendNameListStrProperty = | |||
DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(NewConveyorBelt),new PropertyMetadata(string.Empty)); | |||
[Category("消息发送名称集合")] | |||
private ObservableCollection<EventSendMessage> EventSendNameList | |||
{ | |||
get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } | |||
set { SetValue(EventSendNameListProperty,value); } | |||
} | |||
private static readonly DependencyProperty EventSendNameListProperty = | |||
DependencyProperty.Register("EventSendNameList",typeof(ObservableCollection<EventSendMessage>),typeof(NewConveyorBelt),new PropertyMetadata(new ObservableCollection<EventSendMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | |||
#endregion | |||
#region 属性变更事件 | |||
@@ -385,17 +352,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
} | |||
} | |||
if (!string.IsNullOrEmpty(EventSendNameListStr)) | |||
{ | |||
try | |||
{ | |||
EventSendNameList = JsonConvert.DeserializeObject<ObservableCollection<EventSendMessage>>(EventSendNameListStr); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
List<string> MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList(); | |||
if (MessageNameL == null || !MessageNameNew.SequenceEqual(MessageNameL)) | |||
{ | |||
@@ -479,17 +436,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
/// </summary> | |||
public void ReceiveNameRefresh() | |||
{ | |||
if (!string.IsNullOrEmpty(EventReceiveNameListStr)) | |||
{ | |||
try | |||
{ | |||
EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
} | |||
#endregion | |||
} | |||
@@ -66,22 +66,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
private void Silos_Loaded(object sender,RoutedEventArgs e) | |||
{ | |||
EventReceiveNameList.CollectionChanged += EventNameList_CollectionChanged; | |||
EventSendNameList.CollectionChanged += EventSendNameList_CollectionChanged; | |||
} | |||
private void EventSendNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | |||
{ | |||
if (EventSendNameList.Count > 0) | |||
{ | |||
try | |||
{ | |||
EventSendNameListStr = JsonConvert.SerializeObject(EventSendNameList); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
} | |||
private void EventNameList_CollectionChanged(object? sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e) | |||
@@ -238,32 +222,32 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
#region 属性 | |||
[Category("值设定")] | |||
public string Value | |||
public string KgValue | |||
{ | |||
get { return (string)GetValue(ValueProperty); } | |||
set { SetValue(ValueProperty,value); } | |||
} | |||
public static readonly DependencyProperty ValueProperty = | |||
DependencyProperty.Register("Value",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | |||
DependencyProperty.Register("KgValue", typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | |||
private static void onTargetChanged(DependencyObject d,DependencyPropertyChangedEventArgs e) => (d as Silos)?.TargetRefresh(); | |||
[Category("值设定")] | |||
public string Text | |||
public string WLText | |||
{ | |||
get { return (string)GetValue(TextProperty); } | |||
set { SetValue(TextProperty,value); } | |||
} | |||
public static readonly DependencyProperty TextProperty = | |||
DependencyProperty.Register("Text",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | |||
DependencyProperty.Register("WLText", typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | |||
[Category("值设定")] | |||
public string Title | |||
public string WLTitle | |||
{ | |||
get { return (string)GetValue(TitleProperty); } | |||
set { SetValue(TitleProperty,value); } | |||
} | |||
public static readonly DependencyProperty TitleProperty = | |||
DependencyProperty.Register("Title",typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | |||
DependencyProperty.Register("WLTitle", typeof(string),typeof(Silos),new PropertyMetadata(new PropertyChangedCallback(onTargetChanged))); | |||
[Category("值设定")] | |||
public int Direction | |||
@@ -296,24 +280,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
set { SetValue(EventReceiveNameListProperty,value); } | |||
} | |||
public static readonly DependencyProperty EventReceiveNameListProperty = | |||
DependencyProperty.Register("EventReceiveNameList",typeof(ObservableCollection<EventReceiveMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventReceiveMessage>(),new PropertyChangedCallback(onEventNameListChanged))); | |||
[Category("名称[自动生成]")] | |||
private string EventSendNameListStr | |||
{ | |||
get { return (string)GetValue(EventSendNameListStrProperty); } | |||
set { SetValue(EventSendNameListStrProperty,value); } | |||
} | |||
private static readonly DependencyProperty EventSendNameListStrProperty = | |||
DependencyProperty.Register("EventSendNameListStr",typeof(string),typeof(Silos),new PropertyMetadata(string.Empty)); | |||
[Category("消息发送名称集合")] | |||
private ObservableCollection<EventSendMessage> EventSendNameList | |||
{ | |||
get { return (ObservableCollection<EventSendMessage>)GetValue(EventSendNameListProperty); } | |||
set { SetValue(EventSendNameListProperty,value); } | |||
} | |||
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(); | |||
DependencyProperty.Register("EventReceiveNameList",typeof(ObservableCollection<EventReceiveMessage>),typeof(Silos),new PropertyMetadata(new ObservableCollection<EventReceiveMessage>())); | |||
#endregion | |||
#region 数据绑定模块 | |||
@@ -432,9 +399,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
if (textBlockValue != null && textBlockText != null && textBlockTitle != null) | |||
{ | |||
textBlockValue.Text = Value; | |||
textBlockText.Text = Text; | |||
textBlockTitle.Text = Title; | |||
textBlockValue.Text = KgValue; | |||
textBlockText.Text = WLText; | |||
textBlockTitle.Text = WLTitle; | |||
} | |||
} | |||
@@ -475,30 +442,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
} | |||
/// <summary> | |||
/// 数据名称变化事件 | |||
/// </summary> | |||
public void DataNameRefresh() | |||
{ | |||
} | |||
/// <summary> | |||
/// 接收数据改变 | |||
/// </summary> | |||
public void ReceiveNameRefresh() | |||
{ | |||
if (!string.IsNullOrEmpty(EventReceiveNameListStr)) | |||
{ | |||
try | |||
{ | |||
EventReceiveNameList = JsonConvert.DeserializeObject<ObservableCollection<EventReceiveMessage>>(EventReceiveNameListStr); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
} | |||
#endregion | |||
@@ -520,18 +469,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
} | |||
} | |||
if (!string.IsNullOrEmpty(EventSendNameListStr)) | |||
{ | |||
try | |||
{ | |||
EventSendNameList = JsonConvert.DeserializeObject<ObservableCollection<EventSendMessage>>(EventSendNameListStr); | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
List<string> MessageNameNew = EventReceiveNameList?.Select(o => o.MeaageName.ToString())?.Distinct()?.ToList(); | |||
if (MessageNameL == null || !MessageNameNew.SequenceEqual(MessageNameL)) | |||
{ | |||
@@ -550,10 +487,12 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
} | |||
} | |||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||
timer.Tick += Timer_Tick; ; | |||
timer.Start(); | |||
if (propertyBing.Count > 0) | |||
{ | |||
timer.Interval = TimeSpan.FromMilliseconds(TimeCount); | |||
timer.Tick += Timer_Tick; ; | |||
timer.Start(); | |||
} | |||
} | |||
private void Timer_Tick(object? sender,EventArgs e) | |||
@@ -612,9 +551,9 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
//必对消息号: | |||
if (msg != null) | |||
{ | |||
Title = mode.Title; | |||
Value = mode.Value; | |||
Text = mode.Text; | |||
WLTitle = mode.Title; | |||
KgValue = mode.Value; | |||
WLText = mode.Text; | |||
} | |||
} | |||
} | |||
@@ -648,7 +587,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
EventSendMessage eventSend = new EventSendMessage(); | |||
eventSend.ControlName = this.Name; | |||
eventSend.ControlTitle = this.Title; | |||
eventSend.ControlTitle = this.WLTitle; | |||
eventSend.ControlSource = image.Tag.ToString(); | |||
eventSend.EventType = ControlEventType.MouseLeftButtonDown; | |||
eventSend.MeaageName = 出料单击事件; | |||
@@ -658,7 +597,7 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
{ | |||
EventSendMessage eventSend = new EventSendMessage(); | |||
eventSend.ControlName = this.Name; | |||
eventSend.ControlTitle = this.Title; | |||
eventSend.ControlTitle = this.WLTitle; | |||
eventSend.ControlSource = image.Tag.ToString(); | |||
eventSend.EventType = ControlEventType.MouseLeftButtonDown; | |||
eventSend.MeaageName = 停止出料单击事件; | |||
@@ -29,8 +29,8 @@ namespace BPASmartClient.SCADAControl.CustomerControls | |||
InitializeComponent(); | |||
Stretch = Stretch.UniformToFill; | |||
//SetCurrentValue(SourceProperty, new BitmapImage(new Uri("pack://application:,,,/Images/借出.png", UriKind.Absolute))); | |||
//Width = 120; | |||
//Height = 40; | |||
Width = 80; | |||
Height = 80; | |||
} | |||
public string ControlType => "控件"; | |||
@@ -295,6 +295,11 @@ | |||
<Style.Setters> | |||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||
<Setter Property="Cursor" Value="Hand" /> | |||
<Setter Property="Background"> | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/button2.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
<Setter Property="Height" Value="25" /> | |||
<Setter Property="Template"> | |||
@@ -311,26 +316,26 @@ | |||
VerticalAlignment="Center" | |||
Cursor="Hand" | |||
FontSize="14" | |||
Foreground="{DynamicResource ButtonSelectForeground}" | |||
Foreground="{TemplateBinding Foreground}" | |||
Text="{TemplateBinding Content}" /> | |||
</StackPanel> | |||
</Border> | |||
<ControlTemplate.Triggers> | |||
<Trigger Property="IsMouseOver" Value="true"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter TargetName="BD" Property="Background" > | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/button2.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
<!--<Setter TargetName="textBlock" Property="Foreground" Value="{TemplateBinding Foreground}" />--> | |||
</Trigger> | |||
<Trigger Property="IsMouseOver" Value="False"> | |||
<Setter TargetName="BD" Property="Background"> | |||
<Setter TargetName="BD" Property="Background" > | |||
<Setter.Value> | |||
<ImageBrush ImageSource="../Images/button1.png" /> | |||
<ImageBrush ImageSource="../Images/button2.png" /> | |||
</Setter.Value> | |||
</Setter> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonSelectForeground}" /> | |||
<!--<Setter TargetName="textBlock" Property="Foreground" Value="{TemplateBinding Foreground}" />--> | |||
</Trigger> | |||
<Trigger Property="IsEnabled" Value="False"> | |||
<Setter TargetName="textBlock" Property="Foreground" Value="{DynamicResource ButtonUnSelectForeground}" /> | |||
@@ -25,15 +25,16 @@ | |||
<ColumnDefinition/> | |||
<ColumnDefinition Width="350"/> | |||
</Grid.ColumnDefinitions> | |||
<!--左侧选择区域--> | |||
<Grid Background="White" > | |||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4"> | |||
<Grid > | |||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Background="White" Margin="4"> | |||
<ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove"> | |||
</ListBox> | |||
</Border> | |||
</Grid> | |||
<!--中间控制区域--> | |||
<DockPanel Grid.Column="1"> | |||
@@ -138,7 +139,7 @@ | |||
<!--中间画布--> | |||
<Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4"> | |||
<Border.Background> | |||
<ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/> | |||
<ImageBrush ImageSource="/Images/bj.png" Stretch="UniformToFill"/> | |||
</Border.Background> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
@@ -187,37 +188,129 @@ | |||
<!--右侧属性栏--> | |||
<Grid Grid.Column="2"> | |||
<TabControl SelectedIndex="0"> | |||
<TabItem Header="控制协议"> | |||
<mypro:PropertyGrid x:Name="kzxy" SelectedObject="{Binding PropeObject}" | |||
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
CategoryGroupHeaderTemplate="{DynamicResource Category}"> | |||
<TabItem Header="属性设置"> | |||
<mypro:PropertyGrid Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
AutoGenerateProperties="False" | |||
CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" > | |||
<mypro:PropertyGrid.PropertyDefinitions> | |||
<mypro:PropertyDefinition Name="FontSize" ></mypro:PropertyDefinition> | |||
<mypro:PropertyDefinition DisplayName="名称" Category="基本属性" DisplayOrder="0" Name="Name" Description="设置控件的标识,可以在Js脚本中通过标识操作控件。"/> | |||
<mypro:PropertyDefinition DisplayName="内容" Category="基本属性" DisplayOrder="1" Name="Content"/> | |||
<mypro:PropertyDefinition DisplayName="标题" Category="基本属性" DisplayOrder="1" Name="Header" Description="Header"/> | |||
<mypro:PropertyDefinition DisplayName="文本" Category="基本属性" DisplayOrder="1" Name="Text" Description="Text"/> | |||
<mypro:PropertyDefinition DisplayName="值" Category="基本属性" DisplayOrder="2" Name="NumberValue" Description="NumberValue"/> | |||
<mypro:PropertyDefinition DisplayName="数值" Category="基本属性" DisplayOrder="2" Name="CurValue" Description="CurValue"/> | |||
<mypro:PropertyDefinition DisplayName="状态值" Category="基本属性" DisplayOrder="2" Name="StatusValue" Description="StatusValue"/> | |||
<mypro:PropertyDefinition DisplayName="勾选状态" Category="基本属性" DisplayOrder="2" Name="IsChecked" Description="IsChecked"/> | |||
<mypro:PropertyDefinition DisplayName="数值" Category="基本属性" DisplayOrder="2" Name="Value" Description="Value"/> | |||
<mypro:PropertyDefinition DisplayName="物料重量(g)" Category="基本属性" DisplayOrder="2" Name="KgValue" Description="克数"/> | |||
<mypro:PropertyDefinition DisplayName="物料描述" Category="基本属性" DisplayOrder="2" Name="WLText" Description="物料描述"/> | |||
<mypro:PropertyDefinition DisplayName="物料标题" Category="基本属性" DisplayOrder="2" Name="WLTitle" Description="物料标题"/> | |||
<mypro:PropertyDefinition DisplayName="标题" Category="基本属性" DisplayOrder="2" Name="Title" Description="标题"/> | |||
<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="MaxValue" Description="MaxValue"/> | |||
<mypro:PropertyDefinition DisplayName="最小值" Category="基本属性" DisplayOrder="3" Name="MinValue" Description="MinValue"/> | |||
<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="Maximum" Description="Maximum"/> | |||
<mypro:PropertyDefinition DisplayName="最小值" Category="基本属性" DisplayOrder="3" Name="Minimum" Description="Minimum"/> | |||
<mypro:PropertyDefinition DisplayName="间隔" Category="基本属性" DisplayOrder="3" Name="Interval"/> | |||
<mypro:PropertyDefinition DisplayName="宽度" Category="基本属性" DisplayOrder="3" Name="Width"/> | |||
<mypro:PropertyDefinition DisplayName="高度" Category="基本属性" DisplayOrder="3" Name="Height"/> | |||
<mypro:PropertyDefinition DisplayName="勾选状态" Category="基本属性" DisplayOrder="3" Name="BindingIsChecked"/> | |||
<mypro:PropertyDefinition DisplayName="路径" Category="基本属性" DisplayOrder="3" Name="Source" /> | |||
<mypro:PropertyDefinition DisplayName="字体大小" Category="基本属性" DisplayOrder="4" Name="FontSize"/> | |||
<mypro:PropertyDefinition DisplayName="字体" Category="基本属性" DisplayOrder="4" Name="FontFamily"/> | |||
<mypro:PropertyDefinition DisplayName="字体样式" Category="基本属性" DisplayOrder="4" Name="FontWeight"/> | |||
<mypro:PropertyDefinition DisplayName="垂直对齐" Category="基本属性" DisplayOrder="4" Name="VerticalContentAlignment"/> | |||
<mypro:PropertyDefinition DisplayName="水平对齐" Category="基本属性" DisplayOrder="4" Name="HorizontalContentAlignment"/> | |||
<mypro:PropertyDefinition DisplayName="所属分组" Category="基本属性" DisplayOrder="4" Name="GroupName"/> | |||
<mypro:PropertyDefinition DisplayName="文本提示" Category="基本属性" DisplayOrder="4" Name="ToolTip"/> | |||
<mypro:PropertyDefinition DisplayName="左边距" Category="基本属性" DisplayOrder="4" Name="(Canvas.Left)"/> | |||
<mypro:PropertyDefinition DisplayName="上边距" Category="基本属性" DisplayOrder="4" Name="(Canvas.Top)"/> | |||
<mypro:PropertyDefinition DisplayName="设备名称" Category="数据绑定模块" DisplayOrder="0" Name="DeviceName"/> | |||
<mypro:PropertyDefinition DisplayName="接口类型" Category="数据绑定模块" DisplayOrder="1" Name="InterfaceMode"/> | |||
<mypro:PropertyDefinition DisplayName="接口参数" Category="数据绑定模块" DisplayOrder="2" Name="InterfaceParameters"/> | |||
<mypro:PropertyDefinition DisplayName="连接信息" Category="数据绑定模块" DisplayOrder="3" Name="DataSouceInformation"/> | |||
<mypro:PropertyDefinition DisplayName="设备解析变量" Category="数据绑定模块" DisplayOrder="4" Name="DeviceValuleName"/> | |||
<mypro:PropertyDefinition DisplayName="数据源" Category="数据绑定模块" DisplayOrder="5" Name="FDataSouce"/> | |||
<mypro:PropertyDefinition DisplayName="代码过滤脚本" Category="数据绑定模块" DisplayOrder="6" Name="Code"/> | |||
<mypro:PropertyDefinition DisplayName="数据结果" Category="数据绑定模块" DisplayOrder="7" Name="GenerateData"/> | |||
<mypro:PropertyDefinition DisplayName="定时间隔" Category="数据绑定模块" DisplayOrder="8" Name="TimeCount"/> | |||
<mypro:PropertyDefinition DisplayName="列表项" Category="集合设置" Name="ItemsString" /> | |||
<mypro:PropertyDefinition DisplayName="列表项" Category="集合设置" Name="TabItems" /> | |||
<mypro:PropertyDefinition DisplayName="前景色" Category="颜色设置" Name="Foreground"/> | |||
<mypro:PropertyDefinition DisplayName="背景色" Category="颜色设置" Name="Background"/> | |||
<mypro:PropertyDefinition DisplayName="边框色" Category="颜色设置" Name="BorderBrush"/> | |||
<mypro:PropertyDefinition DisplayName="填充" Category="基本属性" DisplayOrder="5" Name="WaveFill"/> | |||
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="WaveThickness"/> | |||
<mypro:PropertyDefinition DisplayName="边框" Category="基本属性" DisplayOrder="5" Name="WaveStroke"/> | |||
<mypro:PropertyDefinition DisplayName="填充" Category="基本属性" DisplayOrder="5" Name="Fill"/> | |||
<mypro:PropertyDefinition DisplayName="边框" Category="基本属性" DisplayOrder="5" Name="Stroke"/> | |||
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="StrokeThickness"/> | |||
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="BorderThickness"/> | |||
<mypro:PropertyDefinition DisplayName="点击事件" Category="事件绑定" DisplayOrder="0" Name="ClickExec" /> | |||
<mypro:PropertyDefinition DisplayName="值改变事件" Category="事件绑定" DisplayOrder="1" Name="ValueChangedExecute" /> | |||
<mypro:PropertyDefinition DisplayName="定时触发" Category="事件绑定" DisplayOrder="2" Name="TikcExecute" /> | |||
<mypro:PropertyDefinition DisplayName="勾选事件" Category="事件绑定" DisplayOrder="3" Name="CheckedExec" /> | |||
<mypro:PropertyDefinition DisplayName="取消勾选事件" Category="事件绑定" DisplayOrder="4" Name="UnCheckedExec" /> | |||
<mypro:PropertyDefinition DisplayName="接收消息集" Category="事件绑定" DisplayOrder="5" Name="EventReceiveNameList" /> | |||
<mypro:PropertyDefinition DisplayName="出料单击事件" Category="事件绑定" DisplayOrder="6" Name="出料单击事件" /> | |||
<mypro:PropertyDefinition DisplayName="停止出料单击事件" Category="事件绑定" DisplayOrder="7" Name="停止出料单击事件" /> | |||
</mypro:PropertyGrid.PropertyDefinitions> | |||
<mypro:PropertyGrid.EditorDefinitions> | |||
<!--EditorTemplateDefinition可添加多个--> | |||
<!--要修改编辑模板的属性的名称--> | |||
<mypro:EditorTemplateDefinition TargetProperties="点击事件,值改变事件,定时触发,勾选事件,取消勾选事件" > | |||
<mypro:EditorTemplateDefinition TargetProperties="Foreground,Background,BorderBrush,WaveFill,WaveStroke,Fill,Stroke"> | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<Grid> | |||
<!-- Command生效: DataTemplate的DataContext指代不明确,需要改为父类的DataContext。 参数Value表示原对象--> | |||
<!--Command="{Binding Path=DataContext.PropeSetCommand ,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=xctk:PropertyGrid}}"--> | |||
<!--DataContext="{Binding DataContext, ElementName=window}" Command="{Binding PropeSetCommand}" CommandParameter="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"--> | |||
<mypro:ColorPicker SelectedColor="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={x:Static s:ColorToStringConverter.Instance}}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="Source"> | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*" x:Name="key"/> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="35"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBox Width="{Binding Width, ElementName=key}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||
<ToggleButton Grid.Column="1" Height="25" Content="编辑" Width="30" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton> | |||
<ToggleButton Grid.Column="1" Height="30" Content="..." Width="26" Margin="5,0,0,0" HorizontalAlignment="Left" Click="LJToggleButton_Click"></ToggleButton> | |||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="代码过滤脚本" > | |||
<!--代码绑定模块--> | |||
<mypro:EditorTemplateDefinition TargetProperties="ClickExec,ValueChangedExecute,TikcExecute,CheckedExec,UnCheckedExec" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="35"/> | |||
</Grid.ColumnDefinitions> | |||
<ToggleButton Grid.Column="1" Height="30" Content="编辑" Width="26" Margin="5,0,0,0" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton> | |||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="Code" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> | |||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap"></TextBox> | |||
</ScrollViewer> | |||
@@ -225,33 +318,27 @@ | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="设备解析变量" > | |||
<mypro:EditorTemplateDefinition TargetProperties="DeviceValuleName" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<Grid> | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}" | |||
></ComboBox> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="设备名称" > | |||
<mypro:EditorTemplateDefinition TargetProperties="DeviceName" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<Grid> | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}" | |||
></ComboBox> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" > | |||
<mypro:EditorTemplateDefinition TargetProperties="Text,Content,Title,Value,BindingIsChecked,Header,KgValue,WLText,WLTitle" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
@@ -282,12 +369,13 @@ | |||
</mypro:PropertyGrid.EditorDefinitions> | |||
</mypro:PropertyGrid> | |||
</TabItem> | |||
<TabItem Header="控件样式"> | |||
<!--<TabItem Header="所有属性"> | |||
<mypro:PropertyGrid x:Name="dsdsdsd" | |||
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</TabItem> | |||
</TabItem>--> | |||
</TabControl> | |||
</Grid> | |||
</Grid> | |||
@@ -35,7 +35,8 @@ namespace BeDesignerSCADA.Controls | |||
/// 布局文件路径 | |||
/// </summary> | |||
public string Path=string.Empty; | |||
MainViewModel viewModel = new MainViewModel(); | |||
public string VariablePath = string.Empty; | |||
MainViewModelNew viewModel = new MainViewModelNew(); | |||
public MainCanvasPanel(string _Path) | |||
{ | |||
InitializeComponent(); | |||
@@ -204,6 +205,21 @@ namespace BeDesignerSCADA.Controls | |||
SaveBtn_Click(null, null); | |||
} | |||
/// <summary> | |||
/// 传入变量管理器地址 | |||
/// </summary> | |||
/// <param name="path"></param> | |||
public void VariableManagerPath(string path) | |||
{ | |||
try | |||
{ | |||
VariablePath = path; | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 保存 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
@@ -272,6 +288,30 @@ namespace BeDesignerSCADA.Controls | |||
} | |||
} | |||
/// <summary> | |||
/// 路径资源选择 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void LJToggleButton_Click(object sender, RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
if (sender is ToggleButton) | |||
{ | |||
ToggleButton toggle = (ToggleButton)sender; | |||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | |||
if (propertyGridCommand != null) | |||
{ | |||
viewModel.SelectPath(propertyGridCommand); | |||
} | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 变量选择 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
@@ -0,0 +1,45 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Drawing; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows.Data; | |||
using System.Windows.Media; | |||
namespace BeDesignerSCADA.Converters | |||
{ | |||
[ValueConversion(typeof(string), typeof(System.Drawing.Color))] | |||
public class ColorToStringConverter : IValueConverter | |||
{ | |||
static ColorToStringConverter() | |||
{ | |||
Instance = new ColorToStringConverter(); | |||
} | |||
public static ColorToStringConverter Instance | |||
{ | |||
get; | |||
private set; | |||
} | |||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |||
{ | |||
if (value is System.Windows.Media.LinearGradientBrush) | |||
{ | |||
return value;// == null ? null : ((System.Windows.Media.LinearGradientBrush)value); | |||
} | |||
else if (value is System.Windows.Media.ImageBrush) | |||
{ | |||
return value;// == null ? null : ((System.Windows.Media.ImageBrush)value); | |||
} | |||
else | |||
return value==null?null:((SolidColorBrush)value).Color; | |||
} | |||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | |||
{ | |||
return value == null ? null : new SolidColorBrush((System.Windows.Media.Color)value); | |||
} | |||
} | |||
} |
@@ -191,37 +191,129 @@ | |||
<!--右侧属性栏--> | |||
<Grid Grid.Column="2"> | |||
<TabControl SelectedIndex="0"> | |||
<TabItem Header="控制协议"> | |||
<mypro:PropertyGrid x:Name="kzxy" SelectedObject="{Binding PropeObject}" | |||
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
CategoryGroupHeaderTemplate="{DynamicResource Category}"> | |||
<TabItem Header="属性设置"> | |||
<mypro:PropertyGrid Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
AutoGenerateProperties="False" | |||
CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" > | |||
<mypro:PropertyGrid.PropertyDefinitions> | |||
<mypro:PropertyDefinition Name="FontSize" ></mypro:PropertyDefinition> | |||
<mypro:PropertyDefinition DisplayName="名称" Category="基本属性" DisplayOrder="0" Name="Name" Description="设置控件的标识,可以在Js脚本中通过标识操作控件。"/> | |||
<mypro:PropertyDefinition DisplayName="内容" Category="基本属性" DisplayOrder="1" Name="Content"/> | |||
<mypro:PropertyDefinition DisplayName="标题" Category="基本属性" DisplayOrder="1" Name="Header" Description="Header"/> | |||
<mypro:PropertyDefinition DisplayName="文本" Category="基本属性" DisplayOrder="1" Name="Text" Description="Text"/> | |||
<mypro:PropertyDefinition DisplayName="值" Category="基本属性" DisplayOrder="2" Name="NumberValue" Description="NumberValue"/> | |||
<mypro:PropertyDefinition DisplayName="数值" Category="基本属性" DisplayOrder="2" Name="CurValue" Description="CurValue"/> | |||
<mypro:PropertyDefinition DisplayName="状态值" Category="基本属性" DisplayOrder="2" Name="StatusValue" Description="StatusValue"/> | |||
<mypro:PropertyDefinition DisplayName="勾选状态" Category="基本属性" DisplayOrder="2" Name="IsChecked" Description="IsChecked"/> | |||
<mypro:PropertyDefinition DisplayName="数值" Category="基本属性" DisplayOrder="2" Name="Value" Description="Value"/> | |||
<mypro:PropertyDefinition DisplayName="物料重量(g)" Category="基本属性" DisplayOrder="2" Name="KgValue" Description="克数"/> | |||
<mypro:PropertyDefinition DisplayName="物料描述" Category="基本属性" DisplayOrder="2" Name="WLText" Description="物料描述"/> | |||
<mypro:PropertyDefinition DisplayName="物料标题" Category="基本属性" DisplayOrder="2" Name="WLTitle" Description="物料标题"/> | |||
<mypro:PropertyDefinition DisplayName="标题" Category="基本属性" DisplayOrder="2" Name="Title" Description="标题"/> | |||
<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="MaxValue" Description="MaxValue"/> | |||
<mypro:PropertyDefinition DisplayName="最小值" Category="基本属性" DisplayOrder="3" Name="MinValue" Description="MinValue"/> | |||
<mypro:PropertyDefinition DisplayName="最大值" Category="基本属性" DisplayOrder="3" Name="Maximum" Description="Maximum"/> | |||
<mypro:PropertyDefinition DisplayName="最小值" Category="基本属性" DisplayOrder="3" Name="Minimum" Description="Minimum"/> | |||
<mypro:PropertyDefinition DisplayName="间隔" Category="基本属性" DisplayOrder="3" Name="Interval"/> | |||
<mypro:PropertyDefinition DisplayName="宽度" Category="基本属性" DisplayOrder="3" Name="Width"/> | |||
<mypro:PropertyDefinition DisplayName="高度" Category="基本属性" DisplayOrder="3" Name="Height"/> | |||
<mypro:PropertyDefinition DisplayName="勾选状态" Category="基本属性" DisplayOrder="3" Name="BindingIsChecked"/> | |||
<mypro:PropertyDefinition DisplayName="路径" Category="基本属性" DisplayOrder="3" Name="Source" /> | |||
<mypro:PropertyDefinition DisplayName="字体大小" Category="基本属性" DisplayOrder="4" Name="FontSize"/> | |||
<mypro:PropertyDefinition DisplayName="字体" Category="基本属性" DisplayOrder="4" Name="FontFamily"/> | |||
<mypro:PropertyDefinition DisplayName="字体样式" Category="基本属性" DisplayOrder="4" Name="FontWeight"/> | |||
<mypro:PropertyDefinition DisplayName="垂直对齐" Category="基本属性" DisplayOrder="4" Name="VerticalContentAlignment"/> | |||
<mypro:PropertyDefinition DisplayName="水平对齐" Category="基本属性" DisplayOrder="4" Name="HorizontalContentAlignment"/> | |||
<mypro:PropertyDefinition DisplayName="所属分组" Category="基本属性" DisplayOrder="4" Name="GroupName"/> | |||
<mypro:PropertyDefinition DisplayName="文本提示" Category="基本属性" DisplayOrder="4" Name="ToolTip"/> | |||
<mypro:PropertyDefinition DisplayName="左边距" Category="基本属性" DisplayOrder="4" Name="(Canvas.Left)"/> | |||
<mypro:PropertyDefinition DisplayName="上边距" Category="基本属性" DisplayOrder="4" Name="(Canvas.Top)"/> | |||
<mypro:PropertyDefinition DisplayName="设备名称" Category="数据绑定模块" DisplayOrder="0" Name="DeviceName"/> | |||
<mypro:PropertyDefinition DisplayName="接口类型" Category="数据绑定模块" DisplayOrder="1" Name="InterfaceMode"/> | |||
<mypro:PropertyDefinition DisplayName="接口参数" Category="数据绑定模块" DisplayOrder="2" Name="InterfaceParameters"/> | |||
<mypro:PropertyDefinition DisplayName="连接信息" Category="数据绑定模块" DisplayOrder="3" Name="DataSouceInformation"/> | |||
<mypro:PropertyDefinition DisplayName="设备解析变量" Category="数据绑定模块" DisplayOrder="4" Name="DeviceValuleName"/> | |||
<mypro:PropertyDefinition DisplayName="数据源" Category="数据绑定模块" DisplayOrder="5" Name="FDataSouce"/> | |||
<mypro:PropertyDefinition DisplayName="代码过滤脚本" Category="数据绑定模块" DisplayOrder="6" Name="Code"/> | |||
<mypro:PropertyDefinition DisplayName="数据结果" Category="数据绑定模块" DisplayOrder="7" Name="GenerateData"/> | |||
<mypro:PropertyDefinition DisplayName="定时间隔" Category="数据绑定模块" DisplayOrder="8" Name="TimeCount"/> | |||
<mypro:PropertyDefinition DisplayName="列表项" Category="集合设置" Name="ItemsString" /> | |||
<mypro:PropertyDefinition DisplayName="列表项" Category="集合设置" Name="TabItems" /> | |||
<mypro:PropertyDefinition DisplayName="前景色" Category="颜色设置" Name="Foreground"/> | |||
<mypro:PropertyDefinition DisplayName="背景色" Category="颜色设置" Name="Background"/> | |||
<mypro:PropertyDefinition DisplayName="边框色" Category="颜色设置" Name="BorderBrush"/> | |||
<mypro:PropertyDefinition DisplayName="填充" Category="基本属性" DisplayOrder="5" Name="WaveFill"/> | |||
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="WaveThickness"/> | |||
<mypro:PropertyDefinition DisplayName="边框" Category="基本属性" DisplayOrder="5" Name="WaveStroke"/> | |||
<mypro:PropertyDefinition DisplayName="填充" Category="基本属性" DisplayOrder="5" Name="Fill"/> | |||
<mypro:PropertyDefinition DisplayName="边框" Category="基本属性" DisplayOrder="5" Name="Stroke"/> | |||
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="StrokeThickness"/> | |||
<mypro:PropertyDefinition DisplayName="边框粗细" Category="基本属性" DisplayOrder="5" Name="BorderThickness"/> | |||
<mypro:PropertyDefinition DisplayName="点击事件" Category="事件绑定" DisplayOrder="0" Name="ClickExec" /> | |||
<mypro:PropertyDefinition DisplayName="值改变事件" Category="事件绑定" DisplayOrder="1" Name="ValueChangedExecute" /> | |||
<mypro:PropertyDefinition DisplayName="定时触发" Category="事件绑定" DisplayOrder="2" Name="TikcExecute" /> | |||
<mypro:PropertyDefinition DisplayName="勾选事件" Category="事件绑定" DisplayOrder="3" Name="CheckedExec" /> | |||
<mypro:PropertyDefinition DisplayName="取消勾选事件" Category="事件绑定" DisplayOrder="4" Name="UnCheckedExec" /> | |||
<mypro:PropertyDefinition DisplayName="接收消息集" Category="事件绑定" DisplayOrder="5" Name="EventReceiveNameList" /> | |||
<mypro:PropertyDefinition DisplayName="出料单击事件" Category="事件绑定" DisplayOrder="6" Name="出料单击事件" /> | |||
<mypro:PropertyDefinition DisplayName="停止出料单击事件" Category="事件绑定" DisplayOrder="7" Name="停止出料单击事件" /> | |||
</mypro:PropertyGrid.PropertyDefinitions> | |||
<mypro:PropertyGrid.EditorDefinitions> | |||
<!--EditorTemplateDefinition可添加多个--> | |||
<!--要修改编辑模板的属性的名称--> | |||
<mypro:EditorTemplateDefinition TargetProperties="点击事件,值改变事件,定时触发,勾选事件,取消勾选事件" > | |||
<mypro:EditorTemplateDefinition TargetProperties="Foreground,Background,BorderBrush,WaveFill,WaveStroke,Fill,Stroke"> | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<Grid> | |||
<!-- Command生效: DataTemplate的DataContext指代不明确,需要改为父类的DataContext。 参数Value表示原对象--> | |||
<!--Command="{Binding Path=DataContext.PropeSetCommand ,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=xctk:PropertyGrid}}"--> | |||
<!--DataContext="{Binding DataContext, ElementName=window}" Command="{Binding PropeSetCommand}" CommandParameter="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"--> | |||
<mypro:ColorPicker SelectedColor="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, Converter={x:Static s:ColorToStringConverter.Instance}}" /> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="Source"> | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*" x:Name="key"/> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="35"/> | |||
</Grid.ColumnDefinitions> | |||
<TextBox Width="{Binding Width, ElementName=key}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||
<ToggleButton Grid.Column="1" Height="25" Content="编辑" Width="30" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton> | |||
<ToggleButton Grid.Column="1" Height="30" Content="..." Width="26" Margin="5,0,0,0" HorizontalAlignment="Left" Click="LJToggleButton_Click"></ToggleButton> | |||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="代码过滤脚本" > | |||
<!--代码绑定模块--> | |||
<mypro:EditorTemplateDefinition TargetProperties="ClickExec,ValueChangedExecute,TikcExecute,CheckedExec,UnCheckedExec" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<Grid> | |||
<Grid.ColumnDefinitions> | |||
<ColumnDefinition Width="*"/> | |||
<ColumnDefinition Width="35"/> | |||
</Grid.ColumnDefinitions> | |||
<ToggleButton Grid.Column="1" Height="30" Content="编辑" Width="26" Margin="5,0,0,0" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton> | |||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center"/> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="Code" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> | |||
<TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap"></TextBox> | |||
</ScrollViewer> | |||
@@ -229,33 +321,27 @@ | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="设备解析变量" > | |||
<mypro:EditorTemplateDefinition TargetProperties="DeviceValuleName" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<Grid> | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}" | |||
></ComboBox> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="设备名称" > | |||
<mypro:EditorTemplateDefinition TargetProperties="DeviceName" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
<Grid> | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
<ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" | |||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}" | |||
></ComboBox> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
</mypro:EditorTemplateDefinition> | |||
<mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" > | |||
<mypro:EditorTemplateDefinition TargetProperties="Text,Content,Title,Value,BindingIsChecked,Header,KgValue,WLText,WLTitle" > | |||
<mypro:EditorTemplateDefinition.EditingTemplate> | |||
<DataTemplate> | |||
<!--此处可自由发挥--> | |||
@@ -278,7 +364,7 @@ | |||
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"/> | |||
</Grid> | |||
<TextBox Grid.Row="2" x:Name="wenben" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox> | |||
</Grid> | |||
</DataTemplate> | |||
</mypro:EditorTemplateDefinition.EditingTemplate> | |||
@@ -286,12 +372,13 @@ | |||
</mypro:PropertyGrid.EditorDefinitions> | |||
</mypro:PropertyGrid> | |||
</TabItem> | |||
<TabItem Header="控件样式"> | |||
<!--<TabItem Header="所有属性"> | |||
<mypro:PropertyGrid x:Name="dsdsdsd" | |||
Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True" | |||
FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False" | |||
CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> | |||
</TabItem> | |||
</TabItem>--> | |||
</TabControl> | |||
</Grid> | |||
</Grid> | |||
@@ -34,155 +34,17 @@ namespace BeDesignerSCADA | |||
public partial class MainWindow : Window | |||
{ | |||
MainViewModel viewModel=new MainViewModel(); | |||
MainViewModelNew viewModel =new MainViewModelNew(); | |||
public MainWindow() | |||
{ | |||
InitializeComponent(); | |||
this.DataContext = viewModel; | |||
viewModel.Loaded(cav, runCanvas); | |||
//控件加载 | |||
Assembly assembly = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.SCADAControl.dll"); //Assembly.GetExecutingAssembly(); | |||
var controls = assembly.GetTypes().Where(t => t.GetInterface("IExecutable") != null).OrderBy(o=>o.Name); | |||
CtlList.ItemsSource = controls; | |||
this.GotFocus += MainWindow_GotFocus; | |||
this.LostFocus += MainWindow_LostFocus; | |||
} | |||
private void MainWindow_LostFocus(object sender, RoutedEventArgs e) | |||
{ | |||
System.Diagnostics.Trace.WriteLine("失去焦点:" + e.OriginalSource.ToString()); | |||
// Console.WriteLine(e.OriginalSource.ToString()); | |||
} | |||
private void MainWindow_GotFocus(object sender, RoutedEventArgs e) | |||
{ | |||
System.Diagnostics.Trace.WriteLine("获得焦点:"+e.OriginalSource.ToString()); | |||
} | |||
#region 加载数据中心与事件中心 | |||
/// <summary> | |||
/// 加载数据中心 | |||
/// </summary> | |||
public void Loading() | |||
{ | |||
//try | |||
//{ | |||
// Assembly assembly1 = Assembly.LoadFile($"{System.AppDomain.CurrentDomain.BaseDirectory}\\BPASmartClient.MessageName.dll"); | |||
// Type type = assembly1.GetType("BPASmartClient.MessageName.MessageName"); | |||
// var control = Activator.CreateInstance(type); | |||
// var fildes = control.GetType().GetFields(); | |||
// foreach (var fi in fildes) | |||
// { | |||
// EventModel eventModel = new EventModel(); | |||
// eventModel.EventValue = fi.GetValue(control)?.ToString(); | |||
// eventModel.EventName = fi.Name; | |||
// foreach (var item in fi.CustomAttributes) | |||
// { | |||
// if (item.AttributeType.Name == "CategoryAttribute") | |||
// { | |||
// eventModel.Category = item.ConstructorArguments.Count() > 0 ? item.ConstructorArguments[0].Value?.ToString() : ""; | |||
// } | |||
// else if (item.AttributeType.Name == "DescriptionAttribute") | |||
// { | |||
// eventModel.Description = item.ConstructorArguments.Count() > 0 ? item.ConstructorArguments[0].Value?.ToString() : ""; | |||
// } | |||
// else if (item.AttributeType.Name == "BrowsableAttribute") | |||
// { | |||
// eventModel.Browsable = item.ConstructorArguments.Count() > 0 ? (bool)item.ConstructorArguments[0].Value : true; | |||
// } | |||
// } | |||
// if (!string.IsNullOrEmpty(eventModel.Category)) | |||
// { | |||
// if (Class_DataBus.GetInstance().EventData.ContainsKey(eventModel.Category)) | |||
// Class_DataBus.GetInstance().EventData[eventModel.Category].Add(eventModel); | |||
// else | |||
// { | |||
// Class_DataBus.GetInstance().EventData[eventModel.Category] = new List<EventModel> { eventModel }; | |||
// } | |||
// } | |||
// } | |||
// type = assembly1.GetType("BPASmartClient.MessageName.DataName"); | |||
// control = Activator.CreateInstance(type); | |||
// fildes = control.GetType().GetFields(); | |||
// foreach (var fi in fildes) | |||
// { | |||
// ALLModel aLLModel = new ALLModel(); | |||
// aLLModel.DataValue = fi.GetValue(control)?.ToString(); | |||
// aLLModel.DataName = fi.Name; | |||
// foreach (var item in fi.CustomAttributes) | |||
// { | |||
// if (item.AttributeType.Name == "CategoryAttribute") | |||
// { | |||
// aLLModel.Category = item.ConstructorArguments.Count() > 0 ? item.ConstructorArguments[0].Value?.ToString() : ""; | |||
// } | |||
// else if (item.AttributeType.Name == "DescriptionAttribute") | |||
// { | |||
// aLLModel.Description = item.ConstructorArguments.Count() > 0 ? item.ConstructorArguments[0].Value?.ToString() : ""; | |||
// } | |||
// else if (item.AttributeType.Name == "BrowsableAttribute") | |||
// { | |||
// aLLModel.Browsable = item.ConstructorArguments.Count() > 0 ? (bool)item.ConstructorArguments[0].Value : true; | |||
// } | |||
// } | |||
// if (!string.IsNullOrEmpty(aLLModel.Category)) | |||
// { | |||
// if (Class_DataBus.GetInstance().ALLData.ContainsKey(aLLModel.Category)) | |||
// Class_DataBus.GetInstance().ALLData[aLLModel.Category].Add(aLLModel); | |||
// else | |||
// { | |||
// Class_DataBus.GetInstance().ALLData[aLLModel.Category] = new List<ALLModel> { aLLModel }; | |||
// } | |||
// } | |||
// } | |||
//} | |||
//catch (Exception ex) | |||
//{ | |||
// System.Windows.MessageBox.Show(ex.Message); | |||
//} | |||
} | |||
/// <summary> | |||
/// 加载本地文件 | |||
/// </summary> | |||
public void LoadFile() | |||
{ | |||
//加载配置数据 | |||
FJson<CommunicationPar>.Read(); | |||
viewModel.DevNameList = new System.Collections.ObjectModel.ObservableCollection<string>(); | |||
viewModel.DevValueList = new System.Collections.ObjectModel.ObservableCollection<string>(); | |||
FJson<CommunicationPar>.Data.CommunicationDevices?.ToList().ForEach(data => | |||
{ | |||
viewModel.DevNameList.Add(data.DeviceName); | |||
data.VarTableModels?.ToList().ForEach((data) => { | |||
if(!viewModel.DevValueList.Contains(data.VarName) && !string.IsNullOrEmpty(data.VarName)) | |||
viewModel.DevValueList.Add(data.VarName); | |||
}); | |||
}); | |||
//CommunicationModel model = new CommunicationModel(); | |||
//Type typeData = model.GetType(); | |||
//PropertyInfo[] properties = typeData.GetProperties(); | |||
//foreach (PropertyInfo property in properties) | |||
//{ | |||
// viewModel.DevValueList.Add(property.Name); | |||
//} | |||
//ICommunicationDevice DeviceType; | |||
//DeviceType = FJson<CommunicationPar>.Data.CommunicationDevices.ElementAt(0).CommDevice; | |||
//VariableInfo variable = new VariableInfo(DeviceType); | |||
//PropertyInfo[] prope = variable.GetType().GetProperties(); | |||
//foreach (var item in prope) | |||
//{ | |||
// viewModel.DevValueList.Add(item.Name); | |||
//} | |||
} | |||
#endregion | |||
#region 位置调整 | |||
/// <summary> | |||
/// 左对齐 | |||
@@ -367,6 +229,30 @@ namespace BeDesignerSCADA | |||
} | |||
} | |||
/// <summary> | |||
/// 路径资源选择 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
/// <param name="e"></param> | |||
private void LJToggleButton_Click(object sender, RoutedEventArgs e) | |||
{ | |||
try | |||
{ | |||
if (sender is ToggleButton) | |||
{ | |||
ToggleButton toggle = (ToggleButton)sender; | |||
Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyGridCommand = toggle.DataContext as Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem; | |||
if (propertyGridCommand != null) | |||
{ | |||
viewModel.SelectPath(propertyGridCommand); | |||
} | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
} | |||
} | |||
/// <summary> | |||
/// 变量选择 | |||
/// </summary> | |||
/// <param name="sender"></param> | |||
@@ -450,5 +336,7 @@ namespace BeDesignerSCADA | |||
Class_DataBus.GetInstance().Dic_DeviceData.Keys?.ToList().ForEach(key => { viewModel.DevNameList.Add(key); }); | |||
} | |||
#endregion | |||
} | |||
} |
@@ -202,6 +202,10 @@ namespace BeDesignerSCADA.ViewModel | |||
/// 启动或者停止 | |||
/// </summary> | |||
public RelayCommand RunUiCommand { get; set; } | |||
/// <summary> | |||
/// 编辑 | |||
/// </summary> | |||
public RelayCommand EditCommand { get; set; } | |||
#endregion | |||
#region 常用函数 | |||
@@ -466,7 +470,7 @@ namespace BeDesignerSCADA.ViewModel | |||
} | |||
#endregion | |||
Dictionary<string, string> EventName = new Dictionary<string, string> { | |||
{"Name","名称" }, | |||
{"Text","文本" }, | |||
@@ -0,0 +1,243 @@ | |||
using BeDesignerSCADA.Common; | |||
using BeDesignerSCADA.Controls; | |||
using BeDesignerSCADA.View; | |||
using BPASmartClient.Compiler; | |||
using BPASmartClient.DATABUS; | |||
using BPASmartClient.MessageName; | |||
using BPASmartClient.MessageName.EnumHelp; | |||
using BPASmartClient.MessageName.发送消息Model; | |||
using BPASmartClient.MessageName.接收消息Model; | |||
using ICSharpCode.AvalonEdit; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using Microsoft.Win32; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
using System.ComponentModel; | |||
using System.Linq; | |||
using System.Reflection; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Windows; | |||
using System.Windows.Input; | |||
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; | |||
namespace BeDesignerSCADA.ViewModel | |||
{ | |||
public class MainViewModelNew : ObservableObject | |||
{ | |||
public MainViewModelNew() | |||
{ | |||
IsRunning = false; | |||
//启动 或者 停止 | |||
RunUiCommand = new RelayCommand(() => | |||
{ | |||
IsRunning = !IsRunning; | |||
}); | |||
} | |||
#region 变量 | |||
/// <summary> | |||
/// 是否正在运行状态 | |||
/// </summary> | |||
private bool _IsRunning = false; | |||
public bool IsRunning | |||
{ | |||
get | |||
{ | |||
return _IsRunning; | |||
} | |||
set | |||
{ | |||
_IsRunning = value; | |||
if (value) | |||
{ | |||
RunCanvasVisibility = Visibility.Visible; | |||
CanvasPanelVisibility = Visibility.Hidden; | |||
} | |||
else | |||
{ | |||
RunCanvasVisibility = Visibility.Hidden; | |||
CanvasPanelVisibility = Visibility.Visible; | |||
} | |||
OnPropertyChanged("IsRunning"); | |||
} | |||
} | |||
/// <summary> | |||
/// 画布是否显示 | |||
/// </summary> | |||
private Visibility _CanvasPanelVisibility; | |||
public Visibility CanvasPanelVisibility | |||
{ | |||
get | |||
{ | |||
return _CanvasPanelVisibility; | |||
} | |||
set | |||
{ | |||
if (_CanvasPanelVisibility == value) | |||
return; | |||
_CanvasPanelVisibility = value; | |||
OnPropertyChanged("CanvasPanelVisibility"); | |||
} | |||
} | |||
/// <summary> | |||
/// 运行代码是否显示 | |||
/// </summary> | |||
private Visibility _RunCanvasVisibility; | |||
public Visibility RunCanvasVisibility | |||
{ | |||
get | |||
{ | |||
return _RunCanvasVisibility; | |||
} | |||
set | |||
{ | |||
if (_RunCanvasVisibility == value) | |||
return; | |||
_RunCanvasVisibility = value; | |||
OnPropertyChanged("RunCanvasVisibility"); | |||
} | |||
} | |||
/// <summary> | |||
/// 当前代码Xaml | |||
/// </summary> | |||
private string _XamlCode; | |||
public string XamlCode | |||
{ | |||
get | |||
{ | |||
return _XamlCode; | |||
} | |||
set | |||
{ | |||
if (_XamlCode == value) | |||
return; | |||
_XamlCode = value; | |||
OnPropertyChanged("XamlCode"); | |||
} | |||
} | |||
/// <summary> | |||
/// 选中控件 | |||
/// </summary> | |||
private FrameworkElement _CanSelectedItem; | |||
public FrameworkElement CanSelectedItem | |||
{ | |||
get | |||
{ | |||
return _CanSelectedItem; | |||
} | |||
set | |||
{ | |||
if (_CanSelectedItem == value) | |||
return; | |||
_CanSelectedItem = value; | |||
OnPropertyChanged("CanSelectedItem"); | |||
} | |||
} | |||
/// <summary> | |||
/// 设备名称集合 | |||
/// </summary> | |||
private ObservableCollection<string> _DevNameList; | |||
public ObservableCollection<string> DevNameList | |||
{ | |||
get | |||
{ | |||
return _DevNameList; | |||
} | |||
set | |||
{ | |||
_DevNameList = value; | |||
OnPropertyChanged("DevNameList"); | |||
} | |||
} | |||
/// <summary> | |||
/// 设备变量集合 | |||
/// </summary> | |||
private ObservableCollection<string> _DevValueList; | |||
public ObservableCollection<string> DevValueList | |||
{ | |||
get | |||
{ | |||
return _DevValueList; | |||
} | |||
set | |||
{ | |||
_DevValueList = value; | |||
OnPropertyChanged("DevValueList"); | |||
} | |||
} | |||
#endregion | |||
#region 命令 | |||
/// <summary> | |||
/// 启动或者停止 | |||
/// </summary> | |||
public RelayCommand RunUiCommand { get; set; } | |||
/// <summary> | |||
/// 编辑 | |||
/// </summary> | |||
public RelayCommand EditCommand { get; set; } | |||
#endregion | |||
#region 常用函数 | |||
/// <summary> | |||
/// 显示当前xaml代码 | |||
/// </summary> | |||
public void ShowCode(TextEditor textEditor) | |||
{ | |||
textEditor.Text = canvasPanel.Save(); | |||
} | |||
#endregion | |||
#region 脚本编辑数据 | |||
/// <summary> | |||
/// 当前编辑界面 | |||
/// </summary> | |||
public CanvasPanel canvasPanel; | |||
/// <summary> | |||
/// 当前运行界面 | |||
/// </summary> | |||
public RunCanvas runCanvas; | |||
/// <summary> | |||
/// 加载 | |||
/// </summary> | |||
/// <param name="obj"></param> | |||
public void Loaded(object objCan, object objRun) | |||
{ | |||
canvasPanel = objCan as CanvasPanel; | |||
runCanvas = objRun as RunCanvas; | |||
} | |||
/// <summary> | |||
/// 编辑 | |||
/// </summary> | |||
/// <param name="obj"></param> | |||
public void Edit(object obj) | |||
{ | |||
string result = JsEditWindow.ShowEdit(((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value?.ToString(), canvasPanel.GetAllExecChildren()); | |||
((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = result; | |||
} | |||
/// <summary> | |||
/// 图片选择路径 | |||
/// </summary> | |||
/// <param name="obj"></param> | |||
public void SelectPath(object obj) | |||
{ | |||
OpenFileDialog ofd = new OpenFileDialog(); | |||
ofd.Filter = "图片|*.jpg;*.png;*.gif;*.jpeg;*.bmp"; | |||
if (ofd.ShowDialog() == true) | |||
{ | |||
((Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem)obj).Value = ofd.FileName; | |||
} | |||
} | |||
#endregion | |||
} | |||
} |