Exemplo n.º 1
0
        private void SetMinimap()
        {
            if (!_minimapInitialized)
            {
                var radar          = _root.ScriptObject.GetMember("Radar").ToObject();
                var radarClipValue = radar.GetMember("RadarClip");

                if (radarClipValue.Type == ValueType.Undefined)
                {
                    return;
                }

                // This shape is used to render the minimap
                var radarClip = radarClipValue.ToObject().Item as SpriteItem;
                var shape     = radarClip.Content.Items[1] as RenderItem;
                shape.RenderCallback = (AptRenderingContext renderContext, Geometry geom, Texture orig) =>
                {
                    var rect = new Rectangle(renderContext.GetBoundingBox(geom));
                    _game.Scene3D.Radar.DrawRadarMinimap(renderContext.GetActiveDrawingContext(), rect, true);
                };

                // This shape is used to render the overlay
                var radarChild = ((SpriteItem)radar.Item).Content.Items[1] as SpriteItem;
                shape = radarChild.Content.Items[1] as RenderItem;
                shape.RenderCallback = (AptRenderingContext renderContext, Geometry geom, Texture orig) =>
                {
                    var rect = new Rectangle(renderContext.GetBoundingBox(geom));
                    _game.Scene3D.Radar.DrawRadarOverlay(renderContext.GetActiveDrawingContext(), rect);
                };

                _minimapInitialized = true;
            }
        }
Exemplo n.º 2
0
        public void EnsureFrame(Rectangle frame)
        {
            if (frame == _frame)
            {
                return;
            }

            _frame = frame;

            RemoveAndDispose(ref _gameFramebuffer);
            RemoveAndDispose(ref _gameColorTarget);

            var width  = (uint)_frame.Width;
            var height = (uint)_frame.Height;

            _gameColorTarget = AddDisposable(_graphicsDevice.ResourceFactory.CreateTexture(
                                                 TextureDescription.Texture2D(
                                                     width,
                                                     height,
                                                     1,
                                                     1,
                                                     PixelFormat.B8_G8_R8_A8_UNorm,
                                                     TextureUsage.RenderTarget | TextureUsage.Sampled)));

            _gameFramebuffer = AddDisposable(_graphicsDevice.ResourceFactory.CreateFramebuffer(
                                                 new FramebufferDescription(null, _gameColorTarget)));

            ClientSizeChanged?.Invoke(this, EventArgs.Empty);
            FramebufferChanged?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 3
0
        protected override Texture CreateTexture(Size size, GraphicsLoadContext loadContext)
        {
            return(MappedImageUtility.CreateTexture(loadContext, size, spriteBatch =>
            {
                var requiresFlip = !loadContext.GraphicsDevice.IsUvOriginTopLeft;

                var leftWidth = _left.Coords.Width;
                var rightWidth = _right.Coords.Width;

                var leftRect = new Rectangle(0, 0, leftWidth, size.Height);

                spriteBatch.DrawImage(
                    _left.Texture.Value,
                    _left.Coords,
                    leftRect.ToRectangleF(),
                    ColorRgbaF.White,
                    requiresFlip);

                var middleRect = new Rectangle(leftRect.Right, 0, size.Width - leftWidth - rightWidth, size.Height);
                spriteBatch.DrawImage(
                    _middle.Texture.Value,
                    _middle.Coords,
                    middleRect.ToRectangleF(),
                    ColorRgbaF.White,
                    requiresFlip);

                var rightRect = new Rectangle(middleRect.Right, 0, rightWidth, size.Height);
                spriteBatch.DrawImage(
                    _right.Texture.Value,
                    _right.Coords,
                    rightRect.ToRectangleF(),
                    ColorRgbaF.White,
                    requiresFlip);
            }));
        }
Exemplo n.º 4
0
        internal TerrainPatch(
            HeightMap heightMap,
            Rectangle patchBounds,
            GraphicsDevice graphicsDevice,
            TerrainPatchIndexBufferCache indexBufferCache,
            Material material)
        {
            DebugName = $"Terrain_{Bounds}";

            Bounds = patchBounds;

            _indexBuffer = indexBufferCache.GetIndexBuffer(
                patchBounds.Width,
                patchBounds.Height,
                out var indices);

            _numIndices = (uint)indices.Length;

            _vertexBuffer = AddDisposable(CreateVertexBuffer(
                                              graphicsDevice,
                                              heightMap,
                                              patchBounds,
                                              indices,
                                              out var boundingBox,
                                              out var triangles));

            BoundingBox = boundingBox;
            Triangles   = triangles;

            MaterialPass = new MaterialPass(material, null);
        }
Exemplo n.º 5
0
 internal TerrainPatch(
     Rectangle patchBounds,
     DeviceBuffer vertexBuffer,
     DeviceBuffer indexBuffer,
     uint numIndices,
     Triangle[] triangles,
     in BoundingBox boundingBox,
Exemplo n.º 6
0
        private TerrainPatch CreatePatch(
            TerrainMaterial terrainMaterial,
            HeightMap heightMap,
            BlendTileData blendTileData,
            Rectangle patchBounds,
            GraphicsDevice graphicsDevice,
            TerrainPatchIndexBufferCache indexBufferCache)
        {
            var indexBuffer = indexBufferCache.GetIndexBuffer(
                patchBounds.Width,
                patchBounds.Height,
                out var indices);

            var vertexBuffer = AddDisposable(CreateVertexBuffer(
                                                 graphicsDevice,
                                                 heightMap,
                                                 patchBounds,
                                                 indices,
                                                 out var boundingBox,
                                                 out var triangles));

            return(new TerrainPatch(
                       terrainMaterial,
                       patchBounds,
                       vertexBuffer,
                       indexBuffer,
                       (uint)indices.Length,
                       triangles,
                       boundingBox));
        }
Exemplo n.º 7
0
        internal TerrainPatch(
            HeightMap heightMap,
            Rectangle patchBounds,
            GraphicsDevice graphicsDevice,
            TerrainPatchIndexBufferCache indexBufferCache,
            Material material)
        {
            Bounds = patchBounds;

            _indexBuffer = indexBufferCache.GetIndexBuffer(
                patchBounds.Width,
                patchBounds.Height,
                out var indices);

            _numIndices = (uint)indices.Length;

            _vertexBuffer = AddDisposable(CreateVertexBuffer(
                                              graphicsDevice,
                                              heightMap,
                                              patchBounds,
                                              indices,
                                              out var boundingBox,
                                              out var triangles));

            BoundingBox = boundingBox;
            Triangles   = triangles;

            _material = material;

            _beforeRender = (CommandList cl, Graphics.Rendering.RenderContext context, in RenderItem renderItem) =>
            {
                cl.SetVertexBuffer(0, _vertexBuffer);
            };
        }
Exemplo n.º 8
0
        internal TerrainPatch(
            HeightMap heightMap,
            Rectangle patchBounds,
            GraphicsDevice graphicsDevice,
            TerrainPatchIndexBufferCache indexBufferCache,
            ResourceSet materialResourceSet)
        {
            Bounds = patchBounds;

            _indexBuffer = indexBufferCache.GetIndexBuffer(
                patchBounds.Width,
                patchBounds.Height,
                out var indices);

            _numIndices = (uint)indices.Length;

            _vertexBuffer = AddDisposable(CreateVertexBuffer(
                                              graphicsDevice,
                                              heightMap,
                                              patchBounds,
                                              indices,
                                              out var boundingBox,
                                              out var triangles));

            BoundingBox = boundingBox;
            Triangles   = triangles;

            _beforeRender = (cl, context) =>
            {
                cl.SetGraphicsResourceSet(4, materialResourceSet);
                cl.SetVertexBuffer(0, _vertexBuffer);
            };
        }
Exemplo n.º 9
0
        public Texture GetStretchableTexture(
            WndWindowDefinition wndWindow,
            WndDrawData wndDrawData,
            int leftIndex,
            int middleIndex,
            int rightIndex)
        {
            var cacheKey = new WndImageKey
            {
                DestinationSize = wndWindow.ScreenRect.ToRectangle().Size,
                LeftImage       = wndDrawData.Items[leftIndex].Image,
                MiddleImage     = wndDrawData.Items[middleIndex].Image,
                RightImage      = wndDrawData.Items[rightIndex].Image
            };

            if (!_cache.TryGetValue(cacheKey, out var result))
            {
                var leftMappedImageTexture   = GetMappedImage(cacheKey.LeftImage);
                var middleMappedImageTexture = GetMappedImage(cacheKey.MiddleImage);
                var rightMappedImageTexture  = GetMappedImage(cacheKey.RightImage);

                if (leftMappedImageTexture != null &&
                    middleMappedImageTexture != null &&
                    rightMappedImageTexture != null)
                {
                    result = CreateTexture(
                        cacheKey,
                        drawingContext =>
                    {
                        var leftWidth  = leftMappedImageTexture.SourceRect.Width;
                        var rightWidth = rightMappedImageTexture.SourceRect.Width;
                        var leftRect   = new Rectangle(0, 0, leftWidth, cacheKey.DestinationSize.Height);
                        drawingContext.DrawImage(
                            leftMappedImageTexture.Texture,
                            leftMappedImageTexture.SourceRect,
                            leftRect);
                        var middleRect = new Rectangle(leftRect.Right, 0, cacheKey.DestinationSize.Width - leftWidth - rightWidth, cacheKey.DestinationSize.Height);
                        drawingContext.DrawImage(
                            middleMappedImageTexture.Texture,
                            middleMappedImageTexture.SourceRect,
                            middleRect);
                        var rightRect = new Rectangle(middleRect.Right, 0, rightWidth, cacheKey.DestinationSize.Height);
                        drawingContext.DrawImage(
                            rightMappedImageTexture.Texture,
                            rightMappedImageTexture.SourceRect,
                            rightRect);
                    });
                }
                else
                {
                    result = null;
                }

                _cache.Add(cacheKey, result);
            }

            return(result);
        }
Exemplo n.º 10
0
        private static DeviceBuffer CreateVertexBuffer(
            GraphicsDevice graphicsDevice,
            HeightMap heightMap,
            Rectangle patchBounds,
            ushort[] indices,
            out AxisAlignedBoundingBox boundingBox,
            out Triangle[] triangles)
        {
            var numVertices = patchBounds.Width * patchBounds.Height;

            var vertices = new TerrainShaderResources.TerrainVertex[numVertices];
            var points   = new Vector3[numVertices];

            var vertexIndex = 0;

            for (var y = patchBounds.Y; y < patchBounds.Y + patchBounds.Height; y++)
            {
                for (var x = patchBounds.X; x < patchBounds.X + patchBounds.Width; x++)
                {
                    var position = heightMap.GetPosition(x, y);
                    points[vertexIndex]     = position;
                    vertices[vertexIndex++] = new TerrainShaderResources.TerrainVertex
                    {
                        Position = position,
                        Normal   = heightMap.Normals[x, y],
                        UV       = new Vector2(x, y)
                    };
                }
            }

            boundingBox = AxisAlignedBoundingBox.CreateFromPoints(points);

            triangles = new Triangle[(patchBounds.Width - 1) * (patchBounds.Height) * 2];

            var triangleIndex = 0;
            var indexIndex    = 0;

            for (var y = 0; y < patchBounds.Height - 1; y++)
            {
                for (var x = 0; x < patchBounds.Width - 1; x++)
                {
                    // Triangle 1
                    triangles[triangleIndex++] = new Triangle(
                        points[indices[indexIndex++]],
                        points[indices[indexIndex++]],
                        points[indices[indexIndex++]]);

                    // Triangle 2
                    triangles[triangleIndex++] = new Triangle(
                        points[indices[indexIndex++]],
                        points[indices[indexIndex++]],
                        points[indices[indexIndex++]]);
                }
            }

            return(graphicsDevice.CreateStaticBuffer(vertices, BufferUsage.VertexBuffer));
        }
Exemplo n.º 11
0
        private List <TerrainPatch> CreatePatches(
            GraphicsDevice graphicsDevice,
            HeightMap heightMap,
            TerrainPatchIndexBufferCache indexBufferCache,
            ResourceSet materialResourceSet,
            ResourceSet radiusCursorDecalsResourceSet,
            Func <ResourceSet> causticsRendererCallback)
        {
            const int numTilesPerPatch = PatchSize - 1;

            var heightMapWidthMinusOne = heightMap.Width - 1;
            var numPatchesX            = heightMapWidthMinusOne / numTilesPerPatch;

            if (heightMapWidthMinusOne % numTilesPerPatch != 0)
            {
                numPatchesX += 1;
            }

            var heightMapHeightMinusOne = heightMap.Height - 1;
            var numPatchesY             = heightMapHeightMinusOne / numTilesPerPatch;

            if (heightMapHeightMinusOne % numTilesPerPatch != 0)
            {
                numPatchesY += 1;
            }

            var patches = new List <TerrainPatch>();

            for (var y = 0; y < numPatchesY; y++)
            {
                for (var x = 0; x < numPatchesX; x++)
                {
                    var patchX = x * numTilesPerPatch;
                    var patchY = y * numTilesPerPatch;

                    var patchBounds = new Rectangle(
                        patchX,
                        patchY,
                        Math.Min(PatchSize, heightMap.Width - patchX),
                        Math.Min(PatchSize, heightMap.Height - patchY));

                    patches.Add(AddDisposable(new TerrainPatch(
                                                  heightMap,
                                                  patchBounds,
                                                  graphicsDevice,
                                                  indexBufferCache,
                                                  materialResourceSet,
                                                  radiusCursorDecalsResourceSet,
                                                  causticsRendererCallback)));
                }
            }

            return(patches);
        }
Exemplo n.º 12
0
        private List <TerrainPatch> CreatePatches(
            GraphicsDevice graphicsDevice,
            HeightMap heightMap,
            BlendTileData blendTileData,
            TerrainMaterial terrainMaterial,
            TerrainPatchIndexBufferCache indexBufferCache)
        {
            const int numTilesPerPatch = Terrain.Terrain.PatchSize - 1;

            var heightMapWidthMinusOne = heightMap.Width - 1;
            var numPatchesX            = heightMapWidthMinusOne / numTilesPerPatch;

            if (heightMapWidthMinusOne % numTilesPerPatch != 0)
            {
                numPatchesX += 1;
            }

            var heightMapHeightMinusOne = heightMap.Height - 1;
            var numPatchesY             = heightMapHeightMinusOne / numTilesPerPatch;

            if (heightMapHeightMinusOne % numTilesPerPatch != 0)
            {
                numPatchesY += 1;
            }

            var patches = new List <TerrainPatch>();

            for (var y = 0; y < numPatchesY; y++)
            {
                for (var x = 0; x < numPatchesX; x++)
                {
                    var patchX = x * numTilesPerPatch;
                    var patchY = y * numTilesPerPatch;

                    var patchBounds = new Rectangle(
                        patchX,
                        patchY,
                        Math.Min(Terrain.Terrain.PatchSize, heightMap.Width - patchX),
                        Math.Min(Terrain.Terrain.PatchSize, heightMap.Height - patchY));

                    patches.Add(CreatePatch(
                                    terrainMaterial,
                                    heightMap,
                                    blendTileData,
                                    patchBounds,
                                    graphicsDevice,
                                    indexBufferCache));
                }
            }

            return(patches);
        }
Exemplo n.º 13
0
        internal TerrainPatch(
            HeightMap heightMap,
            Rectangle patchBounds,
            GraphicsDevice graphicsDevice,
            TerrainPatchIndexBufferCache indexBufferCache,
            ResourceSet materialResourceSet,
            ResourceSet radiusCursorDecalsResourceSet,
            Func <ResourceSet> causticsRendererCallback)
        {
            Bounds = patchBounds;

            _indexBuffer = indexBufferCache.GetIndexBuffer(
                patchBounds.Width,
                patchBounds.Height,
                out var indices);

            _numIndices = (uint)indices.Length;

            _vertexBuffer = AddDisposable(CreateVertexBuffer(
                                              graphicsDevice,
                                              heightMap,
                                              patchBounds,
                                              indices,
                                              out var boundingBox,
                                              out var triangles));

            BoundingBox = boundingBox;
            Triangles   = triangles;

            _beforeRender = (cl, context) =>
            {
                var isRender = context.Scene3D.Waters.IsRenderCaustics;
                if (isRender)
                {
                    var causticsResourceSet = causticsRendererCallback.Invoke();
                    cl.SetGraphicsResourceSet(4, causticsResourceSet);
                }
                else
                {
                    cl.SetGraphicsResourceSet(4, materialResourceSet);
                }
                cl.SetGraphicsResourceSet(5, radiusCursorDecalsResourceSet);
                cl.SetVertexBuffer(0, _vertexBuffer);
            };
        }
Exemplo n.º 14
0
        internal TerrainPatch(
            TerrainMaterial terrainMaterial,
            Rectangle patchBounds,
            DeviceBuffer vertexBuffer,
            DeviceBuffer indexBuffer,
            uint numIndices,
            Triangle[] triangles,
            BoundingBox boundingBox)
        {
            _terrainMaterial = terrainMaterial;

            Bounds = patchBounds;

            _vertexBuffer = vertexBuffer;
            _indexBuffer  = indexBuffer;
            _numIndices   = numIndices;

            BoundingBox = boundingBox;
            Triangles   = triangles;
        }
Exemplo n.º 15
0
        public Image CreateStretchableImage(
            WndDrawData wndDrawData,
            int leftIndex,
            int middleIndex,
            int rightIndex)
        {
            var leftImage   = wndDrawData.Items[leftIndex].Image;
            var middleImage = wndDrawData.Items[middleIndex].Image;
            var rightImage  = wndDrawData.Items[rightIndex].Image;

            var leftMappedImageTexture   = GetMappedImage(leftImage);
            var middleMappedImageTexture = GetMappedImage(middleImage);
            var rightMappedImageTexture  = GetMappedImage(rightImage);

            if (leftMappedImageTexture != null &&
                middleMappedImageTexture != null &&
                rightMappedImageTexture != null)
            {
                var naturalSize = new Size(
                    leftMappedImageTexture.SourceRect.Width + middleMappedImageTexture.SourceRect.Width + rightMappedImageTexture.SourceRect.Width,
                    leftMappedImageTexture.SourceRect.Height);

                return(new Image(naturalSize, size =>
                {
                    var cacheKey = new WndImageKey
                    {
                        DestinationSize = size,
                        LeftImage = leftImage,
                        MiddleImage = middleImage,
                        RightImage = rightImage
                    };

                    if (!_cache.TryGetValue(cacheKey, out var result))
                    {
                        result = CreateTexture(
                            cacheKey,
                            spriteBatch =>
                        {
                            var leftWidth = leftMappedImageTexture.SourceRect.Width;
                            var rightWidth = rightMappedImageTexture.SourceRect.Width;
                            var leftRect = new Rectangle(0, 0, leftWidth, cacheKey.DestinationSize.Height);
                            spriteBatch.DrawImage(
                                leftMappedImageTexture.Texture,
                                leftMappedImageTexture.SourceRect,
                                leftRect.ToRectangleF(),
                                ColorRgbaF.White);
                            var middleRect = new Rectangle(leftRect.Right, 0, cacheKey.DestinationSize.Width - leftWidth - rightWidth, cacheKey.DestinationSize.Height);
                            spriteBatch.DrawImage(
                                middleMappedImageTexture.Texture,
                                middleMappedImageTexture.SourceRect,
                                middleRect.ToRectangleF(),
                                ColorRgbaF.White);
                            var rightRect = new Rectangle(middleRect.Right, 0, rightWidth, cacheKey.DestinationSize.Height);
                            spriteBatch.DrawImage(
                                rightMappedImageTexture.Texture,
                                rightMappedImageTexture.SourceRect,
                                rightRect.ToRectangleF(),
                                ColorRgbaF.White);
                        });

                        _cache.Add(cacheKey, result);
                    }

                    return result;
                }));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 16
0
        public Image CreateStretchableImage(
            WndDrawData wndDrawData,
            int leftIndex,
            int middleIndex,
            int rightIndex)
        {
            var leftImage   = wndDrawData.Items[leftIndex].Image;
            var middleImage = wndDrawData.Items[middleIndex].Image;
            var rightImage  = wndDrawData.Items[rightIndex].Image;

            var leftMappedImageTexture   = GetMappedImage(leftImage);
            var middleMappedImageTexture = GetMappedImage(middleImage);
            var rightMappedImageTexture  = GetMappedImage(rightImage);

            if (leftMappedImageTexture != null &&
                middleMappedImageTexture != null &&
                rightMappedImageTexture != null)
            {
                var naturalSize = new Size(
                    leftMappedImageTexture.Coords.Width + middleMappedImageTexture.Coords.Width + rightMappedImageTexture.Coords.Width,
                    leftMappedImageTexture.Coords.Height);

                bool requiresFlip = !_contentManager.GraphicsDevice.IsUvOriginTopLeft;

                return(new Image("WndImage", naturalSize, size =>
                {
                    var cacheKey = new WndImageKey
                    {
                        DestinationSize = size,
                        LeftImage = leftImage,
                        MiddleImage = middleImage,
                        RightImage = rightImage
                    };

                    if (!_cache.TryGetValue(cacheKey, out var result))
                    {
                        result = CreateTexture(
                            cacheKey,
                            spriteBatch =>
                        {
                            var leftWidth = leftMappedImageTexture.Coords.Width;
                            var rightWidth = rightMappedImageTexture.Coords.Width;
                            var leftRect = new Rectangle(0, 0, leftWidth, cacheKey.DestinationSize.Height);
                            spriteBatch.DrawImage(
                                leftMappedImageTexture.Texture.Value,
                                leftMappedImageTexture.Coords,
                                leftRect.ToRectangleF(),
                                ColorRgbaF.White,
                                requiresFlip);
                            var middleRect = new Rectangle(leftRect.Right, 0, cacheKey.DestinationSize.Width - leftWidth - rightWidth, cacheKey.DestinationSize.Height);
                            spriteBatch.DrawImage(
                                middleMappedImageTexture.Texture.Value,
                                middleMappedImageTexture.Coords,
                                middleRect.ToRectangleF(),
                                ColorRgbaF.White,
                                requiresFlip);
                            var rightRect = new Rectangle(middleRect.Right, 0, rightWidth, cacheKey.DestinationSize.Height);
                            spriteBatch.DrawImage(
                                rightMappedImageTexture.Texture.Value,
                                rightMappedImageTexture.Coords,
                                rightRect.ToRectangleF(),
                                ColorRgbaF.White,
                                requiresFlip);
                        });

                        _cache.Add(cacheKey, result);
                    }

                    return result;
                }));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 17
0
        private void UpdateCommandbuttons()
        {
            if (_game.Scene3D.LocalPlayer.SelectedUnits.Count == 0)
            {
                return;
            }

            var selectedUnit = _game.Scene3D.LocalPlayer.SelectedUnits.First();

            if (selectedUnit == null)
            {
                return;
            }
            if (selectedUnit.Definition.CommandSet == null || selectedUnit.Definition.CommandSet.Value == null)
            {
                return;
            }

            var isProducing = selectedUnit.ProductionUpdate?.IsProducing ?? false;
            var commandSet  = selectedUnit.Definition.CommandSet.Value;

            var aptCommandButtons = _root.ScriptObject.GetMember("CommandButtons").ToObject();

            for (var i = 1; i <= 6; i++)
            {
                var commandButton = aptCommandButtons.GetMember((i - 1).ToString()).ToObject();
                var placeHolder   = commandButton.GetMember("placeholder").ToObject();
                placeHolder.Item.Visible = false;

                if (!commandSet.Buttons.ContainsKey(i))
                {
                    continue;
                }
                var button = commandSet.Buttons[i].Value;
                if (!button.InPalantir || button.Command == CommandType.Revive)
                {
                    continue;
                }

                var createContent = commandButton.GetMember("CreateContent");
                var args          = new List <Value>();
                args.Add(Value.FromString("bttn"));
                args.Add(Value.FromString("CommandButton"));

                //TODO: fix so this works
                FunctionCommon.ExecuteFunction(createContent, args.ToArray(), commandButton.Item.ScriptObject, _window.Context.Avm);

                placeHolder.Item.Visible = true;
                var shape = (placeHolder.Item as SpriteItem).Content.Items[1] as RenderItem;

                var(count, progress) = isProducing ? selectedUnit.ProductionUpdate.GetCountAndProgress(button) : (0, 0.0f);

                var texture = button.ButtonImage.Value;
                shape.RenderCallback = (AptRenderingContext renderContext, Geometry geom, Texture orig) =>
                {
                    var enabled = selectedUnit.CanPurchase(button);
                    var rect    = new Rectangle(renderContext.GetBoundingBox(geom)).ToRectangleF();
                    renderContext.GetActiveDrawingContext().DrawMappedImage(texture, rect, grayscaled: !enabled);

                    if (count > 0)
                    {
                        renderContext.GetActiveDrawingContext().FillRectangleRadial360(
                            new Rectangle(rect),
                            new ColorRgbaF(1.0f, 1.0f, 1.0f, 0.6f),
                            progress);

                        if (count > 1)
                        {
                            var textRect = new Rectangle(RectangleF.Transform(rect, Matrix3x2.CreateTranslation(new Vector2(0, rect.Width / 4))));
                            renderContext.GetActiveDrawingContext().DrawText(count.ToString(), _font, TextAlignment.Center, _fontColor, textRect);
                        }
                    }
                };
            }
        }