Beispiel #1
0
        public Selection Current()
        {
            if (_lastWnd == null)
            {
                return(null);
            }

            bool     wasOob;
            Position pos = _lastWnd.GetPosition(_lastX, _lastY, out wasOob);

            Edge edge = _selObj as Edge;

            if (edge == null)
            {
                _lastWnd.Selected = !wasOob;
                return(wasOob ? null : new Selection(_selObj, _lastWnd, pos));
            }

            if (_lastWnd == _orgWnd)
            {
                edge.Distance = new Position(
                    pos.col - _orgPos.col,
                    pos.row - _orgPos.row
                    );
            }
            else
            {
                edge.Distance = new Position(0, 0);
            }

            return(new Selection(_selObj, _lastWnd, pos));
        }
Beispiel #2
0
        public DragObject(TileWindow wnd, int x, int y)
        {
            _lastX = x;
            _lastY = y;

            _lastWnd = wnd;
            _orgWnd  = wnd;

            bool wasOob;

            _orgPos = _orgWnd.GetPosition(x, y, out wasOob);
            if (wasOob)
            {
                throw new ArgumentOutOfRangeException();
            }

            _selObj = _orgWnd.PieceAt(_orgPos);
            if (_selObj is Tile)
            {
                Bitmap img = _orgWnd.TileBitmap(_selObj as Tile);
                img  = img.SetAlpha(curAlpha).Scale(curScale);
                _cur = new Cursor(img.GetHicon());
            }

            _orgWnd.Cursor = new Selection(_selObj, _orgWnd, _orgPos);
            _orgWnd.AdoptCursor();
            Transfer.Source = _orgWnd.Cursor;
        }
Beispiel #3
0
        private bool HasLeft(TileWindow wnd)
        {
            if (wnd == null || wnd != _orgWnd)
            {
                return(true);
            }

            if (_selObj is Edge)
            {
                var dist = ((Edge)_selObj).Distance;
                return(dist.col != 0 || dist.row != 0);
            }

            bool     wasOob;
            Position loc = wnd.GetPosition(_lastX, _lastY, out wasOob);

            return(!wasOob && (loc.col != _orgPos.col || loc.row != _orgPos.row));
        }
Beispiel #4
0
        private void ShowMenuAt(TileWindow wnd, int x, int y)
        {
            bool wasOob;

            wnd.Position = wnd.GetPosition(x, y, out wasOob);
            if (wasOob)
            {
                ClearSelection();
                SetSample(null);
                return;
            }

            if (wnd == inputWnd)
            {
                SetSample(inputWnd.PieceAt(inputWnd.Position) as Tile);
            }

            Transfer.Source = wnd.CurrentSelection();
            if (wnd.EdgeOf(wnd.Position) == EdgeKind.None)
            {
                wnd.ShowMenu(x, y);
            }
        }