protected override IMouseAction GetMouseAction(MouseEventArgs e, Keys modifierKeys, MapToolContext ctx) { if (modifierKeys.HasFlag(Keys.Alt)) { return(new PanZoomMouseAction()); } else { Point tilePt = ctx.ToTile(e.Location); // If the cursor is not on a selected tile then clear the selection and select // the tile directly under the cursor. if (!selectionService.SelectedItems.Any(i => i.Bounds.Contains(tilePt))) { selectionService.ClearSelection(); selectionService.ModifySelection(e.Location, ctx, SelectionAction.Add); } if (selectionService.SelectedItems.Any()) { return(new MoveItemsDragAction( selectionRenderer, selectionService, historyService)); } return(null); } }
protected override void OnClick(MouseEventArgs e, Keys modifierKeys, MapToolContext ctx) { if (ctx.MapEditingService.AddItem(item, ctx.ToTile(e.Location), this.transaction, CollisionAction.Abort)) { ctx.Viewport.Invalidate(); } }
protected override void OnClick(MouseEventArgs e, Keys modifierKeys, MapToolContext ctx) { lastTile = ctx.ToTile(e.Location); if (ctx.MapEditingService.DeleteTile(lastTile, transaction, true)) { ctx.Viewport.Invalidate(); } }
private Point GetItemPoint(MapToolContext ctx, Point clientPt) { var tilePt = ctx.ToTile(clientPt); tilePt = new Point( tilePt.X - (tilePt.X - startTile.X) % itemSize.Width, tilePt.Y - (tilePt.Y - startTile.Y) % itemSize.Height); return(tilePt); }
public void OnMouseDown(MouseEventArgs e, Keys modifierKeys, MapToolContext ctx) { Point tilePt = ctx.ToTile(e.Location); Item item = ctx.MapEditingService.GetItem(tilePt, true); if (item != null) { Item itemCopy = new Item(); itemCopy.CopyFrom(item); pickTarget.Pick(itemCopy); } }
public void OnMouseDown(MouseEventArgs e, MapToolContext ctx) { if (e.Button == MouseButtons.Left) { Point tilePt = ctx.ToTile(e.Location); // If the cursor is not on a selected tile then clear the selection and select // the tile directly under the cursor. if (!selectionService.SelectedItems.Any(i => i.Bounds.Contains(tilePt))) { selectionService.ClearSelection(); selectionService.ModifySelection(e.Location, ctx, SelectionAction.Add); } if (selectionService.SelectedItems.Any()) { this.isDragging = true; this.dragStart = e.Location; } } }
protected override IMouseAction GetMouseAction(MouseEventArgs e, Keys modifierKeys, MapToolContext ctx) { if (modifierKeys.HasFlag(Keys.Alt)) { return new PanZoomMouseAction(); } else if (e.Button == MouseButtons.Left) { Point tilePt = ctx.ToTile(e.Location); if (selectionService.SelectedItems.Any(i => i.Bounds.Contains(tilePt))) { return new MoveItemsDragAction(selectionRenderer, selectionService, historyService); } else { selectionService.ClearSelection(); return new MarqueeSelectAction(selectionService); } } return null; }