/// <summary> /// Використовує інструмент: визначає горизонтальну та вертикальну відстань між початковою точкою та точкою використання, та переміщає на неї шар. /// </summary> /// <param name="UsePoint">Точка використання.</param> public override void UseTool(Point UsePoint) { if (ToolLayer.Visible) { Point newLoc; if (ToolLayer.Text != null) { newLoc = ToolLayer.Text.Location; } else { newLoc = ToolLayer.Location; } if (ToolLayer.Shape == null) { newLoc.X += UsePoint.X - InitialPoint.X; newLoc.Y += UsePoint.Y - InitialPoint.Y; } if (ToolLayer.Text != null) { ToolLayer.Text.Location = newLoc; ToolLayer.RefreshContents(); } else if (ToolLayer.Shape != null) { int xOffset = UsePoint.X - InitialPoint.X; int yOffset = UsePoint.Y - InitialPoint.Y; newLoc = ToolLayer.Shape.Point1; newLoc.X += xOffset; newLoc.Y += yOffset; ToolLayer.Shape.Point1 = newLoc; newLoc = ToolLayer.Shape.Point2; newLoc.X += xOffset; newLoc.Y += yOffset; ToolLayer.Shape.Point2 = newLoc; ToolLayer.RefreshContents(); } else { ToolLayer.Location = newLoc; } InitialPoint = UsePoint; } }
public TileRectangleAction(Room r, ToolLayer l, int t, Rectangle a) : base(r, l, t) { Area = a; if (Area.X < 0) { Area.Width += Area.X; Area.X = 0; } if (Area.Y < 0) { Area.Height += Area.Y; Area.Y = 0; } if (Area.X + Area.Width >= Grid.Width) { Area.Width = Grid.Width - Area.X; } if (Area.Y + Area.Height >= Grid.Height) { Area.Height = Grid.Height - Area.Y; } for (int x = Area.X; x < Area.X + Area.Width; x++) { for (int y = Area.Y; y < Area.Y + Area.Height; y++) { if (Grid[x, y] != Tileset) { PreviousTiles.Add((new Point(x, y), Grid[x, y])); } } } }
public TileBrushAction(Room r, ToolLayer l, int t, Point p) : base(r, l, t) { Points = new HashSet <Point>(); AddPoint(p); }