void Start() { labelInfo.Text = "Таймер\n" + "запущен ;)"; WaitBar.Visible = true; WaitBar.StartWaiting(); groupSelectAction.Enabled = false; panelSetTime.Enabled = false; listSelectTime.Enabled = false; switchSelectTime.Enabled = false; start = true; if (switchSelectTime.Value) { try { int input = Convert.ToInt32(textBoxSetTime.Text), sum = input * 60; time = Convert.ToString(sum); } catch { switchSelectTime.Value = false; } } else { SetTime(); } timeLeft = Convert.ToInt32(time); timer.Start(); buttonStart.Enabled = false; buttonCancel.Enabled = true; WindowState = FormWindowState.Minimized; if (WindowState == FormWindowState.Minimized) { ShowInTaskbar = false; notifyIcon.Visible = true; notifyIcon.BalloonTipTitle = "Таймер запущен"; notifyIcon.BalloonTipText = "Программа была спрятана в трей" + " и продолжит свою работу.\n" + $"Компьютер {actionLog} через {Convert.ToInt32(time) / 60} минут"; notifyIcon.ShowBalloonTip(1500); } }
void Stop() { labelInfo.Text = "Таймер\n" + "остановлен..."; WaitBar.Visible = false; WaitBar.StopWaiting(); groupSelectAction.Enabled = true; panelSetTime.Enabled = true; listSelectTime.Enabled = true; switchSelectTime.Enabled = true; start = false; timer.Stop(); labelTimer.Text = string.Empty; buttonStart.Enabled = true; buttonCancel.Enabled = false; ShowInTaskbar = true; notifyIcon.Visible = false; WindowState = FormWindowState.Normal; }