Beispiel #1
0
        void Tiles_Drop(object sender, DragEventArgs e)
        {
            Tile t = (Tile)e.Data.GetData("scTile");

            if (UtilityFunctions.GetAncestorOfType <Canvas>(t) != null)
            {
                Canvas squareCnt = (Canvas)t.Parent;

                squareCnt.Children.Clear();
                BoardSquare thisSquare = (BoardSquare)squareCnt.Parent;
                thisSquare.PlacedTile = null;

                UtilityFunctions.GetAncestorOfType <GameWindow>(thisSquare).WordInPlay.Remove(thisSquare.MyCoords);

                PlayerTiles.Add(t);

                Redraw();
            }
        }
Beispiel #2
0
        //drag/drop code
        void BoardSquare_Drop(object sender, DragEventArgs e)
        {
            Tile t = (Tile)e.Data.GetData("scTile");

            if (UtilityFunctions.GetAncestorOfType <Tiles>(t) != null)
            {
                StackPanel letterTray = (StackPanel)t.Parent;
                Grid       layout     = (Grid)letterTray.Parent;
                Tiles      these      = (Tiles)layout.Parent;
                these.PlayerTiles.Remove(t);
                letterTray.Children.Remove(t);

                if (!Put(t))
                {
                    //put stuff back noob
                    these.PlayerTiles.Add(t);
                    letterTray.Children.Add(t);
                }
            }
            else if (UtilityFunctions.GetAncestorOfType <BoardSquare>(t) != null)
            {
                BoardSquare other = UtilityFunctions.GetAncestorOfType <BoardSquare>(t);
                other.PlacedTile = null;
                other.SquareContainer.Children.Clear();

                if (!Put(t))
                {
                    other.PlacedTile = t;
                    other.SquareContainer.Children.Add(t);
                }

                UtilityFunctions.GetAncestorOfType <GameWindow>(this).WordInPlay.Remove(other.MyCoords);
            }

            //change bg back
            SquareContainer.Background = ("#" + MySquare.Gradient).ToBrush();

            Redraw();
        }