Esempio n. 1
0
 public override string ToString()
 {
     if (String.IsNullOrEmpty(id))
     {
         return($"Espacio libre -> {Nucleo.RepresentarKB(Size)}");
     }
     else
     {
         return($"{id} -> {Nucleo.RepresentarKB(Size)}");
     }
 }
Esempio n. 2
0
 private void BtnSize_Click(object sender, EventArgs e)
 {
     try
     {
         MiMemoria      = new Memoria(Nucleo.TransformarAKB(double.Parse(tbSize.Text), cbUnidad.Text), pnMemoria.Height);
         pnSize.Visible = false;
         pnSO.Visible   = true;
         lblSize.Text   = Nucleo.RepresentarKB(MiMemoria.Size);
     }
     catch
     {
         MessageBox.Show("Error al agregar la memoria");
     }
 }
Esempio n. 3
0
 private void btnAgregarTarea_Click(object sender, EventArgs e)
 {
     if (!jPanel.Visible)
     {
         jPanel.Visible = true;
     }
     if (MiMemoria.AgregarParticion(Nucleo.TransformarAKB(double.Parse(tbTarea.Text), cbUnidad.Text), true, tbTitle.Text))
     {
         DibujarGrafica();
     }
     else
     {
         lbSB.DataSource = MiMemoria.StandBy;
         //MessageBox.Show("Error al agregar la tarea, no hay suficiente espacio disponible");
     }
 }
Esempio n. 4
0
        public Particion CrearParticion(double _size, bool _estado, string _titulo)
        {
            double value = (_size * 100) / Size;

            value = Nucleo.Truncate(value, 0);
            double porcentaje = 0;

            if (value.ToString().Length == 1)
            {
                porcentaje = double.Parse(".0" + value.ToString());
            }
            else
            {
                porcentaje = double.Parse("." + value.ToString());
            }

            double    height    = porcentaje * Height;
            int       heightInt = (int)height;
            Particion P         = new Particion(_size, heightInt, _estado, _titulo);

            return(P);
        }
Esempio n. 5
0
        public void DibujarGrafica()
        {
            double Cant = MiMemoria.MemoriaTotal;

            dtgLibres.Rows.Clear();
            dtgTareas.Rows.Clear();
            pnMemoria.Controls.Clear();
            int i = 0;

            //MessageBox.Show($"Memoria Total: {MiMemoria.Height.ToString()}, height respecto{MiMemoria.SO.miPanel.Height.ToString()}");

            lbTareas.Items.Clear();

            MiMemoria.modo = "particiones";
            foreach (Particion p in MiMemoria)
            {
                //MessageBox.Show($"Memoria Total: {MiMemoria.Size.ToString()}, height respecto{p.Height.ToString()}");
                Cant -= p.Size;
                pnMemoria.Controls.Add(p.GetPanel(Cant));
                if (!p.Ocupada)
                {
                    i++;
                    dtgLibres.Rows.Add(i, p.PosicionY, p.Size);
                }
            }
            i = 0;
            MiMemoria.modo = "tareas";
            foreach (Particion p in MiMemoria)
            {
                //MessageBox.Show($"Memoria Total: {MiMemoria.Size.ToString()}, height respecto{p.Height.ToString()}");
                dtgTareas.Rows.Add(p.id, p.PosicionY, p.Size);
                lbTareas.Items.Add(p.ToString());
            }
            pnMemoria.Controls.Add(MiMemoria.SO.GetPanel(0));
            MiMemoria.MostrarMemoriaDisponible();
            lblDisponible.Text = Nucleo.RepresentarKB(MiMemoria.MemoriaDisponible);
        }
Esempio n. 6
0
 private void BtnAgregarSO_Click(object sender, EventArgs e)
 {
     try
     {
         double SOValue = Nucleo.TransformarAKB(double.Parse(tbSO.Text), cbUnidad.Text);
         if (SOValue != 0)
         {
             if (MiMemoria.AgregarSO(SOValue))
             {
                 DibujarGrafica();
                 pnSO.Visible     = false;
                 pnTareas.Visible = true;
             }
             else
             {
                 MessageBox.Show("Error al agregar el sistema operativo");
             }
         }
     }
     catch
     {
         MessageBox.Show("Error al agregar el sistema operativo");
     }
 }
Esempio n. 7
0
        public Panel GetPanel()
        {
            Panel miPanel = new Panel()
            {
                Dock   = DockStyle.Top,
                Height = this.Height
            };

            if (SO)
            {
                Panel Left = new Panel()
                {
                    Dock      = DockStyle.Left,
                    Width     = 150,
                    BackColor = System.Drawing.Color.White
                };
                Left.Controls.Add(new Label()
                {
                    Dock = DockStyle.Top, Text = $"{Nucleo.RepresentarKB(Size)}", Font = new System.Drawing.Font("Century Gothic", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                });
                Left.Controls.Add(new Panel {
                    Dock = DockStyle.Bottom, Height = 3, BackColor = System.Drawing.Color.Black
                });
                miPanel.Controls.Add(Left);
                Panel Right = new Panel {
                    Dock = DockStyle.Fill, BackColor = System.Drawing.Color.Black
                };
                Right.Controls.Add(new Label()
                {
                    TextAlign = System.Drawing.ContentAlignment.MiddleCenter, ForeColor = System.Drawing.Color.White, Dock = DockStyle.Fill, Text = "S.O.", Font = new System.Drawing.Font("Century Gothic", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                });;
                Right.Controls.Add(new Panel {
                    Dock = DockStyle.Bottom, Height = 3, BackColor = System.Drawing.Color.Black
                });

                miPanel.Controls.Add(Right);
            }
            else
            {
                if (Ocupada)
                {
                    Panel Left = new Panel()
                    {
                        Dock      = DockStyle.Left,
                        Width     = 150,
                        BackColor = System.Drawing.Color.White
                    };
                    Left.Controls.Add(new Label()
                    {
                        Dock = DockStyle.Top, Text = $"{id} ", Font = new System.Drawing.Font("Century Gothic", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                    });
                    Left.Controls.Add(new Label()
                    {
                        Dock = DockStyle.Top, Text = $"{Nucleo.RepresentarKB(Size)}", Font = new System.Drawing.Font("Century Gothic", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                    });
                    Left.Controls.Add(new Panel {
                        Dock = DockStyle.Bottom, Height = 3, BackColor = System.Drawing.Color.Black
                    });
                    miPanel.Controls.Add(Left);
                    Panel Right = new Panel {
                        Dock = DockStyle.Fill, BackColor = System.Drawing.Color.Red
                    };
                    Right.Controls.Add(new Panel {
                        Dock = DockStyle.Bottom, Height = 3, BackColor = System.Drawing.Color.Black
                    });
                    miPanel.Controls.Add(Right);
                }
                else
                {
                    Panel Left = new Panel()
                    {
                        Dock      = DockStyle.Left,
                        Width     = 150,
                        BackColor = System.Drawing.Color.White
                    };
                    Left.Controls.Add(new Label()
                    {
                        Text = Nucleo.RepresentarKB(Size), Font = new System.Drawing.Font("Century Gothic", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)))
                    });
                    Left.Controls.Add(new Panel {
                        Dock = DockStyle.Bottom, Height = 3, BackColor = System.Drawing.Color.Black
                    });
                    miPanel.Controls.Add(Left);
                    Panel Right = new Panel {
                        Dock = DockStyle.Fill, BackColor = System.Drawing.Color.Blue
                    };
                    Right.Controls.Add(new Panel {
                        Dock = DockStyle.Bottom, Height = 3, BackColor = System.Drawing.Color.Black
                    });
                    miPanel.Controls.Add(Right);
                }
            }


            return(miPanel);
        }