WPF 制作机械手动画

偶然的机会想做一个双手臂运转的机械手动作动画,重要的是有前辈写好的可以模仿: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.rhkb.cn/news/32885.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python-leetcode-子数组最大平均数 I

643. 子数组最大平均数 I - 力扣&#xff08;LeetCode&#xff09; 可以使用滑动窗口&#xff08;Sliding Window&#xff09;的方法来解决这个问题。具体步骤如下&#xff1a; 先计算数组 nums 中前 k 个元素的和 sum_k&#xff0c;作为初始窗口的和。然后滑动窗口&#xff0…

「 机器人 」扑翼飞行器通过总气动力控制四自由度运动方法

一、前言 在扑翼飞行中,总气动力(Total Aerodynamic Force)是指扑翼在运动过程中受到的所有空气动力作用的合力。它是由以下两种主要力的合成结果: 1. 升力(Lift, ):垂直于空气流方向的力,用于支持飞行器(或生物)的重量。 2. 阻力(Drag, ):平行于空气流方向的力,…

【C语言系列】字符函数和字符串函数

字符函数和字符串函数 一、字符分类函数二、字符转换函数三、strlen的使用和模拟实现3.1strlen函数3.2strlen函数模拟实现 四、strcpy的使用和模拟实现4.1strcpy函数4.2strcpy函数的模拟实现 五、strcat的使用和模拟实现5.1strcat函数5.2strcat函数的模拟实现 六、strcmp的使用…

飞鸟与鱼不同路

看&#xff0c;好美的太阳。 嘿嘿&#xff0c;今天我提出辞去综合教研室主任一职&#xff0c;不想在这个管理上废时间啦~ 把时间用来考试.........用来做自己的事情。 哈哈哈哈~

AI本地部署

文档加载&#xff08;Document Loading&#xff09;&#xff1a;从多种不同来源加载文档。LangChain提供了100多种不同的文档加载器&#xff0c;包括PDF在内的非结构化的数据、SQL在内的结构化的数据&#xff0c;以及Python、Java之类的代码等​ •文本分割&#xff08;Splitti…

计算机视觉算法实战——驾驶员分心检测(主页有源码)

✨个人主页欢迎您的访问 ✨期待您的三连 ✨ ✨个人主页欢迎您的访问 ✨期待您的三连 ✨ ✨个人主页欢迎您的访问 ✨期待您的三连✨ ​ ​​​ 1. 领域简介&#xff1a;驾驶员分心检测的意义与挑战 驾驶员分心检测是智能驾驶安全领域的重要研究方向。据统计&#xff0c;全球每…

2025因果机器学习好中高区idea汇总

机器学习变天了&#xff01;近来因果机器学习大热&#xff0c;这便意味着机器学习已经从“预测”向“理解”的范式转变。同时&#xff0c;这也是我们发论文、找创新的好时机。 因果机器学习可谓是&#xff0c;提高模型决策科学性和可靠性的“仙丹”&#xff01;其核心就在于&a…

Linux笔记---文件系统硬件部分

1. 文件系统 文件系统是操作系统用于明确存储设备&#xff08;常见的是磁盘&#xff0c;也有基于NAND Flash的固态硬盘&#xff09;或分区上的文件的方法和数据结构&#xff0c;即在存储设备上组织文件的方法。 1.1 基本组成 索引节点&#xff08;inode&#xff09;&#xff…

AutoSar架构-----XCP模块与协议介绍

1、XCP 模块定义 XCP 一般要求如下图&#xff1a; XCP 导入的类型需要如下表这些头文件&#xff1a; 2、ETAS 工具配置 2.1、XcpGeneral 配置 3、XCP 协议 ASAM-MCD-1MC&#xff1a;ECU 和标定测量系统接口 ASAM-MCD-2MC&#xff1a;即 A2L 文件&#xff0c;是控制器内部信息…

江科大51单片机笔记【10】DS1302时钟可调时钟(下)

写在前言 此为博主自学江科大51单片机&#xff08;B站&#xff09;的笔记&#xff0c;方便后续重温知识 在后面的章节中&#xff0c;为了防止篇幅过长和易于查找&#xff0c;我把一个小节分成两部分来发&#xff0c;上章节主要是关于本节课的硬件介绍、电路图、原理图等理论知识…

字节流 InputStream/OutputStream

一、java的I/O java的I/O(输入/输出)流是用于处理数据输入和输出的抽象类。 java的I/O流主要分为两大类&#xff0c;字节流跟字符流。 字节流&#xff1a;用于处理二进制数据&#xff0c;包括InputStream和OutputStream两个主要类及其子类。 字符流&#xff1a;用于处理字符…

使用位运算如何找到数组中只出现一次的数?

题目链接&#xff1a;137. 只出现一次的数字 II - 力扣&#xff08;LeetCode&#xff09; 算法解析 位运算是用于二进制的运算符号。而对于多次出现的数字&#xff0c;其二进制都是一模一样的&#xff0c;这里是3次重复的出现是数字。由此我们可以想到&#xff0c;如果我们由低…

最节省服务器,手搓电子证书查询系统

用户预算150元&#xff0c;想要一个最简单证书查询系统。前台能查询证书、后台管理员能登录能修改密码&#xff0c;证书能够手动输入修改删除、批量导入导出删除数据、查询搜索。能够兼容苹果、安卓、PC三端浏览器&#xff0c;最后帮忙部署到云服务器上。 用户预算不多&#xf…

.net 6程序在IIS中部署后点击IIS设置报错“执行此操作时出错”

.net 6写的程序&#xff0c;需要在Windows服务器的IIS中部署&#xff0c;由于是刚装的系统&#xff0c;先安装.net 6运行时&#xff0c;装了才发现没有IIS&#xff0c;于是又通过“添加角色和功能”添加与IIS相关的功能。安装完毕后&#xff0c;在IIS中添加网站&#xff0c;并将…

探针泄露(WEB)

##解题思路 题目提示是探针泄露&#xff0c;未及时删除的探针可能造成严重的数据泄露 探针的文件常见命名为tz.php&#xff0c;访问它 对于php相关参数&#xff0c;我们是可以点击的&#xff0c;点击phpinfo访问 跳转后搜索flag&#xff0c;得到flag

考研复试c语言常见问答题汇总2

11. 关键字和一般标识符有什么不同&#xff1f; C语言中关键字与一般标识符区别&#xff1a; 定义&#xff1a;关键字是C语言预定义的特殊单词&#xff08;如int、for&#xff09;&#xff0c;有固定含义&#xff1b;标识符是自定义的名称&#xff08;如变量名、函数名&#xf…

贝壳找房:以 OceanBase 为 JuiceFS 元数据引擎,构建 AI 存储底座

本文作者&#xff1a;王天庆&#xff0c;贝壳计算存储方向容器引擎团队负责人&#xff0c;他专注于云原生技术和AI基础设施的架构设计与实践&#xff0c;在为公司搭建高效、可靠的基础设施的同时&#xff0c;促进了大模型技术在企业内部的快速落地与应用。 导语&#xff1a;随着…

人工智能-周志华ML版|系列习题参考答案与综合测试目录

YI时间&#xff5c;松子茶碎碎念&#xff5c;MM-DFW&#xff5c;LAMBDA系列 星标&#x1f31f;松子茶 更新不掉队&#x1f31f; 作者 | 松子茶 © 原创内容(除图片外) 未经作者授权&#xff0c;严禁转载或镜像 机器学习是人工智能领域的核心课程之一。机器学习的基本概念…

OSPF-单区域的配置

一、单区域概念&#xff1a; 单区域OSPF中&#xff0c;整个网络被视为一个区域&#xff0c;区域ID通常为0&#xff08;骨干区域&#xff09;。所有的路由器都在这个区域内交换链路状态信息。 补充知识点&#xff1a; OSPF为何需要loopback接口&#xff1a; 1.Loopback接口的…

基于Bert模型的增量微调3-使用csv文件训练

我们使用weibo评价数据&#xff0c;8分类的csv格式数据集。 一、创建数据集合 使用csv格式的数据作为数据集。 1、创建MydataCSV.py from torch.utils.data import Dataset from datasets import load_datasetclass MyDataset(Dataset):#初始化数据集def __init__(self, s…