コード例 #1
0
        public static void drawMEMontior(Graphics gfx, MEMonitor monitor)
        {
            gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            if (monitor.currentValue < 0)
            {
                monitor.currentValue = 0;
            }
            if (monitor.currentValue > 100)
            {
                monitor.currentValue = 100;
            }
            String text = monitor.currentValue + "%";
            SizeF  size = gfx.MeasureString(text, percentageFont);

            MEMonitorBrush      = new SolidBrush(bgColor);
            ME_MonitorPen       = new Pen(MEMonitorBrush);
            ME_MonitorPen.Width = monitor.thickness;
            Rectangle area = new Rectangle(monitor.x, monitor.y, monitor.radius * 2, monitor.radius * 2);

            gfx.DrawEllipse(ME_MonitorPen, area);
            ME_MonitorPen.Brush = new SolidBrush(Color.FromArgb(fgColor.A + 2 * monitor.currentValue, fgColor.R, fgColor.G, fgColor.B));
            gfx.DrawArc(ME_MonitorPen, area, -90, (int)(360.0 / 100 * monitor.currentValue));
            MEMonitorBrush = new SolidBrush(fontColor);
            if (monitor.showPercent)
            {
                gfx.DrawString(text, percentageFont, MEMonitorBrush, (int)(monitor.x + monitor.radius - size.Width / 2), monitor.y + monitor.radius - size.Height / 2);
            }
            ME_MonitorPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            ME_MonitorPen.Width     = monitor.thickness / 4;
            // if (monitor.currentValue >= 100)
            //    ME_MonitorPen.Brush = new SolidBrush(fgColor);
            // else ME_MonitorPen.Brush = new SolidBrush(bgColor);
            //  gfx.DrawEllipse(ME_MonitorPen, new Rectangle(monitor.x + monitor.thickness, monitor.y + monitor.thickness, (monitor.radius - monitor.thickness) * 2, (monitor.radius - monitor.thickness) * 2));
            MEMonitorBrush = new SolidBrush(fontColor);
            gfx.DrawString(monitor.majorText, majorFont, MEMonitorBrush, monitor.x + monitor.radius * 2 + 40, monitor.y + monitor.radius - 50);
            gfx.DrawString(monitor.minorText, minorFont, MEMonitorBrush, monitor.x + monitor.radius * 2 + 40 + 5, monitor.y + monitor.radius + 10);
        }
コード例 #2
0
 /**
  * Draws a MEMontior ontop of the graphics-object.
  * Displays text as per default.
  *
  * @param Graphics gfx, graphics-object to draw Monitor on
  * @param MEMonitor monitor, monitor to be drawn
  */
 public static void DrawMEMontior(Graphics gfx, MEMonitor monitor)
 {
     DrawMEMontior(gfx, monitor, true);
 }