コード例 #1
0
        protected override void DrawIndexedDirection(SKCanvas g, TextureTile tile, NeighbourIndex idx)
        {
            var points = new List <IntPoint>();

            var rect = GetTileHighlightArea(tile);

            var left    = rect.X;
            var top     = rect.Y;
            var right   = rect.X + rect.Width - 1;
            var bottom  = rect.Y + rect.Height - 1;
            var centerX = MidPoint(rect.X, rect.X + rect.Width);
            var centerY = MidPoint(rect.Y, rect.Y + rect.Height);

            switch (idx)
            {
            case NeighbourIndex.North:
                points.Add(new IntPoint(left, top));
                points.Add(new IntPoint(right, top));
                break;

            case NeighbourIndex.NorthEast:
                points.Add(new IntPoint(centerX, top));
                points.Add(new IntPoint(right, top));
                points.Add(new IntPoint(right, centerY));
                break;

            case NeighbourIndex.East:
                points.Add(new IntPoint(right, top));
                points.Add(new IntPoint(right, bottom));
                break;

            case NeighbourIndex.SouthEast:
                points.Add(new IntPoint(right, centerY));
                points.Add(new IntPoint(right, bottom));
                points.Add(new IntPoint(centerX, bottom));
                break;

            case NeighbourIndex.South:
                points.Add(new IntPoint(left, bottom));
                points.Add(new IntPoint(right, bottom));
                break;

            case NeighbourIndex.SouthWest:
                points.Add(new IntPoint(centerX, bottom));
                points.Add(new IntPoint(left, bottom));
                points.Add(new IntPoint(left, centerY));
                break;

            case NeighbourIndex.West:
                points.Add(new IntPoint(left, top));
                points.Add(new IntPoint(left, bottom));
                break;

            case NeighbourIndex.NorthWest:
                points.Add(new IntPoint(left, centerY));
                points.Add(new IntPoint(left, top));
                points.Add(new IntPoint(centerX, top));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(idx), idx, null);
            }

            var pen = Grid.TextureTileFormattingMetaData.TileHighlightColor ?? Preferences.DefaultTileHighlightColor;

            g.DrawGeometry(pen, points);
        }