mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-04-24 03:24:00 +00:00
桌面环境:增加环境变量APP并给Paint应用程序增加更多画图工具
This commit is contained in:
53
Gui/Apps/Paint/Tools/Eraser.cs
Normal file
53
Gui/Apps/Paint/Tools/Eraser.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Cosmos.System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps.Paint.Tools
|
||||
{
|
||||
internal class Eraser : Tool
|
||||
{
|
||||
public Eraser() : base("Eraser")
|
||||
{
|
||||
}
|
||||
|
||||
private bool joinLine;
|
||||
private int joinX;
|
||||
private int joinY;
|
||||
|
||||
internal override void Run(Paint paint, Window canvas, MouseState mouseState, int mouseX, int mouseY)
|
||||
{
|
||||
if (mouseState == MouseState.Left)
|
||||
{
|
||||
if (joinLine)
|
||||
{
|
||||
canvas.DrawLine(joinX, joinY, mouseX, mouseY, Color.White);
|
||||
}
|
||||
|
||||
for (int y = -4; y <= 4; y++)
|
||||
{
|
||||
for (int x = -4; x <= 4; x++)
|
||||
{
|
||||
int drawX = mouseX + x;
|
||||
int drawY = mouseY + y;
|
||||
if (paint.IsInBounds(drawX, drawY))
|
||||
{
|
||||
canvas.DrawPoint(drawX, drawY, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
joinLine = true;
|
||||
joinX = mouseX;
|
||||
joinY = mouseY;
|
||||
}
|
||||
else
|
||||
{
|
||||
joinLine = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Deselected()
|
||||
{
|
||||
joinLine = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Gui/Apps/Paint/Tools/FilledCircleTool.cs
Normal file
58
Gui/Apps/Paint/Tools/FilledCircleTool.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Cosmos.System;
|
||||
using System;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps.Paint.Tools
|
||||
{
|
||||
internal class FilledCircleTool : Tool
|
||||
{
|
||||
public FilledCircleTool() : base("Filled Circle")
|
||||
{
|
||||
}
|
||||
|
||||
private bool started;
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
internal override void Run(Paint paint, Window canvas, MouseState mouseState, int mouseX, int mouseY)
|
||||
{
|
||||
if (mouseState == MouseState.Left)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
started = true;
|
||||
startX = mouseX;
|
||||
startY = mouseY;
|
||||
}
|
||||
}
|
||||
else if (started)
|
||||
{
|
||||
int radiusX = Math.Abs(mouseX - startX);
|
||||
int radiusY = Math.Abs(mouseY - startY);
|
||||
int radius = Math.Max(radiusX, radiusY);
|
||||
|
||||
for (int y = -radius; y <= radius; y++)
|
||||
{
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
{
|
||||
if ((x * x) + (y * y) <= radius * radius)
|
||||
{
|
||||
int drawX = startX + x;
|
||||
int drawY = startY + y;
|
||||
if (paint.IsInBounds(drawX, drawY))
|
||||
{
|
||||
canvas.DrawPoint(drawX, drawY, paint.SelectedColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Deselected()
|
||||
{
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Gui/Apps/Paint/Tools/FilledRectangleTool.cs
Normal file
43
Gui/Apps/Paint/Tools/FilledRectangleTool.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Cosmos.System;
|
||||
using System;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps.Paint.Tools
|
||||
{
|
||||
internal class FilledRectangleTool : Tool
|
||||
{
|
||||
public FilledRectangleTool() : base("Filled Rect")
|
||||
{
|
||||
}
|
||||
|
||||
private bool started;
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
internal override void Run(Paint paint, Window canvas, MouseState mouseState, int mouseX, int mouseY)
|
||||
{
|
||||
if (mouseState == MouseState.Left)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
started = true;
|
||||
startX = mouseX;
|
||||
startY = mouseY;
|
||||
}
|
||||
}
|
||||
else if (started)
|
||||
{
|
||||
int x = Math.Min(startX, mouseX);
|
||||
int y = Math.Min(startY, mouseY);
|
||||
int width = Math.Abs(mouseX - startX) + 1;
|
||||
int height = Math.Abs(mouseY - startY) + 1;
|
||||
canvas.DrawFilledRectangle(x, y, width, height, paint.SelectedColor);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Deselected()
|
||||
{
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Gui/Apps/Paint/Tools/LineTool.cs
Normal file
38
Gui/Apps/Paint/Tools/LineTool.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Cosmos.System;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps.Paint.Tools
|
||||
{
|
||||
internal class LineTool : Tool
|
||||
{
|
||||
public LineTool() : base("Line")
|
||||
{
|
||||
}
|
||||
|
||||
private bool started;
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
internal override void Run(Paint paint, Window canvas, MouseState mouseState, int mouseX, int mouseY)
|
||||
{
|
||||
if (mouseState == MouseState.Left)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
started = true;
|
||||
startX = mouseX;
|
||||
startY = mouseY;
|
||||
}
|
||||
}
|
||||
else if (started)
|
||||
{
|
||||
canvas.DrawLine(startX, startY, mouseX, mouseY, paint.SelectedColor);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Deselected()
|
||||
{
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
Gui/Apps/Paint/Tools/RectangleTool.cs
Normal file
43
Gui/Apps/Paint/Tools/RectangleTool.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Cosmos.System;
|
||||
using System;
|
||||
|
||||
namespace CMLeonOS.Gui.Apps.Paint.Tools
|
||||
{
|
||||
internal class RectangleTool : Tool
|
||||
{
|
||||
public RectangleTool() : base("Rectangle")
|
||||
{
|
||||
}
|
||||
|
||||
private bool started;
|
||||
private int startX;
|
||||
private int startY;
|
||||
|
||||
internal override void Run(Paint paint, Window canvas, MouseState mouseState, int mouseX, int mouseY)
|
||||
{
|
||||
if (mouseState == MouseState.Left)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
started = true;
|
||||
startX = mouseX;
|
||||
startY = mouseY;
|
||||
}
|
||||
}
|
||||
else if (started)
|
||||
{
|
||||
int x = Math.Min(startX, mouseX);
|
||||
int y = Math.Min(startY, mouseY);
|
||||
int width = Math.Abs(mouseX - startX) + 1;
|
||||
int height = Math.Abs(mouseY - startY) + 1;
|
||||
canvas.DrawRectangle(x, y, width, height, paint.SelectedColor);
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Deselected()
|
||||
{
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user