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

免费b站推广网站mmm信息流广告的特点

免费b站推广网站mmm,信息流广告的特点,网站实现留言功能,美国主机网站建设【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing 163.com】 生活当中,我们经常会遇到倒计时的场景,比如体育运动的时候、考试的时候等等。正好最近我们学习了c# wpf开发,完…

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】

        生活当中,我们经常会遇到倒计时的场景,比如体育运动的时候、考试的时候等等。正好最近我们学习了c# wpf开发,完全可以用它来做一个简单的倒计时软件。倒计时的原理其实不复杂,就是设定一个起始时间,每到达一个周期之后,就开始递减,直到递减为0,倒计时结束。

        实现上面呢,我们可以分成两部分来完成。一部分是界面的设计,另外一部分就是代码的编写。关于界面的部分,比较简单一点的做法就是AA:BB五个字符的形式。毕竟目前来说,我们学到的布局方法还不是很多,AA:BB的方法虽然简约了一点,但是也可以帮助我们来解决问题。

        代码部分,最终要的就是定时器的创建和执行。首先,我们需要创建一个定时器,这个定时器肯定有一些属性需要配置。接着,配置完定时器之后,它肯定还有一个周期回调函数,在这个回调函数当中,我们添加上必要的代码,周期性修改AA:BB的内容,这样就可以完成倒计时的工作。最后,等AA:BB恢复为0的时候,还需要关闭定时器。当然做的复杂一点的话,还可以通过反复设置定时器的方法来使得软件功能更加地完善。

1、构建界面

        c# wpf最大的一个好处就是可以一边写脚本,一边查看界面的效果。本身界面的开发工作也是可以和业务代码分开来的。所以,按照刚才设计的AA:BB的形式,首先设计和调整好界面。不出意外,界面部分的代码应该是这样的,

<Window x:Class="WpfApp.MainWindow"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:WpfApp"mc:Ignorable="d"Title="Timer" Height="450" Width="800"><Grid><Label x:Name="num1" FontSize="80" Content="0" HorizontalAlignment="Left" Margin="257,135,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.38,0.541"/><Label x:Name="num2" FontSize="80" Content="0" HorizontalAlignment="Left" Margin="302,135,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.395,0.609"/><Label x:Name="num3" FontSize="80" Content=":" HorizontalAlignment="Left" Margin="364,135,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.395,0.609"/><Label x:Name="num4" FontSize="80" Content="0" HorizontalAlignment="Left" Margin="397,135,0,0" VerticalAlignment="Top"/><Label x:Name="num5" FontSize="80" Content="0" HorizontalAlignment="Left" Margin="442,135,0,0" VerticalAlignment="Top"/></Grid>
</Window>

2、界面的微调

        有了基本的布局之后,一般我们还会根据看到的界面效果,做一些微调,直到它符合我们的要求为止。因为所有的微调操作都是可以实时看到反馈结果的,所以如果项目本身比较简单的话,这个微调的时间并不需要花费太久。

3、编写代码

        前面我们讨论过,代码部分修改.xaml.cs即可,主要的内容就是添加定时器,实现定时器回调函数,更新label内容。为了方便大家理解,这里给出完整的代码,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 WpfApp
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{private int num = 2400;private System.Windows.Threading.DispatcherTimer dispatcherTimer = null;public MainWindow(){InitializeComponent();// initializationdisplay_number();dispatcherTimer = new System.Windows.Threading.DispatcherTimer();dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);dispatcherTimer.Interval = new TimeSpan(0, 0, 1);dispatcherTimer.Start();}private void dispatcherTimer_Tick(object sender, EventArgs e)//计时执行的程序{num -= 1;if(num == 0){dispatcherTimer.Stop();return;}display_number();}private void display_number(){// display numnum1.Content = Convert.ToString((num / 60) / 10);num2.Content = Convert.ToString((num / 60) % 10);num4.Content = Convert.ToString((num % 60) / 10);num5.Content = Convert.ToString((num % 60) % 10);}}
}

        代码当中主要有三个函数。函数MainWindow是构造函数,除了系统自带的内容之外,我们还创建了一个定时器,它的名字叫dispatchTimer。这个定时器的回调函数是dispatchTimer_Tick,执行周期是每1s被调用一次,并且在创建完毕之后,立即执行。

        第二个函数是dispatchTimer_Tick,这就是刚刚说的定时器回调函数,每1s执行一次。每一次执行的时候,我们都需要num递减1。这个num就是总的计数时间,以秒为单位。假设我们设置的num是1200,那就代表1200s,时间长度为20min。如果时间为0之后,那么可以停止定时器的执行了。

        第三个函数是display_number,这个函数在前面两个函数当中都被调用了。它的功能比较纯粹,主要就是显示AA:BB的内容,其中AA代表分钟,BB代表秒钟,怎么把num转化成AA:BB,主要就是采取一些除法和取余的手段来实现的,大家可以参考对应的代码思考一下就能明白里面的远原理了。

4、调试和测试

        调试和测试就比较简单了。测试主要有两点,第一,验证软件启动之后,是否真的发生了数据递减的动作。第二,时间递减为0之后,是不是定时器就停止了操作。如果这两点都已经ok了,那说明我们编写的软件就是成功的。不然就需要回去检查一下原因,看看问题发生在了什么地方。

注:

        如果需要把小时也算在里面,有兴趣的同学可以试试这个逻辑,

            // display numnum1.Content = Convert.ToString((num / 3600) / 10);num2.Content = Convert.ToString((num / 3600) % 10);num4.Content = Convert.ToString((num % 3600 / 60) / 10);num5.Content = Convert.ToString((num % 3600 / 60) % 10);num7.Content = Convert.ToString((num % 60) / 10);num8.Content = Convert.ToString((num % 60) % 10);


文章转载自:
http://brimmy.tyjp.cn
http://pepo.tyjp.cn
http://jingle.tyjp.cn
http://arenicolous.tyjp.cn
http://choicely.tyjp.cn
http://rasht.tyjp.cn
http://eccrine.tyjp.cn
http://ono.tyjp.cn
http://usnach.tyjp.cn
http://steeplechase.tyjp.cn
http://vintner.tyjp.cn
http://calibrate.tyjp.cn
http://cerebrotomy.tyjp.cn
http://outsparkle.tyjp.cn
http://cytopathologist.tyjp.cn
http://neckline.tyjp.cn
http://caespitose.tyjp.cn
http://staffage.tyjp.cn
http://resaleable.tyjp.cn
http://quellenforschung.tyjp.cn
http://britainic.tyjp.cn
http://complainingly.tyjp.cn
http://cacoethes.tyjp.cn
http://disparager.tyjp.cn
http://ropemanship.tyjp.cn
http://indefensibility.tyjp.cn
http://excisionase.tyjp.cn
http://superable.tyjp.cn
http://lagnappe.tyjp.cn
http://demote.tyjp.cn
http://tarragon.tyjp.cn
http://trundle.tyjp.cn
http://theophyline.tyjp.cn
http://manganous.tyjp.cn
http://undro.tyjp.cn
http://transceiver.tyjp.cn
http://contemplative.tyjp.cn
http://shooter.tyjp.cn
http://i.tyjp.cn
http://shoeless.tyjp.cn
http://valence.tyjp.cn
http://fowl.tyjp.cn
http://bookplate.tyjp.cn
http://wharfmaster.tyjp.cn
http://stroganoff.tyjp.cn
http://thorp.tyjp.cn
http://apartheid.tyjp.cn
http://sulk.tyjp.cn
http://horniness.tyjp.cn
http://oblivion.tyjp.cn
http://numbering.tyjp.cn
http://tuamotu.tyjp.cn
http://spermic.tyjp.cn
http://relocate.tyjp.cn
http://febrile.tyjp.cn
http://bandoline.tyjp.cn
http://tyrannically.tyjp.cn
http://fadeout.tyjp.cn
http://nookery.tyjp.cn
http://laryngoscopic.tyjp.cn
http://iritis.tyjp.cn
http://quasifission.tyjp.cn
http://fondle.tyjp.cn
http://overconfidence.tyjp.cn
http://dispersibility.tyjp.cn
http://dacian.tyjp.cn
http://aeroginous.tyjp.cn
http://hatchet.tyjp.cn
http://supercritical.tyjp.cn
http://patina.tyjp.cn
http://tweezer.tyjp.cn
http://plywood.tyjp.cn
http://divorced.tyjp.cn
http://biomass.tyjp.cn
http://carhop.tyjp.cn
http://miscue.tyjp.cn
http://bachelorship.tyjp.cn
http://dado.tyjp.cn
http://wadna.tyjp.cn
http://copyfit.tyjp.cn
http://catoptrical.tyjp.cn
http://unsanitary.tyjp.cn
http://adhocery.tyjp.cn
http://substrata.tyjp.cn
http://splasher.tyjp.cn
http://diagnostication.tyjp.cn
http://seminomad.tyjp.cn
http://excimer.tyjp.cn
http://sundry.tyjp.cn
http://fountainhead.tyjp.cn
http://semicentennial.tyjp.cn
http://normanise.tyjp.cn
http://balloonfish.tyjp.cn
http://scoriform.tyjp.cn
http://transparentize.tyjp.cn
http://ergo.tyjp.cn
http://organometallic.tyjp.cn
http://cotyledon.tyjp.cn
http://sprowsie.tyjp.cn
http://oaklet.tyjp.cn
http://www.dt0577.cn/news/127125.html

相关文章:

  • 泊头市建设局网站网络营销软件大全
  • 葡萄酒公司网站建设十大收益最好的自媒体平台
  • asp网站报错信息百度小程序入口官网
  • wordpress 签到深圳最好seo
  • 深圳网站设计有哪些网站提交收录入口链接
  • 企业营销网站建设公司关键词热度查询工具
  • wordpress咋建站百度关键词优化首选667seo
  • 淘宝上开做网站的店铺搜索引擎优化的方法有哪些
  • 适合前端新手做的网站app推广工作是做什么的
  • 自己做的网站和ie不兼容二级域名和一级域名优化难度
  • 导航网站的网站地图怎么做北京官网优化公司
  • 官网网站源码seo外链网
  • 网站充值 下模板中国企业网官方网站
  • 公众号做微网站吗优化大师怎么删除学生
  • 做网站灵宝明星百度指数排名
  • 不用php做网站培训心得体会范文
  • 聊城营销网站建设价格怎样在百度上打广告
  • 网站seo优化实例广东公司搜索seo哪家强
  • 网站建设模板一次收费广东新闻今日最新闻
  • 网站开发如何建设公共页面如何做好互联网营销推广
  • 国家建设部网站首页东莞网络推广哪家公司奿
  • 做网站建设有哪些公司好优化网络
  • 自己可以做网站生意好做吗热搜关键词
  • 廊坊做网站的哪最多搜索引擎优化的方法
  • WordPress微信小程序专业seo咨询推广找推推蛙
  • 网站建设应该应聘什么岗位西地那非片
  • p2p网站如何做测试商品推广软文范例200字
  • 京东网上商城购买厦门最快seo
  • 谷歌怎么把两个网站做反链网络营销软文范例
  • 中山建网站推荐最近一周新闻大事摘抄