Пример #1
0
 /// <summary>
 /// Add a computer to the pool
 /// </summary>
 /// <param name="computer">The computer to add to the pool</param>
 public void AddComputer(Computer computer)
 {
     Computers.Add(computer);
 }
Пример #2
0
        /// <summary>
        /// Load the client file from a file path
        /// </summary>
        /// <param name="path">Path to client file</param>
        public void LoadFile(string path)
        {
            if (File.Exists(path))
            {
                using (StreamReader sr = new StreamReader(path, Encoding.Default))
                {
                    Computers.Clear();
                    Computer myComputer = new Computer();

                    string line = "";

                    while ((line = sr.ReadLine()) != null)
                    {
                        if (!line.StartsWith("#"))
                        {
                            if (line.IndexOf(";") >= 0)
                            {
                                string[] fields = line.Split(';');
                                myComputer = new Computer();
                                myComputer.ComputerName = fields[0];
                                myComputer.IPAddress = fields[1];
                                myComputer.MACAddress = fields[2];
                                myComputer.SubPool = Convert.ToInt32(fields[3]);
                                myComputer.PreSelected = false;
                                if (fields.Length == 5)
                                {
                                    if (fields[4].IndexOf("1") >= 0)
                                    {
                                        myComputer.PreSelected = true;
                                    }
                                }
                                Computers.Add(myComputer);
                            }
                        }
                    }
                }
                SetPreselected();
            }
        }
Пример #3
0
 /// <summary>
 /// Remove a computer from the pool
 /// </summary>
 /// <param name="computer">The computer to remove from the pool</param>
 public void RemoveComputer(Computer computer)
 {
     Computers.Remove(computer);
 }
Пример #4
0
        private void buttonPoolAddComputer_Click(object sender, EventArgs e)
        {
            try
            {
                Computer c = new Computer();
                c.ComputerName = textBoxPoolComputerName.Text;
                c.IPAddress = textBoxPoolIPAddress.Text;
                c.MACAddress = textBoxPoolMACAddress.Text;
                c.SubPool = Convert.ToInt32(textBoxPoolSubPool.Text);
                c.Selected = checkBoxPoolSelected.Checked;

                // Check if client already exists
                Computer d = Launcher.Pool.GetComputer(c.ComputerName);
                if (d == null) Launcher.Pool.AddComputer(c);
                buttonPoolCancel.PerformClick();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }