You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.1 KiB
123 lines
3.1 KiB
#if NETFX || NETCORE
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Apewer.Surface
|
|
{
|
|
|
|
/// <summary></summary>
|
|
internal class BlockList : ListBox
|
|
{
|
|
private List<Color> _color = new List<Color>();
|
|
|
|
/// <summary></summary>
|
|
public BlockList()
|
|
{
|
|
Font = FormsUtility.DefaultFont;
|
|
BorderStyle = BorderStyle.None;
|
|
DrawMode = DrawMode.OwnerDrawVariable;
|
|
SelectionMode = SelectionMode.One;
|
|
|
|
MeasureItem += event_measureitem;
|
|
DrawItem += event_drawitem;
|
|
}
|
|
|
|
/// <summary></summary>
|
|
private void event_drawitem(object sender, DrawItemEventArgs e)
|
|
{
|
|
if (_color.Count > 0)
|
|
{
|
|
RectangleF vrf = new RectangleF(8, e.Bounds.Top + 4, e.Bounds.Width - 16, 16);
|
|
Brush vb = new SolidBrush(getcolor(e.Index));
|
|
string vs = Items[e.Index].ToString();
|
|
e.DrawBackground();
|
|
e.DrawFocusRectangle();
|
|
e.Graphics.DrawString(vs, e.Font, vb, vrf);
|
|
}
|
|
}
|
|
|
|
/// <summary></summary>
|
|
private void event_measureitem(object sender, MeasureItemEventArgs e)
|
|
{
|
|
e.ItemHeight = 25;
|
|
}
|
|
|
|
/// <summary></summary>
|
|
private Color getcolor(int argIndex)
|
|
{
|
|
if (argIndex >= _color.Count) return ForeColor;
|
|
return _color[argIndex];
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void append(string argText)
|
|
{
|
|
write(argText, ForeColor);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void write(string argText)
|
|
{
|
|
write(argText, ForeColor);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void black(string argText)
|
|
{
|
|
write(argText, FormsUtility.Black);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void green(string argText)
|
|
{
|
|
write(argText, FormsUtility.Green);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void red(string argText)
|
|
{
|
|
write(argText, FormsUtility.Red);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void gray(string argText)
|
|
{
|
|
write(argText, FormsUtility.GraceLocked);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void error(string argText)
|
|
{
|
|
red(argText);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void write(string argText, Color argColor)
|
|
{
|
|
var vtext = string.IsNullOrEmpty(argText) ? "" : argText.Trim();
|
|
while (_color.Count < Items.Count)
|
|
{
|
|
_color.Add(ForeColor);
|
|
}
|
|
while (_color.Count > Items.Count)
|
|
{
|
|
_color.RemoveAt(_color.Count - 1);
|
|
}
|
|
_color.Add((argColor == null) ? FormsUtility.Black : argColor);
|
|
Items.Add(vtext);
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public void selectlast()
|
|
{
|
|
if (Items.Count > 0) SelectedIndex = Items.Count - 1;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|