Example #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("New Design clears all data", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (result == DialogResult.OK)
            {
                Hole_List.Clear();
                PS_List.Clear();
                Memory.Clear();
                tableLayoutPanel1.Controls.Clear();
                frm2.Reset();
                Memory_OP.Reset();
                label5.Text      = "New Design";
                button3.Enabled  = true;
                button6.Enabled  = false;
                label2.Visible   = false;
                button3.Visible  = false;
                button1.Visible  = true;
                button2.Visible  = true;
                textBox1.Text    = "";
                textBox1.Enabled = true;
                listBox1.Items.Clear();
                checkedListBox1.Items.Clear();
                listBox1.Visible        = true;
                checkedListBox1.Visible = false;
                button5.Visible         = false;
                button2.Enabled         = false;
                groupBox2.Enabled       = false;
            }
        }
Example #2
0
 private void button6_Click(object sender, EventArgs e)
 {
     Memory_OP.Compaction(size, ref Hole_List, Memory);
     Memory_Layout();
     label5.Text     = "Memory Compact";
     button6.Enabled = false;
 }
Example #3
0
 private void button3_Click(object sender, EventArgs e)
 {
     int[] indices = checkedListBox1.CheckedIndices.Cast <int>().ToArray();
     if (indices.Length == 0)
     {
         MessageBox.Show("Please select one process at least :)");
     }
     else
     {
         for (int i = 0; i < indices.Length; i++)
         {
             Memory_OP.DeAlloc(PS_List[indices[i] - i], ref Hole_List, Memory);
             PS_List.RemoveAt(indices[i] - i);
             checkedListBox1.Items.RemoveAt(indices[i] - i);
         }
         Memory_Layout();
         groupBox2.Enabled = true;
         if (checkedListBox1.Items.Count == 0)
         {
             label2.Visible  = false;
             label5.Text     = "Memory Empty";
             button3.Enabled = false;
             button6.Enabled = false;
         }
         else
         {
             label5.Text = "Memory Layout";
             if (Hole_List.Count == 1)
             {
                 if (Memory.Last().Value.sg_name.Contains("Hole"))
                 {
                     label5.Text     = "Memory Compact";
                     button6.Enabled = false;
                 }
                 else
                 {
                     button6.Enabled = true;
                 }
             }
             else
             {
                 button6.Enabled = true;
             }
         }
     }
 }
Example #4
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            var answer = MessageBox.Show("Choosed the wanted method?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (answer == DialogResult.Yes)
            {
                var result = frm3.ShowDialog();
                if (result == DialogResult.OK)
                {
                    char mt;
                    if (radioButton1.Checked)
                    {
                        mt = 'F';
                    }
                    else if (radioButton2.Checked)
                    {
                        mt = 'B';
                    }
                    else
                    {
                        mt = 'W';
                    }
                    if (!Memory_OP.Mem_Alloc(PS_List.Last(), ref Hole_List, mt, Memory))
                    {
                        Memory_OP.DeAlloc(PS_List.Last(), ref Hole_List, Memory);
                        PS_List.RemoveAt(PS_List.Count - 1);
                        MessageBox.Show("Process does not fit :(");
                    }
                    else
                    {
                        Memory_Layout();
                        label5.Text = "Process Allocation";
                        checkedListBox1.Items.Add(PS_List.Last().name);
                        label2.Visible  = true;
                        button3.Enabled = true;
                        if (!Hole_List.Any())
                        {
                            label5.Text       = "Memory Full";
                            button6.Enabled   = false;
                            groupBox2.Enabled = false;
                        }
                    }
                }
            }
        }