zoukankan      html  css  js  c++  java
  • 环形进度条(原创)

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

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

    在这里我使用了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));
    
    
    
        }
    }

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

     
  • 相关阅读:
    Git在eclipse中的使用
    Git协同开发产生的版本冲突
    git&github-远程库的拉取
    【题解】p6160 [Cnoi2020]向量
    【题解】p2388 阶乘之乘
    友情链接
    O(1)求解自然数异或和
    【题解】uva1104 chips challenge
    【题解】p1809 过河问题
    多步操作产生错误,请检查每一步的状态
  • 原文地址:https://www.cnblogs.com/liu1314/p/5764277.html
Copyright © 2011-2022 走看看