/// <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(HT7SegmentDisplay)) { HT7SegmentDisplay d = disp as HT7SegmentDisplay; 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) { HT7SegmentDisplay disp = new HT7SegmentDisplay(); disp.Name = "digit_sign"; disp.Value = -1; this.Controls.Add(disp); } for (int idx = 0; idx < count; idx++) { HT7SegmentDisplay disp = new HT7SegmentDisplay(); disp.Name = "digit_" + idx.ToString(); disp.Click += this.DisplayClicked; if (sepIndex - 1 == idx) { disp.ShowDP = true; } this.Controls.Add(disp); } this.RepositionControls(); }