日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UserAccountInfo时间倒计时

發布時間:2025/4/16 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UserAccountInfo时间倒计时 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

界面如下:

代碼如下:

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";//默認方法是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("使用網絡協議期間出錯時引發的異常! " + 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;
}
}

}
}

轉載于:https://www.cnblogs.com/1175429393wljblog/p/5813452.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。