Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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;
                }
            }
        }
Exemplo n.º 7
0
        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;
        }