コード例 #1
0
ファイル: MoveTool.cs プロジェクト: MadDanEccles/NHSE
        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);
            }
        }
コード例 #2
0
ファイル: PaintAction.cs プロジェクト: MadDanEccles/NHSE
 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();
     }
 }
コード例 #3
0
ファイル: EraseAction.cs プロジェクト: MadDanEccles/NHSE
 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();
     }
 }
コード例 #4
0
ファイル: PaintAction.cs プロジェクト: MadDanEccles/NHSE
        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);
        }
コード例 #5
0
ファイル: PickAction.cs プロジェクト: MadDanEccles/NHSE
        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);
            }
        }
コード例 #6
0
ファイル: MoveTool.cs プロジェクト: MadDanEccles/NHSE
        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;
                }
            }
        }
コード例 #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;
        }