ARC两种效果

复制代码
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Arc"
        xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" x:Class="Arc.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary>
            <local:NumberToAngle x:Key="NTA"/>
            <Storyboard x:Key="Storyboard1">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(ed:Arc.EndAngle)" Storyboard.TargetName="N">
                    <EasingDoubleKeyFrame KeyTime="0:0:3" Value="270"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(ed:Arc.EndAngle)" Storyboard.TargetName="W">
                    <EasingDoubleKeyFrame KeyTime="0:0:4" Value="360"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ResourceDictionary>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
        </EventTrigger>
    </Window.Triggers>
    <Grid>
        <ed:Arc x:Name="W" ArcThickness="0.05" ArcThicknessUnit="Percent" EndAngle="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="199" Width="199" Margin="0" Stretch="None" Stroke="Transparent" StartAngle="0" Fill="#FF0FE0F5" RenderTransformOrigin="0.5,0.5">
            <ed:Arc.RenderTransform>
                <TransformGroup>
                    <!--<ScaleTransform ScaleY="1" ScaleX="-1"/>--><!--逆时针打开-->
                    <!--<SkewTransform AngleY="0" AngleX="0"/>
                    <RotateTransform Angle="0"/>
                    <TranslateTransform/>-->
                </TransformGroup>
            </ed:Arc.RenderTransform>
        </ed:Arc>
        <ed:Arc x:Name="N" ArcThickness="0.05" ArcThicknessUnit="Percent" EndAngle="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="199" Width="199" Margin="0" Stretch="None" Stroke="Transparent" StartAngle="0" Fill="#FF1025F3" RenderTransformOrigin="0.5,0.5">
            <ed:Arc.RenderTransform>
                <TransformGroup>
                    <!--<ScaleTransform ScaleY="1" ScaleX="-1"/>--><!--逆时针打开-->
                    <!--<SkewTransform AngleY="0" AngleX="0"/>
                    <RotateTransform Angle="0"/>
                    <TranslateTransform/>-->
                </TransformGroup>
            </ed:Arc.RenderTransform>
        </ed:Arc>

        <TextBlock HorizontalAlignment="Center" Margin="0" TextWrapping="Wrap" Text="{Binding ElementName=W,Path=EndAngle,Converter={StaticResource NTA},StringFormat={}{0:P0}}" VerticalAlignment="Center"/>

    </Grid>
</Window>
View Code
复制代码

复制代码
<Window x:Class="Arc.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Arc"
        xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
        mc:Ignorable="d"
        Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <Storyboard x:Key="stb">
            <DoubleAnimation Storyboard.TargetName="arcBack" Storyboard.TargetProperty="EndAngle" To="360" Duration="0:0:2"/>
            <DoubleAnimation Storyboard.TargetName="arcFore" Storyboard.TargetProperty="EndAngle" To="180" Duration="0:0:1"/>
            <DoubleAnimation Storyboard.TargetName="rtf" Storyboard.TargetProperty="Angle" To="360" Duration="0:0:2" BeginTime="0:0:1" RepeatBehavior="Forever"/>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers>
        <EventTrigger SourceName="btnGo" RoutedEvent="Button.Click">
            <BeginStoryboard Storyboard="{StaticResource stb}"/>
        </EventTrigger>
    </Window.Triggers>
    <Grid>
        <Button Name="btnGo" Width="50" Height="50" HorizontalAlignment="Left" VerticalAlignment="Top" Content="go"/>
        <Grid x:Name="layout" Width="100" Height="100">
            <ed:Arc Name="arcBack" StartAngle="0" EndAngle="0" ArcThickness="8" Fill="#053894" Stretch="None"/>
            <ed:Arc Name="arcFore" StartAngle="0" EndAngle="0" ArcThickness="8" Stretch="None" RenderTransformOrigin="0.5,0.5">
                <ed:Arc.Fill>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="Transparent" Offset="0"/>
                        <GradientStop Color="#00E0FF" Offset="1"/>
                    </LinearGradientBrush>
                </ed:Arc.Fill>
                <ed:Arc.RenderTransform>
                    <RotateTransform x:Name="rtf" Angle="0"/>
                </ed:Arc.RenderTransform>
            </ed:Arc>
        </Grid>
    </Grid>
</Window>
View Code
复制代码

 

posted @   眾尋  阅读(259)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
点击右上角即可分享
微信分享提示
主题色彩