当前位置: 首页 > news >正文

陕西网站建设咨询/seo黑帽教程视频

陕西网站建设咨询,seo黑帽教程视频,东莞百度推广教程,深圳微信网站制作WPF loading遮罩层 LoadingMask 原文:WPF loading遮罩层 LoadingMask大家可能很纠结在异步query数据的时候想在wpf程序中显示一个loading的遮罩吧 今天就为大家介绍下遮罩的制作 源码下载 点击此处 先上张效果图看看 如果不如您的法眼 可以移步了 或者有更好的效果 可以留言给我…
WPF loading遮罩层 LoadingMask
原文:WPF loading遮罩层 LoadingMask

大家可能很纠结在异步query数据的时候想在wpf程序中显示一个loading的遮罩吧

今天就为大家介绍下遮罩的制作

源码下载 点击此处


先上张效果图看看 如果不如您的法眼 可以移步了 或者有更好的效果 可以留言给我 



废话不多说 直接贴代码 一个usercontrol

<UserControl x:Class="LoadingMask_Demo.LoadingWait"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" IsVisibleChanged="HandleVisibleChanged"><UserControl.Background><SolidColorBrush Color="Black" Opacity="0.2"  /></UserControl.Background><UserControl.Resources><SolidColorBrush Color="#FF007BE5" x:Key="CirclesColor" /><!--<SolidColorBrush Color="Black" x:Key="BackgroundColor" Opacity=".20" />--></UserControl.Resources><Viewbox Width="100" Height="100"  HorizontalAlignment="Center"  VerticalAlignment="Center"><Grid x:Name="LayoutRoot"   Background="Transparent"  ToolTip="Please wait...."  HorizontalAlignment="Center"  VerticalAlignment="Center"><TextBlock Text="Loading..."  HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Foreground="#FFE3953D" FontWeight="Bold" /><Canvas RenderTransformOrigin="0.5,0.5"  HorizontalAlignment="Center"  VerticalAlignment="Center" Width="120"  Height="120" Loaded="HandleLoaded"  Unloaded="HandleUnloaded"  ><Ellipse x:Name="C0" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="1.0"/><Ellipse x:Name="C1" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.9"/><Ellipse x:Name="C2" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.8"/><Ellipse x:Name="C3" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.7"/><Ellipse x:Name="C4" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.6"/><Ellipse x:Name="C5" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.5"/><Ellipse x:Name="C6" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.4"/><Ellipse x:Name="C7" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.3"/><Ellipse x:Name="C8" Width="20" Height="20"  Canvas.Left="0"  Canvas.Top="0" Stretch="Fill"  Fill="{StaticResource CirclesColor}" Opacity="0.2"/><Canvas.RenderTransform><RotateTransform x:Name="SpinnerRotate"  Angle="0" /></Canvas.RenderTransform></Canvas></Grid></Viewbox>
</UserControl>后台代码:using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;namespace LoadingMask_Demo
{/// <summary>/// Interaction logic for LoadingWait.xaml/// </summary>public partial class LoadingWait : UserControl{#region Dataprivate readonly DispatcherTimer animationTimer;#endregion#region Constructorpublic LoadingWait(){InitializeComponent();animationTimer = new DispatcherTimer(DispatcherPriority.ContextIdle, Dispatcher);animationTimer.Interval = new TimeSpan(0, 0, 0, 0, 90);}#endregion#region Private Methodsprivate void Start(){animationTimer.Tick += HandleAnimationTick;animationTimer.Start();}private void Stop(){animationTimer.Stop();animationTimer.Tick -= HandleAnimationTick;}private void HandleAnimationTick(object sender, EventArgs e){SpinnerRotate.Angle = (SpinnerRotate.Angle + 36) % 360;}private void HandleLoaded(object sender, RoutedEventArgs e){const double offset = Math.PI;const double step = Math.PI * 2 / 10.0;SetPosition(C0, offset, 0.0, step);SetPosition(C1, offset, 1.0, step);SetPosition(C2, offset, 2.0, step);SetPosition(C3, offset, 3.0, step);SetPosition(C4, offset, 4.0, step);SetPosition(C5, offset, 5.0, step);SetPosition(C6, offset, 6.0, step);SetPosition(C7, offset, 7.0, step);SetPosition(C8, offset, 8.0, step);}private void SetPosition(Ellipse ellipse, double offset,double posOffSet, double step){ellipse.SetValue(Canvas.LeftProperty, 50.0+ Math.Sin(offset + posOffSet * step) * 50.0);ellipse.SetValue(Canvas.TopProperty, 50+ Math.Cos(offset + posOffSet * step) * 50.0);}private void HandleUnloaded(object sender, RoutedEventArgs e){Stop();}private void HandleVisibleChanged(object sender,DependencyPropertyChangedEventArgs e){bool isVisible = (bool)e.NewValue;if (isVisible)Start();elseStop();}#endregion  }
}

调用的代码也贴出来吧


<Window x:Class="LoadingMask_Demo.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525"xmlns:local="clr-namespace:LoadingMask_Demo"><DockPanel><StackPanel Orientation="Horizontal" DockPanel.Dock="Top"><Button  Content="show" Width="70" Height="30" Click="ShowButton_Click" /><Button  Content="hide" Width="70" Height="30" Click="HideButton_Click"/></StackPanel><Grid Background="#FF484848" DockPanel.Dock="Bottom"><TextBlock Text="asdfasdfasdf" Foreground="White"/><local:LoadingWait x:Name="_loading"  Visibility="Collapsed"/></Grid></DockPanel>
</Window>后台代码using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace LoadingMask_Demo
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}private void ShowButton_Click(object sender, RoutedEventArgs e){this._loading.Visibility = Visibility.Visible;}private void HideButton_Click(object sender, RoutedEventArgs e){this._loading.Visibility = Visibility.Collapsed;}}
}




posted on 2019-04-25 14:09 NET未来之路 阅读(...) 评论(...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/p/10768132.html

http://www.lbrq.cn/news/1335907.html

相关文章:

  • 营销型网站建设主要教学内容/小程序平台
  • 企业网站排行榜/一站式软文发布推广平台
  • 做英文网站公司/手机网站免费客服系统
  • 影视广告宣传片制作公司/seo搜索排名
  • 网站建设都用哪个好/网络销售的工作内容
  • 基于java开发网站开发/5188关键词平台
  • 北京米兰广告设计有限公司/网站推广与优化平台
  • 做b2b网站管理系统/外包公司怎么赚钱
  • 用dw做网站时怎么添加弹窗/今日全国疫情一览表
  • ppt设计公司/短视频排名seo
  • 自己怎么做淘宝客网站吗/sem与seo
  • python做网站设计/域名注册查询阿里云
  • wordpress 钩子大全/北京seo技术交流
  • 个人博客搭建wordpress/网络优化seo
  • 做5g网站/中山seo推广优化
  • 买房子最好的网站/bt磁力搜索
  • 重庆seo小z博客/西安seo网络推广
  • 网站里的图片切换怎么做/长沙做网站推广公司咨询
  • 公众号推送怎么制作/宁波网站关键词优化排名
  • 2015年做啥网站致富/湖北网站seo
  • 江宁住房和城乡建设局网站/网站注册搜索引擎的目的是
  • 网站开发招聘名称/优化关键词排名推广
  • 怎么接网站开发外包/电商代运营一般收多少服务费
  • 做网站用需要几个软件/营销策划是做什么
  • 温州网站建设优化公司/农大南路网络营销推广优化
  • wordpress主题框架开发/seo会被取代吗
  • 如何申请自己的个人网站/深圳seo推广公司
  • 深圳龙华鸿宇大厦网站建设/建网站的软件有哪些
  • 企业网站产品分类多怎么做seo/近期网络舆情事件热点分析
  • 深圳网站建设 手机网站建设/今日头条极速版官网
  • 1小时 MySQL 数据库基础速通
  • 负载均衡详解
  • 编程技能:递归
  • 软考 系统架构设计师系列知识点之杂项集萃(121)
  • Rust学习笔记(一)|Rust初体验 猜数游戏
  • 【排序算法】⑥快速排序:Hoare、挖坑法、前后指针法