public void StartWork() { if (m_bIsOverTime && m_mode == TimerMode.MODE_WORK && TomatoTimerWPF.TimerSettings.Default.GoogleCal_EnableEvent) { OpenGoogleCalender(m_TimeDateStart, DateTime.Now); } SetWindowFlash(false); m_TimeDateStart = DateTime.Now; m_TimeDatePauseStart = DateTime.Now; m_TimeSpanPause = TimeSpan.FromMinutes(0); m_TimeSpan = TimeSpan.FromMinutes(0); m_mode = TimerMode.MODE_WORK; m_bIsPause = false; //if (menuClose.Visibility == System.Windows.Visibility.Collapsed) //{ // menuClose.Visibility = System.Windows.Visibility.Visible; // btnClose.Visibility = System.Windows.Visibility.Collapsed; //} UpdateUI(); }
// c'tor public TetrisModelImpl() { Debug.WriteLine("c'tor TetrisModel"); this.random = new Random(); this.testTetriCounter = 0; this.board = new TetrisBoard(this.NumRows, this.NumColumns); this.board.BoardChanged += this.TetrisBoard_Changed; this.board.LinesCompleted += this.TetrisBoard_LinesCompleted; this.state = TetrisState.Idle; this.gameState = GameState.GameIdle; this.viewCellList = new ViewCellList(); // initialize score management this.level = 1; this.lines = 0; this.score = 0; // setup timer this.timerMode = TimerMode.Normal; this.maxIntervalCounter = MaxIntervalCounter; this.currentIntervalCounter = 0; }
public void ReadDataFromPCIE(object sender, EventArgs e) { try { this.delGate(EMGthread.startChannel, EMGthread.channelCount, this.data); for (int i = 0; i < EMGthread.channelCount; i++) { dataHistory[dataIndMeas, i] = this.data[i]; } dataIndMeas++; if (dataIndMeas >= this.dataPerMeasurment) { dataIndMeas = 0; this.readDataTimer.Stop(); this.ReadyToSave(sender, e); this.measurmentMode = TimerMode.Pause; this.readDataTimer.Tick -= new System.EventHandler(this.ReadDataFromPCIE); this.readDataTimer.Tick += new System.EventHandler(this.ReadDataPauseMode); } } catch (System.Exception err) { MessageBox.Show(err.Message); } }
public void StartRelax() { if (m_bIsOverTime && m_mode == TimerMode.MODE_WORK && TomatoTimerWPF.TimerSettings.Default.GoogleCal_EnableEvent) { OpenGoogleCalender(m_TimeDateStart, DateTime.Now); } SetWindowFlash(false); m_TimeDateStart = DateTime.Now; m_TimeDatePauseStart = DateTime.Now; m_TimeSpanPause = TimeSpan.FromMinutes(0); m_TimeSpan = TimeSpan.FromMinutes(0); m_mode = TimerMode.MODE_RELAX; if (m_pageButtons != null) { if (m_pageButtons.GetIsLongMouseDown()) { m_mode = TimerMode.MODE_RELAX_LONG; } } m_bIsPause = false; //if (menuClose.Visibility == System.Windows.Visibility.Visible) //{ // menuClose.Visibility = System.Windows.Visibility.Collapsed; // btnClose.Visibility = System.Windows.Visibility.Visible; //} UpdateUI(); }
private void btnStart_Click(object sender, RoutedEventArgs e) { if (btnStart.Content.ToString().StartsWith("Start")) { var strHours = Hours.SelectionBoxItem.ToString(); var strMinutes = Minutes.SelectionBoxItem.ToString(); var timerMode = Type.SelectionBoxItem.ToString(); double hours; double minutes; double.TryParse(strHours, out hours); double.TryParse(strMinutes, out minutes); expectedTime = DateTime.Now.AddHours(hours).AddMinutes(minutes); selectedMode = timerMode.StartsWith("Sleep") ? TimerMode.Sleep : TimerMode.ShutDown; btnStart.Content = "Stop"; btnStart.Background = Brushes.Red; Timer.Start(); } else { selectedMode = TimerMode.Nope; expectedTime = DateTime.MaxValue; label.Content = "Please choose time."; btnStart.Content = "Start"; btnStart.Background = Brushes.Green; label.Content = "Please choose time."; Timer.Stop(); } }
private static extern uint timeSetEvent( uint uDelay, uint uResolution, LpTimeProcDelegate lpTimeProc, int dwUser, TimerMode fuEvent );
private void ImPlayingButtonClickEventHandler(object sender, RoutedEventArgs e) { TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; TaskbarItemInfo.ProgressValue = 0; _timerMode = TimerMode.Play; TimerDisplay.Invoke(x => x.ResetWorkTimer()); }
/// <summary> /// Method that updates all the elements in the HUD /// </summary> protected override void UpdateHUD() { base.UpdateHUD(); if (GameModeBase.activeGameMode == null) { return; } TimerMode timerMode = GameModeBase.activeGameMode as TimerMode; if (timerMode == null) { Debug.LogError("Got timedHUD, but no timed GameMode", this); return; } //Here we convert the timer to a readable M:SS structure //Todo, put this conversion in a Utility script float timer = timerMode.remainingTime; int minutes = Mathf.FloorToInt(timer / 60F); int seconds = Mathf.FloorToInt(timer - minutes * 60); string formattedTime = string.Format("{0:0}:{1:00}", minutes, seconds); timerTextfield.text = formattedTime; }
private void InitializeSettingsAndStartTimer(DateTime startTime, TimerMode timerMode) { ModeTimer = timerMode; ModeFunction = Settings.Default.ModeFunction; switch (ModeTimer) { case TimerMode.Started: Log.Info("WorkTimer in Start mode"); StartTimer(m_TimerHelper.GetTestingStartTime(startTime, 0)); //testing purpose break; case TimerMode.Paused: Log.Info("WorkTimer in Pause mode"); TimerText.Text = Formatter.FormatTimeSpan(Settings.Default.PauseTime); TimerPauseAdjustments(); break; case TimerMode.Stopped: Log.Info("WorkTimer in Stop mode"); TimerStopAdjustments(); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// /// </summary> /// <param name="givenTime"></param> /// <param name="timerMode"></param> public void StartTimer(float givenTime, string timerName = "", TimerMode timerMode = TimerMode.Countdown, bool restartAfterEnd = false) { cachedTimerDuration = givenTime; //cache time in case restarts restartAfterTimerFinish = restartAfterEnd; //cache timerIsActive = true; ToggleVisuals(true); switch (timerMode) { case TimerMode.Countdown: //fire alarm after this much time passes timerEndTime = Time.time + givenTime; break; case TimerMode.Alarm: //fire alarm at this time timerEndTime = givenTime; break; } //handle visuals if (timerTitleText) { timerTitleText.text = timerName; } coroutine_updateVisuals = StartCoroutine(UpdateVisuals()); }
public NeatlyTimerImplement InitFrame(NeatlyBehaviour bh, Action <float> action, float intervalFrame, bool once) { Init(bh, action); m_IntervalFrame = intervalFrame; m_TimerMode = TimerMode.Frame; m_Once = once; return(this); }
public NeatlyTimerImplement InitClock(GameObject go, Action <float> action, float intervalClock, bool once) { Init(go, action); m_IntervalClock = intervalClock; m_TimerMode = TimerMode.Clock; m_Once = once; return(this); }
public NeatlyTimerImplement InitFrame(GameObject go, Action <float> action, float intervalFrame, bool once) { Init(go, action); m_IntervalFrame = intervalFrame; m_TimerMode = TimerMode.Frame; m_Once = once; return(this); }
public void SetTimer(int minutes, int seconds) { _running = true; _timerMode = TimerMode.CountDown; _timerMinutes = minutes; _timerSeconds = seconds; _timerStartTime = Time.time; }
public NeatlyTimerImplement InitClock(NeatlyBehaviour bh, Action <float> action, float intervalClock, bool once) { Init(bh, action); m_IntervalClock = intervalClock; m_TimerMode = TimerMode.Clock; m_Once = once; return(this); }
StopwatchModelProgram() { // We begin be initializing the system with the time showing, // the timer reset and not frozen. timerDisplayed = false; timerFrozen = false; timerMode = TimerMode.Reset; }
public Timer(float targetTimeSeconds, bool triggerOnce, TimerMode mode = TimerMode.Game) { TargetTimeSeconds = targetTimeSeconds; CurrentTimeSeconds = 0.0f; TriggerOnce = triggerOnce; HasTriggered = false; StartTimeSeconds = -1; Mode = mode; }
public NeatlyTimerImplement InitClock(object obj, Action <float> action, float intervalClock, bool once) { Init(obj, action); m_IntervalClock = intervalClock; m_TimerMode = TimerMode.Clock; m_Once = once; IsEnabled = true; return(this); }
/// <summary> /// Initialize timer with default values. /// </summary> private void Initialize() { _mode = TimerMode.Periodic; _period = Capabilities.periodMin; _resolution = 1; IsRunning = false; _timeProcPeriodic = TimerPeriodicEventCallback; _timeProcOneShot = TimerOneShotEventCallback; _tickRaiser = OnTick; }
public static TTimer Set <TTimer>(GameObject owner, float triggerTime, TimerMode mode = TimerMode.OneShot) where TTimer : Timer { TTimer timer = owner.AddComponent <TTimer>(); timer.TriggerTime = triggerTime; timer.Mode = mode; return(timer); }
public MemoryLogic(MemoryGame game, TimerMode timerMode, MemoryPlayers players, Stream loadStream = null) { // Check of we een spel moeten laden bool loadGame = loadStream != null; // copieer de benodige data vanuit het memorygame object game currentGame = game; context = currentGame.context; memoryCards = currentGame.memoryCards; gameInterface = currentGame.context.gameInterface; nKaartenGelijk = currentGame.nKaartenGelijk; // deze lijst gebruiken we om de zetten te onthouden moves = new List <Move>(); // timer om de kaarten na een tijdje terug te leggen kaartTimer = new Timer(); kaartTimer.Interval = 1000; // tijd tot kaarten weer terug vallen in ms kaartTimer.AutoReset = false; // zorgt dat een timer een keer aftelt // registreer de callback functie KaartenTerugLeggen voor het event Elapsed kaartTimer.Elapsed += KaartenTerugLeggen; // maak de feedback overlay images KaartFeedback = new MemoryOverlays(currentGame); // Setup de player data if (loadGame) { playerGroup = loadStream.Load() as MemoryPlayers; } else { playerGroup = players; } // als een nieuwe game word gestart dobbelen we wie start if (!loadGame) { playerGroup.aanZet = Global.RandomNumberGenerator.Next(playerGroup.players.Count); } // setup of herlaad de game status if (loadGame) { gameStatus = loadStream.Load() as GameStatus; } else { gameStatus = new GameStatus(timerMode, currentGame.nKaartenUniek); } // setup het game interface gameInterface.Setup(this); }
static public TimerMode GetCurrentTimerMode() { TimerMode retValue = TimerMode.WAIT_PAUSE; try { retValue = timerMode; } catch (Exception) { }; return(retValue); }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked == true) { mode = TimerMode.StopWatch; } else { mode = TimerMode.Timer; } }
private void DoBeginAllWayDown() { if (this.State != TetrisState.Normal) { return; } // accelerate timer this.timerMode = TimerMode.Accelerated; // increase amount of active timer ticks this.State = TetrisState.Accelerated; // allow only 'MoveDown' actions from now on }
// Initialize timer with default values. private void Initialize() { this.mode = TimerMode.Periodic; this.period = Capabilities.periodMin; this.resolution = 1; running = false; timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback); timeProcOneShot = new TimeProc(TimerOneShotEventCallback); tickRaiser = new EventRaiser(OnTick); }
//Setup Timer game mode public void SetupTimerMode() { TimerMode mode = gameObject.AddComponent <TimerMode>(); mode.timerUI = timerUI; mode.SetupMode(gameTimer); mode.SetupDifficult(dificulty); FindObjectOfType <LapDetector>().totalLaps = 1; timerItems.gameObject.SetActive(true); timerUI.gameObject.SetActive(true); }
internal Timer(TimerQueue queue, TimerMode mode, TimerExecutionContext context, bool isLongRunning, uint dueTime, uint period, TimerCallback callback) { Debug.Assert(queue != null); Debug.Assert(callback != null); Queue = queue; Mode = mode; ExecutionContext = context; IsLongRunning = isLongRunning; Period = period; DueTime = dueTime; Callback = callback; }
// Token: 0x060002B0 RID: 688 RVA: 0x0000A160 File Offset: 0x00008360 public Timer(uint period, uint resolution, TimerMode mode) { if (period < Timer.MinimumPeriod || period > Timer.MaximumPeriod) { throw new ArgumentOutOfRangeException("period", period, "The specified period was outside of the range specified by Timer.MinimumPeriod and Timer.MaximumPeriod."); } if (!mode.IsDefined <TimerMode>()) { throw new ArgumentOutOfRangeException("mode", mode, "The specified TimerMode value was not defined."); } this.period = period; this.resolution = resolution; this.mode = mode; }
// Initialize timer with default values. void Initialize() { this.mode = TimerMode.PERIODIC; this.interval = Capabilities.intervalMin; this.resolution = 1; running = false; disposed = false; synchronizingObject = null; site = null; timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback); timeProcOneShot = new TimeProc(TimerOneShotEventCallback); tickRaiser = new EventRaiser(OnTick); }
public ThreadTimer() : this(ThreadTimerQueue.Instance) { if (!Stopwatch.IsHighResolution) { throw new NotImplementedException("Stopwatch is not IsHighResolution"); } isRunning = false; mode = TimerMode.Periodic; resolution = TimeSpan.FromMilliseconds(1); period = resolution; tickRaiser = new EventRaiser(OnTick); }
//Setup Item mode public void SetupItemMode() { TimerMode mode = gameObject.AddComponent <TimerMode>(); mode.timerUI = timerUI; mode.SetupMode(gameItemsTimer); FindObjectOfType <LapDetector>().totalLaps = 1; timerUI.gameObject.SetActive(true); boostItems.gameObject.SetActive(true); loseControlItems.gameObject.SetActive(true); jumpItems.gameObject.SetActive(true); }
public ThreadTimer() : this(ThreadTimerQueue.Instance) { if (!Stopwatch.IsHighResolution) { throw new NotImplementedException("Stopwatch is not IsHighResolution"); } isRunning = false; mode = TimerMode.Periodic; resolution = TimeSpan.FromMilliseconds(1); period = resolution; tickRaiser = new EventRaiser(OnTick); }
private static extern int timeSetEvent(int delay, int resolution, TimerProc proc, IntPtr user, TimerMode mode);
public Timer(float targetTimeSeconds, bool triggerOnce, TimerMode mode = TimerMode.Game) { TargetTimeSeconds = targetTimeSeconds; CurrentTimeSeconds = 0.0f; TriggerOnce = triggerOnce; HasTriggered = false; StartTimeSeconds = -1; Mode = mode; }
private void CancelTimer() { timerMode = TimerMode.None; fastTimer.Enabled = false; }
private void convertToShutdownToolStripMenuItem_Click(object sender, EventArgs e) { timerMode = TimerMode.Shutdown; }
/////////////////////////////////////////////////////////////////////////////// // Methods and Eventhandling for Background tasks // /////////////////////////////////////////////////////////////////////////////// #region BACKGROUNDWORKER #endregion //BACKGROUNDWORKER /////////////////////////////////////////////////////////////////////////////// // Methods for doing main class job // /////////////////////////////////////////////////////////////////////////////// #region PRIVATEMETHODS /// <summary> /// Initialize timer with default values. /// </summary> private void Initialize() { this.mode = TimerMode.Periodic; this.period = Capabilities.PeriodMin; this.resolution = 1; this.running = false; this.timeProcPeriodic = new TimeProc(this.TimerPeriodicEventCallback); this.timeProcOneShot = new TimeProc(this.TimerOneShotEventCallback); this.tickRaiser = new EventRaiser(this.OnTick); }
private void StartTimer(TimeSpan timeDelay) { timerTarget = DateTime.Now + timeDelay; timerMode = TimerMode.Shutdown; fastTimer.Enabled = (timerMode != TimerMode.None) && ((timerTarget - DateTime.Now).TotalSeconds < 120); }
private void InitialiseTimer() { _timerMode = TimerMode.Rest; var timer = new DispatcherTimer(); timer.Interval = _oneSecond; timer.Tick += (sender, e) => { switch (_timerMode) { case TimerMode.Work: TimerDisplay.Invoke(x => x.Increment()); break; case TimerMode.Play: TimerDisplay.Invoke(x => x.Decrement()); break; } }; timer.Start(); }
private void ImRestingButtonClickEventHandler(object sender, RoutedEventArgs e) { TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate; TaskbarItemInfo.ProgressValue = 0; _timerMode = TimerMode.Rest; }
internal Timer( TimerQueue queue, TimerMode mode, TimerExecutionContext context, bool isLongRunning, uint dueTime, uint period, TimerCallback callback ) { Debug.Assert( queue != null ); Debug.Assert( callback != null ); Queue = queue; Mode = mode; ExecutionContext = context; IsLongRunning = isLongRunning; Period = period; DueTime = dueTime; Callback = callback; }
private EventArgs m_eventArgs; // Private user event args to pass into Ticks call #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the <see cref="PrecisionTimer"/> class. /// </summary> public PrecisionTimer() { // Initialize timer with default values. m_mode = TimerMode.Periodic; m_running = false; if (Common.IsPosixEnvironment) { m_timer = new Timer(); m_timer.Elapsed += m_timer_Elapsed; m_period = 10; m_resolution = 10; } else { m_timeProc = TimerEventCallback; m_period = Capabilities.PeriodMinimum; m_resolution = 1; } }
private EventArgs m_eventArgs; // Private user event args to pass into Ticks call #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the Timer class. /// </summary> public PrecisionTimer() { // Initialize timer with default values. m_mode = TimerMode.Periodic; m_period = Capabilities.PeriodMinimum; m_resolution = 1; m_running = false; m_timeProc = TimerEventCallback; }
private void convertToRebootToolStripMenuItem_Click(object sender, EventArgs e) { timerMode = TimerMode.Reboot; }
private EventArgs m_eventArgs; // Private user event args to pass into Ticks call #endregion #region [ Constructors ] /// <summary> /// Initializes a new instance of the <see cref="PrecisionTimer"/> class. /// </summary> public PrecisionTimer() { // Initialize timer with default values. m_mode = TimerMode.Periodic; m_running = false; #if MONO m_timer = new Timer(); m_timer.Elapsed += m_timer_Elapsed; m_period = 10; m_resolution = 10; #else m_timeProc = TimerEventCallback; m_period = Capabilities.PeriodMinimum; m_resolution = 1; #endif }
private void ImPlayingButtonClickEventHandler(object sender, RoutedEventArgs e) { TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal; TaskbarItemInfo.ProgressValue = 0; _timerMode = TimerMode.Play; TimerDisplay.Invoke(x => x.ResetWorkTimer()); }
public Timer(TimerMode mode, int resetValue) { Mode = mode; _resetValue = resetValue; Reset(); }
private void ImWorkingButtonClickEventHandler(object sender, RoutedEventArgs e) { TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; TaskbarItemInfo.ProgressValue = 0; _timerMode = TimerMode.Work; }
void resetLapButton() { // For the reset/lap button to do anything the watch needs to be // in timer mode. The timer must also not be currently reset in // order to be reset. Condition.IsTrue(timerDisplayed); Condition.IsTrue(timerMode != TimerMode.Reset); // If the timer is running then we freeze/unfreeze the display. If // the timer is stopped then we reset the timer. if (timerMode == TimerMode.Stopped) { timerMode = TimerMode.Reset; } else { timerFrozen = !timerFrozen; } }
/// <summary> /// Initializes a new instance of the Timer class with the user /// supplied callback and state information, timer period, resolution, /// and timer mode. /// </summary> /// <param name="callback"> /// A TimerCallback delegate representing a method to be executed when /// a timer event occurs. /// </param> /// <param name="state"> /// An object containing information to be used by the callback method, /// or a null reference. /// </param> /// <param name="period"> /// The time between timer events in milliseconds. /// </param> /// <param name="resolution"> /// The timer resolution in milliseconds. /// </param> /// <param name="mode"> /// The timer mode. /// </param> public Timer(TimerCallback callback, object state, int period, int resolution, TimerMode mode) { // // Initialize fields. // this.callback = callback; this.state = state; timeProcPeriodic = new TimeProc(OnTimerPeriodicEvent); timeProcOneShot = new TimeProc(OnTimerOneShotEvent); Mode = mode; Period = period; Resolution = resolution; running = false; }
void startStopButton() { // For the stop/start button to do anything the watch needs to be // in timer mode. Condition.IsTrue(timerDisplayed); // If the watch is in timer mode and the start/stop button is // pressed then the timer is either started or stopped depending // on its previous state. if (timerMode == TimerMode.Reset || timerMode == TimerMode.Stopped) { timerMode = TimerMode.Running; } else { timerMode = TimerMode.Stopped; // When we stop the timer we want the current timed duration // to be seen, so we unfreeze the display. timerFrozen = false; } }
// Initialize timer with default values. void Initialize() { this.mode = TimerMode.PERIODIC; this.interval = Capabilities.intervalMin; this.resolution = 1; running = false; disposed = false; synchronizingObject = null; site = null; timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback); timeProcOneShot = new TimeProc(TimerOneShotEventCallback); tickRaiser = new EventRaiser(OnTick); }
public Timer(TimerMode mode) { Mode = mode; Reset(); }
private void convertToSleepToolStripMenuItem_Click(object sender, EventArgs e) { timerMode = TimerMode.Sleep; }
private Timer InternalCreateTimer( TimerMode mode, TimerExecutionContext context, TimerCallback callback, uint dueTime, uint period, bool isLongRunning ) { Debug.Assert( _hQueue != IntPtr.Zero ); if( _hQueue == IntPtr.Zero ) throw new InvalidOperationException( "The timer queue has already been disposed." ); Debug.Assert( callback != null ); if( callback == null ) throw new ArgumentNullException( "callback" ); switch( mode ) { case TimerMode.OneShot: Debug.Assert( dueTime > 0 ); Debug.Assert( period == 0 ); if( dueTime <= 0 ) throw new ArgumentOutOfRangeException( "dueTime", dueTime, "One-shot timers require a due time of 1ms or more." ); break; case TimerMode.Periodic: Debug.Assert( period > 0 ); if( period <= 0 ) throw new ArgumentOutOfRangeException( "period", period, "Periodic timers require a period of 1ms or more." ); break; } NativeMethods.TimerQueueFlags flags = ( NativeMethods.TimerQueueFlags )( ( uint )mode | ( uint )context ); if( isLongRunning == true ) flags |= NativeMethods.TimerQueueFlags.WT_EXECUTELONGFUNCTION; Timer timer = new Timer( this, mode, context, isLongRunning, dueTime, period, callback ); lock( _syncRoot ) { timer.Entry = _timers.Enqueue( timer ); timer.ID = _timerId++; } IntPtr handle = IntPtr.Zero; bool result = NativeMethods.CreateTimerQueueTimer( ref handle, _hQueue, _delegate, new IntPtr( timer.ID ), dueTime, period, flags ); Debug.Assert( result == true ); if( result == false ) { lock( _syncRoot ) _timers.Remove( timer.Entry ); int error = Marshal.GetLastWin32Error(); throw new Win32Exception( error, "Unable to create timer instance." ); } timer.Handle = handle; return timer; }
private void convertToHibernateToolStripMenuItem_Click(object sender, EventArgs e) { timerMode = TimerMode.Hibernate; }
private void OnTimerModeChanged(TimerMode oldValue, TimerMode newValue) { timerMode = newValue; switch(newValue) { case TimerMode.GeneralPurpose64: timer34.Enabled = false; break; case TimerMode.Watchdog64: case TimerMode.Chained32: this.Log(LogLevel.Warning, "Unsupported TMS320 timer mode set: {0}", newValue); break; } UpdateTimerLimits(); }