Exemplo n.º 1
0
        private void btn_to_form5_Click(object sender, EventArgs e)
        {
            bool success = true;
            int  index   = 1;

            foreach (KeyValuePair <int, List <TextBox> > h in holes)
            {
                int location;
                int size;
                int test;

                string s;

                s = (h.Value[0].Text);
                if (s == null || int.TryParse(s, out test) == false)
                {
                    MessageBox.Show("Please enter a valid number\n" + "\t Hole" + index.ToString() + " Location");
                    success = false;
                    break;
                }
                location = int.Parse(s);

                s = (h.Value[1].Text);
                if (s == null || int.TryParse(s, out test) == false || int.Parse(s) == 0)
                {
                    MessageBox.Show("Please enter a valid number\n" + "\t Hole" + index.ToString() + " Size");
                    success = false;
                    break;
                }

                size = int.Parse(s);

                hole nh = new hole(size, location);
                if (nh.get_size() + nh.get_start_location() > memory.get_size())
                {
                    MessageBox.Show("\t      ERROR \n  Hole" + index.ToString() + " is Outside than memory space");
                    return;
                }
                memory.add_hole(nh);
                index++;
            }
            memory.merge_holes();
            if (memory.get_total_empty_space() > memory.get_size())
            {
                MessageBox.Show("\t       ERROR \n Size of Holes is greater than memory size");
                return;
            }
            if (success)
            {
                Form6 frm = new Form6(processes, memory);
                Visible = false;
                frm.ShowDialog();
                Close();
            }
        }