Ejemplo n.º 1
0
        public override void SetBounds(int x, int y, int width, int height)
        {
            float maxWidth  = width;
            float maxHeight = height;

            for (int i = Count - 1; i >= 0; i--)
            {
                RectangleF relativeEntry = RelativeEntries[i];
                float      entryWidth    = (int)(width * relativeEntry.Width);
                float      entryHeight   = (int)(height * relativeEntry.Height);
                if (entryWidth < 0f || entryHeight < 0f)
                {
                    throw new InvalidOperationException();
                }

                float entryX = (int)(width * relativeEntry.X);
                float entryY = (int)(height * relativeEntry.Y);

                GuiComponent comp = this[i];
                comp.SetBounds((int)(x + entryX), (int)(y + entryY), (int)entryWidth, (int)entryHeight);
                if (maxWidth < entryX + comp.Bounds.Width)
                {
                    maxWidth = entryX + comp.Bounds.Width;
                }
                if (maxHeight < entryY + comp.Bounds.Height)
                {
                    maxHeight = entryY + comp.Bounds.Height;
                }
            }

            base.SetBounds(x, y, (int)maxWidth, (int)maxHeight);
        }
Ejemplo n.º 2
0
        public void ChangeScreen(GuiComponent screen)
        {
            CurrentScreen?.Hide();
            CurrentScreen = screen;
            CurrentScreen?.Show();

            CurrentScreen?.SetBounds(0, 0, StaticDisplay.DisplayWidth, StaticDisplay.DisplayHeight);
        }
Ejemplo n.º 3
0
        public override void SetBounds(int x, int y, int width, int height)
        {
            float padX       = width * PaddingX;
            float padY       = height * PaddingY;
            float gridWidth  = width / Cols - padX * (1f + 1f / Cols);
            float gridHeight = height / Rows - padY * (1f + 1f / Rows);

            float maxWidth  = width;
            float maxHeight = height;

            for (int i = Count - 1; i >= 0; i--)
            {
                Rectangle gridEntry   = GridEntries[i];
                float     entryWidth  = gridWidth * gridEntry.Width + padX * (gridEntry.Width - 1f);
                float     entryHeight = gridHeight * gridEntry.Height + padY * (gridEntry.Height - 1f);
                if (entryWidth < 0f || entryHeight < 0f)
                {
                    throw new InvalidOperationException();
                }

                float entryX = padX + (padX + gridWidth) * gridEntry.X;
                float entryY = padY + (padY + gridHeight) * gridEntry.Y;

                GuiComponent comp = this[i];
                comp.SetBounds((int)(x + entryX), (int)(y + entryY), (int)entryWidth, (int)entryHeight);
                if (maxWidth < entryX + comp.Bounds.Width)
                {
                    maxWidth = entryX + comp.Bounds.Width;
                }
                if (maxHeight < entryY + comp.Bounds.Height)
                {
                    maxHeight = entryY + comp.Bounds.Height;
                }
            }

            base.SetBounds(x, y, (int)(maxWidth + padX), (int)(maxHeight + padY));
        }
Ejemplo n.º 4
0
 public new void Remove(GuiComponent comp) => throw new InvalidOperationException();
Ejemplo n.º 5
0
 public void Add(GuiComponent item, Rectangle gridEntry)
 {
     GridEntries.Add(gridEntry);
     base.Add(item);
 }
Ejemplo n.º 6
0
 public void Add(GuiComponent item, RectangleF relativeEntry)
 {
     RelativeEntries.Add(relativeEntry);
     base.Add(item);
 }