Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                if (listBox1.SelectedIndex < 0)
                {
                    bool found = false;
                    foreach (ProgList searcher in Programs)
                    {
                        if (textBox2.Text == searcher.Path)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        ProgList item = new ProgList(textBox1.Text, textBox2.Text, textBox3.Text, checkBox1.Checked, checkBox2.Checked, checkBox3.Checked);
                        Programs.Add(item);
                        SavePrograms(Programs);
                        UpdateProgList();
                    }
                    else
                    {
                        MessageBox.Show("Program with same executable already found! Skipping!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    Programs[listBox1.SelectedIndex] = new ProgList(textBox1.Text, textBox2.Text, textBox3.Text, checkBox1.Checked, checkBox2.Checked, checkBox3.Checked);
                    //Programs.Add(item);
                    SavePrograms(Programs);
                    UpdateProgList();

                    // MessageBox.Show("Program with same executable already found! Skipping!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }


                disableEdit();
            }
            else
            {
                MessageBox.Show("Please Enter Program Name and Executable Name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        List <ProgList> LoadPrograms(string path = @"TimeStop.csv")
        {
            List <ProgList> data = new List <ProgList>();

            if (File.Exists(path))
            {
                string[] lines = System.IO.File.ReadAllLines(path);
                // Display the file contents by using a foreach loop.
                foreach (string line in lines)
                {
                    string[] settings = line.Split(';');
                    ProgList item     = new ProgList();
                    item.Name    = settings[0];
                    item.Path    = settings[1];
                    item.Version = settings[2];
                    item.Timer   = bool.Parse(settings[3]);
                    item.Warn    = bool.Parse(settings[4]);
                    item.Stop    = bool.Parse(settings[5]);
                    data.Add(item);
                }
            }

            return(data);
        }