restructure
This commit is contained in:
30
PCPalConfigurator/Rendering/Elements/BarElement.cs
Normal file
30
PCPalConfigurator/Rendering/Elements/BarElement.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace PCPalConfigurator.Rendering.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a bar graph element in the OLED preview
|
||||
/// </summary>
|
||||
public class BarElement : PreviewElement
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int Value { get; set; }
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
// Draw outline rectangle
|
||||
g.DrawRectangle(Pens.White, X, Y, Width, Height);
|
||||
|
||||
// Calculate fill width based on value (0-100)
|
||||
int fillWidth = (int)(Width * (Value / 100.0));
|
||||
if (fillWidth > 0)
|
||||
{
|
||||
// Draw filled portion
|
||||
g.FillRectangle(Brushes.White, X + 1, Y + 1, fillWidth - 1, Height - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
PCPalConfigurator/Rendering/Elements/IconElement.cs
Normal file
24
PCPalConfigurator/Rendering/Elements/IconElement.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace PCPalConfigurator.Rendering.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an icon element in the OLED preview
|
||||
/// </summary>
|
||||
public class IconElement : PreviewElement
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
// For preview, just draw a placeholder rectangle with icon name
|
||||
g.DrawRectangle(Pens.Gray, X, Y, 24, 24);
|
||||
using (Font font = new Font("Arial", 6))
|
||||
{
|
||||
g.DrawString(Name, font, Brushes.White, X + 2, Y + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
PCPalConfigurator/Rendering/Elements/LineElement.cs
Normal file
20
PCPalConfigurator/Rendering/Elements/LineElement.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace PCPalConfigurator.Rendering.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a line element in the OLED preview
|
||||
/// </summary>
|
||||
public class LineElement : PreviewElement
|
||||
{
|
||||
public int X1 { get; set; }
|
||||
public int Y1 { get; set; }
|
||||
public int X2 { get; set; }
|
||||
public int Y2 { get; set; }
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
g.DrawLine(Pens.White, X1, Y1, X2, Y2);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
PCPalConfigurator/Rendering/Elements/RectElement.cs
Normal file
30
PCPalConfigurator/Rendering/Elements/RectElement.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace PCPalConfigurator.Rendering.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a rectangle or box element in the OLED preview
|
||||
/// </summary>
|
||||
public class RectElement : PreviewElement
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
public bool Filled { get; set; }
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
if (Filled)
|
||||
{
|
||||
// Draw filled box
|
||||
g.FillRectangle(Brushes.White, X, Y, Width, Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Draw outline rectangle
|
||||
g.DrawRectangle(Pens.White, X, Y, Width, Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
PCPalConfigurator/Rendering/Elements/TextElement.cs
Normal file
31
PCPalConfigurator/Rendering/Elements/TextElement.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace PCPalConfigurator.Rendering.Elements
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a text element in the OLED preview
|
||||
/// </summary>
|
||||
public class TextElement : PreviewElement
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Size { get; set; }
|
||||
public string Text { get; set; }
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
// Choose font size based on the size parameter
|
||||
Font font;
|
||||
switch (Size)
|
||||
{
|
||||
case 1: font = new Font("Consolas", 8); break;
|
||||
case 2: font = new Font("Consolas", 10); break;
|
||||
case 3: font = new Font("Consolas", 12); break;
|
||||
default: font = new Font("Consolas", 8); break;
|
||||
}
|
||||
|
||||
// Draw text with white color
|
||||
g.DrawString(Text, font, Brushes.White, X, Y - font.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user