public void SetSelection(int tx, int ty, int width, int height)
{
if (width != 0 && height != 0)
{
if (tx < 0)
{
width += tx;
tx = 0;
}
if (ty < 0)
{
height += ty;
ty = 0;
}
if (width + tx > Screen.Width) width = Screen.Width - tx;
if (height + ty > Screen.Height) height = Screen.Height - ty;
// all in tile sizes
Selection = new Rectangle(tx, ty, width, height);
DrawSelectionAnts();
}
else
{
Selection = null;
using (Graphics g = Graphics.FromImage(toolLayer))
{
g.Clear(Color.Transparent);
}
}
if (SelectionChanged != null)
{
SelectionChanged(this, Selection);
}
}