Inheritance: System.Windows.Controls.Canvas
コード例 #1
0
        private void Flood(ScreenCanvas canvas, int tile_x, int tile_y, int tile_id, int brush_x, int brush_y)
        {
            var selection = canvas.Screen.Selection;
            if (selection != null)
            {
                // only paint inside selection
                if (!selection.Value.Contains(tile_x, tile_y))
                {
                    return;
                }
            }

            var old = canvas.Screen.TileAt(tile_x, tile_y);
            // checking whether this is already the new tile prevents infinite recursion, but
            // it can prevent filling a solid area with a brush that uses that same tile
            if (old == null || old.Id != tile_id || old.Id == _brush.Cells[brush_x][brush_y].tile.Id) return;

            _brush.DrawOn(canvas.Screen, tile_x, tile_y);
            changes.Add(new TileChange(canvas.Screen, tile_x, tile_y, tile_id, _brush.Cells[brush_x][brush_y].tile.Id));

            Flood(canvas, tile_x - 1, tile_y, tile_id, (brush_x == 0) ? width - 1 : brush_x - 1, brush_y);
            Flood(canvas, tile_x + 1, tile_y, tile_id, (brush_x == width - 1) ? 0 : brush_x + 1, brush_y);
            Flood(canvas, tile_x, tile_y - 1, tile_id, brush_x, (brush_y == 0) ? height - 1 : brush_y - 1);
            Flood(canvas, tile_x, tile_y + 1, tile_id, brush_x, (brush_y == height - 1) ? 0 : brush_y + 1);
        }
コード例 #2
0
 public void Move(ScreenCanvas canvas, Common.Geometry.Point location)
 {
     if (_dragging)
     {
         canvas.Margin = new Thickness(canvas.Margin.Left + location.X - _dragAnchorOffset.X, canvas.Margin.Top + location.Y - _dragAnchorOffset.Y, 0, 0);
     }
 }
コード例 #3
0
        public void RightClick(ScreenCanvas surface, Point location)
        {
            int tile_x = location.X / surface.Screen.Tileset.TileSize;
            int tile_y = location.Y / surface.Screen.Tileset.TileSize;

            var tile = surface.Screen.TileAt(tile_x, tile_y);
            ViewModelMediator.Current.GetEvent<TileSelectedEventArgs>().Raise(this, new TileSelectedEventArgs() { Tile = tile });
        }
コード例 #4
0
 public void Click(ScreenCanvas surface, Point location)
 {
     tx1 = location.X / surface.Screen.Tileset.TileSize;
     ty1 = location.Y / surface.Screen.Tileset.TileSize;
     tx2 = tx1;
     ty2 = ty1;
     held = true;
 }
コード例 #5
0
 private void SetSelection(ScreenCanvas surface)
 {
     surface.Screen.SetSelection(
         Math.Min(tx1, tx2),
         Math.Min(ty1, ty2),
         Math.Abs(tx2 - tx1),
         Math.Abs(ty2 - ty1)
     );
 }
コード例 #6
0
        public void Click(ScreenCanvas canvas, Common.Geometry.Point location)
        {
            _dragging = true;
            _dragAnchorOffset = new Vector(location.X, location.Y);

            canvas.CaptureMouse();

            Canvas.SetZIndex(canvas, 100);
        }
コード例 #7
0
        public void Move(ScreenCanvas surface, Point location)
        {
            if (held)
            {
                tx2 = (int)Math.Round(location.X / (float)surface.Screen.Tileset.TileSize);
                ty2 = (int)Math.Round(location.Y / (float)surface.Screen.Tileset.TileSize);

                SetSelection(surface);
            }
        }
コード例 #8
0
 public void RightClick(ScreenCanvas canvas, Point location)
 {
     var i = canvas.Screen.FindEntityAt(location);
     if (i >= 0)
     {
         var e = canvas.Screen.GetEntity(i);
         canvas.Screen.RemoveEntity(e);
         canvas.Screen.Stage.PushHistoryAction(new RemoveEntityAction(e, canvas.Screen));
     }
 }
コード例 #9
0
        public void Release(ScreenCanvas canvas, Common.Geometry.Point location)
        {
            _dragging = false;

            canvas.ReleaseMouseCapture();

            Canvas.SetZIndex(canvas, 1);

            ViewModelMediator.Current.GetEvent<LayoutScreenDroppedEventArgs>().Raise(canvas, new LayoutScreenDroppedEventArgs() { Canvas = canvas });
        }
コード例 #10
0
        public void Release(ScreenCanvas canvas, Point location)
        {
            var args = new TestLocationSelectedEventArgs() {
                Screen = canvas.Screen.Name,
                X = location.X,
                Y = location.Y
            };

            ViewModelMediator.Current.GetEvent<TestLocationSelectedEventArgs>().Raise(this, args);
        }
コード例 #11
0
        public void Click(ScreenCanvas canvas, Point location)
        {
            var screen = canvas.Screen;
            changes = new List<TileChange>();

            Point tilePos = new Point(location.X / screen.Tileset.TileSize, location.Y / screen.Tileset.TileSize);

            var selection = screen.Selection;
            if (selection != null)
            {
                // only paint inside selection
                if (!selection.Value.Contains(tilePos))
                {
                    startTiles = null;
                    endTiles = null;
                    return;
                }
            }

            startTiles = new int?[screen.Width, screen.Height];
            endTiles = new int?[screen.Width, screen.Height];

            // check for line drawing
            if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.None)
            {
                var xdist = Math.Abs(tilePos.X - currentTilePos.X);
                var ydist = Math.Abs(tilePos.Y - currentTilePos.Y);

                if (xdist >= ydist)
                {
                    var min = Math.Min(currentTilePos.X, tilePos.X);
                    var max = Math.Max(currentTilePos.X, tilePos.X);
                    for (int i = min; i <= max; i++)
                    {
                        Draw(screen, i, currentTilePos.Y);
                    }
                }
                else
                {
                    var min = Math.Min(currentTilePos.Y, tilePos.Y);
                    var max = Math.Max(currentTilePos.Y, tilePos.Y);
                    for (int i = min; i <= max; i++)
                    {
                        Draw(screen, currentTilePos.X, i);
                    }
                }
            }
            else
            {
                Draw(screen, tilePos.X, tilePos.Y);
                held = true;
            }

            currentTilePos = tilePos;
        }
コード例 #12
0
 public double DownDistanceTo(ScreenCanvas second)
 {
     if ((this.Margin.Left < second.Margin.Left + second.Screen.PixelWidth) && (this.Margin.Left + this.Screen.PixelWidth > second.Margin.Left))
     {
         return(Math.Abs(second.Margin.Top - (this.Margin.Top + this.Screen.PixelHeight)));
     }
     else
     {
         return(double.PositiveInfinity);
     }
 }
コード例 #13
0
 public double DownDistanceTo(ScreenCanvas second)
 {
     if ((this.Margin.Left < second.Margin.Left + second.Screen.PixelWidth) && (this.Margin.Left + this.Screen.PixelWidth > second.Margin.Left))
     {
         return Math.Abs(second.Margin.Top - (this.Margin.Top + this.Screen.PixelHeight));
     }
     else
     {
         return double.PositiveInfinity;
     }
 }
コード例 #14
0
        public void Click(ScreenCanvas canvas, Point location)
        {
            int tile_x = location.X / canvas.Screen.Tileset.TileSize;
            int tile_y = location.Y / canvas.Screen.Tileset.TileSize;

            var old = canvas.Screen.TileAt(tile_x, tile_y);

            Flood(canvas, tile_x, tile_y, old.Id, 0, 0);

            canvas.Screen.Stage.PushHistoryAction(new DrawAction("Fill", changes));

            changes.Clear();
        }
コード例 #15
0
        public void Click(ScreenCanvas canvas, Point location)
        {
            var placement = new Common.EntityPlacement() {
                entity = _entity.Name,
                direction = Common.Direction.Unknown,
                screenX = location.X,
                screenY = location.Y
            };

            canvas.Screen.AddEntity(placement);

            canvas.Screen.Stage.PushHistoryAction(new AddEntityAction(placement, canvas.Screen));
        }
コード例 #16
0
        public void JoinRightwardTo(ScreenCanvas canvas)
        {
            var tileTopOne = (int)Math.Round(this.Margin.Top / Screen.Tileset.TileSize);
            var tileTopTwo = (int)Math.Round(canvas.Margin.Top / Screen.Tileset.TileSize);

            var startPoint = Math.Max(tileTopOne, tileTopTwo);
            var endPoint = Math.Min(tileTopOne + Screen.Height, tileTopTwo + canvas.Screen.Height);

            var startTileOne = (startPoint - tileTopOne);
            var startTileTwo = (startPoint - tileTopTwo);
            var length = endPoint - startPoint;

            var join = new MegaMan.Common.Join();
            join.screenOne = Screen.Name;
            join.screenTwo = canvas.Screen.Name;
            join.direction = Common.JoinDirection.Both;
            join.type = Common.JoinType.Vertical;
            join.offsetOne = startTileOne;
            join.offsetTwo = startTileTwo;
            join.Size = length;

            Screen.Stage.AddJoin(join);
        }
コード例 #17
0
        public void JoinDownwardTo(ScreenCanvas canvas)
        {
            var tileLeftOne = (int)Math.Round(this.Margin.Left / Screen.Tileset.TileSize);
            var tileLeftTwo = (int)Math.Round(canvas.Margin.Left / Screen.Tileset.TileSize);

            var startPoint = Math.Max(tileLeftOne, tileLeftTwo);
            var endPoint   = Math.Min(tileLeftOne + Screen.Width, tileLeftTwo + canvas.Screen.Width);

            var startTileOne = (startPoint - tileLeftOne);
            var startTileTwo = (startPoint - tileLeftTwo);
            var length       = endPoint - startPoint;

            var join = new MegaMan.Common.Join();

            join.screenOne = Screen.Name;
            join.screenTwo = canvas.Screen.Name;
            join.direction = Common.JoinDirection.Both;
            join.type      = Common.JoinType.Horizontal;
            join.offsetOne = startTileOne;
            join.offsetTwo = startTileTwo;
            join.Size      = length;

            Screen.Stage.AddJoin(join);
        }
コード例 #18
0
 public void Click(ScreenCanvas canvas, Point location) { }
コード例 #19
0
 public void Release(ScreenCanvas canvas, Point location)
 {
     int tilePosX = location.X / canvas.Screen.Tileset.TileSize;
     canvas.Screen.CleaveVertically(tilePosX);
 }
コード例 #20
0
 public void Release(ScreenCanvas canvas, Point location)
 {
     canvas.Screen.Stage.AddContinuePoint(canvas.Screen, location);
 }
コード例 #21
0
 protected override void DestroyScreenCanvas(ScreenCanvas canvas)
 {
 }
コード例 #22
0
 private MegaMan.Common.Geometry.Point GetCanvasLocation(ScreenCanvas surface)
 {
     return(new MegaMan.Common.Geometry.Point((int)surface.Margin.Left, (int)surface.Margin.Top));
 }
コード例 #23
0
        public void Release(ScreenCanvas canvas, Point location)
        {

        }
コード例 #24
0
        public void Move(ScreenCanvas canvas, Point location)
        {
            var screen = canvas.Screen;

            if (!held) return;

            Point pos = new Point(location.X / screen.Tileset.TileSize, location.Y / screen.Tileset.TileSize);
            if (pos == currentTilePos) return; // don't keep drawing on the same spot

            Draw(screen, pos.X, pos.Y);
        }
コード例 #25
0
 public void RightClick(ScreenCanvas surface, Point location)
 {
     surface.Screen.SetSelection(0, 0, 0, 0);
 }
コード例 #26
0
 private MegaMan.Common.Geometry.Point GetCanvasLocation(ScreenCanvas surface)
 {
     return new MegaMan.Common.Geometry.Point((int)surface.Margin.Left, (int)surface.Margin.Top);
 }
コード例 #27
0
 private void SetCanvasLocation(ScreenCanvas surface, MegaMan.Common.Geometry.Point location)
 {
     surface.Margin = new Thickness(location.X, location.Y, 0, 0);
 }
コード例 #28
0
 public void Release(ScreenCanvas surface, Point location)
 {
     held = false;
 }
コード例 #29
0
 protected abstract void DestroyScreenCanvas(ScreenCanvas canvas);
コード例 #30
0
 public void Move(ScreenCanvas canvas, Point location) { }
コード例 #31
0
 protected abstract void DestroyScreenCanvas(ScreenCanvas canvas);
コード例 #32
0
ファイル: StageTileControl.cs プロジェクト: laazer/cs_megaman
 protected override void DestroyScreenCanvas(ScreenCanvas canvas)
 {
     
 }
コード例 #33
0
        public void RightClick(ScreenCanvas canvas, Common.Geometry.Point location)
        {

        }
コード例 #34
0
        public void Release(ScreenCanvas canvas, Point location)
        {
            if (startTiles == null) return;

            held = false;

            canvas.Screen.Stage.PushHistoryAction(new DrawAction("Brush", changes));
        }
コード例 #35
0
 private void SetCanvasLocation(ScreenCanvas surface, MegaMan.Common.Geometry.Point location)
 {
     surface.Margin = new Thickness(location.X, location.Y, 0, 0);
 }