日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

UserAccountInfo时间倒计时

發(fā)布時(shí)間:2025/4/16 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UserAccountInfo时间倒计时 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

界面如下:

代碼如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace WeChatTool
{
public partial class UserAccountInfo : UserControl
{
private TimeSpan timespan = new TimeSpan(2, 0, 0);
private double startTime;
System.Timers.Timer timer = new System.Timers.Timer();
public UserAccountInfo()
{
InitializeComponent();
timer.Enabled = true;
timer.Interval = 1000;
timer.Stop();
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_tick);
}

private void UserAccountInfo_Load(object sender, EventArgs e)
{

}

private void btnProduceToken_Click(object sender, EventArgs e)
{
string token = "";
try
{
Uri url = new Uri("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx04ec9a465d7bbaf2&secret=a31fbf89aa42f984bb3f13a8bf5db949");
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "GET";//默認(rèn)方法是GET
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
token = reader.ReadToEnd();
this.rtbToken.Text = token;
Properties.Settings.Default.token = token;
startTime = timespan.TotalSeconds;
timer.Start();

}
catch (ProtocolViolationException ex)
{
MessageBox.Show("使用網(wǎng)絡(luò)協(xié)議期間出錯(cuò)時(shí)引發(fā)的異常! " + ex.ToString(), "提示信息!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
//throw;
}
}

private void btnRefresh_Click(object sender, EventArgs e)
{
this.timer.Stop();
this.btnTimer.Text = null;
}

private void timer_tick(object sender, System.Timers.ElapsedEventArgs e)
{
setTimer(startTime);
}

public delegate void SetTimer(double timer);

private void setTimer(double timer)
{
if (this.InvokeRequired)
{
this.Invoke(new SetTimer(setTimer), timer);
}
else
{
DateTime datetime = new DateTime(2016,8,18,(int)(timer/3600),(int)((timer/60)%60),(int)((timer/1)%60));
this.btnTimer.Text = datetime.ToString();
startTime -= 1;
}
}

}
}

轉(zhuǎn)載于:https://www.cnblogs.com/1175429393wljblog/p/5813452.html

總結(jié)

以上是生活随笔為你收集整理的UserAccountInfo时间倒计时的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。