示例#1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     Computer myComputer = new Computer();
     myComputer.ComputerName = textBoxComputerName.Text;
     myComputer.IPAddress = textBoxIPAddress.Text;
     myComputer.MACAddress = textBoxMACAddress.Text;
     myComputer.SubPool = Convert.ToInt32(textBoxSubPool.Text);
     myComputer.Selected = checkBoxSelected.Checked;
     SelectComputerForm.myPool.AddComputer(myComputer);
     SelectComputerForm.RefreshList();
     this.Close();
 }
示例#2
0
 public void AddComputer(Computer computer)
 {
     Computers.Add(computer);
 }
示例#3
0
 public void RemoveComputer(Computer computer)
 {
     Computers.Remove(computer);
 }
示例#4
0
        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();
            }
        }