首次上传

This commit is contained in:
hanqiangqiang
2026-06-15 10:56:30 +08:00
commit b0213b94d6
4160 changed files with 736101 additions and 0 deletions
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace MECF.Framework.UI.Client.IndustrialControl.Converters
{
[ValueConversion(typeof(double), typeof(string))]
class Double2StringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return "-";
double dVal = (double)value;
if (parameter == null || string.IsNullOrEmpty(parameter.ToString()))
return dVal == Double.NaN ? "-" : string.Format("{0:F1}", dVal);
else
return dVal == Double.NaN ? "-" : string.Format("{0:" + parameter.ToString() + "}", dVal);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace MECF.Framework.UI.Client.IndustrialControl.Converters
{
public class MultiplesValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter == null)
{
return value;
}
else
{
return System.Convert.ToDouble(value) * System.Convert.ToDouble(parameter);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace MECF.Framework.UI.Client.IndustrialControl.Converters
{
public class VisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (parameter == null)
{
if (System.Convert.ToBoolean(value)) return Visibility.Visible;
else return Visibility.Hidden;
}
else
{
if (System.Convert.ToBoolean(value)) return Visibility.Hidden;
else return Visibility.Visible;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}
@@ -0,0 +1,88 @@
<UserControl
x:Class="MECF.Framework.UI.Client.IndustrialControl.PipeLine"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MECF.Framework.UI.Client.IndustrialControl.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.IndustrialControl"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="489"
Height="95"
mc:Ignorable="d">
<UserControl.Resources>
<converters:MultiplesValueConverter x:Key="multiConverter" />
<converters:VisibilityConverter x:Key="visibilityConverter" />
</UserControl.Resources>
<Grid>
<Grid x:Name="grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Canvas
x:Name="canvas1"
Grid.Column="0"
Width="{Binding ElementName=grid1, Path=ActualHeight}"
Height="{Binding ElementName=grid1, Path=ActualHeight}"
ClipToBounds="True">
<Ellipse
x:Name="ellipe1"
Grid.Column="0"
Canvas.Left="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=0}"
Canvas.Top="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=0}"
Width="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=2}"
Height="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=2}"
Margin="0,0,0,0">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
<GradientStop Offset="0" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=EdgeColor}" />
<GradientStop Offset="0.5" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=CenterColor}" />
<GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=EdgeColor}" />
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Canvas>
<Canvas
x:Name="canvas2"
Grid.Column="2"
Width="{Binding ElementName=grid1, Path=ActualHeight}"
Height="{Binding ElementName=grid1, Path=ActualHeight}"
ClipToBounds="True">
<Ellipse
x:Name="ellipe2"
Canvas.Left="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=-1}"
Canvas.Top="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=-1}"
Width="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=2}"
Height="{Binding ElementName=grid1, Path=ActualHeight, Converter={StaticResource multiConverter}, ConverterParameter=2}">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
<GradientStop Offset="0" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=EdgeColor}" />
<GradientStop Offset="0.5" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=CenterColor}" />
<GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=EdgeColor}" />
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Canvas>
<Rectangle Grid.Column="1" Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=EdgeColor}" />
<GradientStop Offset="0.5" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=CenterColor}" />
<GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=EdgeColor}" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
<Path
x:Name="path1"
StrokeDashArray="5,5"
StrokeDashOffset="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=LineOffect}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=PipeLineWidth}"
Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=PipeLineActive, Converter={StaticResource visibilityConverter}}">
<Path.Stroke>
<SolidColorBrush Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLine}}, Path=ActiveLineCenterColor}" />
</Path.Stroke>
</Path>
</Grid>
</UserControl>
@@ -0,0 +1,388 @@
using System;
using System.Collections.Generic;
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;
using System.Windows.Media.Animation;
using MECF.Framework.UI.Client.IndustrialControl.Converters;
namespace MECF.Framework.UI.Client.IndustrialControl
{
/// <summary>
/// HslPipeLine.xaml 的交互逻辑
/// </summary>
public partial class PipeLine : UserControl
{
#region Contructor
/// <summary>
/// 实例化一个管道对象
/// </summary>
public PipeLine( )
{
InitializeComponent( );
//Binding binding = new Binding( );
//binding.Source = grid1;
//binding.Path = new PropertyPath( "ActualHeight" );
//binding.Converter = new MultiplesValueConverter( );
//binding.ConverterParameter = -1;
//ellipe1.SetBinding( Canvas.TopProperty, binding );
offectDoubleAnimation = new DoubleAnimation( 0, 10, TimeSpan.FromMilliseconds( 1000 ) );
offectDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
private DoubleAnimation offectDoubleAnimation = null;
#endregion
#region Property Dependency
#region LeftDirection Property
/// <summary>
/// 设置左边的方向
/// </summary>
public HslPipeTurnDirection LeftDirection
{
get { return (HslPipeTurnDirection)GetValue( LeftDirectionProperty ); }
set { SetValue( LeftDirectionProperty, value ); }
}
// Using a DependencyProperty as the backing store for LeftDirection. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LeftDirectionProperty =
DependencyProperty.Register( "LeftDirection", typeof( HslPipeTurnDirection ), typeof(PipeLine),
new PropertyMetadata( HslPipeTurnDirection.Left, new PropertyChangedCallback( LeftDirectionPropertyChangedCallback ) ) );
public static void LeftDirectionPropertyChangedCallback( System.Windows.DependencyObject dependency, System.Windows.DependencyPropertyChangedEventArgs e )
{
PipeLine pipeLine = (PipeLine)dependency;
pipeLine.UpdateLeftDirectionBinding( );
}
public void UpdateLeftDirectionBinding( )
{
BindingOperations.ClearBinding( ellipe1, Canvas.TopProperty );
if(LeftDirection == HslPipeTurnDirection.Left)
{
canvas1.Visibility = Visibility.Visible;
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = 0;
ellipe1.SetBinding( Canvas.TopProperty, binding );
}
else if (LeftDirection == HslPipeTurnDirection.Right)
{
canvas1.Visibility = Visibility.Visible;
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = -1;
ellipe1.SetBinding( Canvas.TopProperty, binding );
}
else
{
canvas1.Visibility = Visibility.Collapsed;
}
UpdatePathData( );
}
#endregion
#region RightDirection Property
/// <summary>
/// 设置右边的方向
/// </summary>
public HslPipeTurnDirection RightDirection
{
get { return (HslPipeTurnDirection)GetValue( RightDirectionProperty ); }
set { SetValue( RightDirectionProperty, value ); }
}
// Using a DependencyProperty as the backing store for LeftDirection. This enables animation, styling, binding, etc...
public static readonly DependencyProperty RightDirectionProperty =
DependencyProperty.Register( "RightDirection", typeof( HslPipeTurnDirection ), typeof( PipeLine ),
new PropertyMetadata( HslPipeTurnDirection.Right, new PropertyChangedCallback( RightDirectionPropertyChangedCallback ) ) );
public static void RightDirectionPropertyChangedCallback( System.Windows.DependencyObject dependency, System.Windows.DependencyPropertyChangedEventArgs e )
{
PipeLine pipeLine = (PipeLine)dependency;
pipeLine.UpdateRightDirectionBinding( );
}
public void UpdateRightDirectionBinding( )
{
BindingOperations.ClearBinding( ellipe2, Canvas.TopProperty );
if (RightDirection == HslPipeTurnDirection.Left)
{
canvas2.Visibility = Visibility.Visible;
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = 0;
ellipe2.SetBinding( Canvas.TopProperty, binding );
}
else if (RightDirection == HslPipeTurnDirection.Right)
{
canvas2.Visibility = Visibility.Visible;
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = -1;
ellipe2.SetBinding( Canvas.TopProperty, binding );
}
else
{
canvas2.Visibility = Visibility.Collapsed;
}
UpdatePathData( );
}
#endregion
#region PipeLineActive Property
public bool PipeLineActive
{
get { return (bool)GetValue( PipeLineActiveProperty ); }
set { SetValue( PipeLineActiveProperty, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineActive. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineActiveProperty =
DependencyProperty.Register( "PipeLineActive", typeof( bool ), typeof(PipeLine), new PropertyMetadata( false ) );
#endregion
protected override void OnRenderSizeChanged( SizeChangedInfo sizeInfo )
{
UpdatePathData( );
base.OnRenderSizeChanged( sizeInfo );
}
#region LineOffect Property
public double LineOffect
{
get { return (double)GetValue( LineOffectProperty ); }
set { SetValue( LineOffectProperty, value ); }
}
// Using a DependencyProperty as the backing store for LineOffect. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LineOffectProperty =
DependencyProperty.Register( "LineOffect", typeof( double ), typeof( PipeLine ), new PropertyMetadata( 0d ) );
public void UpdatePathData( )
{
//Console.WriteLine( "Size Changed" );
var g = new StreamGeometry( );
using (StreamGeometryContext context = g.Open( ))
{
if (LeftDirection == HslPipeTurnDirection.Left)
{
context.BeginFigure( new Point( ActualHeight / 2, ActualHeight ), false, false );
context.ArcTo( new Point( ActualHeight, ActualHeight / 2 ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Clockwise, true, false );
}
else if (LeftDirection == HslPipeTurnDirection.Right)
{
context.BeginFigure( new Point( ActualHeight / 2, 0 ), false, false );
context.ArcTo( new Point( ActualHeight, ActualHeight / 2 ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Counterclockwise, true, false );
}
else
{
context.BeginFigure( new Point( 0, ActualHeight / 2 ), false, false );
context.LineTo( new Point( ActualHeight, ActualHeight / 2 ), true, false );
}
context.LineTo( new Point( ActualWidth - ActualHeight, ActualHeight / 2 ), true, false );
if (RightDirection == HslPipeTurnDirection.Left)
{
context.ArcTo( new Point( ActualWidth - ActualHeight / 2, ActualHeight ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Clockwise, true, false );
}
else if (RightDirection == HslPipeTurnDirection.Right)
{
context.ArcTo( new Point( ActualWidth - ActualHeight / 2, 0 ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Counterclockwise, true, false );
}
else
{
context.LineTo( new Point( ActualWidth, ActualHeight / 2 ), true, false );
}
}
path1.Data = g;
}
#endregion
#region MoveSpeed Property
/// <summary>
/// 获取或设置流动的速度
/// </summary>
public double MoveSpeed
{
get { return (double)GetValue( MoveSpeedProperty ); }
set { SetValue( MoveSpeedProperty, value ); }
}
// Using a DependencyProperty as the backing store for MoveSpeed. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MoveSpeedProperty =
DependencyProperty.Register( "MoveSpeed", typeof( double ), typeof(PipeLine), new PropertyMetadata( 0.3d, new PropertyChangedCallback( MoveSpeedPropertyChangedCallback ) ) );
public static void MoveSpeedPropertyChangedCallback( DependencyObject dependency, DependencyPropertyChangedEventArgs e )
{
PipeLine pipeLine = (PipeLine)dependency;
pipeLine.UpdateMoveSpeed( );
}
private Storyboard storyboard = new Storyboard( );
public void UpdateMoveSpeed( )
{
if (MoveSpeed > 0)
{
path1.Visibility = Visibility.Visible;
offectDoubleAnimation.From = 0d;
offectDoubleAnimation.To = 10d;
offectDoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / MoveSpeed );
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
else if (MoveSpeed < 0)
{
path1.Visibility = Visibility.Visible;
offectDoubleAnimation.From = 0d;
offectDoubleAnimation.To = -10d;
offectDoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / Math.Abs( MoveSpeed ) );
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
else
{
offectDoubleAnimation.From = 0d;
offectDoubleAnimation.To = 0d;
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
path1.Visibility = Visibility.Hidden;
}
}
#endregion
#region CenterColor Property
/// <summary>
/// 管道的中心颜色
/// </summary>
public Color CenterColor
{
get { return (Color)GetValue( CenterColorProperty ); }
set { SetValue( CenterColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for CenterColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CenterColorProperty =
DependencyProperty.Register( "CenterColor", typeof( Color ), typeof(PipeLine), new PropertyMetadata( Colors.LightGray ) );
#endregion
#region PipeLineWidth Property
/// <summary>
/// 管道活动状态时的中心线的线条宽度
/// </summary>
public int PipeLineWidth
{
get { return (int)GetValue( PipeLineWidthProperty ); }
set { SetValue( PipeLineWidthProperty, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineWidth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineWidthProperty =
DependencyProperty.Register( "PipeLineWidth", typeof( int ), typeof(PipeLine), new PropertyMetadata( 2 ) );
#endregion
#region ActiveLineCenterColor Property
/// <summary>
/// 管道活动状态时的中心线的颜色信息
/// </summary>
public Color ActiveLineCenterColor
{
get { return (Color)GetValue( ActiveLineCenterColorProperty ); }
set { SetValue( ActiveLineCenterColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for ActiveLineCenterColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ActiveLineCenterColorProperty =
DependencyProperty.Register( "ActiveLineCenterColor", typeof( Color ), typeof(PipeLine), new PropertyMetadata( Colors.DodgerBlue ) );
#endregion
#region MyRegion
/// <summary>
/// 管道控件的边缘颜色
/// </summary>
public Color EdgeColor
{
get { return (Color)GetValue( EdgeColorProperty ); }
set { SetValue( EdgeColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for EdgeColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty EdgeColorProperty =
DependencyProperty.Register( "EdgeColor", typeof( Color ), typeof(PipeLine), new PropertyMetadata( Colors.DimGray ) );
#endregion
#endregion
}
/// <summary>
/// 管道线的端点朝向
/// </summary>
public enum HslPipeTurnDirection
{
/// <summary>
/// 向上
/// </summary>
Up = 1,
/// <summary>
/// 向下
/// </summary>
Down = 2,
/// <summary>
/// 向左
/// </summary>
Left = 3,
/// <summary>
/// 向右
/// </summary>
Right = 4,
/// <summary>
/// 无效果
/// </summary>
None = 5,
}
}
@@ -0,0 +1,162 @@
<UserControl x:Class="MECF.Framework.UI.Client.IndustrialControl.PipeLineKnot"
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:MECF.Framework.UI.Client.IndustrialControl" xmlns:converters="clr-namespace:MECF.Framework.UI.Client.IndustrialControl.Converters"
mc:Ignorable="d" Height="50" Width="140">
<UserControl.Resources>
<converters:MultiplesValueConverter x:Key="multiConverter"></converters:MultiplesValueConverter>
<converters:VisibilityConverter x:Key="visibilityConverter"></converters:VisibilityConverter>
</UserControl.Resources>
<Grid>
<Grid>
<Grid x:Name="grid1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.2}"/>
<ColumnDefinition Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=2}"/>
<ColumnDefinition Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.2}"/>
</Grid.ColumnDefinitions>
<Canvas x:Name="canvas1" Grid.Column="1" Height="{Binding ElementName=grid1,Path=ActualHeight}" Panel.ZIndex="1" ClipToBounds="True">
<!--<Rectangle
Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=2}"
Height="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=1}"
Fill="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path= ThroughInnerColor}"
Stretch="Fill">
</Rectangle>-->
<Ellipse x:Name="ellipe1" Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=2}"
Height="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=2}" Margin="0,0,0,0"
Canvas.Left="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0}"
Canvas.Top="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0}" StrokeThickness="20">
<Ellipse.Fill>
<RadialGradientBrush RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.5,0.5">
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="Transparent" Offset="0.5"/>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.75"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Canvas>
<Canvas x:Name="canvas0" Grid.Column="0" Grid.ColumnSpan="2" Height="{Binding ElementName=grid1,Path=ActualHeight}" Panel.ZIndex="2" ClipToBounds="True" >
<!--<Rectangle HorizontalAlignment="Left"
Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.7}"
Height="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.4}"
Canvas.Top="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.6}"
Canvas.Left="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0}"
Stretch="Fill" VerticalAlignment="Bottom">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>-->
<Polygon x:Name="polygon1" Points="0,30 0,50 40,50 20,30">
<Polygon.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</LinearGradientBrush>
</Polygon.Fill>
</Polygon>
</Canvas>
<Canvas x:Name="canvas2" Grid.Column="1" Grid.ColumnSpan="2" Height="{Binding ElementName=grid1,Path=ActualHeight}" Panel.ZIndex="3"
ClipToBounds="True">
<Polygon x:Name="polygon2" Points="20,30 0,50 40,50 40,30">
<Polygon.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</LinearGradientBrush>
</Polygon.Fill>
</Polygon>
<!--<Rectangle HorizontalAlignment="Left"
Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.7}"
Height="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.4}"
Canvas.Top="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.6}"
Canvas.Left="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=1.6}"
Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>-->
</Canvas>
<!--<Canvas x:Name="canvas1" Height="{Binding ElementName=grid1,Path=ActualHeight}" ClipToBounds="True">
<Ellipse x:Name="ellipe1" Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=2}"
Height="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=2}" Margin="0,0,0,0"
Canvas.Left="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0}"
Canvas.Top="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0}">
<Ellipse.Fill>
<RadialGradientBrush RadiusX="0.5" RadiusY="0.5" GradientOrigin="0.5,0.5">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Canvas>-->
<!--"M 845,279.985C 931.658,279.985 1018.34,279.985 1105,279.985C 1105,299.983 1105,319.987 1105,339.985C 1028.01,339.985 950.992,339.985 874,339.985C 848.163,339.985 800.702,346.404 784,334.985C 781.812,178.668 732.256,94.5063 596,68.9849C 560.374,62.3121 512.668,64.0407 480,72.9849C 449.745,81.2685 422.874,94.0963 401,110.985C 359.798,142.796 336.036,193.961 323,253.985C 318.45,274.936 323.166,324.932 313,339.985C 208.677,339.985 104.323,339.985 0,339.985C 0,319.987 0,299.983 0,279.985C 86.3247,279.985 172.675,279.985 259,279.985C 258.786,238.704 275.928,201.062 289,170.985C 339.73,54.2648 477.485,-40.0917 653,16.9849C 741.485,45.7598 792.051,111.087 825,195.985C 834.218,219.737 844.7,248.709 845,279.985 Z"-->
<!--<Canvas x:Name="canvas1" Height="{Binding ElementName=grid1,Path=ActualHeight}" ClipToBounds="True">
<Path Data="M 940.501,475.001C 940.501,477.335 -164.499,477.335 -164.499,475.001C -93.5065,475.001 -22.4923,475.001 48.5006,475.001C 62.926,475.002 113.357,478.137 118.501,471.001C 119.167,462.336 119.834,453.667 120.501,445.001C 124.167,426.003 127.834,407 131.501,388.001C 150.136,325.703 182.058,274.512 229.501,241.001C 253.792,223.843 284.618,212.15 317.501,204.001C 336.832,202.002 356.169,200.001 375.501,198.001C 528.987,197.863 604.716,267.379 640.501,384.001C 649.058,411.89 650.279,443.097 656.5,474.001C 751.158,474.335 845.843,474.668 940.501,475.001 Z"
Stretch="Fill" StrokeThickness="10" x:Name="pathThrough"
Width="250.532"
Height="85" Canvas.Left="1.234" Canvas.Top="10">
<Path.Stroke>
<LinearGradientBrush StartPoint="0.4,0.9" EndPoint="0.4,1">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=EdgeColor}" Offset="1"></GradientStop>
</LinearGradientBrush>
</Path.Stroke>
</Path>
</Canvas>-->
<!--" "-->
<!--
<Rectangle Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=EdgeColor}" Offset="0"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=CenterColor}" Offset="0.5"></GradientStop>
<GradientStop Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=EdgeColor}" Offset="1"></GradientStop>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>-->
</Grid>
<Path x:Name="path1"
Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=PipeLineActive,Converter={StaticResource visibilityConverter}}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=PipeLineWidth}"
StrokeDashOffset="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=LineOffect}" StrokeDashArray="5,5"
Height="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=0.6}"
Width="{Binding ElementName=grid1,Path=ActualHeight,Converter={StaticResource multiConverter},ConverterParameter=4}"
Stretch="Fill">
<Path.Stroke>
<SolidColorBrush Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLineKnot}},Path=ActiveLineCenterColor}"></SolidColorBrush>
</Path.Stroke>
</Path>
</Grid>
</Grid>
<!--<Path x:Name="path1"
Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=PipeLineActive,Converter={StaticResource visibilityConverter}}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=PipeLineWidth}"
StrokeDashOffset="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=LineOffect}" StrokeDashArray="5,5">
<Path.Stroke>
<SolidColorBrush Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:PipeLine}},Path=ActiveLineCenterColor}"></SolidColorBrush>
</Path.Stroke>
</Path>-->
</UserControl>
@@ -0,0 +1,414 @@
using System;
using System.Collections.Generic;
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;
using System.Windows.Media.Animation;
using MECF.Framework.UI.Client.IndustrialControl.Converters;
namespace MECF.Framework.UI.Client.IndustrialControl
{
/// <summary>
/// HslPipeLine.xaml 的交互逻辑
/// </summary>
public partial class PipeLineKnot: UserControl
{
#region Contructor
/// <summary>
/// 实例化一个管道对象
/// </summary>
public PipeLineKnot( )
{
InitializeComponent( );
//Binding binding = new Binding();
//binding.Source = grid1;
//binding.Path = new PropertyPath("ActualHeight");
//binding.Converter = new MultiplesValueConverter();
//binding.ConverterParameter = -1;
//ellipe1.SetBinding( Canvas.TopProperty, binding );
offectDoubleAnimation = new DoubleAnimation( 0, 10, TimeSpan.FromMilliseconds( 1000 ) );
offectDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
private DoubleAnimation offectDoubleAnimation = null;
#endregion
#region Property Dependency
#region LeftDirection Property
/// <summary>
/// 设置左边的方向
/// </summary>
public HslPipeTurnDirection LeftDirection
{
get { return (HslPipeTurnDirection)GetValue( LeftDirectionProperty ); }
set { SetValue( LeftDirectionProperty, value ); }
}
// Using a DependencyProperty as the backing store for LeftDirection. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LeftDirectionProperty =
DependencyProperty.Register( "LeftDirection", typeof( HslPipeTurnDirection ), typeof(PipeLineKnot),
new PropertyMetadata( HslPipeTurnDirection.Left, new PropertyChangedCallback( LeftDirectionPropertyChangedCallback ) ) );
/// <summary>
/// Description
/// </summary>
public static readonly DependencyProperty ThroughInnerColorProperty =
DependencyProperty.Register("ThroughInnerColor",
typeof(string),
typeof(PipeLineKnot),
new FrameworkPropertyMetadata("White"));
/// <summary>
/// A property wrapper for the <see cref="BalloonTextProperty"/>
/// dependency property:<br/>
/// Description
/// </summary>
public string ThroughInnerColor
{
get { return (string)GetValue(ThroughInnerColorProperty); }
set { SetValue(ThroughInnerColorProperty, value); }
}
public static void LeftDirectionPropertyChangedCallback( System.Windows.DependencyObject dependency, System.Windows.DependencyPropertyChangedEventArgs e )
{
PipeLine pipeLine = (PipeLine)dependency;
pipeLine.UpdateLeftDirectionBinding( );
}
public void UpdateLeftDirectionBinding( )
{
if(LeftDirection == HslPipeTurnDirection.Left)
{
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = 0;
}
else if (LeftDirection == HslPipeTurnDirection.Right)
{
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = -1;
}
else
{
}
UpdatePathData( );
}
public void UpdatePath()
{
polygon1.Points = new PointCollection(new Point[]
{
new Point(0, ActualHeight*0.6),
new Point(0, ActualHeight),
new Point( ActualHeight*0.7, ActualHeight),
new Point( ActualHeight *0.3, ActualHeight*0.6),
});
polygon2.Points = new PointCollection(new Point[]
{
new Point(ActualHeight*1.9, ActualHeight*0.6),
new Point(ActualHeight*1.5, ActualHeight),
new Point( ActualHeight*2.2, ActualHeight),
new Point( ActualHeight*2.2 , ActualHeight*0.6),
});
}
#endregion
#region RightDirection Property
/// <summary>
/// 设置右边的方向
/// </summary>
public HslPipeTurnDirection RightDirection
{
get { return (HslPipeTurnDirection)GetValue( RightDirectionProperty ); }
set { SetValue( RightDirectionProperty, value ); }
}
// Using a DependencyProperty as the backing store for LeftDirection. This enables animation, styling, binding, etc...
public static readonly DependencyProperty RightDirectionProperty =
DependencyProperty.Register( "RightDirection", typeof( HslPipeTurnDirection ), typeof(PipeLineKnot),
new PropertyMetadata( HslPipeTurnDirection.Right, new PropertyChangedCallback( RightDirectionPropertyChangedCallback ) ) );
public static void RightDirectionPropertyChangedCallback( System.Windows.DependencyObject dependency, System.Windows.DependencyPropertyChangedEventArgs e )
{
PipeLine pipeLine = (PipeLine)dependency;
pipeLine.UpdateRightDirectionBinding( );
}
public void UpdateRightDirectionBinding( )
{
if (RightDirection == HslPipeTurnDirection.Left)
{
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = 0;
}
else if (RightDirection == HslPipeTurnDirection.Right)
{
Binding binding = new Binding( );
binding.Source = grid1;
binding.Path = new PropertyPath( "ActualHeight" );
binding.Converter = new MultiplesValueConverter( );
binding.ConverterParameter = -1;
}
else
{
}
UpdatePathData( );
}
#endregion
#region PipeLineActive Property
public bool PipeLineActive
{
get { return (bool)GetValue( PipeLineActiveProperty ); }
set { SetValue( PipeLineActiveProperty, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineActive. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineActiveProperty =
DependencyProperty.Register( "PipeLineActive", typeof( bool ), typeof(PipeLineKnot), new PropertyMetadata( false ) );
#endregion
protected override void OnRenderSizeChanged( SizeChangedInfo sizeInfo )
{
UpdatePath();
UpdatePathData( );
base.OnRenderSizeChanged( sizeInfo );
}
#region LineOffect Property
public double LineOffect
{
get { return (double)GetValue( LineOffectProperty ); }
set { SetValue( LineOffectProperty, value ); }
}
// Using a DependencyProperty as the backing store for LineOffect. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LineOffectProperty =
DependencyProperty.Register( "LineOffect", typeof( double ), typeof(PipeLineKnot), new PropertyMetadata( 0d ) );
public void UpdatePathData()
{
//Console.WriteLine("Size Changed");
var g = new StreamGeometry();
using (StreamGeometryContext context = g.Open())
{
context.BeginFigure(new Point(0, ActualHeight * 0.6), false, false);
context.LineTo(new Point(ActualHeight * 0.3, ActualHeight * 0.6), true, false);
context.ArcTo(new Point(ActualHeight * 1.2, ActualHeight * 0.6), new Size(ActualHeight / 5, ActualHeight / 5), 180, false, SweepDirection.Clockwise, true, false);
context.LineTo(new Point(ActualHeight * 2.5, ActualHeight * 0.6), true, false);
//if (LeftDirection == HslPipeTurnDirection.Left)
//{
// context.BeginFigure( new Point( ActualHeight / 2, ActualHeight ), false, false );
// context.ArcTo( new Point( ActualHeight, ActualHeight / 2 ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Clockwise, true, false );
//}
//else if (LeftDirection == HslPipeTurnDirection.Right)
//{
// context.BeginFigure( new Point( ActualHeight / 2, 0 ), false, false );
// context.ArcTo( new Point( ActualHeight, ActualHeight / 2 ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Counterclockwise, true, false );
//}
//else
//{
// context.BeginFigure( new Point( 0, ActualHeight / 2 ), false, false );
// context.LineTo( new Point( ActualHeight, ActualHeight / 2 ), true, false );
//}
//context.LineTo( new Point( ActualWidth - ActualHeight, ActualHeight / 2 ), true, false );
//if (RightDirection == HslPipeTurnDirection.Left)
//{
// context.ArcTo( new Point( ActualWidth - ActualHeight / 2, ActualHeight ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Clockwise, true, false );
//}
//else if (RightDirection == HslPipeTurnDirection.Right)
//{
// context.ArcTo( new Point( ActualWidth - ActualHeight / 2, 0 ), new Size( ActualHeight / 2, ActualHeight / 2 ), 0, false, SweepDirection.Counterclockwise, true, false );
//}
//else
//{
// context.LineTo( new Point( ActualWidth, ActualHeight / 2 ), true, false );
//}
}
path1.Data = g;
}
#endregion
#region MoveSpeed Property
/// <summary>
/// 获取或设置流动的速度
/// </summary>
public double MoveSpeed
{
get { return (double)GetValue( MoveSpeedProperty ); }
set { SetValue( MoveSpeedProperty, value ); }
}
// Using a DependencyProperty as the backing store for MoveSpeed. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MoveSpeedProperty =
DependencyProperty.Register( "MoveSpeed", typeof( double ), typeof(PipeLineKnot), new PropertyMetadata( 0.3d, new PropertyChangedCallback( MoveSpeedPropertyChangedCallback ) ) );
public static void MoveSpeedPropertyChangedCallback( DependencyObject dependency, DependencyPropertyChangedEventArgs e )
{
PipeLineKnot pipeLine = (PipeLineKnot)dependency;
pipeLine.UpdateMoveSpeed( );
}
private Storyboard storyboard = new Storyboard( );
public void UpdateMoveSpeed( )
{
if (MoveSpeed > 0)
{
offectDoubleAnimation.From = 0d;
offectDoubleAnimation.To = 10d;
offectDoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / MoveSpeed );
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
else if (MoveSpeed < 0)
{
offectDoubleAnimation.From = 0d;
offectDoubleAnimation.To = -10d;
offectDoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / Math.Abs( MoveSpeed ) );
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
else
{
offectDoubleAnimation.From = 0d;
offectDoubleAnimation.To = 0d;
BeginAnimation( LineOffectProperty, offectDoubleAnimation );
}
}
#endregion
#region CenterColor Property
/// <summary>
/// 管道的中心颜色
/// </summary>
public Color CenterColor
{
get { return (Color)GetValue( CenterColorProperty ); }
set { SetValue( CenterColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for CenterColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CenterColorProperty =
DependencyProperty.Register( "CenterColor", typeof( Color ), typeof(PipeLineKnot), new PropertyMetadata( Colors.LightGray ) );
#endregion
#region PipeLineWidth Property
/// <summary>
/// 管道活动状态时的中心线的线条宽度
/// </summary>
public int PipeLineWidth
{
get { return (int)GetValue( PipeLineWidthProperty ); }
set { SetValue( PipeLineWidthProperty, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineWidth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineWidthProperty =
DependencyProperty.Register( "PipeLineWidth", typeof( int ), typeof(PipeLineKnot), new PropertyMetadata( 2 ) );
#endregion
#region ActiveLineCenterColor Property
/// <summary>
/// 管道活动状态时的中心线的颜色信息
/// </summary>
public Color ActiveLineCenterColor
{
get { return (Color)GetValue( ActiveLineCenterColorProperty ); }
set { SetValue( ActiveLineCenterColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for ActiveLineCenterColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ActiveLineCenterColorProperty =
DependencyProperty.Register( "ActiveLineCenterColor", typeof( Color ), typeof(PipeLineKnot), new PropertyMetadata( Colors.DodgerBlue ) );
#endregion
#region MyRegion
/// <summary>
/// 管道控件的边缘颜色
/// </summary>
public Color EdgeColor
{
get { return (Color)GetValue( EdgeColorProperty ); }
set { SetValue( EdgeColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for EdgeColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty EdgeColorProperty =
DependencyProperty.Register( "EdgeColor", typeof( Color ), typeof(PipeLineKnot), new PropertyMetadata( Colors.DimGray ) );
public static readonly DependencyProperty KnotElliColorProperty =
DependencyProperty.Register("KnotElliColor",
typeof(string),
typeof(PipeLineKnot),
new FrameworkPropertyMetadata("Black"));
/// <summary>
/// A property wrapper for the <see cref="BalloonTextProperty"/>
/// dependency property:<br/>
/// Description
/// </summary>
public string KnotElliColor
{
get { return (string)GetValue(KnotElliColorProperty); }
set { SetValue(KnotElliColorProperty, value); }
}
#endregion
#endregion
}
}
@@ -0,0 +1,69 @@
<UserControl
x:Class="MECF.Framework.UI.Client.IndustrialControl.PipeLineThree"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:MECF.Framework.UI.Client.IndustrialControl.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.IndustrialControl"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="200"
d:DesignWidth="300"
mc:Ignorable="d">
<UserControl.Resources>
<converters:VisibilityConverter x:Key="visibilityConverter" />
</UserControl.Resources>
<Canvas x:Name="canvas1">
<Rectangle
Width="{Binding ElementName=canvas1, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeWidth}"
Stretch="Fill">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=EdgeColor}" />
<GradientStop Offset="0.5" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=CenterColor}" />
<GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=EdgeColor}" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Polygon x:Name="polygon1" Points="130,40 150,20 170,40 170,200 130,200 130, 40">
<Polygon.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Offset="0" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=EdgeColor}" />
<GradientStop Offset="0.5" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=CenterColor}" />
<GradientStop Offset="1" Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=EdgeColor}" />
</LinearGradientBrush>
</Polygon.Fill>
</Polygon>
<Path
x:Name="path1"
StrokeDashArray="5,5"
StrokeDashOffset="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=LineOffect1}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeLineWidth}"
Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeLineActive1, Converter={StaticResource visibilityConverter}}">
<Path.Stroke>
<SolidColorBrush Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=ActiveLineCenterColor}" />
</Path.Stroke>
</Path>
<Path
x:Name="path2"
StrokeDashArray="5,5"
StrokeDashOffset="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=LineOffect2}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeLineWidth}"
Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeLineActive2, Converter={StaticResource visibilityConverter}}">
<Path.Stroke>
<SolidColorBrush Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=ActiveLineCenterColor}" />
</Path.Stroke>
</Path>
<Path
x:Name="path3"
StrokeDashArray="5,5"
StrokeDashOffset="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=LineOffect3}"
StrokeThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeLineWidth}"
Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=PipeLineActive3, Converter={StaticResource visibilityConverter}}">
<Path.Stroke>
<SolidColorBrush Color="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:PipeLineThree}}, Path=ActiveLineCenterColor}" />
</Path.Stroke>
</Path>
</Canvas>
</UserControl>
@@ -0,0 +1,404 @@
using System;
using System.Collections.Generic;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MECF.Framework.UI.Client.IndustrialControl
{
/// <summary>
/// HslPipeLineThree.xaml 的交互逻辑
/// </summary>
public partial class PipeLineThree : UserControl
{
public PipeLineThree( )
{
InitializeComponent( );
offect1DoubleAnimation = new DoubleAnimation( 0, 10, TimeSpan.FromMilliseconds( 1000 ) );
offect1DoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
BeginAnimation( LineOffect1Property, offect1DoubleAnimation );
offect2DoubleAnimation = new DoubleAnimation( 0, 10, TimeSpan.FromMilliseconds( 1000 ) );
offect2DoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
BeginAnimation( LineOffect2Property, offect2DoubleAnimation );
offect3DoubleAnimation = new DoubleAnimation( 0, 10, TimeSpan.FromMilliseconds( 1000 ) );
offect3DoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
BeginAnimation( LineOffect3Property, offect3DoubleAnimation );
}
/// <summary>
/// 获取或设置管道控件的边缘颜色
/// </summary>
public Color EdgeColor
{
get { return (Color)GetValue( EdgeColorProperty ); }
set { SetValue( EdgeColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for EdgeColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty EdgeColorProperty =
DependencyProperty.Register( "EdgeColor", typeof( Color ), typeof(PipeLineThree), new PropertyMetadata( Colors.DimGray ) );
/// <summary>
/// 管道的中心颜色
/// </summary>
public Color CenterColor
{
get { return (Color)GetValue( CenterColorProperty ); }
set { SetValue( CenterColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for CenterColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CenterColorProperty =
DependencyProperty.Register( "CenterColor", typeof( Color ), typeof(PipeLineThree), new PropertyMetadata( Colors.LightGray ) );
/// <summary>
/// 获取或设置管道1号线是否激活液体显示
/// </summary>
public bool PipeLineActive1
{
get { return (bool)GetValue( PipeLineActive1Property ); }
set { SetValue( PipeLineActive1Property, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineActive1. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineActive1Property =
DependencyProperty.Register( "PipeLineActive1", typeof( bool ), typeof(PipeLineThree), new PropertyMetadata( false ) );
/// <summary>
/// 获取或设置管道2号线是否激活液体显示
/// </summary>
public bool PipeLineActive2
{
get { return (bool)GetValue( PipeLineActive2Property ); }
set { SetValue( PipeLineActive2Property, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineActive2. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineActive2Property =
DependencyProperty.Register( "PipeLineActive2", typeof( bool ), typeof(PipeLineThree), new PropertyMetadata( false ) );
/// <summary>
/// 获取或设置管道3号线是否激活液体显示
/// </summary>
public bool PipeLineActive3
{
get { return (bool)GetValue( PipeLineActive3Property ); }
set { SetValue( PipeLineActive3Property, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineActive3. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineActive3Property =
DependencyProperty.Register( "PipeLineActive3", typeof( bool ), typeof(PipeLineThree), new PropertyMetadata( false ) );
/// <summary>
/// 获取或设置管道1号线液体流动的速度,0为静止,正数为正向流动,负数为反向流动
/// </summary>
public double MoveSpeed1
{
get { return (double)GetValue( MoveSpeed1Property ); }
set { SetValue( MoveSpeed1Property, value ); }
}
// Using a DependencyProperty as the backing store for MoveSpeed1. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MoveSpeed1Property =
DependencyProperty.Register( "MoveSpeed1", typeof( double ), typeof(PipeLineThree),
new PropertyMetadata( 0d, new PropertyChangedCallback( MoveSpeed1PropertyChangedCallback ) ) );
public static void MoveSpeed1PropertyChangedCallback( DependencyObject dependency, DependencyPropertyChangedEventArgs e )
{
PipeLineThree pipeLine = (PipeLineThree)dependency;
pipeLine.UpdateMoveSpeed1( );
}
private DoubleAnimation offect1DoubleAnimation = null;
public void UpdateMoveSpeed1( )
{
if (MoveSpeed1 > 0)
{
path1.Visibility = Visibility.Visible;
offect1DoubleAnimation.From = 0d;
offect1DoubleAnimation.To = 10d;
offect1DoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / MoveSpeed1 );
BeginAnimation( LineOffect1Property, offect1DoubleAnimation );
}
else if (MoveSpeed1 < 0)
{
path1.Visibility = Visibility.Visible;
offect1DoubleAnimation.From = 0d;
offect1DoubleAnimation.To = -10d;
offect1DoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / Math.Abs( MoveSpeed1 ) );
BeginAnimation( LineOffect1Property, offect1DoubleAnimation );
}
else
{
offect1DoubleAnimation.From = 0d;
offect1DoubleAnimation.To = 0d;
BeginAnimation( LineOffect1Property, offect1DoubleAnimation );
path1.Visibility = Visibility.Hidden;
}
}
/// <summary>
/// 获取或设置管道2号线液体流动的速度,0为静止,正数为正向流动,负数为反向流动
/// </summary>
public double MoveSpeed2
{
get { return (double)GetValue( MoveSpeed2Property ); }
set { SetValue( MoveSpeed2Property, value ); }
}
// Using a DependencyProperty as the backing store for MoveSpeed2. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MoveSpeed2Property =
DependencyProperty.Register( "MoveSpeed2", typeof( double ), typeof(PipeLineThree),
new PropertyMetadata( 0d, new PropertyChangedCallback( MoveSpeed2PropertyChangedCallback ) ) );
public static void MoveSpeed2PropertyChangedCallback( DependencyObject dependency, DependencyPropertyChangedEventArgs e )
{
PipeLineThree pipeLine = (PipeLineThree)dependency;
pipeLine.UpdateMoveSpeed2( );
}
private DoubleAnimation offect2DoubleAnimation = null;
public void UpdateMoveSpeed2( )
{
if (MoveSpeed2 > 0)
{
path2.Visibility = Visibility.Visible;
offect2DoubleAnimation.From = 0d;
offect2DoubleAnimation.To = 10d;
offect2DoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / MoveSpeed2 );
BeginAnimation( LineOffect2Property, offect2DoubleAnimation );
}
else if (MoveSpeed2 < 0)
{
path2.Visibility = Visibility.Visible;
offect2DoubleAnimation.From = 0d;
offect2DoubleAnimation.To = -10d;
offect2DoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / Math.Abs( MoveSpeed2 ) );
BeginAnimation( LineOffect2Property, offect2DoubleAnimation );
}
else
{
offect2DoubleAnimation.From = 0d;
offect2DoubleAnimation.To = 0d;
BeginAnimation( LineOffect2Property, offect2DoubleAnimation );
path2.Visibility = Visibility.Hidden;
}
}
/// <summary>
/// 获取或设置管道3号线液体流动的速度,0为静止,正数为正向流动,负数为反向流动
/// </summary>
public double MoveSpeed3
{
get { return (double)GetValue( MoveSpeed3Property ); }
set { SetValue( MoveSpeed3Property, value ); }
}
// Using a DependencyProperty as the backing store for MoveSpeed3. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MoveSpeed3Property =
DependencyProperty.Register( "MoveSpeed3", typeof( double ), typeof(PipeLineThree),
new PropertyMetadata( 0d, new PropertyChangedCallback( MoveSpeed3PropertyChangedCallback ) ) );
public static void MoveSpeed3PropertyChangedCallback( DependencyObject dependency, DependencyPropertyChangedEventArgs e )
{
PipeLineThree pipeLine = (PipeLineThree)dependency;
pipeLine.UpdateMoveSpeed3( );
}
private DoubleAnimation offect3DoubleAnimation = null;
public void UpdateMoveSpeed3( )
{
if (MoveSpeed3 > 0)
{
path3.Visibility = Visibility.Visible;
offect3DoubleAnimation.From = 0d;
offect3DoubleAnimation.To = 10d;
offect3DoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / MoveSpeed3 );
BeginAnimation( LineOffect3Property, offect3DoubleAnimation );
}
else if (MoveSpeed3 < 0)
{
path3.Visibility = Visibility.Visible;
offect3DoubleAnimation.From = 0d;
offect3DoubleAnimation.To = -10d;
offect3DoubleAnimation.Duration = TimeSpan.FromMilliseconds( 300 / Math.Abs( MoveSpeed3 ) );
BeginAnimation( LineOffect3Property, offect3DoubleAnimation );
}
else
{
offect3DoubleAnimation.From = 0d;
offect3DoubleAnimation.To = 0d;
BeginAnimation( LineOffect3Property, offect3DoubleAnimation );
path3.Visibility = Visibility.Hidden;
}
}
/// <summary>
/// 管道1的偏移
/// </summary>
public double LineOffect1
{
get { return (double)GetValue( LineOffect1Property ); }
set { SetValue( LineOffect1Property, value ); }
}
// Using a DependencyProperty as the backing store for LineOffect1. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LineOffect1Property =
DependencyProperty.Register( "LineOffect1", typeof( double ), typeof(PipeLineThree), new PropertyMetadata( 0d ) );
/// <summary>
/// 管道2的偏移
/// </summary>
public double LineOffect2
{
get { return (double)GetValue( LineOffect2Property ); }
set { SetValue( LineOffect2Property, value ); }
}
// Using a DependencyProperty as the backing store for LineOffect2. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LineOffect2Property =
DependencyProperty.Register( "LineOffect2", typeof( double ), typeof(PipeLineThree), new PropertyMetadata( 0d ) );
/// <summary>
/// 管道3的偏移
/// </summary>
public double LineOffect3
{
get { return (double)GetValue( LineOffect3Property ); }
set { SetValue( LineOffect3Property, value ); }
}
// Using a DependencyProperty as the backing store for LineOffect3. This enables animation, styling, binding, etc...
public static readonly DependencyProperty LineOffect3Property =
DependencyProperty.Register( "LineOffect3", typeof( double ), typeof(PipeLineThree), new PropertyMetadata( 0d ) );
/// <summary>
/// 获取或设置中间管道线的宽度信息,默认为3
/// </summary>
public int PipeLineWidth
{
get { return (int)GetValue( PipeLineWidthProperty ); }
set { SetValue( PipeLineWidthProperty, value ); }
}
// Using a DependencyProperty as the backing store for PipeLineWidth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeLineWidthProperty =
DependencyProperty.Register( "PipeLineWidth", typeof( int ), typeof(PipeLineThree), new PropertyMetadata( 2 ) );
/// <summary>
/// 获取或设置流动状态时管道控件的中心颜色
/// </summary>
public Color ActiveLineCenterColor
{
get { return (Color)GetValue( ActiveLineCenterColorProperty ); }
set { SetValue( ActiveLineCenterColorProperty, value ); }
}
// Using a DependencyProperty as the backing store for ActiveLineCenterColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ActiveLineCenterColorProperty =
DependencyProperty.Register( "ActiveLineCenterColor", typeof( Color ), typeof(PipeLineThree), new PropertyMetadata( Colors.DodgerBlue ) );
/// <summary>
/// 获取或设置管道的宽度,默认为30
/// </summary>
public int PipeWidth
{
get { return (int)GetValue( PipeWidthProperty ); }
set { SetValue( PipeWidthProperty, value ); }
}
// Using a DependencyProperty as the backing store for PipeWidth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PipeWidthProperty =
DependencyProperty.Register( "PipeWidth", typeof( int ), typeof(PipeLineThree),
new PropertyMetadata( 30, new PropertyChangedCallback( PipeWidthPropertyChangedCallback ) ) );
public static void PipeWidthPropertyChangedCallback( DependencyObject dependency, DependencyPropertyChangedEventArgs e )
{
PipeLineThree pipeLine = (PipeLineThree)dependency;
pipeLine.PipeWidthUpdate( );
}
public void PipeWidthUpdate( )
{
UpdatePath( );
}
protected override void OnRenderSizeChanged( SizeChangedInfo sizeInfo )
{
UpdatePath( );
base.OnRenderSizeChanged( sizeInfo );
}
public void UpdatePath( )
{
polygon1.Points = new PointCollection( new Point[]
{
new Point(ActualWidth / 2 - PipeWidth / 2d, PipeWidth),
new Point(ActualWidth / 2, PipeWidth / 2d),
new Point(ActualWidth / 2 + PipeWidth / 2d, PipeWidth),
new Point(ActualWidth / 2 + PipeWidth / 2d, ActualHeight),
new Point(ActualWidth / 2 - PipeWidth / 2d, ActualHeight),
new Point(ActualWidth / 2 - PipeWidth / 2d, PipeWidth),
} );
var g1 = new StreamGeometry( );
using (StreamGeometryContext context = g1.Open( ))
{
context.BeginFigure( new Point( 0, PipeWidth / 2d ), false, false );
context.LineTo( new Point( ActualWidth, PipeWidth / 2d ), true, false );
}
path1.Data = g1;
var g2 = new StreamGeometry( );
using (StreamGeometryContext context = g2.Open( ))
{
context.BeginFigure( new Point( 0, PipeWidth / 2d ), false, false );
context.LineTo( new Point( ActualWidth / 2 - PipeWidth / 2d, PipeWidth / 2d ), true, false );
context.ArcTo( new Point( ActualWidth / 2, PipeWidth ), new Size( PipeWidth / 2d, PipeWidth / 2d ), 0, false, SweepDirection.Clockwise, true, false );
context.LineTo( new Point( ActualWidth / 2, ActualHeight ), true, false );
}
path2.Data = g2;
var g3 = new StreamGeometry( );
using (StreamGeometryContext context = g3.Open( ))
{
context.BeginFigure( new Point( ActualWidth, PipeWidth / 2d ), false, false );
context.LineTo( new Point( ActualWidth / 2 + PipeWidth / 2d, PipeWidth / 2d ), true, false );
context.ArcTo( new Point( ActualWidth / 2, PipeWidth ), new Size( PipeWidth / 2d, PipeWidth / 2d ), 0, false, SweepDirection.Counterclockwise, true, false );
context.LineTo( new Point( ActualWidth / 2, ActualHeight ), true, false );
}
path3.Data = g3;
}
}
}