mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-14 21:26:35 +08:00
阀门优化
This commit is contained in:
@@ -86,18 +86,6 @@ namespace AIStudio.Wpf.SFC
|
|||||||
if (startbtn != null && startbtn.LinkPoint.Value == 0)//停止
|
if (startbtn != null && startbtn.LinkPoint.Value == 0)//停止
|
||||||
{
|
{
|
||||||
ResetStatus(viewModel);
|
ResetStatus(viewModel);
|
||||||
|
|
||||||
//关闭所有阀门
|
|
||||||
foreach (var node in SFCNodes[viewModel].OfType<Simulate_SolenoidViewModel>())
|
|
||||||
{
|
|
||||||
if (node.DILinkPoint != null)
|
|
||||||
{
|
|
||||||
node.DILinkPoint.Value = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//真实情况不会改变容器液位,只是为了模拟重新启动时候为了低液位处理的
|
|
||||||
//tank.LinkPoint.Value = 0;
|
|
||||||
}
|
}
|
||||||
else//启动
|
else//启动
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -79,6 +79,34 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type ToggleButton}" x:Key="SolenoidControlToggleButtonStyle">
|
||||||
|
<Setter Property="Background" Value="Red"/>
|
||||||
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||||
|
<Grid x:Name="Grid" Margin="{TemplateBinding Padding}">
|
||||||
|
<Ellipse x:Name="path" Fill="Red" Stroke="Black" Stretch="Uniform"/>
|
||||||
|
</Grid>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource GrayBrush8}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsPressed" Value="True">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource Fluent.Ribbon.Brushes.HighlightBrush}" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsChecked" Value="True">
|
||||||
|
<Setter Property="Fill" TargetName="path" Value="Green" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsEnabled" Value="false">
|
||||||
|
<Setter Property="Opacity" Value="0.6" TargetName="Grid"/>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
<Style TargetType="{x:Type ToggleButton}" x:Key="SolenoidToggleButtonStyle">
|
<Style TargetType="{x:Type ToggleButton}" x:Key="SolenoidToggleButtonStyle">
|
||||||
<Setter Property="Background" Value="Red"/>
|
<Setter Property="Background" Value="Red"/>
|
||||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||||
@@ -140,7 +168,8 @@
|
|||||||
|
|
||||||
<ControlTemplate x:Key="SolenoidStyle" TargetType="{x:Type ContentControl}">
|
<ControlTemplate x:Key="SolenoidStyle" TargetType="{x:Type ContentControl}">
|
||||||
<Grid Margin="0,5">
|
<Grid Margin="0,5">
|
||||||
<ToggleButton Style="{StaticResource SolenoidToggleButtonStyle}" IsChecked="{Binding DOLinkPoint.Value, Converter={StaticResource IntToBoolConverter}}"/>
|
<ToggleButton Style="{StaticResource SolenoidToggleButtonStyle}" IsChecked="{Binding DOLinkPoint.Value, Converter={StaticResource IntToBoolConverter}}" IsHitTestVisible="False" />
|
||||||
|
<ToggleButton Style="{StaticResource SolenoidControlToggleButtonStyle}" IsChecked="{Binding DILinkPoint.Value, Converter={StaticResource IntToBoolConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="16" Height="16"/>
|
||||||
<TextBlock Text="{Binding Text}" RenderTransformOrigin="0.5,1" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="2">
|
<TextBlock Text="{Binding Text}" RenderTransformOrigin="0.5,1" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="2">
|
||||||
<TextBlock.RenderTransform>
|
<TextBlock.RenderTransform>
|
||||||
<TranslateTransform Y="16"/>
|
<TranslateTransform Y="16"/>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Util.DiagramDesigner;
|
using Util.DiagramDesigner;
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
public class Simulate_SolenoidViewModel : SFCNode
|
public class Simulate_SolenoidViewModel : SFCNode
|
||||||
{
|
{
|
||||||
|
private IDisposable diChangedSubscription;
|
||||||
public Simulate_SolenoidViewModel() : base(SFCNodeKinds.Simulate_Solenoid)
|
public Simulate_SolenoidViewModel() : base(SFCNodeKinds.Simulate_Solenoid)
|
||||||
{
|
{
|
||||||
ItemWidth = 32;
|
ItemWidth = 32;
|
||||||
@@ -21,6 +23,17 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Init()
|
||||||
|
{
|
||||||
|
base.Init();
|
||||||
|
if (diChangedSubscription != null)
|
||||||
|
{
|
||||||
|
diChangedSubscription.Dispose();
|
||||||
|
}
|
||||||
|
Random random = new Random();
|
||||||
|
diChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Value").Throttle(TimeSpan.FromSeconds(random.Next(1,10))).Subscribe(OnValueChanged);//Sample
|
||||||
|
}
|
||||||
|
|
||||||
private bool _showText;
|
private bool _showText;
|
||||||
public override bool ShowText
|
public override bool ShowText
|
||||||
{
|
{
|
||||||
@@ -64,11 +77,19 @@ namespace AIStudio.Wpf.SFC.ViewModels
|
|||||||
{
|
{
|
||||||
if (DOLinkPoint != null)
|
if (DOLinkPoint != null)
|
||||||
{
|
{
|
||||||
DOLinkPoint.Value = DILinkPoint.Value;
|
Value = DILinkPoint.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnValueChanged(string propertyName)
|
||||||
|
{
|
||||||
|
if (DOLinkPoint != null)
|
||||||
|
{
|
||||||
|
DOLinkPoint.Value = Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 反馈
|
/// 反馈
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -130,6 +131,18 @@ namespace Util.DiagramDesigner
|
|||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, args);
|
PropertyChanged?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IObservable<string> WhenPropertyChanged
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Observable
|
||||||
|
.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>(
|
||||||
|
h => this.PropertyChanged += h,
|
||||||
|
h => this.PropertyChanged -= h)
|
||||||
|
.Select(x => x.EventArgs.PropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ValuePropertyChangedEventArgs : PropertyChangedEventArgs
|
public class ValuePropertyChangedEventArgs : PropertyChangedEventArgs
|
||||||
|
|||||||
Reference in New Issue
Block a user