예제 #1
0
        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();
        }
예제 #2
0
        // 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;
        }
예제 #3
0
파일: EMGthread.cs 프로젝트: EMGteam/EMG
 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);
     }
 }
예제 #4
0
        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();
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
 private static extern uint timeSetEvent(
     uint uDelay,
     uint uResolution,
     LpTimeProcDelegate lpTimeProc,
     int dwUser,
     TimerMode fuEvent
     );
예제 #7
0
		private void ImPlayingButtonClickEventHandler(object sender, RoutedEventArgs e)
		{
			TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
			TaskbarItemInfo.ProgressValue = 0;
			_timerMode = TimerMode.Play;
			TimerDisplay.Invoke(x => x.ResetWorkTimer());
		}
예제 #8
0
    /// <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;
    }
예제 #9
0
        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();
            }
        }
예제 #10
0
        /// <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());
        }
예제 #11
0
 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);
 }
예제 #12
0
 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);
 }
예제 #13
0
 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);
 }
예제 #14
0
 public void SetTimer(int minutes, int seconds)
 {
     _running        = true;
     _timerMode      = TimerMode.CountDown;
     _timerMinutes   = minutes;
     _timerSeconds   = seconds;
     _timerStartTime = Time.time;
 }
예제 #15
0
 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);
 }
예제 #16
0
 StopwatchModelProgram()
 {
     // We begin be initializing the system with the time showing,
     // the timer reset and not frozen.
     timerDisplayed = false;
     timerFrozen = false;
     timerMode = TimerMode.Reset;
 }
예제 #17
0
 public Timer(float targetTimeSeconds, bool triggerOnce, TimerMode mode = TimerMode.Game)
 {
     TargetTimeSeconds  = targetTimeSeconds;
     CurrentTimeSeconds = 0.0f;
     TriggerOnce        = triggerOnce;
     HasTriggered       = false;
     StartTimeSeconds   = -1;
     Mode = mode;
 }
예제 #18
0
 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);
 }
예제 #19
0
 /// <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;
 }
예제 #20
0
파일: Timer.cs 프로젝트: 2BitStudios/Slerpy
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
        static public TimerMode GetCurrentTimerMode()
        {
            TimerMode retValue = TimerMode.WAIT_PAUSE;

            try
            {
                retValue = timerMode;
            }
            catch (Exception) { };
            return(retValue);
        }
예제 #23
0
 private void checkBox1_CheckedChanged(object sender, EventArgs e)
 {
     if (checkBox1.Checked == true)
     {
         mode = TimerMode.StopWatch;
     }
     else
     {
         mode = TimerMode.Timer;
     }
 }
예제 #24
0
        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
        }
예제 #25
0
        // 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);
        }
예제 #26
0
    //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);
    }
예제 #27
0
        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;
        }
예제 #28
0
파일: Timer.cs 프로젝트: xchellx/Demolisher
 // 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;
 }
예제 #29
0
        // 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);
        }
예제 #30
0
        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);
        }
예제 #31
0
    //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);
    }
예제 #32
0
        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);
        }
예제 #33
0
파일: PrecisionTimer.cs 프로젝트: rmc00/gsf
 private static extern int timeSetEvent(int delay, int resolution, TimerProc proc, IntPtr user, TimerMode mode);
예제 #34
0
파일: Timer.cs 프로젝트: scorvi/dwarfcorp
 public Timer(float targetTimeSeconds, bool triggerOnce, TimerMode mode = TimerMode.Game)
 {
     TargetTimeSeconds = targetTimeSeconds;
     CurrentTimeSeconds = 0.0f;
     TriggerOnce = triggerOnce;
     HasTriggered = false;
     StartTimeSeconds = -1;
     Mode = mode;
 }
예제 #35
0
 private void CancelTimer()
 {
     timerMode = TimerMode.None;
     fastTimer.Enabled = false;
 }
예제 #36
0
 private void convertToShutdownToolStripMenuItem_Click(object sender, EventArgs e)
 {
     timerMode = TimerMode.Shutdown;
 }
예제 #37
0
    ///////////////////////////////////////////////////////////////////////////////
    // 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);
    }
예제 #38
0
        private void StartTimer(TimeSpan timeDelay)
        {
            timerTarget = DateTime.Now + timeDelay;
            timerMode = TimerMode.Shutdown;

            fastTimer.Enabled = (timerMode != TimerMode.None) &&
                                ((timerTarget - DateTime.Now).TotalSeconds < 120);
        }
예제 #39
0
        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();
        }
예제 #40
0
 private void ImRestingButtonClickEventHandler(object sender, RoutedEventArgs e)
 {
     TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;
     TaskbarItemInfo.ProgressValue = 0;
     _timerMode = TimerMode.Rest;
 }
예제 #41
0
        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;
        }
예제 #42
0
파일: PrecisionTimer.cs 프로젝트: rmc00/gsf
        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;
            }
        }
예제 #43
0
        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;
        }
예제 #44
0
 private void convertToRebootToolStripMenuItem_Click(object sender, EventArgs e)
 {
     timerMode = TimerMode.Reboot;
 }
예제 #45
0
파일: PrecisionTimer.cs 프로젝트: rmc00/gsf
        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
        }
예제 #46
0
 private void ImPlayingButtonClickEventHandler(object sender, RoutedEventArgs e)
 {
     TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
     TaskbarItemInfo.ProgressValue = 0;
     _timerMode = TimerMode.Play;
     TimerDisplay.Invoke(x => x.ResetWorkTimer());
 }
예제 #47
0
파일: Timer.cs 프로젝트: cadahl/defense
 public Timer(TimerMode mode, int resetValue)
 {
     Mode = mode;
     _resetValue = resetValue;
     Reset();
 }
예제 #48
0
 private void ImWorkingButtonClickEventHandler(object sender, RoutedEventArgs e)
 {
     TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None;
     TaskbarItemInfo.ProgressValue = 0;
     _timerMode = TimerMode.Work;
 }
예제 #49
0
        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;
            }
        }
예제 #50
0
        /// <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;
        }
예제 #51
0
        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;
            }
        }
예제 #52
0
        // 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);
        }
예제 #53
0
파일: Timer.cs 프로젝트: cadahl/defense
 public Timer(TimerMode mode)
 {
     Mode = mode;
     Reset();
 }
예제 #54
0
 private void convertToSleepToolStripMenuItem_Click(object sender, EventArgs e)
 {
     timerMode = TimerMode.Sleep;
 }
예제 #55
0
        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;
        }
예제 #56
0
 private void convertToHibernateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     timerMode = TimerMode.Hibernate;
 }
예제 #57
0
 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();
 }