/// <summary>
        /// Reposition of the digital displaies
        /// </summary>
        protected void RepositionControls()
        {
            Rectangle rc = this.ClientRectangle;

            if (this.Controls.Count <= 0)
            {
                return;
            }

            int  digitW   = rc.Width / this.Controls.Count;
            bool signFind = false;

            foreach (Control disp in this.Controls)
            {
                if (disp.GetType() == typeof(ZeroitLB7SegmentDisplay))
                {
                    ZeroitLB7SegmentDisplay d = disp as ZeroitLB7SegmentDisplay;

                    int idDigit = 0;
                    if (d.Name.Contains("digit_sign") != false)
                    {
                        signFind = true;
                    }
                    else
                    {
                        if (d.Name.Contains("digit_") != false)
                        {
                            string s = d.Name.Remove(0, 6);
                            idDigit = Convert.ToInt32(s);

                            if (signFind != false)
                            {
                                idDigit++;
                            }
                        }
                    }

                    Point pos = new Point();
                    pos.X      = idDigit * digitW;
                    pos.Y      = 0;
                    d.Location = pos;

                    Size dim = new Size();
                    dim.Width  = digitW;
                    dim.Height = rc.Height;
                    d.Size     = dim;
                }
            }
        }
        /// <summary>
        /// Update the controls of the meter
        /// </summary>
        protected virtual void UpdateControls()
        {
            int count = this.Format.Length;

            this._dpPos = -1;

            char[] seps     = new char[] { '.', ',' };
            int    sepIndex = this.Format.IndexOfAny(seps);

            if (sepIndex > 0)
            {
                count--;
                this._dpPos     = sepIndex - 1;
                this._numDigits = count;
            }

            this._numDigits = count;

            this.Controls.Clear();

            if (this.Signed != false)
            {
                ZeroitLB7SegmentDisplay disp = new ZeroitLB7SegmentDisplay();
                disp.Name  = "digit_sign";
                disp.Value = -1;
                this.Controls.Add(disp);
            }

            for (int idx = 0; idx < count; idx++)
            {
                ZeroitLB7SegmentDisplay disp = new ZeroitLB7SegmentDisplay();

                disp.Name = "digit_" + idx.ToString();

                disp.Click += this.DisplayClicked;

                if (sepIndex - 1 == idx)
                {
                    disp.ShowDP = true;
                }

                this.Controls.Add(disp);
            }

            this.RepositionControls();
        }
Example #3
0
        /// <summary>
        /// Drawing method
        /// </summary>
        /// <param name="Gr">The gr.</param>
        /// <exception cref="System.ArgumentNullException">Gr</exception>
        /// <exception cref="System.NullReferenceException">Associated control is not valid</exception>
        public override void Draw(Graphics Gr)
        {
            if (Gr == null)
            {
                throw new ArgumentNullException("Gr");
            }

            ZeroitLB7SegmentDisplay ctrl = this.Display;

            if (ctrl == null)
            {
                throw new NullReferenceException("Associated control is not valid");
            }

            RectangleF _rc = new RectangleF(0, 0, ctrl.Width, ctrl.Height);

            Gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            this.DrawBackground(Gr, _rc);
            this.DrawOffSegments(Gr, _rc);
            this.DrawValue(Gr, _rc);
        }