mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Reorganize project structure
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
using RemSox.Shared.UI.GUI.Rendering;
|
||||
|
||||
using System.Drawing;
|
||||
|
||||
namespace RemSox.Kernel.UI.GUI.UIEelements.Controls;
|
||||
|
||||
public class ProgressBar() : Control("ProgressBar")
|
||||
{
|
||||
public int Value
|
||||
{
|
||||
get;
|
||||
set => SetProperty(nameof(Value), ref field, value);
|
||||
}
|
||||
|
||||
public Color FillColor
|
||||
{
|
||||
get;
|
||||
set => SetProperty(nameof(FillColor), ref field, value);
|
||||
} = Color.Green;
|
||||
|
||||
public override IEnumerable<RenderCommand> ToPrimitives(int windowId)
|
||||
{
|
||||
// Background
|
||||
yield return new RenderCommand
|
||||
{
|
||||
WindowId = windowId,
|
||||
ElementId = PrimitiveId(0),
|
||||
Type = RenderCommandType.DrawFilledRect,
|
||||
Position = Position,
|
||||
Properties = new Dictionary<string, object?>
|
||||
{
|
||||
["Color"] = BackgroundColor,
|
||||
["Size"] = Size,
|
||||
}
|
||||
};
|
||||
|
||||
// Fill
|
||||
int fillWidth = Size.Width * Math.Clamp(Value, 0, 100) / 100;
|
||||
|
||||
if (fillWidth > 0)
|
||||
{
|
||||
yield return new RenderCommand
|
||||
{
|
||||
WindowId = windowId,
|
||||
ElementId = PrimitiveId(1),
|
||||
Type = RenderCommandType.DrawFilledRect,
|
||||
Position = Position,
|
||||
Properties = new Dictionary<string, object?>
|
||||
{
|
||||
["Color"] = FillColor,
|
||||
["Size"] = new Size(fillWidth, Size.Height),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Border
|
||||
yield return new RenderCommand
|
||||
{
|
||||
WindowId = windowId,
|
||||
ElementId = PrimitiveId(2),
|
||||
Type = RenderCommandType.DrawRectBorder,
|
||||
Position = Position,
|
||||
Properties = new Dictionary<string, object?>
|
||||
{
|
||||
["Color"] = Color.DarkGray,
|
||||
["Size"] = Size,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user