コード例 #1
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            base.DrawBackground(drawContext, bounds);

            // Calculate text bounds

            float     textHeight = bounds.Height / 4;
            Rectangle textBounds = new Rectangle(bounds.X, bounds.Bottom - textHeight, bounds.Width, textHeight);

            // Calculate button bounds

            float     buttonDimension = Math.Min(bounds.Width, bounds.Height - textHeight);
            float     buttonRadius    = buttonDimension / 2;
            Rectangle buttonBounds    = new Rectangle(
                bounds.Center.X - buttonRadius,
                bounds.Center.Y - (textHeight / 2) - buttonRadius,
                buttonDimension,
                buttonDimension);

            // Calculate image bounds

            float     imageDimension = buttonDimension / 2;
            Rectangle imageBounds    = new Rectangle(
                buttonBounds.Center.X - (imageDimension / 2),
                buttonBounds.Center.Y - (imageDimension / 2),
                imageDimension,
                imageDimension);

            Bitmap icon = this.RadioButtonItem.Icon;

            if (this._isTouchDown)
            {
                drawContext.FillEllipse(buttonBounds, this.Theme.SubtleForegroundColor);
                if (null != icon)
                {
                    drawContext.DrawImage(icon, imageBounds, Colors.White);
                }
            }
            else if (this.IsChecked)
            {
                drawContext.FillEllipse(buttonBounds, this.Theme.AccentColor);
                if (null != icon)
                {
                    drawContext.DrawImage(icon, imageBounds, Colors.White);
                }
            }
            else
            {
                drawContext.DrawEllipse(buttonBounds.Center, buttonRadius - 1.0f, buttonRadius - 1.0f, this.Theme.SubtleForegroundColor, strokeWidth: 1.0f);
                if (null != icon)
                {
                    drawContext.DrawImage(icon, imageBounds, this.Theme.SubtleForegroundColor);
                }
            }

            drawContext.DrawText(this.RadioButtonItem.Text, textBounds, this.Theme.SubtleForegroundColor, this._textFormat);
        }
コード例 #2
0
        protected override void DrawBackground(
            IDrawContext drawContext,
            Rectangle bounds)
        {
            base.DrawBackground(drawContext, bounds);

            // Calculate text bounds

            float     textHeight = bounds.Height;
            Rectangle textBounds = new Rectangle(bounds.X, bounds.Bottom - textHeight, bounds.Width, textHeight);

            // Calculate button bounds

            float     buttonDimension = Math.Min(bounds.Width, bounds.Height);
            float     buttonRadius    = buttonDimension / 2;
            Rectangle buttonBounds    = new Rectangle(
                bounds.Center.X - buttonRadius,
                bounds.Center.Y - buttonRadius,
                buttonDimension,
                buttonDimension);

            if (this._isTouchDown)
            {
                drawContext.FillEllipse(buttonBounds, this.Theme.SubtleForegroundColor);
                drawContext.DrawText(this._text, textBounds, Colors.White, this._textFormat);
            }
            else if (this.IsChecked)
            {
                drawContext.FillEllipse(buttonBounds, this.Theme.AccentColor);
                drawContext.DrawText(this._text, textBounds, Colors.White, this._textFormat);
            }
            else
            {
                drawContext.DrawEllipse(buttonBounds.Center, buttonRadius - 1.0f, buttonRadius - 1.0f, this.Theme.SubtleForegroundColor, strokeWidth: 1.0f);
                drawContext.DrawText(this._text, textBounds, this.Theme.SubtleForegroundColor, this._textFormat);
            }
        }