小米视频加载进度条效果实现
好吧,其实这些都是我闲暇时自己做着玩的,以前总是拿来主义,现在分享一下让我也为大家做一点贡献好了。废话不说了,看效果。
好吧 其实没什么技术含量 直接上代码好了 和我上一篇利用WPF动画实现圆形进度条是一个道理,表现形式不同而已。
1 <UserControl x:Class="MyUserControlLibrary.CircleProgressbarcontrol" 2 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 3 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 4 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 5 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 6 xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" 7 xmlns:local ="clr-namespace:MyUserControlLibrary" 8 mc:Ignorable="d" 9 d:DesignHeight="60" d:DesignWidth="60" MinWidth="60" MinHeight="60" Loaded="UserControl_Loaded"> 10 <UserControl.Resources> 11 <local:ConverterCircleToPercent x:Key="converter"/> 12 <Storyboard x:Key="MainStoryboard"> 13 <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(ed:Arc.EndAngle)" Storyboard.TargetName="ProgressArea"> 14 <EasingDoubleKeyFrame KeyTime="0" Value="0"/> 15 <EasingDoubleKeyFrame KeyTime="0:0:0.05" Value="360"/> 16 </DoubleAnimationUsingKeyFrames> 17 </Storyboard> 18 </UserControl.Resources> 19 <Grid> 20 <Border Name="MainBorder" Margin="0,0,0,0" CornerRadius="500" BorderThickness="2" BorderBrush="White" Opacity="0.6" Background="Black"/> 21 <ed:Arc Name="ProgressArea" Margin="5,5,5,5" ArcThickness="1" StartAngle="0" EndAngle="0" ArcThicknessUnit="Percent" Stretch="None" Fill="White" Opacity="0.4"/> 22 <Ellipse Name="CenterCircle" Width="5" Height="5" Fill="White" Opacity="0.7"/> 23 <Label Name="AreaShow" Margin="10,10,10,10" Content="{Binding ElementName=ProgressArea, Path=EndAngle,Converter={StaticResource converter}}" Foreground="White" FontFamily="宋体" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="20" Opacity="0.8"/> 24 </Grid> 25 </UserControl>
XMAL前端
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Windows; 6 using System.Windows.Controls; 7 using System.Windows.Data; 8 using System.Windows.Documents; 9 using System.Windows.Input; 10 using System.Windows.Media; 11 using System.Windows.Media.Animation; 12 using System.Windows.Media.Imaging; 13 using System.Windows.Navigation; 14 using System.Windows.Shapes; 15 16 namespace MyUserControlLibrary 17 { 18 /// <summary> 19 /// CircleProgressbarcontrol.xaml 的交互逻辑 20 /// </summary> 21 public partial class CircleProgressbarcontrol : UserControl 22 { 23 #region 属性 24 25 private bool isShowPercent = true; 26 /// <summary> 27 /// 是否显示百分比 28 /// </summary> 29 [System.ComponentModel.Browsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("获取或设置是否显示百分比")] 30 public bool IsShowPercent { 31 get { 32 return isShowPercent; 33 } 34 set { 35 isShowPercent = value; 36 if (isShowPercent) 37 { 38 AreaShow.Visibility = System.Windows.Visibility.Visible; 39 } 40 else { 41 AreaShow.Visibility = System.Windows.Visibility.Hidden; 42 } 43 } 44 } 45 46 private TimeSpan percentTimeSpan = new TimeSpan(0, 0, 1); 47 /// <summary> 48 /// 每次更新百分比时的经过时间 49 /// </summary> 50 [System.ComponentModel.Browsable(true),System.ComponentModel.Category("Appearance"),System.ComponentModel.Description("获取或设置每次更新百分比时的经过时间")] 51 public TimeSpan PercentTimeSpan { 52 get { 53 return percentTimeSpan; 54 } 55 set { 56 percentTimeSpan = value; 57 Storyboard sb = (Storyboard)this.Resources["MainStoryboard"]; 58 ((DoubleAnimationUsingKeyFrames)sb.Children[0]).KeyFrames[1].KeyTime = KeyTime.FromTimeSpan(value); 59 } 60 } 61 62 #endregion 63 64 public CircleProgressbarcontrol() 65 { 66 InitializeComponent(); 67 } 68 69 #region 方法 70 71 /// <summary> 72 /// 设置当前百分比 73 /// </summary> 74 /// <param name="d">百分比</param> 75 public void setPercent(double d) { 76 Storyboard sb = (Storyboard)this.Resources["MainStoryboard"]; 77 ((DoubleAnimationUsingKeyFrames)sb.Children[0]).KeyFrames[0].Value = ProgressArea.EndAngle; 78 ((DoubleAnimationUsingKeyFrames)sb.Children[0]).KeyFrames[1].Value = d*3.6; 79 sb.Begin(); 80 } 81 82 #endregion 83 84 #region 事件 85 86 //界面调整 87 private void UserControl_Loaded(object sender, RoutedEventArgs e) 88 { 89 if (Double.IsNaN(Width)) 90 { 91 if (ActualWidth >= ActualHeight) 92 { 93 double t = (ActualWidth - ActualHeight) / 2; 94 MainBorder.Margin = new Thickness(t, 0, t, 0); 95 ProgressArea.Margin = new Thickness(t + 5, 5, t + 5, 5); 96 AreaShow.Margin = new Thickness(t + 10, 10, t + 10, 10); 97 } 98 else 99 { 100 double t = (ActualHeight - ActualWidth) / 2; 101 MainBorder.Margin = new Thickness(0, t + 0, 0, t + 0); 102 ProgressArea.Margin = new Thickness(5, t + 5, 5, t + 5); 103 AreaShow.Margin = new Thickness(10, t + 10, 10, t + 10); 104 } 105 AreaShow.FontSize = AreaShow.ActualWidth / 2; 106 } 107 else 108 { 109 if (Width >= Height) 110 { 111 double t = (Width - Height) / 2; 112 MainBorder.Margin = new Thickness(t, 0, t, 0); 113 ProgressArea.Margin = new Thickness(t + 5, 5, t + 5, 5); 114 AreaShow.Margin = new Thickness(t + 10, 10, t + 10, 10); 115 } 116 else 117 { 118 double t = (Height - Width) / 2; 119 MainBorder.Margin = new Thickness(0, t, 0, t); 120 ProgressArea.Margin = new Thickness(5, t + 5, 5, t + 5); 121 AreaShow.Margin = new Thickness(10, t + 10, 10, t + 10); 122 } 123 AreaShow.FontSize = AreaShow.ActualWidth / 2; 124 } 125 } 126 127 #endregion 128 } 129 }
后台代码
1 using System; 2 using System.Collections.Generic; 3 using System.Globalization; 4 using System.Linq; 5 using System.Text; 6 using System.Windows.Data; 7 8 namespace MyUserControlLibrary 9 { 10 /// <summary> 11 /// 将角度转化成百分比 12 /// </summary> 13 public class ConverterCircleToPercent:IValueConverter 14 { 15 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 { 17 return (int)(double.Parse(value.ToString()) * 10 / 36); 18 } 19 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 20 { 21 throw new NullReferenceException(); 22 } 23 } 24 }
转换器
小米视频加载进度条效果实现相关推荐
- html实现图片加载动画效果,HTML5+javascript实现图片加载进度动画效果
在网上找资料的时候,看到网上有图片加载进度的效果,手痒就自己也写了一个. 图片加载完后,隐藏loading效果. 想看加载效果,请ctrel+F5强制刷新或者清理缓存. 效果预览: 0% 代码如下: ...
- CSS3超酷网页Loading加载进度条动画效果
在jQuery之家上发现的一款css3效果. CSS3 animation超酷网页Loading加载进度条动画效果 >>查看演示 > ...
- 缓冲进度条或加载进度条
缓冲进度条或加载进度条,在加载页面或者视频加载过程中,为了做到更好的UI及App功能体验交互,这些缓冲加载的等待效果是必不可少的: 下面来看一下旋转的动画效果:那么,他们的具体源码在这里:loadin ...
- Android缓冲进度条或加载进度条
缓冲进度条或加载进度条,在加载页面或者视频加载过程中,为了做到更好的UI及App功能体验交互,这些缓冲加载的等待效果是必不可少的: 下面来看一下旋转的动画效果: 那么,他们的具体源码在这里:loadi ...
- Android学习笔记(Android Studio)3-3(ProgressBar ProgressDialog)(加载进度条、转圈圈)UI组件之弹出组件
Android学习笔记3-3 推荐新手向学习视频:B站https://www.bilibili.com/video/av38409964点我传送 3-3 ProgressBar & Progr ...
- WKWebView Safari调试、JS互调、加载进度条、JS中alert、confirm、prompt
主要内容 Safari调试 swift/OC与JS互调 增加加载进度条 支持JS中alert.confirm.prompt Safari调试 设置 -> safari --> 高级,开启J ...
- 【原生JS插件】LoadingBar页面顶部加载进度条
先展示一下已经实现的效果: 预览地址:http://dtdxrk.github.io/js-plug/LoadingBar/index.html 看到手机上的浏览器内置了页面的加载进度条,想用在pc上 ...
- js网页顶部线性页面加载进度条,jquery头部线性进度条总结
前言 网页顶部加载进度条,近年来很流行,很多网站都采用了这种加载方式.网上也有这样类似的插件,今天我们总结一下网页顶部线性页面加载进度条. 头部LoadingBar线性进度条总结 上面的代码只是静态效 ...
- html5 圆形加载进度条,纯css3超酷圆形Loading加载进度条特效
这是一款效果炫酷的纯css3圆形Loading加载进度条特效插件.该loading特效使用:before和:after伪元素来制作动画d的不同部分,然后给他们设置absolute定位和CSS tran ...
最新文章
- CentOS 7.5 如何升级Git实录
- 实现线程哪种方法更好_实施数据以实现更好的用户体验设计的4种方法
- The Life Cycle of a Servlet
- c语言 文件 long double 读取,读取*.wav音频文件
- ch6 列表和导航条
- Codeforces Round #716 (Div. 2)
- php面试编程题_PHP程序员面试题(经典汇总,mysql为主)
- 我们是怎样发出声音的?
- MethodInterceptor拦截器
- 辽宁工业大学计算机复试经验,辽宁工业大学车辆工程考研经验
- 百度分享代码_网销侠:网络营销百问百答之51,百度小程序是什么
- 秩为1的矩阵的性质总结
- win10前置耳机插孔没声音_iqoo耳机突然没声音-杰讯手机维修中心
- 迅为IMX6ULL开发板Linux系统移植-NXP官方Linux源码编译
- 一种去除U盘写保护的可行方法(dd 命令解决)
- 手撸Mybatis源码-基础版
- 文件删除需要管理员权限
- IE浏览器 请求报304,解决办法 设置页面禁止缓存
- Kali 开机启动慢解决方案(用时56秒)
- OSChina 周一乱弹 ——程序员已经习惯熬夜了吧
热门文章
- 每日问题记录20171117
- scrapy爬虫程序xpath中文编码报错
- 方法执行[置顶] onPause()和onStop()的使用方法及注意事项
- C#压缩解压zip 文件
- w10系统没有打开方式_小白怎么制作微软官方win10系统安装启动U盘
- 对前端来说token代表了什么_在线公开课 | 前端工程师如何突破瓶颈更好地变现自己...
- 用 Flask 来写个轻博客 (33) — 使用 Flask-RESTful 来构建 RESTful API 之二
- STM32H7的FDCAN
- STVD出现红色区域
- 制作旋转LED的经验