WPF 制作机械手动画

embedded/2025/3/19 20:28:44/

偶然的机会想做一个双手臂运转的机械手动作动画,重要的是有前辈写好的可以模仿:WPF开发经验-实现一种三轴机械手控件 - 一团静火 - 博客园

shit,公司禁止上传图片了

-------------------------------------------------------------------------------------

涵盖知识:

1.不可不知的WPF转换(Transform)_wpf matrixtransform-CSDN博客;

2.WPF中的VisualState(视觉状态)_wpf visualstate-CSDN博客;

3.WPF中RenderTransform详解_rendertransformorigin-CSDN博客

----------------------------------------------------------------------------------------

把代码放上来

1.自定义的机械手控件

	public class WaferRobotControl: Control{static WaferRobotControl(){DefaultStyleKeyProperty.OverrideMetadata(typeof(WaferRobotControl), new FrameworkPropertyMetadata(typeof(WaferRobotControl)));}public static readonly DependencyProperty WaferProperty = DependencyProperty.Register("Wafer", typeof(int), typeof(WaferRobotControl));public int Wafer { get => (int)GetValue(WaferProperty); set => SetValue(WaferProperty, value); }public static readonly DependencyProperty RobotWActionProperty = DependencyProperty.Register("RobotWAction",typeof(WaferRobotWAction),typeof(WaferRobotControl),new PropertyMetadata(WaferRobotWAction.W_Origin, RobotWActionPropertyChangedCallback));public WaferRobotWAction RobotWAction{get => (WaferRobotWAction)GetValue(RobotWActionProperty);set => SetValue(RobotWActionProperty, value);}private static void RobotWActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e){var control = d as WaferRobotControl;var oldAct = (WaferRobotWAction)e.OldValue;var newAct = (WaferRobotWAction)e.NewValue;switch (newAct){case WaferRobotWAction.W_Origin:VisualStateManager.GoToState(control, newAct.ToString(), true);break;case WaferRobotWAction.W_StickOut:if (newAct != oldAct){VisualStateManager.GoToState(control, newAct.ToString(), true);}break;default:break;}}public static readonly DependencyProperty RobotRActionProperty = DependencyProperty.Register("RobotRAction",typeof(WaferRobotRAction),typeof(WaferRobotControl),new PropertyMetadata(WaferRobotRAction.R_Origin, RobotRActionPropertyChangedCallback));public WaferRobotRAction RobotRAction{get => (WaferRobotRAction)GetValue(RobotRActionProperty);set => SetValue(RobotRActionProperty, value);}private static void RobotRActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e){var control = d as WaferRobotControl;var oldAct = (WaferRobotRAction)e.OldValue;var newAct = (WaferRobotRAction)e.NewValue;switch (newAct){case WaferRobotRAction.R_Origin:VisualStateManager.GoToState(control, newAct.ToString(), true);break;case WaferRobotRAction.R_StickOut:if (newAct != oldAct){VisualStateManager.GoToState(control, newAct.ToString(), true);}break;default:break;}}public static readonly DependencyProperty RobotTActionProperty = DependencyProperty.Register("RobotTAction",typeof(WaferRobotTAction),typeof(WaferRobotControl),new PropertyMetadata(WaferRobotTAction.T_Origin, RobotTActionPropertyChangedCallback));public WaferRobotTAction RobotTAction{get => (WaferRobotTAction)GetValue(RobotTActionProperty);set => SetValue(RobotTActionProperty, value);}private static void RobotTActionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e){var control = d as WaferRobotControl;var oldAct = (WaferRobotTAction)e.OldValue;var newAct = (WaferRobotTAction)e.NewValue;switch (newAct){case WaferRobotTAction.T_Origin:VisualStateManager.GoToState(control, newAct.ToString(), true);break;case WaferRobotTAction.T_CW:if (newAct != oldAct){VisualStateManager.GoToState(control, newAct.ToString(), true);}break;case WaferRobotTAction.T_CCW:if (newAct != oldAct){VisualStateManager.GoToState(control, newAct.ToString(), true);}break;default:break;}}public override void OnApplyTemplate(){base.OnApplyTemplate();VisualStateManager.GoToState(this, WaferRobotWAction.W_Origin.ToString(), true);VisualStateManager.GoToState(this, WaferRobotRAction.R_Origin.ToString(), true);VisualStateManager.GoToState(this, WaferRobotTAction.T_Origin.ToString(), true);}}
}

2.机械手手臂(轴)状态

public enum WaferRobotRAction
{R_Origin,R_StickOut
}
public enum WaferRobotWAction
{W_Origin,W_StickOut
}
public enum WaferRobotTAction
{T_Origin,T_CW,T_CCW
}

3.控件对应的模版

<SolidColorBrush x:Key="robotBorderBrush" Color="#030303" />
<Style TargetType="{x:Type myWaferRobot:WaferRobotControl}" ><Setter Property="Cursor" Value="Hand" /><Setter Property="Width" Value="200"/><Setter Property="Height" Value="300"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type myWaferRobot:WaferRobotControl}"><Viewbox x:Name="viewbox" Stretch="Fill"><VisualStateManager.VisualStateGroups><!--<VisualStateGroup Name="RobotActions"><VisualStateGroup.Transitions><VisualTransition To="Z_CW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotZAct" Storyboard.TargetProperty="Y"><LinearDoubleKeyFrame Value="-90" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotUpDownAct" Storyboard.TargetProperty="Y"><LinearDoubleKeyFrame Value="-90" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition><VisualTransition To="Z_CCW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotZAct" Storyboard.TargetProperty="Y"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotUpDownAct" Storyboard.TargetProperty="Y"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition></VisualStateGroup.Transitions><VisualState Name="Z_Origin"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotZAct" Storyboard.TargetProperty="Y" ><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotUpDownAct" Storyboard.TargetProperty="Y" ><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="Z_CW"><Storyboard  FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotZAct" Storyboard.TargetProperty="Y" Duration="0" ><LinearDoubleKeyFrame Value="-90" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotUpDownAct" Storyboard.TargetProperty="Y" ><LinearDoubleKeyFrame Value="-90" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="Z_CCW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotZAct" Storyboard.TargetProperty="Y" ><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotUpDownAct" Storyboard.TargetProperty="Y" ><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup>--><VisualStateGroup Name="RobotArmRActions"><VisualStateGroup.Transitions><VisualTransition To="R_StickOut"><Storyboard FillBehavior="HoldEnd" SpeedRatio="6"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="70" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="0" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="-65" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="0" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="80" KeyTime="0:0:1"/><LinearDoubleKeyFrame Value="70" KeyTime="0:0:2"/><LinearDoubleKeyFrame Value="60" KeyTime="0:0:3"/><LinearDoubleKeyFrame Value="50" KeyTime="0:0:4"/><LinearDoubleKeyFrame Value="40" KeyTime="0:0:5"/><LinearDoubleKeyFrame Value="30" KeyTime="0:0:6"/><LinearDoubleKeyFrame Value="20" KeyTime="0:0:7"/><LinearDoubleKeyFrame Value="10" KeyTime="0:0:8"/><LinearDoubleKeyFrame Value="0  " KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition><VisualTransition To="R_Origin"><Storyboard FillBehavior="HoldEnd" SpeedRatio="6"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="68" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="-65" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:9"/><LinearDoubleKeyFrame Value="80" KeyTime="0:0:8"/><LinearDoubleKeyFrame Value="70" KeyTime="0:0:7"/><LinearDoubleKeyFrame Value="60" KeyTime="0:0:6"/><LinearDoubleKeyFrame Value="50" KeyTime="0:0:5"/><LinearDoubleKeyFrame Value="40" KeyTime="0:0:4"/><LinearDoubleKeyFrame Value="30" KeyTime="0:0:3"/><LinearDoubleKeyFrame Value="20" KeyTime="0:0:2"/><LinearDoubleKeyFrame Value="10" KeyTime="0:0:1"/><LinearDoubleKeyFrame Value="0  " KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition></VisualStateGroup.Transitions><VisualState Name="R_StickOut"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="R_Origin"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="68" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="-65" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armRT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup><VisualStateGroup Name="RobotArmWActions"><VisualStateGroup.Transitions><VisualTransition To="W_StickOut"><Storyboard FillBehavior="HoldEnd" SpeedRatio="6"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="-68" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="0" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="63" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="0" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="80" KeyTime="0:0:1"/><LinearDoubleKeyFrame Value="70" KeyTime="0:0:2"/><LinearDoubleKeyFrame Value="60" KeyTime="0:0:3"/><LinearDoubleKeyFrame Value="50" KeyTime="0:0:4"/><LinearDoubleKeyFrame Value="40" KeyTime="0:0:5"/><LinearDoubleKeyFrame Value="30" KeyTime="0:0:6"/><LinearDoubleKeyFrame Value="20" KeyTime="0:0:7"/><LinearDoubleKeyFrame Value="10" KeyTime="0:0:8"/><LinearDoubleKeyFrame Value="0  " KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition><VisualTransition To="W_Origin"><Storyboard FillBehavior="HoldEnd" SpeedRatio="6"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="-68" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/><LinearDoubleKeyFrame Value="63" KeyTime="0:0:9"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:9"/><LinearDoubleKeyFrame Value="80" KeyTime="0:0:8"/><LinearDoubleKeyFrame Value="70" KeyTime="0:0:7"/><LinearDoubleKeyFrame Value="60" KeyTime="0:0:6"/><LinearDoubleKeyFrame Value="50" KeyTime="0:0:5"/><LinearDoubleKeyFrame Value="40" KeyTime="0:0:4"/><LinearDoubleKeyFrame Value="30" KeyTime="0:0:3"/><LinearDoubleKeyFrame Value="20" KeyTime="0:0:2"/><LinearDoubleKeyFrame Value="10" KeyTime="0:0:1"/><LinearDoubleKeyFrame Value="0  " KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition></VisualStateGroup.Transitions><VisualState Name="W_StickOut"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="W_Origin"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT1RotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="-68" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2ArmRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="63" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames><DoubleAnimationUsingKeyFrames Storyboard.TargetName="armWT2Act" Storyboard.TargetProperty="X"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup><VisualStateGroup Name="RobotTActions"><VisualStateGroup.Transitions><VisualTransition To="T_Origin"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition><VisualTransition To="T_CW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="180" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition><VisualTransition To="T_CCW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="0" KeyTime="0:0:1"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualTransition></VisualStateGroup.Transitions><VisualState Name="T_Origin"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="90" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="T_CCW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="00" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState><VisualState Name="T_CW"><Storyboard FillBehavior="HoldEnd"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="robotRotateAct" Storyboard.TargetProperty="Angle"><LinearDoubleKeyFrame Value="180" KeyTime="0:0:0"/></DoubleAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup></VisualStateManager.VisualStateGroups><Canvas Width="200" Height="300"  Background="Transparent" ><Canvas x:Name="robot" Width="200" Height="200" RenderTransformOrigin="0.5 0.5" Background="BlanchedAlmond" ><Canvas.RenderTransform><TransformGroup><RotateTransform  x:Name="robotRotateAct"/><TranslateTransform  x:Name="robotUpDownAct"/></TransformGroup></Canvas.RenderTransform><Canvas x:Name="armWT1" Width="200" Height="100" Canvas.Left="0" Canvas.Top="50"    RenderTransformOrigin="0.5 0.5" Background="Transparent"><Canvas.RenderTransform><RotateTransform  x:Name="armWT1RotateAct"/></Canvas.RenderTransform><Canvas x:Name="armWT1Arm" Width="70" Height="30"  Canvas.Left="30" Canvas.Top="35" ><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#FF7F50" StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="0 5" IsClosed="True"><LineSegment Point="51 0"/><LineSegment Point="51 30" IsStroked="False"/><LineSegment Point="0 25"/><LineSegment Point="0 5" IsStroked="False"/></PathFigure></PathGeometry></Path.Data></Path><Path Stroke="{StaticResource robotBorderBrush}" StrokeThickness="1" Canvas.Left="0" StrokeEndLineCap="Round" StrokeStartLineCap="Round" Fill="#FF7F50"Data="M 0,5 A 10,10 0 0 0 0,25"></Path></Canvas><Canvas x:Name="armWT1Center"  Width="40" Height="40" Canvas.Left="80" Canvas.Top="30" ><Path  Stroke="{StaticResource robotBorderBrush}"  Fill="Blue" StrokeThickness="1" StrokeEndLineCap="Round"  ><Path.Data><PathGeometry><PathFigure StartPoint="0 6" IsClosed="True"><LineSegment Point="6 0"/><LineSegment Point="34 0"/><LineSegment Point="40 6"/><LineSegment Point="40 34"/><LineSegment Point="34 40"/><LineSegment Point="6 40"/><LineSegment Point="0 34"/></PathFigure></PathGeometry></Path.Data></Path></Canvas></Canvas><Canvas x:Name="armWT2" Width="70" Height="50"  Canvas.Left="-95" Canvas.Top="80" Background="Transparent"><Canvas.RenderTransform><TransformGroup><TranslateTransform x:Name="armWT2Act"></TranslateTransform></TransformGroup></Canvas.RenderTransform><Canvas x:Name="armWT2Arm" Width="70" Height="20"  Canvas.Left="50" Canvas.Top="10" RenderTransformOrigin="0 0.5"  ><Canvas.RenderTransform><RotateTransform x:Name="armWT2ArmRotateAct"/></Canvas.RenderTransform><Path Stroke="{StaticResource robotBorderBrush}" StrokeThickness="1" Canvas.Left="70" StrokeEndLineCap="Round" StrokeStartLineCap="Round" Fill="#6495ED"Data="M 0,0 A 10,10 0 0 1 0,20"></Path><Path Stroke="{StaticResource robotBorderBrush}" StrokeThickness="1" Canvas.Left="0" StrokeEndLineCap="Round" StrokeStartLineCap="Round" Fill="#6495ED"Data="M 0,0 A 10,10 0 0 0 0,20"></Path><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#6495ED" StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="70 0" ><LineSegment Point="0 0" /><LineSegment Point="0 20" IsStroked="False"/><LineSegment Point="70 20"/><LineSegment Point="70 0" IsStroked="False"/></PathFigure></PathGeometry></Path.Data></Path><Ellipse Width="12" Height="12" Stroke="#030303" StrokeThickness="2"  Fill="Transparent" Canvas.Top="4" Canvas.Left="62"/></Canvas><Canvas x:Name="armWGripper" Height="40" Width="50"  Canvas.Left="0" Canvas.Top="0" ><Path  Stroke="{StaticResource robotBorderBrush}"  StrokeThickness="2" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="30 14" ><LineSegment Point="10 14" /><LineSegment Point="4 8" /><LineSegment Point="-6 8" /></PathFigure><PathFigure StartPoint="30 26" ><LineSegment Point="10 26" /><LineSegment Point="4 32" /><LineSegment Point="-6 32" /></PathFigure></PathGeometry></Path.Data></Path><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#7A7E90"  StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="40 0" ><LineSegment Point="60 0" /><LineSegment Point="60 40" /><LineSegment Point="40 40" /><LineSegment Point="30 30" /><LineSegment Point="30 10" /><LineSegment Point="40 0" /></PathFigure></PathGeometry></Path.Data></Path><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#7A7E90" StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="30 10" ><LineSegment Point="20 10" /><LineSegment Point="20 30" /><LineSegment Point="30 30" /><LineSegment Point="30 10" IsStroked="False"/></PathFigure></PathGeometry></Path.Data></Path><Ellipse Width="12" Height="12" Stroke="#030303" StrokeThickness="2"  Fill="Transparent" Canvas.Top="14" Canvas.Left="44"/><Ellipse x:Name="waferW" Width="40" Height="40" StrokeThickness="1" Stroke="Black"  Canvas.Left="-24" Fill="Blue"Visibility="{Binding Wafer,Converter={StaticResource cvt1}}"/><!--RelativeSource={RelativeSource TemplatedParent}}"Fill="{Binding Wafer,Converter={StaticResource WaferIntToColorConverter},RelativeSource={RelativeSource TemplatedParent}}"/>--></Canvas></Canvas><Canvas x:Name="armRT1" Width="200" Height="100" Canvas.Left="0" Canvas.Top="50"    RenderTransformOrigin="0.5 0.5" Background="Transparent"><Canvas.RenderTransform><RotateTransform  x:Name="armRT1RotateAct"/></Canvas.RenderTransform><Canvas x:Name="armRT1Arm" Width="70" Height="30"  Canvas.Left="30" Canvas.Top="35" ><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#FF7F50" StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="0 5" IsClosed="True"><LineSegment Point="51 0"/><LineSegment Point="51 30" IsStroked="False"/><LineSegment Point="0 25"/><LineSegment Point="0 5" IsStroked="False"/></PathFigure></PathGeometry></Path.Data></Path><Path Stroke="{StaticResource robotBorderBrush}" StrokeThickness="1" Canvas.Left="0" StrokeEndLineCap="Round" StrokeStartLineCap="Round" Fill="#FF7F50"Data="M 0,5 A 10,10 0 0 0 0,25"></Path></Canvas><Canvas x:Name="armRT1Center"  Width="40" Height="40" Canvas.Left="80" Canvas.Top="30" ><Path  Stroke="{StaticResource robotBorderBrush}"  Fill="Blue" StrokeThickness="1" StrokeEndLineCap="Round"  ><Path.Data><PathGeometry><PathFigure StartPoint="0 6" IsClosed="True"><LineSegment Point="6 0"/><LineSegment Point="34 0"/><LineSegment Point="40 6"/><LineSegment Point="40 34"/><LineSegment Point="34 40"/><LineSegment Point="6 40"/><LineSegment Point="0 34"/></PathFigure></PathGeometry></Path.Data></Path></Canvas></Canvas><Canvas x:Name="armRT2" Width="70" Height="50"  Canvas.Left="-95" Canvas.Top="80" Background="Transparent"><Canvas.RenderTransform><TransformGroup><TranslateTransform x:Name="armRT2Act"></TranslateTransform></TransformGroup></Canvas.RenderTransform><Canvas x:Name="armRT2Arm" Width="70" Height="20"  Canvas.Left="50" Canvas.Top="10" RenderTransformOrigin="0 0.5"  ><Canvas.RenderTransform><RotateTransform x:Name="armRT2ArmRotateAct"/></Canvas.RenderTransform><Path Stroke="{StaticResource robotBorderBrush}" StrokeThickness="1" Canvas.Left="70" StrokeEndLineCap="Round" StrokeStartLineCap="Round" Fill="#6495ED"Data="M 0,0 A 10,10 0 0 1 0,20"></Path><Path Stroke="{StaticResource robotBorderBrush}" StrokeThickness="1" Canvas.Left="0" StrokeEndLineCap="Round" StrokeStartLineCap="Round" Fill="#6495ED"Data="M 0,0 A 10,10 0 0 0 0,20"></Path><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#6495ED" StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="70 0" ><LineSegment Point="0 0" /><LineSegment Point="0 20" IsStroked="False"/><LineSegment Point="70 20"/><LineSegment Point="70 0" IsStroked="False"/></PathFigure></PathGeometry></Path.Data></Path><Ellipse Width="12" Height="12" Stroke="#030303" StrokeThickness="2"  Fill="Transparent" Canvas.Top="4" Canvas.Left="62"/></Canvas><Canvas x:Name="armRGripper" Height="40" Width="50"  Canvas.Left="0" Canvas.Top="0" ><Path  Stroke="{StaticResource robotBorderBrush}"  StrokeThickness="2" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="30 14" ><LineSegment Point="10 14" /><LineSegment Point="4 8" /><LineSegment Point="-6 8" /></PathFigure><PathFigure StartPoint="30 26" ><LineSegment Point="10 26" /><LineSegment Point="4 32" /><LineSegment Point="-6 32" /></PathFigure></PathGeometry></Path.Data></Path><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#7A7E90"  StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="40 0" ><LineSegment Point="60 0" /><LineSegment Point="60 40" /><LineSegment Point="40 40" /><LineSegment Point="30 30" /><LineSegment Point="30 10" /><LineSegment Point="40 0" /></PathFigure></PathGeometry></Path.Data></Path><Path  Stroke="{StaticResource robotBorderBrush}" Fill="#7A7E90" StrokeThickness="1" StrokeEndLineCap="Round" ><Path.Data><PathGeometry><PathFigure StartPoint="30 10" ><LineSegment Point="20 10" /><LineSegment Point="20 30" /><LineSegment Point="30 30" /><LineSegment Point="30 10" IsStroked="False"/></PathFigure></PathGeometry></Path.Data></Path><Ellipse Width="12" Height="12" Stroke="#030303" StrokeThickness="2"  Fill="Transparent" Canvas.Top="14" Canvas.Left="44"/><Ellipse x:Name="waferR" Width="40" Height="40" StrokeThickness="1" Stroke="Black"  Canvas.Left="-24" Fill="Blue"Visibility="{Binding Wafer,Converter={StaticResource cvt1}}"/><!--RelativeSource={RelativeSource TemplatedParent}}"Fill="{Binding Wafer,Converter={StaticResource WaferIntToColorConverter},RelativeSource={RelativeSource TemplatedParent}}"/>--></Canvas></Canvas></Canvas></Canvas></Viewbox></ControlTemplate></Setter.Value></Setter>
</Style>

使用:

private void TCWButton_Click(object sender, RoutedEventArgs e)
{robot.RobotTAction = WaferRobotTAction.T_CW;
}

通过方法里改变控件对象的属性就可以改变控件的现实状态;
 


http://www.ppmy.cn/embedded/173944.html

相关文章

《我的Python觉醒之路》之转型Python(十五)——控制流

[今天是2025年3月17日&#xff0c;继续复习第一章节、第二章节的内容 ] 《我的Python觉醒之路》之转型Python&#xff08;十四&#xff09;——控制流

数据通信与计算机网络——网络模型

主要内容 任务分层 OSI模型 OSI模型的各层功能 TCP/IP协议族 寻址 一、任务分层 设想一个情景&#xff0c;两个好朋友通过邮件相互通信&#xff0c;如果没有邮局所提供的服务&#xff0c;两个人的通信过程会非常复杂。在这个过程中&#xff0c;有三个主体&#xff0c;发…

大型语言模型(LLM)部署中的内存消耗计算

在部署大型语言模型&#xff08;LLM&#xff09;时&#xff0c;显存&#xff08;VRAM&#xff09;的合理规划是决定模型能否高效运行的核心问题。本文将通过详细的公式推导和示例计算&#xff0c;系统解析模型权重、键值缓存&#xff08;KV Cache&#xff09;、激活内存及额外开…

HTML语言的贪心算法

HTML语言的贪心算法&#xff1a;理论与实践 引言 在编程和算法研究中&#xff0c;贪心算法是一种广泛应用的解决问题的方法。它通过对每一阶段选择最优解的方式来构建整个问题的解决方案。贪心算法不一定能在所有情况下得到最优解&#xff0c;但在许多实际问题中&#xff0c;…

【机器学习】基于conda虚拟环境的gcc、g++版本升级

最近在学习大模型部署&#xff0c;需要安装flash-attn&#xff0c;在编译时报错 c: error: unrecognized command line option ‘-stdc17’centos7.9默认gcc最高版本为4.8.5 (base) [rootxx ~]# cat /proc/version Linux version 3.10.0-1160.el7.x86_64 (mockbuildkbuilder.…

MySQL 5.7 vs MySQL 8.0 高频面试题解析

一、基础概念与核心差异 1. 默认字符集的变化 问&#xff1a; MySQL 5.7 和 8.0 的默认字符集有何不同&#xff1f;为什么要修改&#xff1f; 答&#xff1a; MySQL 5.7 默认字符集为 latin1&#xff0c;可能导致中文乱码。MySQL 8.0 默认改为 utf8mb4&#xff08;支持4字节…

深度探索DeepSeek部署的安全底线

摘要 在本地部署DeepSeek时&#xff0c;必须严格遵守安全底线。攻击者可能通过服务接口对DeepSeek模型数据进行篡改&#xff0c;包括删除模型或修改模型训练数据。此外&#xff0c;攻击者还可能注入恶意代码或删除关键组件&#xff0c;从而导致服务崩溃。因此&#xff0c;在部署…

【综述】An Introduction to Vision-Language Modeling【二】

介绍 第一节的内容 该文章对视觉语言模型进行介绍&#xff0c;解释了什么是视觉语言模型&#xff0c;怎么训练的&#xff0c;如果基于各种研究目标来有效评估它。这项工作不是一个现有工作的综述&#xff0c;而是对视觉语言模型进行清晰易理解的介绍&#xff0c;以便更好入门…