Exemplo n.º 1
0
        /// <summary>
        /// Create a RoundGauge object
        /// </summary>
        public RoundGauge()
        {
            // set defaults
            updating = true;

            BackColor    = Color.Cornsilk;
            ValueArc     = 300;
            currentValue = 0;

            valueFont          = new Font(FontFamily.GenericMonospace, valueFontSize, FontStyle.Regular);
            face               = new Rectangle(bezelWidth, bezelWidth, diameter - (2 * bezelWidth), diameter - (2 * bezelWidth));
            bufferBitmap       = new Bitmap(diameter, diameter);
            needle             = new Needle(this.Width, valueAngle, (Width / 2 - bezelWidth - lineBezelSpacing));
            needle.Width       = needleWidth;
            needle.NeedleColor = needleColor;

                        #if DESIGN
            lamps.LampsChanged += new ChangeHandler(lamps_LampChanged);
                        #endif

            UpdateNeedleLength();
            unitsPerDegree = (double)ValueArc / (double)(maxValue - minValue);

            updating = false;
            this.Refresh();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Fired when the RoundGauge is resized
        /// </summary>
        /// <param name="e"></param>
        protected override void OnResize(EventArgs e)
        {
            diameter = Width = Height;

            face         = new Rectangle(bezelWidth, bezelWidth, diameter - (2 * bezelWidth), diameter - (2 * bezelWidth));
            bufferBitmap = new Bitmap(diameter, diameter);
            DetermineValueRect(ref valueRect, ref valueBorder);
            needle       = new Needle(this.Width, valueAngle, (Width / 2 - bezelWidth - lineBezelSpacing));
            needle.Width = needleWidth;

            // update lamp data
            int lampx = 0, lampy = 0;

            lampdiameter = (int)((this.Width / 2) - ((this.Width / 2) / 1.4142135623730950488016887242097));

            foreach (Lamp l in lamps)
            {
                switch (l.Position)
                {
                case LampPosition.UpperLeft:
                    lampx = lampdiameter + 1;
                    lampy = lampdiameter + 1;
                    break;

                case LampPosition.UpperRight:
                    lampx = this.Width - 1;
                    lampy = lampdiameter + 1;
                    break;

                case LampPosition.LowerLeft:
                    lampx = lampdiameter + 1;
                    lampy = this.Height - 1;
                    break;

                case LampPosition.LowerRight:
                    lampx = this.Width - 1;
                    lampy = this.Height - 1;
                    break;
                }
                l.UpperRight = new Point(lampx, lampy);
                l.Diameter   = lampdiameter;
            }

            base.OnResize(e);

            if (!updating)
            {
                this.Refresh();
            }
        }
Exemplo n.º 3
0
        private void RecalculateFace()
        {
            diameter = Width = Height;

            face         = new Rectangle(bezelWidth, bezelWidth, diameter - (2 * bezelWidth), diameter - (2 * bezelWidth));
            bufferBitmap = new Bitmap(diameter, diameter);
            DetermineValueRect(out valueRect, out valueBorder);
            needle       = new Needle(this.Width, valueAngle, (Width / 2 - bezelWidth - lineBezelSpacing));
            needle.Width = needleWidth;

            // update lamp data
            int lampx = 0, lampy = 0;

            lampdiameter = (int)((this.Width / 2) - ((this.Width / 2) / 1.4142135623730950488016887242097));

            foreach (Lamp l in lamps)
            {
                switch (l.Position)
                {
                case LampPosition.UpperLeft:
                    lampx = lampdiameter + 1;
                    lampy = lampdiameter + 1;
                    break;

                case LampPosition.UpperRight:
                    lampx = this.Width - 1;
                    lampy = lampdiameter + 1;
                    break;

                case LampPosition.LowerLeft:
                    lampx = lampdiameter + 1;
                    lampy = this.Height - 1;
                    break;

                case LampPosition.LowerRight:
                    lampx = this.Width - 1;
                    lampy = this.Height - 1;
                    break;
                }
                l.UpperRight = new Point(lampx, lampy);
                l.Diameter   = lampdiameter;
            }
        }