コード例 #1
0
        public Geometry CreateMarkerPath(int index, GameMap.Marker marker)
        {
            GameMap map = (GameMap)DataContext;

            if (map != null)
            {
                GameMap.MapCell cell = map.IndexToCell(index);

                Rect rect = CellRect(cell);

                double penWidth = CurrentScale;


                switch (marker.Style)
                {
                case GameMap.MarkerStyle.Square:


                    return(rect.RectanglePath(penWidth));

                case GameMap.MarkerStyle.Circle:

                    Rect cicleRect = rect;
                    cicleRect.ScaleCenter(.9, .9);

                    return(rect.CirclePath(penWidth));

                case GameMap.MarkerStyle.Diamond:
                    return(rect.DiamondPath(penWidth));

                case GameMap.MarkerStyle.Target:
                    return(rect.TargetPath(penWidth));

                case GameMap.MarkerStyle.Star:
                    return(rect.StarPath(0));
                }
            }

            return(null);
        }
コード例 #2
0
        public void DrawMarker(DrawingContext context, int index, GameMap.Marker marker)
        {
            GameMap map = (GameMap)DataContext;

            if (map != null)
            {
                GameMap.MapCell cell = map.IndexToCell(index);

                Rect rect = CellRect(cell);

                Color brushColor = marker.Color;
                brushColor.A = (byte)(brushColor.A / 2);

                double penWidth = Math.Min(UseCellSize.Width, UseCellSize.Height) / 25.0;


                Brush b = new SolidColorBrush(brushColor);
                Pen   p = new Pen(new SolidColorBrush(marker.Color), penWidth);


                context.DrawGeometry(b, p, CreateMarkerPath(index, marker));
            }
        }