mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-04 00:56:19 +02:00
Increase UI element sizes and add maxWidth support to DrawString methods
This commit is contained in:
@@ -27,7 +27,7 @@ internal class DesktopProcess() : Process("Desktop Manager")
|
||||
Button button = testWindow.CreateUIElement<UI.GUI.UIEelements.Controls.Button>(b =>
|
||||
{
|
||||
b.Position = new System.Drawing.Point(20, 30);
|
||||
b.Size = new System.Drawing.Size(100, 30);
|
||||
b.Size = new System.Drawing.Size(200, 30);
|
||||
b.Text = "Click Me";
|
||||
b.BackgroundColor = System.Drawing.Color.LightBlue;
|
||||
});
|
||||
@@ -41,7 +41,7 @@ internal class DesktopProcess() : Process("Desktop Manager")
|
||||
CheckBox check = testWindow.CreateUIElement<UI.GUI.UIEelements.Controls.CheckBox>(c =>
|
||||
{
|
||||
c.Position = new System.Drawing.Point(20, 80);
|
||||
c.Size = new System.Drawing.Size(100, 30);
|
||||
c.Size = new System.Drawing.Size(200, 30);
|
||||
c.Text = "Check Me";
|
||||
c.IsChecked = true;
|
||||
});
|
||||
|
||||
@@ -238,7 +238,7 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
{
|
||||
int tx = command.Position.X + (size.Width / 2) - (text.Length * 4);
|
||||
int ty = command.Position.Y + (size.Height / 2) - 8;
|
||||
canvas.DrawStringHeight(text, PCScreenFont.DefaultFont, fg, tx, ty, size.Height - 8);
|
||||
canvas.DrawStringHeight(text, PCScreenFont.DefaultFont, fg, tx, ty, size.Height - 8, size.Width);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ public sealed class CanvasRenderSource : IRenderSource
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
canvas.DrawStringHeight(text, PCScreenFont.DefaultFont, fg, command.Position.X + boxSize + 5, command.Position.Y - 2, boxSize);
|
||||
canvas.DrawStringHeight(text, PCScreenFont.DefaultFont, fg, command.Position.X + boxSize + 5, command.Position.Y - 2, boxSize, size.Width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,22 @@ namespace RemSox.Utils;
|
||||
|
||||
public static class CanvasExtensions
|
||||
{
|
||||
public static void DrawStringScale(this Canvas canvas, string str, Font font, Color color, int x, int y, int scale)
|
||||
public static void DrawStringScale(this Canvas canvas, string str, Font font, Color color, int x, int y, int scale, int maxWidth = int.MaxValue)
|
||||
{
|
||||
int len = str.Length;
|
||||
byte width = font.Width;
|
||||
|
||||
int targetWidth = width * scale;
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
if (x + targetWidth > maxWidth)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
canvas.DrawCharScale(str[i], font, color, x, y, scale);
|
||||
x += width * scale;
|
||||
x += targetWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +64,7 @@ public static class CanvasExtensions
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawStringHeight(this Canvas canvas, string str, Font font, Color color, int x, int y, int targetHeight)
|
||||
public static void DrawStringHeight(this Canvas canvas, string str, Font font, Color color, int x, int y, int targetHeight, int maxWidth = int.MaxValue)
|
||||
{
|
||||
byte width = font.Width;
|
||||
byte height = font.Height;
|
||||
@@ -66,6 +73,11 @@ public static class CanvasExtensions
|
||||
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (x + targetWidth > maxWidth)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
canvas.DrawCharHeight(str[i], font, color, x, y, targetHeight);
|
||||
x += targetWidth;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user