コード例 #1
0
 public override string ToString()
 {
     if (String.IsNullOrEmpty(id))
     {
         return($"Espacio libre -> {Nucleo.RepresentarKB(Size)}");
     }
     else
     {
         return($"{id} -> {Nucleo.RepresentarKB(Size)}");
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: fegarza/ParticionadaDinamica
 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");
     }
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: fegarza/ParticionadaDinamica
 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");
     }
 }
コード例 #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);
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: fegarza/ParticionadaDinamica
        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);
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: fegarza/ParticionadaDinamica
 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");
     }
 }
コード例 #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);
        }