/// <summary> /// Change the number of elements in our LED array. This destroys /// the previous elements, and creates new ones in their place, applying /// all the current options to the new ones. /// </summary> /// <param name="count">Number of elements to create.</param> public void RecreateSegments(int count) { if (segments != null) { for (int i = 0; i < segments.Length; i++) { segments[i].Parent = null; segments[i].Dispose(); } } if (count <= 0) { return; } segments = new SevenSegment[count]; for (int i = 0; i < count; i++) { segments[i] = new SevenSegment(); segments[i].Parent = this; segments[i].Top = 0; segments[i].Height = this.Height; segments[i].Anchor = AnchorStyles.Top | AnchorStyles.Bottom; segments[i].Visible = true; if (this.Name == "led_ohm") { segments[i].Click += new EventHandler((o, e) => { Mndz.Form1 f1 = Program.mainwnd; f1.Invoke(new Action <object, object>(f1.led_ohm_Click), new object[] { o, e }); }); } } ResizeSegments(true); UpdateSegments(); this.Value = theValue; }
static void Main() { mainwnd = new Form1(); msg = new MsgDlg(); Application.Run(mainwnd); }