//This method starts the timer for system shutdown.
        private void ShutdownTimer()
        {
            double time;

            if (File_Managment.ReadFromSettings("shutdownTime") == null || Convert.ToInt32(File_Managment.ReadFromSettings("shutdownTime")) <= 10)
            {
                MessageBox.Show("Invalid shutdown Time! Setting time to 60 min.");
                time = TimeSpan.FromMinutes(60D).TotalMilliseconds;
                File_Managment.SaveToSettings("shutdownTime", "60");
            }
            else
            {
                time = TimeSpan.FromMinutes(Convert.ToDouble(File_Managment.ReadFromSettings("shutdownTime"))).TotalMilliseconds;
            }
            System.Timers.Timer aTimer = new System.Timers.Timer();
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            aTimer.Interval = time;
            aTimer.Enabled  = true;
        }
Example #2
0
        //Event-Handler that saves the simple options.
        private void applySimpleButton_Click(object sender, EventArgs e)
        {
            File_Managment.SaveToSettings("shutdownEnabled", shutdownCheck.Checked.ToString());
            int shutdownint = 0;

            int.TryParse(shutdownTimeTextBox.Text, out shutdownint);
            if (shutdownint <= 10 || shutdownTimeTextBox.Text == null)
            {
                shutdownTimeTextBox.Text = "15";
            }

            File_Managment.SaveToSettings("shutdownTime", shutdownTimeTextBox.Text);
            File_Managment.SaveToSettings("programsEnabled", startProgram.Checked.ToString());
            File_Managment.SaveToSettings("websitesEnabled", openWebsite.Checked.ToString());
            File_Managment.SaveToSettings("soundsEnabled", playSounds.Checked.ToString());
            File_Managment.SaveToSettings("soundsDelay", soundsDelay.Text);

            File_Managment.SaveToWebsites(websitesTextBox.Lines);
            MessageBox.Show("A restart is required to apply the changes.");
        }