示例#1
0
        private void DrawCountingStones()
        {
            m_BoardVisual.Children.Remove(m_CountingVisual);

            if (DisplayCountedStones)
            {
                m_CountingVisual = new DrawingVisual();
                int blackScore = 0;
                int whiteScore = 0;

                using (DrawingContext dc = m_CountingVisual.RenderOpen())
                {
                    for (int j = 0; j < BoardSize; ++j)
                    {
                        for (int i = 0; i < BoardSize; ++i)
                        {
                            GoBoardPoint point = new GoBoardPoint(i, j);
                            if (m_StoneList.ContainsKey(point))
                            {
                                Stone stone = m_StoneList[point];
                                if (stone == Stone.Empty || stone == Stone.Boundary)
                                {
                                    throw new Exception(String.Format("Found a stone with no valid color at point {0},{1}!", point.X, point.Y));
                                }

                                Pen    annoPen   = m_WhiteStoneAnnotationPen;
                                Brush  annoColor = Brushes.Black;
                                String score     = String.Empty;
                                if (stone == Stone.Black)
                                {
                                    // overwrite for black
                                    annoPen   = m_BlackStoneAnnotationPen;
                                    annoColor = Brushes.White;
                                    blackScore++;
                                    score = String.Format("{0}", blackScore);
                                }
                                else
                                {
                                    whiteScore++;
                                    score = String.Format("{0}", whiteScore);
                                }

                                FormattedText text = new FormattedText(score, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, m_BoardTypeface, 8, annoColor);
                                dc.DrawText(text, new Point(getPosX(point.X) - text.Width / 2, getPosY(point.Y) - text.Height / 2));
                            }
                        }
                    }
                }
                m_BoardVisual.Children.Add(m_CountingVisual);
            }
        }
示例#2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            Point pos = e.GetPosition(this);

            if (!m_GoBoardHitBox.Contains(new Point(pos.X - m_Border, pos.Y - m_Border)))
            {
                m_MousePosition = GoBoardPoint.Empty;
                DrawMouseHoverVisual();
                return;
            }

            int x = (int)Math.Round((pos.X - m_Border) / (m_GoBoardRect.Width / m_BoardSize));
            int y = (int)Math.Round((pos.Y - m_Border) / (m_GoBoardRect.Height / m_BoardSize));

            m_MousePosition = new GoBoardPoint(x, y);
            DrawMouseHoverVisual();
        }
 public RoutedMovePlayedEventArgs(RoutedEvent routedEvent, object source, GoBoardPoint pos, Stone stoneColor)
     : base(routedEvent, source)
 {
     Position = pos;
     StoneColor = stoneColor;
 }
示例#4
0
 public GoBoardAnnotation(GoBoardAnnotationType type, GoBoardPoint position, string text)
 {
     m_Type     = type;
     m_Position = position;
     m_Text     = text;
 }
示例#5
0
 public GoBoardAnnotation(GoBoardAnnotationType type, GoBoardPoint position)
     : this(type, position, "")
 {
 }
 public RoutedMovePlayedEventArgs(RoutedEvent routedEvent, object source, GoBoardPoint pos, Stone stoneColor)
     : base(routedEvent, source)
 {
     Position   = pos;
     StoneColor = stoneColor;
 }
示例#7
0
 public GoBoardAnnotation(GoBoardAnnotationType type, GoBoardPoint position, string text)
 {
     m_Type = type;
     m_Position = position;
     m_Text = text;
 }
示例#8
0
 public GoBoardAnnotation(GoBoardAnnotationType type, GoBoardPoint position)
     : this(type, position, "")
 {
 }
示例#9
0
        private void DrawCountingStones()
        {
            m_BoardVisual.Children.Remove(m_CountingVisual);

            if (DisplayCountedStones)
            {
                m_CountingVisual = new DrawingVisual();
                int blackScore = 0;
                int whiteScore = 0;

                using (DrawingContext dc = m_CountingVisual.RenderOpen())
                {
                    for (int j = 0; j < BoardSize; ++j)
                    {
                        for (int i = 0; i < BoardSize; ++i)
                        {
                            GoBoardPoint point = new GoBoardPoint(i, j);
                            if (m_StoneList.ContainsKey(point))
                            {
                                Stone stone = m_StoneList[point];
                                if (stone == Stone.Empty || stone == Stone.Boundary)
                                {
                                    throw new Exception(String.Format("Found a stone with no valid color at point {0},{1}!", point.X, point.Y));
                                }

                                Pen annoPen = m_WhiteStoneAnnotationPen;
                                Brush annoColor = Brushes.Black;
                                String score = String.Empty;
                                if (stone == Stone.Black)
                                {
                                    // overwrite for black
                                    annoPen = m_BlackStoneAnnotationPen;
                                    annoColor = Brushes.White;
                                    blackScore++;
                                    score = String.Format("{0}", blackScore);
                                }
                                else
                                {
                                    whiteScore++;
                                    score = String.Format("{0}", whiteScore);
                                }

                                FormattedText text = new FormattedText(score, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, m_BoardTypeface, 8, annoColor);
                                dc.DrawText(text, new Point(getPosX(point.X) - text.Width / 2, getPosY(point.Y) - text.Height / 2));
                            }
                        }
                    }
                }
                m_BoardVisual.Children.Add(m_CountingVisual);
            }
        }
示例#10
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            Point pos = e.GetPosition(this);

            if (!m_GoBoardHitBox.Contains(new Point(pos.X - m_Border, pos.Y - m_Border)))
            {
                m_MousePosition = GoBoardPoint.Empty;
                DrawMouseHoverVisual();
                return;
            }

            int x = (int)Math.Round((pos.X - m_Border) / (m_GoBoardRect.Width / m_BoardSize));
            int y = (int)Math.Round((pos.Y - m_Border) / (m_GoBoardRect.Height / m_BoardSize));

            m_MousePosition = new GoBoardPoint(x, y);
            DrawMouseHoverVisual();
        }