2020-05-22 21:12:09 +02:00
|
|
|
using System.Drawing;
|
2020-09-11 10:38:55 +02:00
|
|
|
using CC_Functions.Core;
|
2020-05-22 21:12:09 +02:00
|
|
|
|
|
|
|
namespace CC_Functions.Commandline.TUI
|
|
|
|
{
|
2020-05-23 15:32:24 +02:00
|
|
|
/// <summary>
|
2020-05-23 17:22:45 +02:00
|
|
|
/// A basic text control
|
2020-05-23 15:32:24 +02:00
|
|
|
/// </summary>
|
2020-05-22 21:12:09 +02:00
|
|
|
public class Label : Control
|
|
|
|
{
|
2020-06-12 19:48:31 +02:00
|
|
|
private string _content;
|
2020-05-23 17:22:45 +02:00
|
|
|
|
2020-05-23 15:32:24 +02:00
|
|
|
/// <summary>
|
2020-05-23 17:22:45 +02:00
|
|
|
/// Creates a new label
|
2020-05-23 15:32:24 +02:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="content">The text inside this label</param>
|
2020-06-12 19:48:31 +02:00
|
|
|
public Label(string content)
|
|
|
|
{
|
|
|
|
_content = "";
|
|
|
|
Content = content;
|
|
|
|
}
|
2020-05-23 17:22:45 +02:00
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override bool Selectable { get; } = false;
|
|
|
|
|
2020-06-12 19:48:31 +02:00
|
|
|
/// <summary>
|
|
|
|
/// The text inside this label
|
|
|
|
/// </summary>
|
|
|
|
public string Content
|
|
|
|
{
|
|
|
|
get => _content;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (_content != value)
|
|
|
|
{
|
|
|
|
_content = value;
|
|
|
|
char[,] inp = Content.ToNdArray2D();
|
|
|
|
int w = inp.GetLength(1);
|
|
|
|
int h = inp.GetLength(0);
|
|
|
|
Size = new Size(w, h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-23 15:32:24 +02:00
|
|
|
/// <inheritdoc />
|
2020-05-22 21:12:09 +02:00
|
|
|
public override Pixel[,] Render()
|
|
|
|
{
|
2020-05-23 15:32:24 +02:00
|
|
|
char[,] inp = Content.ToNdArray2D();
|
2020-05-22 21:12:09 +02:00
|
|
|
int w = inp.GetLength(0);
|
|
|
|
int h = inp.GetLength(1);
|
|
|
|
Pixel[,] output = new Pixel[w, h];
|
|
|
|
for (int x = 0; x < w; x++)
|
|
|
|
for (int y = 0; y < h; y++)
|
|
|
|
output[x, y] = new Pixel(BackColor, ForeColor, inp[x, y]);
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|