| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2017/3/3 17:44:09
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Threading;
- using System.Windows.Threading;
- using GalaSoft.MvvmLight;
- using Muchinfo.MTPClient.Resources;
- namespace Muchinfo.MTPClient.Bank.ViewModels
- {
- public class IdentifyCodeTimerViewModel:ViewModelBase
- {
- private const int c_tick = 60;
- private DispatcherTimer indentifyCodeTimer;
- private bool _isEnable=true;
- /// <summary>
- /// 是否可以点验证码
- /// </summary>
- public bool IsEnalbe
- {
- get { return _isEnable; }
- set { Set(() => IsEnalbe, ref _isEnable, value); }
- }
-
- /// <summary>
- /// 当前倒数多少秒
- /// </summary>
- public string CurrentTick
- {
- // get { return _currentTick; }
- get
- {
- if (_curerntSconds <= 0)
- {
- return Client_Resource.Content_GetIdentifyCode;
- }
- return _curerntSconds + "s";
- }
- }
- /// <summary>
- /// 当前秒数
- /// </summary>
- private int _curerntSconds=0;
- /// <summary>
- /// 当前秒数
- /// </summary>
- public int CurerntSconds
- {
- get { return _curerntSconds; }
- set
- {
- Set(() => CurerntSconds, ref _curerntSconds, value);
- RaisePropertyChanged(() => CurrentTick);
- }
- }
-
- public IdentifyCodeTimerViewModel()
- {
- indentifyCodeTimer=new DispatcherTimer();
- indentifyCodeTimer.Interval =new TimeSpan(0,0,0, 1);
- indentifyCodeTimer.Tick += indentifyCodeTimer_Tick;
-
- }
- void indentifyCodeTimer_Tick(object sender, EventArgs e)
- {
-
- CurerntSconds -= 1;
- if (CurerntSconds <= 0)
- {
- indentifyCodeTimer.Stop();
- IsEnalbe = true;
- }
- }
- /// <summary>
- /// 启动计时
- /// </summary>
- public void Start()
- {
- if (indentifyCodeTimer != null)
- {
- indentifyCodeTimer.Start();
- CurerntSconds = c_tick;
- IsEnalbe = false;
- }
- }
- }
- }
|