Пример #1
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);

            bounds.Inflate(-Padding.Width, -Padding.Height);
            bounds.Offset(Padding.Left, Padding.Top);

            PointF CenterPoint = new PointF(
                bounds.Left + (bounds.Width / 2f),
                bounds.Top + (bounds.Height / 2f));

            float pieRadius = Radius - Math.Max(2, (Radius / 10f));

            // for smoothness, any better idea ?
            using (Pen pen = new Pen(Color.Gray, 3f)) {
                ctx.DrawCircle(pen, CenterPoint.X, CenterPoint.Y, Radius - 1.5f);
            }

            using (Brush brush = new SolidBrush(Style.BorderColorPen.Color)) {
                ctx.FillCircle(brush, CenterPoint.X, CenterPoint.Y, Radius - 0.5f);
            }

            Color dataColor;

            if (!Enabled)
            {
                dataColor = Theme.Colors.Base1;
            }
            else if (CustomColor != Color.Empty)
            {
                dataColor = CustomColor;
            }
            else
            {
                dataColor = Theme.GetContextColor(ColorContext);
            }

            using (Brush dataBrush = new SolidBrush(dataColor)) {
                ctx.FillPie(dataBrush,
                            CenterPoint.X,
                            CenterPoint.Y,
                            pieRadius,
                            pieRadius,
                            0, 360f * Value / (MaxValue - MinValue));
            }

            ctx.FillCircle(Style.BackColorBrush, CenterPoint.X, CenterPoint.Y, Radius * 0.5f);

            ctx.DrawString((Value * 100f).ToString("n0") + "%", Font, Style.ForeColorBrush,
                           bounds, FontFormat.DefaultSingleLineCentered);
        }
Пример #2
0
        public override void PaintBackground(IGUIContext ctx, Widget widget)
        {
            RectangleF bounds = widget.Bounds;

            bounds.Offset(-1, -1);
            float radius = bounds.Width / 2f;

            // this is not the final wisdom..
            //PointF center = new PointF (bounds.Left + radius - widget.Margin.Left, bounds.Top + radius - widget.Margin.Top);
            PointF center = new PointF(bounds.Left + radius, bounds.Top + radius);

            radius -= 2f;

            if (BackColorBrush.Color != Color.Empty)
            {
                ctx.FillCircle(BackColorBrush, center.X, center.Y, radius);
            }

            if (BorderColorPen.Color != Color.Empty && BorderColorPen.Width > 0)
            {
                ctx.DrawCircle(BorderColorPen, center.X, center.Y, radius);
            }
        }