Esempio n. 1
0
        private void TimerButton_Click(object sender, EventArgs e)
        {
            //Right click delete
            if (e.GetType().Equals(typeof(MouseEventArgs)))
            {
                MouseEventArgs mouse = (MouseEventArgs)e;
                if (mouse.Button == MouseButtons.Right)
                {
                    TimerMenuStrip.Show(Cursor.Position);
                }
            }

            BLIO.Log("TimerButton clicked!");
            //Get selected TimerItem
            BunifuFlatButton clickedButton = (BunifuFlatButton)sender;

            BLIO.Log("^^^^ (" + clickedButton.Text + ")");
            //Remove all the text apart from the id and store it
            int id = Convert.ToInt32(clickedButton.Text.Replace("Timer", "").Replace(" ", ""));

            foreach (TimerItem itm in timers)
            {
                if (itm.ID == id)
                {
                    currentTimerItem = itm;

                    if (currentTimerItem.IsRunning())
                    {
                        tmrCountdown.Start();
                    }
                    else
                    {
                        tmrCountdown.Stop();
                    }


                    BLIO.Log("Setting values of (UCTimer) numericupdowns");
                    TimeSpan time = TimeSpan.FromSeconds((double)currentTimerItem.SecondsRemaining);
                    numSeconds.Value = time.Seconds;
                    numMinutes.Value = time.Minutes;
                    numHours.Value   = time.Hours;
                }
            }

            //Show play or pause depending on if the selected timer is running or not
            if (currentTimerItem.IsRunning())
            {
                btnPauseResumeTimer.Iconimage = Properties.Resources.pause_2x1;
            }
            else
            {
                btnPauseResumeTimer.Iconimage = Properties.Resources.Play;
            }

            EnableButton(clickedButton);
        }