Click here to Skip to main content
15,893,814 members
Articles / Multimedia / GDI+

Industrial Controls 2

Rate me:
Please Sign up or sign in to vote.
4.92/5 (135 votes)
21 Feb 2010CPOL10 min read 241.5K   29.9K   364  
A library of controls with a custon renderer for use in the controls processes panel display
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using LBSoft.IndustrialCtrls.Base;

namespace LBSoft.IndustrialCtrls.Meters
{
    public class LBDigitalMeterRenderer : LBRendererBase
    {
        #region (* Constructor *)
        public LBDigitalMeterRenderer()
        {
        }
        #endregion

        #region (* Overrided methods *)
        public override void Draw(Graphics Gr)
        {
            if (this.Meter == null)
                return;

            RectangleF _rc = new RectangleF(0, 0, this.Meter.Width, this.Meter.Height);
            Gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            this.DrawBackground(Gr, _rc);
            this.DrawBorder(Gr, _rc);
        }
        #endregion

        #region (* Properties *)
        public LBDigitalMeter Meter
        {
            get { return this.Control as LBDigitalMeter; }
        }
        #endregion

        #region (* Virtual methods *)
        public virtual bool DrawBackground(Graphics gr, RectangleF rc)
        {
            if (this.Meter == null)
                return false;

            Color c = this.Meter.BackColor;
            SolidBrush br = new SolidBrush(c);
            Pen pen = new Pen(c);

            Rectangle _rcTmp = new Rectangle(0, 0, this.Meter.Width, this.Meter.Height);
            gr.DrawRectangle(pen, _rcTmp);
            gr.FillRectangle(br, rc);

            br.Dispose();
            pen.Dispose();

            return true;
        }

        public virtual bool DrawBorder(Graphics gr, RectangleF rc)
        {
            if (this.Meter == null)
                return false;

            return true;
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Promax Srl
Italy Italy
Software developer with over 16 years of experience, specializing on MFC/C++, C# and software architecture


Company : Promax S.r.l.


Comments and Discussions