private void button3_Click(object sender, EventArgs e)
        {
            hole.sort(segments);
            int         start = 0;
            List <hole> temp  = new List <hole>();

            for (int i = 0; i < segments.Count; i++)
            {
                if (segments[i].start > start)
                {
                    hole t = new hole(start, segments[i].start - start);
                    temp.Add(t);
                }
                start = segments[i].start + segments[i].size;
            }
            if (start < Form1.total_memory_size)
            {
                hole t = new hole(start, Form1.total_memory_size - start);
                temp.Add(t);
            }
            for (int i = 0; i < temp.Count; i++)
            {
                segments.Add(temp[i]);
            }

            schedular2 = new worstfit(segments, processes);
            schedular2.fix();
            segments = schedular2.holes;
            Form7 form = new Form7(holes, segments, processes, num_of_process, 2);

            form.Show();
            Hide();
        }
 void trans()
 {
     if (Form1.type_of_algorithm == 1)
     {
         schedular1 = new firstfit(holes, processes);
         schedular1.First_Fit_Algorithm();
         segments = schedular1.holes;
         ShowDialog4(schedular1.segments_not_allocated);
     }
     else if (Form1.type_of_algorithm == 2)
     {
         schedular2 = new worstfit(holes, processes);
         schedular2.computebestFit();
         segments = schedular2.holes;
         ShowDialog4(schedular2.holdProcesses);
     }
     else if (Form1.type_of_algorithm == 3)
     {
         schedular2 = new worstfit(holes, processes);
         schedular2.computeWorstFit();
         segments = schedular2.holes;
         ShowDialog4(schedular2.holdProcesses);
     }
     Draw();
 }
        private void button2_Click(object sender, EventArgs e)
        {
            List <process> p = ShowDialog3();
            worstfit       t = new worstfit(segments, p);

            t.deallocator();
            segments = t.holes;
            Form7 form = new Form7(holes, segments, processes, num_of_process, 2);

            form.Show();
            Hide();
        }
        public Form7()
        {
            InitializeComponent();


            num_of_process = Form1.no_of_processes;

            for (int i = 0; i < Form1.no_of_holes; i++)
            {
                hole h = new hole(Form1.holes_start_adress[i], Form1.holes_sizes[i]);
                holes.Add(h);
            }

            int idx = 0;

            for (int i = 0; i < Form1.no_of_processes; i++)
            {
                process p = new process(i + 1, Form1.no_of_segments[i]);
                for (int j = 0; j < Form1.no_of_segments[i]; j++)
                {
                    p.segmenst_sizes[j]  = Form1.size_of_segments[idx];
                    p.name_of_segment[j] = Form1.name_of_segments[idx];
                    idx++;
                }
                processes.Add(p);
            }

            colors     = new Color[15];
            colors[0]  = Color.Maroon;
            colors[1]  = Color.Yellow;
            colors[2]  = Color.Violet;
            colors[3]  = Color.Blue;
            colors[4]  = Color.Lime;
            colors[5]  = Color.Chocolate;
            colors[6]  = Color.Aqua;
            colors[7]  = Color.DarkGreen;
            colors[8]  = Color.Maroon;
            colors[9]  = Color.Pink;
            colors[10] = Color.Silver;
            colors[11] = Color.BlanchedAlmond;
            colors[12] = Color.Cyan;
            colors[13] = Color.Fuchsia;
            colors[14] = Color.Gold;
            if (Form1.type_of_algorithm == 1)
            {
                schedular1 = new firstfit(holes, processes);
                schedular1.First_Fit_Algorithm();
                segments = schedular1.holes;
                ShowDialog4(schedular1.segments_not_allocated);
            }
            else if (Form1.type_of_algorithm == 2)
            {
                schedular2 = new worstfit(holes, processes);
                schedular2.computebestFit();
                segments = schedular2.holes;
                ShowDialog4(schedular2.holdProcesses);
            }
            else if (Form1.type_of_algorithm == 3)
            {
                schedular2 = new worstfit(holes, processes);
                schedular2.computeWorstFit();
                segments = schedular2.holes;
                ShowDialog4(schedular2.holdProcesses);
            }
            Draw();
        }