mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
GUI桌面环境
This commit is contained in:
60
Gui/Apps/Paint/ToolBox.cs
Normal file
60
Gui/Apps/Paint/ToolBox.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using CMLeonOS.Gui.UILib;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps.Paint
|
||||
{
|
||||
internal class ToolBox : Window
|
||||
{
|
||||
private Paint paintInstance;
|
||||
|
||||
private Table table;
|
||||
|
||||
internal Tool SelectedTool;
|
||||
|
||||
internal readonly List<Tool> Tools = new List<Tool>()
|
||||
{
|
||||
new Tools.Pencil(),
|
||||
new Tools.CircleBrush()
|
||||
};
|
||||
|
||||
private void TableClicked(int x, int y)
|
||||
{
|
||||
Tool tool = table.Cells[table.SelectedCellIndex].Tag as Tool;
|
||||
|
||||
if (tool != SelectedTool)
|
||||
{
|
||||
SelectedTool.Deselected();
|
||||
SelectedTool = tool;
|
||||
}
|
||||
}
|
||||
|
||||
internal ToolBox(Paint paint, int x, int y, int width, int height) : base(paint, x, y, width, height)
|
||||
{
|
||||
paintInstance = paint;
|
||||
|
||||
|
||||
Clear(Color.FromArgb(107, 107, 107));
|
||||
DrawString("Toolbox", Color.White, 8, 8);
|
||||
|
||||
table = new Table(this, 0, 32, Width, Height - 32);
|
||||
table.AllowDeselection = false;
|
||||
table.CellHeight = 24;
|
||||
table.TextAlignment = Alignment.Middle;
|
||||
table.OnClick = TableClicked;
|
||||
|
||||
foreach (Tool tool in Tools)
|
||||
{
|
||||
table.Cells.Add(new TableCell(tool.Name, tool));
|
||||
}
|
||||
|
||||
SelectedTool = Tools[0];
|
||||
table.SelectedCellIndex = 0;
|
||||
|
||||
table.Render();
|
||||
|
||||
WM.AddWindow(this);
|
||||
WM.AddWindow(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user