示例#1
0
        /// <summary>
        /// Draws the Analysis control panel.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The paint event.</param>
        private void DrawHandler(Object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.SmoothingMode      = SmoothingMode.HighSpeed;
            g.PixelOffsetMode    = PixelOffsetMode.HighSpeed;
            g.CompositingQuality = CompositingQuality.HighSpeed;

            Brush brush = _isSearching ? DisabledPieceBrush : EnabledPieceBrush;

            foreach (KeyValuePair <Int32, Rectangle> pair in SelectionPieces)
            {
                if (pair.Key == _selectedPiece)
                {
                    g.FillRectangle(SelectionBrush, pair.Value);
                }

                switch (pair.Key)
                {
                default:
                    VisualPiece.DrawAt(g, pair.Key, pair.Value.Location, brush);
                    break;

                case Piece.Empty:
                    g.DrawString(CrossString, CrossFont, brush, 17, 69);
                    break;

                case ArrowCode:
                    g.DrawString(ArrowString, ArrowFont, brush, 11, 7);
                    break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Animates the given move between the given initial and final locations.
        /// </summary>
        /// <param name="move">The move to animate.</param>
        /// <param name="initial">The initial location of the moving piece.</param>
        /// <param name="final">The final location of the moving piece.</param>
        private static void Animate(Int32 move, Point initial, Point final)
        {
            VisualPiece piece = null;

            lock (PiecesLock)
                for (Int32 i = 0; i < _pieces.Count; i++)
                {
                    if (_pieces[i].IsAt(initial))
                    {
                        piece = _pieces[i];
                        break;
                    }
                }

            new Thread(new ThreadStart(() => {
                piece.MoveTo(final);
                if (Move.IsPromotion(move))
                {
                    piece.Promote(Move.Special(move));
                }
            }))
            {
                IsBackground = true
            }.Start();
        }