• 环形进度条(转)


    一直都是在博客园上看别人的分享 今天就突然心血来潮想把自己以前写的一个环形进度条分享给大家

    这是我的第一篇博客,希望大家多多指教;

    在这里我使用了blend里面的Arc控件 和一个定时器来控制endangle 值 

    项目的结构如下:

    xaml代码如下:

    复制代码
    <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"
            x:Name="mainwindow"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <ed:Arc ArcThickness="20" ArcThicknessUnit="Pixel" EndAngle="{Binding EndAngle,ElementName=mainwindow}" Fill="Yellow" HorizontalAlignment="Left" Margin="155.783,113.934,0,106.066" Stretch="None" Stroke="Gray" StartAngle="0" Width="100"/>
            <ed:Arc ArcThickness="20" ArcThicknessUnit="Pixel" EndAngle="360" Fill="Transparent" HorizontalAlignment="Left" Margin="155.783,113.934,0,106.066" Stretch="None" Stroke="Black" StartAngle="0" Width="100"/>
        </Grid>
    </Window>
    复制代码

    注意:在这里需要注意 如果你只是安装了vs但是么有blend 你需要在项目中添加Microsoft.Expression.Drawing.dll 这个类库

    然后添加引用 再添加命名空间

    xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" x:Class="Arc.MainWindow"这个命名空间哦 


    后台代码如下:
    复制代码
    using System;
    using System.Windows;
    using System.Windows.Threading;
    
    namespace Arc
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
                this.Loaded += MainWindow_Loaded;
            }
            DispatcherTimer Time = new DispatcherTimer();
    
            private void MainWindow_Loaded(object sender, RoutedEventArgs e)
            {
                Time.Tick += new EventHandler(Time_Tick);
                Time.Interval = new TimeSpan(10000);
                Time.Start();
            }
    
            private void Time_Tick(object sender, EventArgs e)
            {
                if (EndAngle < 360)
                {
                    EndAngle++;
                }
                else
                {
                    EndAngle = 360;
                }
            }
    
            public double EndAngle
            {
                get { return (double)GetValue(EndAngleProperty); }
                set { SetValue(EndAngleProperty, value); }
            }
            public static readonly DependencyProperty EndAngleProperty =
                DependencyProperty.Register("EndAngle", typeof(double), typeof(MainWindow), new PropertyMetadata(0d));
    
    
    
        }
    }
    复制代码

    如果想显示进度值可以自己添加哦 在这里我就不写了

  • 相关阅读:
    R 多图间距调整
    ggplot2 颜色渐变(离散颜色)设置
    R语言因子排序
    利用plink软件基于LD信息过滤SNP
    利用vcftools比较两个vcf文件
    在R语言中使用Stringr进行字符串操作
    perl 数组快速去除重复元素
    Shell中 ##%% 操作变量名
    Java基础之数值类型之间的转换
    Java中0.2减0.1 结果为什么不是0.1?
  • 原文地址:https://www.cnblogs.com/ExMan/p/5765557.html
Copyright © 2020-2023  润新知