• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TimerState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TimerState的典型用法代码示例。如果您正苦于以下问题:C# TimerState类的具体用法?C# TimerState怎么用?C# TimerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TimerState类属于命名空间,在下文中一共展示了TimerState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Convert

 private Brush Convert(TimerState state)
 {
     Brush result = null;
     switch (state)
     {
         case TimerState.Ready:
             result = ReadyBrush;
             break;
         case TimerState.Sprint:
             result = SprintBrush;
             break;
         case TimerState.HomeStraight:
             result = HomeStraightBrush;
             break;
         case TimerState.Break:
             result = BreakBrush;
             break;
         case TimerState.BreakOverrun:
             result = BreanOverrunBrush;
             break;
         default:
             break;
     }
     return result;
 }
开发者ID:kewkie,项目名称:WorkBalance,代码行数:25,代码来源:TimerStateToBrushConverter.cs


示例2: buttonStart_Click

 private void buttonStart_Click(object sender, EventArgs e)
 {
     switch (this.timerState)
     {
         case TimerState.Stopped:
             this.elapsedTime = TimeSpan.FromSeconds(0);
             this.timer.Start();
             this.labelTime.Text = Config.GetTimeString(TimeSpan.FromSeconds(0));
             this.buttonStart.Text = @"Pause";
             this.timerState = TimerState.Started;
             this.buttonStop.Enabled = true;
             break;
         case TimerState.Started:
             this.timer.Stop();
             this.buttonStart.Text = @"Start";
             this.config.Save();
             this.timerState = TimerState.Paused;
             break;
         case TimerState.Paused:
             this.timer.Start();
             this.buttonStart.Text = @"Pause";
             this.timerState = TimerState.Started;
             break;
         default:
             break;
     }
 }
开发者ID:pongo,项目名称:uppTimer,代码行数:27,代码来源:Form1.cs


示例3: Stop

 public void Stop()
 {
     State = TimerState.Stopped;
     CurrentTime = TimeSpan.Zero;
     OnStopped();
     Stopped.Raise(this, EventArgs.Empty);
 }
开发者ID:gitter-badger,项目名称:MonoGame.Extended,代码行数:7,代码来源:GameTimer.cs


示例4: Timer

        public Timer()
        {
            if (System.Diagnostics.Debugger.IsAttached)
            {
                m_SprintDuration = TimeSpan.FromSeconds(10);
                m_HomeStraightDuration = TimeSpan.FromSeconds(1);
                m_BreakDuration = TimeSpan.FromSeconds(5);
                m_MaxBreakDuration = TimeSpan.FromSeconds(10);
            }
            else
            {
                m_SprintDuration = TimeSpan.FromMinutes(25);
                m_HomeStraightDuration = TimeSpan.FromMinutes(1);
                m_BreakDuration = TimeSpan.FromMinutes(5);
                m_MaxBreakDuration = TimeSpan.FromMinutes(60);
            }

            m_InternalStates = new Dictionary<TimerState, ITimerState>();
            m_InternalStates.Add(TimerState.Ready, new ReadyTimerState(this));
            m_InternalStates.Add(TimerState.Sprint, new SprintTimerState(this));
            m_InternalStates.Add(TimerState.HomeStraight, new HomeStraightTimerState(this));
            m_InternalStates.Add(TimerState.Break, new BreakTimerState(this));
            m_InternalStates.Add(TimerState.BreakOverrun, new BreakOverrunTimerState(this));

            m_Timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) };
            m_Timer.Tick += (s, e) => m_InternalState.HandleSecondElapsed();

            _State = TimerState.Ready;
            m_InternalState = m_InternalStates[_State];
            m_InternalState.OnEnter();
        }
开发者ID:kewkie,项目名称:WorkBalance,代码行数:31,代码来源:Timer.cs


示例5: Start

 // Use this for initialization
 void Start()
 {
     actualTimeRemaining = 0f;
     minutesRemaining = 0;
     secondsRemaining = 0;
     timerState = TimerState.PAUSED;
     gameManagerScript = gameManagerObject.GetComponent<GameManager>();
 }
开发者ID:cpioli,项目名称:Ecovoi,代码行数:9,代码来源:TimerBehavior.cs


示例6: GetStateString

        public static string GetStateString(TimerState state)
        {
            var formatString = " ({0}{1})";
            var workOrBreak = state.ToString().Contains("Work") ? "work" : "break";
            var paused = state.ToString().Contains("Pause") ? " paused" : "";

            return string.Format(formatString, workOrBreak, paused);
        }
开发者ID:reliak,项目名称:reliak-timer,代码行数:8,代码来源:FormatHelper.cs


示例7: InvokeEventHandler

 internal static void InvokeEventHandler(EventHandler<TimerStateChangedEventArgs> handler, object sender, TimerState previousState, TimerState newState)
 {
     var snapshot = handler;
     if (snapshot != null)
     {
         snapshot.DynamicInvoke(sender, new TimerStateChangedEventArgs(previousState, newState));
     }
 }
开发者ID:kewkie,项目名称:WorkBalance,代码行数:8,代码来源:TimerStateChangedEventArgs.cs


示例8: Timer

 public Timer() {
     this.interval = 10;
     this.loop = true;
     this.showCountDown = true;
     this.onClientElapsed = "";
     this.finalSecondsBlink = false;
     this.finalSecondsThreshold = 0;
     this.timerState = TimerState.Started;
 }
开发者ID:katshann,项目名称:ogen,代码行数:9,代码来源:Timer.cs


示例9: PerformanceTimer

        public PerformanceTimer()
        {
            timerState = TimerState.Stopped;

            if (QueryPerformanceFrequency(ref tickFreq) == false)
            {
                throw new ApplicationException("Failed to query for the performance frequency!");
            }
        }
开发者ID:edwardsak,项目名称:homm,代码行数:9,代码来源:Timer.cs


示例10: Reset

        public void Reset()
        {
            // Stop tracking and reset time
            timer.Stop();
            TimerState = TimerState.Stopped;

            startTime = DateTime.Now;
            endTime = startTime;

            CalculateCurrentSpan(endTime, startTime);
        }
开发者ID:Blackjack92,项目名称:TimeManagement,代码行数:11,代码来源:TimerService.cs


示例11: SimpleScheduler

        /// <summary>
        /// Initializes a new instance of the <see cref="SimpleScheduler"/> class.
        /// </summary>
        /// <param name="applicationMapPath">
        /// The application map path.
        /// </param>
        /// <param name="connection">
        /// The connection.
        /// </param>
        /// <param name="period">
        /// The period.
        /// </param>
        /// <remarks>
        /// </remarks>
        protected SimpleScheduler(string applicationMapPath, IDbConnection connection, long period)
        {
            this.localSchDB = new SchedulerDB(connection, applicationMapPath);
            this.localPeriod = period;

            this.localTimerState = new TimerState();

            var t = new Timer(this.Schedule, this.localTimerState, Timeout.Infinite, Timeout.Infinite);

            this.localTimerState.Timer = t;
        }
开发者ID:divyang4481,项目名称:appleseedapp,代码行数:25,代码来源:SimpleScheduler.cs


示例12: Update

    // Update is called once per frame
    void Update()
    {
        if (state == TimerState.Started) {
            timeRemaining -= Time.deltaTime;
            timerLabel.text = string.Format("Time Remaining: {0}", Mathf.RoundToInt(timeRemaining));

            if (timeRemaining < 0f) {
                state = TimerState.Stopped;
                GameManager.Instance.OnOutOfTime();
            }
        }
    }
开发者ID:millwardesque,项目名称:FoodGun,代码行数:13,代码来源:UITimer.cs


示例13: Update

        public void Update(GameTime gameTime)
        {
            if(State!=TimerState.Running) return;

            CurrentTime += gameTime.ElapsedGameTime.TotalMilliseconds;
            if (CurrentTime >= TargetTime)
            {
                CurrentTime = 0;

                if (!Looping) State = TimerState.Finished;

                _callback();
            }
        }
开发者ID:GarethIW,项目名称:TimersAndTweens-XNA,代码行数:14,代码来源:Timer.cs


示例14: RedditAuth

 public RedditAuth(IWebAgent agent)
 {
     _uname = ConfigurationManager.AppSettings["BotUsername"];
     _pass = ConfigurationManager.AppSettings["BotPassword"];
     _clientId = ConfigurationManager.AppSettings["ClientID"];
     _clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
     _redirectUri = ConfigurationManager.AppSettings["RedirectURI"];
     if ( string.IsNullOrEmpty( _uname ) ) throw new Exception( "Missing 'BotUsername' in config" );
     if ( string.IsNullOrEmpty( _pass ) ) throw new Exception( "Missing 'BotPassword' in config" );
     if ( string.IsNullOrEmpty( _clientId ) ) throw new Exception( "Missing 'ClientID' in config" );
     if ( string.IsNullOrEmpty( _clientSecret ) ) throw new Exception( "Missing 'ClientSecret' in config" );
     if ( string.IsNullOrEmpty( _redirectUri ) ) throw new Exception( "Missing 'RedirectURI' in config" );
     _webAgent = agent;
     _timerState = new TimerState();
 }
开发者ID:CrustyJew,项目名称:DirtBag,代码行数:15,代码来源:RedditAuth.cs


示例15: ChangeState

        public void ChangeState(TimerState state)
        {
            using (var session = DocumentStore.OpenSession())
            {
                session.Store(new StateChangedEvent
                {
                    Date = DateTimeOffset.Now,
                    OldState = CurrentState,
                    NewState = state
                });
                session.SaveChanges();
            }

            CurrentState = state;

            if (StateChanged != null)
            {
                StateChanged(state);
            }
        }
开发者ID:daniellangnet,项目名称:FocusMeter,代码行数:20,代码来源:StateManager.cs


示例16: ToggleStartStop

        public void ToggleStartStop()
        {
            // Toggle tracking
            if (TimerState == TimerState.Stopped)
            {
                // Same behavior for reset and stop
                startTime = DateTime.Now;
                timer.Start();
                TimerState = TimerState.Tracking;
            }
            else
            {
                endTime = DateTime.Now;
                timer.Stop();

                // Call event that the time was tracked
                OnTimeTracked();

                // Reset time after tracking
                Reset();
            }
        }
开发者ID:Blackjack92,项目名称:TimeManagement,代码行数:22,代码来源:TimerService.cs


示例17: Timer

        public Timer(
			Guid id,
			string name,
			string description,
			TimeSpan interval,
			TimerState state,
			TimeSpan elapsedTime,
			EventHandlerCollection eventHandlerCollection = null)
        {
            name.ThrowIfNull("name");
            description.ThrowIfNull("description");
            if (interval < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("interval");
            }

            _id = id;
            Name = name;
            Description = description;
            _interval = interval;
            _eventHandlerCollection = eventHandlerCollection;
            State = state;
            ElapsedTime = elapsedTime;
        }
开发者ID:tj-miller,项目名称:TextAdventure,代码行数:24,代码来源:Timer.cs


示例18: ChangeState

        public void ChangeState(TimerState state)
        {
            if(state == CurrentState)
                return;

            using (var session = DocumentStore.OpenSession())
            {
                session.Store(new StateChangedEvent
                {
                    MachineName = Environment.MachineName,
                    Date = DateTimeOffset.Now,
                    OldState = CurrentState,
                    NewState = state
                });
                session.SaveChanges();
            }

            CurrentState = state;

            if (StateChanged != null)
            {
                StateChanged(state);
            }
        }
开发者ID:blackenedstrang,项目名称:FocusMeter,代码行数:24,代码来源:StateManager.cs


示例19: TimerForm_Load

        private void TimerForm_Load(object sender, EventArgs e)
        {
            // Timer object fires once per second
            timerState = TimerState.INIT;
            t = new Timer();
            t.Interval = 1000;
            t.Tick += DecrementTimer;

            // subscribe view
            TimerChanged += UpdateView;
        }
开发者ID:replacer808,项目名称:egg-timer-csharp,代码行数:11,代码来源:Form1.cs


示例20: RunTimer

        private void RunTimer()
        {
            // input validation
            if (!(int.TryParse(txtSec.Text, out seconds))
                || !(int.TryParse(txtMin.Text, out minutes))
                || !(int.TryParse(txtHrs.Text, out hours)))
            {
                return;
            }

            txtSec.ReadOnly = true; // while timer runs
            txtMin.ReadOnly = true;
            txtHrs.ReadOnly = true;
            timerState = TimerState.STARTED;
            DecrementTimer(this, new EventArgs()); // don't want to wait a full second before starting countdown
            t.Start();
            btnStart.Text = "Stop";
        }
开发者ID:replacer808,项目名称:egg-timer-csharp,代码行数:18,代码来源:Form1.cs



注:本文中的TimerState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TimerType类代码示例发布时间:2022-05-24
下一篇:
C# TimerEx类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap