Example #1
0
        public void DeleteEdge(EdgeKind kind)
        {
            if (_cl == null)
            {
                return;
            }

            int x, y;

            Edge.GetCoords(kind, out x, out y);

            if (x == -1)
            {
                DeleteCollageColumn(0);
            }
            else if (x == 1)
            {
                DeleteCollageColumn(_cl.Columns - 1);
            }

            if (y == -1)
            {
                DeleteCollageRow(0);
            }
            else if (y == 1)
            {
                DeleteCollageRow(_cl.Rows - 1);
            }
        }
Example #2
0
        public override void ReceiveTile(Tile obj, Position loc)
        {
            if (_cl == null)
            {
                _cl = new Collage(_fmt, 1, false);
                _cl.AddBlankTiles(1);
                Activate(_main.toolBox);
            }

            EdgeKind kind = EdgeOf(loc);

            if (kind != EdgeKind.None)
            {
                int x, y;
                Edge.GetCoords(kind, out x, out y);

                Edge e = _edges[(int)kind];
                e.Distance = new Position(x, y);
                ResizeCollage(e);

                if (x == -1)
                {
                    loc.col = 0;
                }
                if (y == -1)
                {
                    loc.row = 0;
                }
            }

            _selPos = loc;
            _cl.SetTile(_selPos, obj as Tile);
            Render();
        }
Example #3
0
        private void ShiftCamera(EdgeKind e)
        {
            int x, y;

            Edge.GetCoords(e, out x, out y);
            ShiftCamera(Math.Abs(x), Math.Abs(y));
        }
Example #4
0
        public override void ResizeCollage(Edge msg)
        {
            if (msg.EdgeKind == EdgeKind.None)
            {
                return;
            }

            int x, y;

            Edge.GetCoords(msg.EdgeKind, out x, out y);
            var dist = msg.Distance;

            Func <int, int, int, Func <int, int>, Func <int, int>, int> resizeAxis = (side, delta, max, insert, delete) =>
            {
                int shift  = 0;
                int length = Math.Abs(delta);
                for (int i = 0; i < length; i++)
                {
                    if (side < 0)
                    {
                        if (delta < 0)
                        {
                            shift += insert(0);
                        }
                        else
                        {
                            shift += delete(0);
                        }
                    }
                    if (side > 0)
                    {
                        if (delta < 0)
                        {
                            shift += delete(--max);
                        }
                        else
                        {
                            shift += insert(max);
                        }
                    }
                }

                return(shift);
            };

            int shiftX = resizeAxis(x, dist.col, _cl.Columns, _cl.InsertColumn, _cl.DeleteColumn);
            int shiftY = resizeAxis(y, dist.row, _cl.Rows, _cl.InsertRow, _cl.DeleteRow);

            ShiftCamera(shiftX, shiftY);
            msg.Distance = new Position(0, 0);

            Render();
        }