コード例 #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);
            }
        }
コード例 #3
0
        public override void OnPaint(IGUIContext ctx, RectangleF bounds)
        {
            base.OnPaint(ctx, bounds);
            if (szDay.Width <= 0 || szDay.Height <= 0)
            {
                return;
            }

            // prev / next buttons
            ctx.DrawString(((char)FontAwesomeIcons.fa_long_arrow_left).ToString(),
                           IconFont, prevArrowHover ? Theme.Brushes.Blue : Theme.Brushes.Base02,
                           prevRec, FontFormat.DefaultIconFontFormatCenter);
            ctx.DrawString(((char)FontAwesomeIcons.fa_long_arrow_right).ToString(),
                           IconFont, nextArrowHover ? Theme.Brushes.Blue : Theme.Brushes.Base02,
                           nextRec, FontFormat.DefaultIconFontFormatCenter);

            DateTime date  = CurrentDate;
            string   title = String.Format("{0} {1}", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(date.Month).ToUpper(), date.Year.ToString());

            using (var clip = new ClipBoundClip(ctx, rTitle)) {
                ctx.DrawString(title, TitleFont, Theme.Brushes.Base02, rTitle, Format);
            }

            for (int i = 0; i < 7; i++)
            {
                RectangleF rx = new RectangleF((int)(bounds.Left + Padding.Left + (i * szDay.Width)), (int)szDay.Height + bounds.Top + Padding.Top, (int)szDay.Width, (int)szDay.Height);
                string     wd = m_Weekdays [i].Substring(0, 1);
                if (i == 0 || i == 6)
                {
                    ctx.DrawString(wd, DayFont, Theme.Brushes.Orange, rx, Format);
                }
                else
                {
                    ctx.DrawString(wd, DayFont, Theme.Brushes.Cyan, rx, Format);
                }
            }

            DateTime  firstDayOfMonth = new DateTime(CurrentDate.Year, CurrentDate.Month, 1);
            DayOfWeek dowStart        = firstDayOfMonth.DayOfWeek;

            int dayMax    = (int)dowStart < 6 ? 35 : 42;
            int currMonth = CurrentDate.Month;

            DateTime today      = DateTime.Now.Date;
            Brush    textBrusch = new SolidBrush(Style.ForeColorBrush.Color);
            float    radius     = Math.Max(MinCircleRadius, Math.Min(MaxCircleRadius, szDay.Width * 0.35f));

            for (int i = 0; i < dayMax; i++)
            {
                int       col = i % 7;
                int       row = (i / 7);
                Rectangle rx  = new Rectangle((int)(bounds.Left + Padding.Left + ((float)col * szDay.Width)), (int)(bounds.Top + Padding.Top + ((float)(row + 2) * szDay.Height)), (int)szDay.Width, (int)szDay.Height);

                DateTime dt = m_MonthView [i];
                string   wd = dt.Day.ToString();

                Color color = Color.Empty;
                if (dt == today)
                {
                    color = TodayBackColor;
                }
                else if (dt == CurrentDate)
                {
                    color = CurrentDayBackColor;
                }
                else if (dt == HoverDate)
                {
                    color = DayHoverBackColor;
                }


                Color textColor = Color.Empty;

                if (!color.IsEmpty)
                {
                    using (var brush = new SolidBrush(color))
                    {
                        ctx.FillCircle(brush, rx.Left + (rx.Width / 2f) - 0.5f, rx.Top + (rx.Height / 2f) - 1f, radius, 1);
                    }

                    textColor = Style.ForeColorBrush.Color;
                }
                else
                {
                    textColor = (col == 0 || col == 6) ? Theme.Colors.Orange : Style.ForeColorBrush.Color;
                }

                if (dt.Month != currMonth)
                {
                    textColor = Color.FromArgb(128, textColor);
                }
                textBrusch.Color = textColor;

                ctx.DrawString(wd, DayFont, textBrusch, rx, Format);
            }
        }