示例#1
0
        //The method that loads all the settings in from the txt files.
        private void LoadSettings()
        {
            File_Managment.CreateDirFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\", "Paths.txt");
            File_Managment.CreateDirFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\", "Websites.txt");
            File_Managment.CreateDirFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\", "Sounds.txt");

            //Simple
            shutdownCheck.Checked    = Convert.ToBoolean(File_Managment.ReadFromSettings("shutdownEnabled"));
            shutdownTimeTextBox.Text = File_Managment.ReadFromSettings("shutdownTime");
            startProgram.Checked     = Convert.ToBoolean(File_Managment.ReadFromSettings("programsEnabled"));
            openWebsite.Checked      = Convert.ToBoolean(File_Managment.ReadFromSettings("websitesEnabled"));
            playSounds.Checked       = Convert.ToBoolean(File_Managment.ReadFromSettings("soundsEnabled"));
            soundsDelay.Text         = File_Managment.ReadFromSettings("soundsDelay");

            programTextBox.Lines          = getExecutableName();
            programTextBox.SelectionStart = programTextBox.Text.Length;
            programTextBox.ScrollToCaret();
            soundTextBox.Lines          = getSoundName();
            soundTextBox.SelectionStart = soundTextBox.Text.Length;
            soundTextBox.ScrollToCaret();
            websitesTextBox.Lines          = File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\Websites.txt");
            websitesTextBox.SelectionStart = websitesTextBox.Text.Length;
            websitesTextBox.ScrollToCaret();

            //Advanced
            cmdTextBox.Lines = File_Managment.ReadFromCMD();
        }
 //This method executes the advanced functions.
 private void Advanced()
 {
     foreach (string command in File_Managment.ReadFromCMD())
     {
         System.Diagnostics.Process.Start("cmd.exe", command);
     }
 }
示例#3
0
        //Event-Handler that removes a sound from the sounds textbox. (Subject to changes)
        private void removeSoundBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Sound Files(*.wav)|*.wav";
            openFileDialog.Title  = "Add sound to list.";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                File_Managment.removeSound(openFileDialog.FileName);
            }

            soundTextBox.Lines          = getSoundName();
            soundTextBox.SelectionStart = soundTextBox.Text.Length;
            soundTextBox.ScrollToCaret();
        }
示例#4
0
        //Event-Handler that removes a program from the program textbox. (Subject to changes)
        private void removeProgrammBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Executables(*.exe)|*.exe";
            openFileDialog.Title  = "Add programm to list.";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                File_Managment.removePath(openFileDialog.FileName);
            }

            programTextBox.Lines          = getExecutableName();
            programTextBox.SelectionStart = programTextBox.Text.Length;
            programTextBox.ScrollToCaret();
        }
 //Opens the websites in the Websites.txt
 private void OpenWebsites()
 {
     File_Managment.CreateDirFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\", "Websites.txt");
     foreach (string line in File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\Websites.txt"))
     {
         if (File_Managment.IsValidUri(line))
         {
             try
             {
                 System.Diagnostics.Process.Start(line);
             }
             catch { }
         }
     }
 }
        //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;
        }
示例#7
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.");
        }
        //This method executes the simple functions.
        private void Simple()
        {
            if (Convert.ToBoolean(File_Managment.ReadFromSettings("shutdownEnabled")))
            {
                ShutdownTimer();
            }

            if (Convert.ToBoolean(File_Managment.ReadFromSettings("programsEnabled")))
            {
                StartPrograms();
            }

            if (Convert.ToBoolean(File_Managment.ReadFromSettings("websitesEnabled")))
            {
                OpenWebsites();
            }

            if (Convert.ToBoolean(File_Managment.ReadFromSettings("soundsEnabled")))
            {
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    SoundPlayer player = new SoundPlayer();
                    foreach (string line in File.ReadAllLines(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\SanguinesStartUpUtils\\Settings\\Sounds.txt"))
                    {
                        try
                        {
                            player = new SoundPlayer(line);
                            player.PlaySync();
                            Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(File_Managment.ReadFromSettings("soundsDelay"))));
                        }
                        catch { }
                    }
                }).Start();
            }
        }
示例#9
0
 //Event-Handler that saves the advanced options.
 private void applyAdvancedButton_Click(object sender, EventArgs e)
 {
     File_Managment.SaveToCMD(cmdTextBox.Lines);
     MessageBox.Show("A restart is required to apply the changes.");
 }