private void CommandCloneBrush()
        {
            if (CommandCanCloneBrush())
            {
                string name = FindCloneBrushName(SelectedBrush.Name);

                Guid newBrushId = Guid.Empty;
                if (SelectedBrush is DynamicTileBrush)
                {
                    DynamicTileBrush oldBrush = SelectedBrush as DynamicTileBrush;
                    DynamicTileBrush newBrush = new DynamicTileBrush(name, oldBrush.TileWidth, oldBrush.TileHeight, oldBrush.BrushClass);
                    for (int i = 0; i < oldBrush.BrushClass.SlotCount; i++)
                    {
                        newBrush.SetTile(i, oldBrush.GetTile(i));
                    }

                    TileBrushManager.DefaultDynamicBrushCollection.Brushes.Add(newBrush);
                    newBrushId = newBrush.Uid;
                }
                else if (SelectedBrush is StaticTileBrush)
                {
                    StaticTileBrush oldBrush = SelectedBrush as StaticTileBrush;
                    StaticTileBrush newBrush = new StaticTileBrush(name, oldBrush.TileWidth, oldBrush.TileHeight);
                    foreach (LocatedTile tile in oldBrush.Tiles)
                    {
                        newBrush.AddTile(tile.Location, tile.Tile);
                    }
                    newBrush.Normalize();

                    TileBrushManager.DefaultStaticBrushCollection.Brushes.Add(newBrush);
                    newBrushId = newBrush.Uid;
                }
                else
                {
                    return;
                }

                OnSyncTileBrushCollection(EventArgs.Empty);
                SelectBrush(newBrushId);
                OnTileBrushSelected(EventArgs.Empty);
            }
        }
Esempio n. 2
0
        private void _buttonOk_Click(object sender, EventArgs e)
        {
            if (!_validateController.ValidateForm())
            {
                return;
            }

            _brush.TrySetName(_nameField.Text);
            _brush.Clear();

            foreach (LocatedTile tile in _layer.Tiles)
            {
                _brush.AddTile(tile.Location, tile.Tile);
            }

            _brush.Normalize();

            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 3
0
        private void EndDrag(PointerEventInfo info, ILevelGeometry viewport)
        {
            Rectangle selection = ClampSelection(_band.Selection);

            StaticTileBrush anonBrush = new StaticTileBrush("User Selected", Layer.TileWidth, Layer.TileHeight);

            foreach (LocatedTile tile in Layer.TilesAt(_band.Selection))
            {
                anonBrush.AddTile(new TileCoord(tile.X - _band.Selection.Left, tile.Y - _band.Selection.Top), tile.Tile);
            }

            anonBrush.Normalize();

            _activeBrush = anonBrush;

            _annots.Remove(_selectionAnnot);
            _selectionAnnot = null;

            //EndAutoScroll(info, viewport);
        }