Ejemplo n.º 1
0
        private void btn_to_form4_Click(object sender, EventArgs e)
        {
            bool success = true;

            foreach (KeyValuePair <int, List <Tuple <TextBox, TextBox> > > element in segments_size)
            {
                int index = element.Key;
                int test;
                for (int i = 0; i < processes[index - 1].get_number_segments(); i++)
                {
                    string s    = element.Value[i].Item1.Text;
                    string name = element.Value[i].Item2.Text;
                    if (s == null || int.TryParse(s, out test) == false || int.Parse(s) <= 0)
                    {
                        MessageBox.Show("Please enter a valid number\n" + "Processs" + index.ToString() + " :Segment" + (i + 1).ToString());
                        success = false;
                        processes[index - 1].clear_segments();
                        break;
                    }

                    else if (name == "")
                    {
                        MessageBox.Show("Please enter a valid Name\n" + "Processs" + index.ToString() + " :Segment" + (i + 1).ToString());
                        success = false;
                        processes[index - 1].clear_segments();
                        break;
                    }

                    else
                    {
                        segment q = new segment(processes[index - 1], int.Parse(element.Value[i].Item1.Text), processes[index - 1].get_color());
                        q.set_index(i + 1);
                        q.set_text(name);
                        processes[index - 1].add_segment(q);
                    }
                }
                if (!success)
                {
                    break;
                }
            }



            if (success)
            {
                Form4 frm = new Form4(processes);
                Visible = false;
                frm.ShowDialog();
                Close();
            }
        }
 public void segments_sort_desc()
 {
     for (int i = 0; i < number_segments; i++)
     {
         for (int j = 1; j < number_segments - i; j++)
         {
             if (segments[i].get_size() < segments[j].get_size())
             {
                 segment t = segments[i];
                 segments[i] = segments[j];
                 segments[j] = t;
             }
         }
     }
 }
 public void add_segment(segment seg)
 {
     this.segments.Add(seg);
 }