private void ChangeComp_Click(object sender, EventArgs e) { CompAddForm fm2 = new CompAddForm(); fm2.ShowDialog(); foreach (KeyValuePair <string, Computer> key in manager.ComputerList) { if (key.Key == ((Computer)CurrentPC.SelectedItem).ComputerName) { key.Value.ComputerName = fm2.textBox1.Text; key.Value.RamChenge((int)fm2.numericUpDown1.Value); key.Value.FrequencyAdd((int)fm2.numericUpDown2.Value); key.Value.CPUs = (int)fm2.numericUpDown3.Value; } } var pc = (Computer)CurrentPC.SelectedItem; var oldItem = CurrentPC.SelectedIndex; pc.ComputerName = fm2.textBox1.Text; pc.RamChenge((int)fm2.numericUpDown1.Value); pc.FrequencyAdd((int)fm2.numericUpDown2.Value); pc.CPUs = (int)fm2.numericUpDown3.Value; CurrentPC.Items[oldItem] = pc; this.Refresh(); CurrentPC.Refresh(); }
private void AddComp_Click(object sender, EventArgs e) { if (CurrentPC.Items.Count == 0) { AddProc.Enabled = !AddProc.Enabled; ButtonActivity(); } CompAddForm fm1 = new CompAddForm(); fm1.ShowDialog(); var comp = manager.AddComp(fm1.textBox1.Text, (int)fm1.numericUpDown1.Value, new Dictionary <string, Process>(), (int)fm1.numericUpDown2.Value, (int)fm1.numericUpDown2.Value); AddProcForm apf = new AddProcForm(); apf.ShowDialog(); proc = new Process(apf.ProcessName.Text, apf.ProcessUser.Text, (int)apf.Cpu.Value, (int)apf.Ram.Value, comp.ComputerName, apf.Discription.Text, (int)apf.Priority.Value); comp.ProcessList.Add(proc.ProcessName, proc); manager.ComputerList.Add(comp.ComputerName, comp); manager.ProcessList.Add(proc.ProcessName, proc); CurrentPC.Items.Add(comp); CurrentPC.SelectedIndex = CurrentPC.Items.Count - 1; table.Rows.Add(proc.ProcessName, proc.Priority, proc.CPU, proc.Ram, proc.Discription, proc.Location); dataGridView1.DataSource = table; }