Пример #1
0
 protected override void OnDragEnd(MouseEventArgs mouseEventArgs, Keys modifierKeys, MapToolContext ctx)
 {
     if (fragment != null)
     {
         using (var trans = historyService.BeginTransaction("Fill Rectangle"))
         {
             foreach (var entry in fragment)
             {
                 ctx.MapEditingService.AddItem(entry.Item, entry.TileRect.Location, trans, CollisionAction.Abort);
             }
         }
     }
     this.renderer.Reset();
 }
Пример #2
0
        protected override void OnDragEnd(MouseEventArgs mouseEventArgs, Keys modifierKeys, MapToolContext ctx)
        {
            bool  createCopy = modifierKeys.HasFlag(Keys.Control);
            Point tileDelta  = GetTileDelta(mouseEventArgs.Location, ctx);

            if (IsValidDropPos(tileDelta, ctx.MapEditingService, createCopy))
            {
                using (var trans = historyService.BeginTransaction($"Move {selectionService.SelectedItems.Count()} items"))
                {
                    if (!createCopy)
                    {
                        // The drop location is valid; delete all tiles to be moved then recreate them in their
                        // new location.
                        foreach (var selectedItem in selectionService.SelectedItems)
                        {
                            ctx.MapEditingService.DeleteTile(selectedItem.Bounds.Location, trans);
                        }
                    }

                    foreach (var selectedItem in selectionService.SelectedItems)
                    {
                        Point newLocation = selectedItem.Bounds.Location;
                        newLocation.Offset(tileDelta);
                        ctx.MapEditingService.AddItem(selectedItem.Item, newLocation, trans);
                    }
                }

                selectionService.ApplyTileDelta(tileDelta);
            }
            else
            {
                MessageBox.Show(ctx.Viewport, "This space is already occupied", "Unable to Move Items", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            selectionRenderer.TileOffset = Point.Empty;
        }
Пример #3
0
 public PaintAction(IHistoryService historyService, Item item)
 {
     this.transaction = historyService.BeginTransaction("Paint");
     this.item        = item;
     this.itemSize    = item.GetSize();
 }
Пример #4
0
 public EraseAction(IHistoryService historyService)
 {
     this.transaction = historyService.BeginTransaction("Eraser");
 }