public override void isNewNumber(Object sender, IsNewNumberEventArgs e) { base.isNewNumber(sender, e); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); try { if (e.Vector.Device == Name) { IsNewNumber?.Invoke(this, new INDICameraNumberEventArgs(e.Vector, e.Device)); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
void IsNewNumber(Object sender, IsNewNumberEventArgs e) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); if ((e.Device == Device || e.Device == "") && e.Vector.Name != "" && e.Vector.Group != "") { try { if (IsHandleCreated) { this.Invoke((MethodInvoker) delegate { GroupBox vector = new GroupBox(); vector.FlatStyle = FlatStyle.Flat; AddDevice(e.Device); AddGroup(e.Vector.Group, e.Device); Control ctl = GetChild(DevicesConnected, e.Device); if (ctl != null) { ctl = GetChild(ctl, e.Device + "_Groups"); if (ctl != null) { ctl = GetChild(ctl, e.Vector.Group); ctl = GetChild(ctl, e.Vector.Group + "_AutoScrollPanel"); Panel pan = (Panel)ctl; if (!ChildPresent(pan, e.Vector.Name)) { if (GetLastChild(pan) != null) { vector.Location = new Point(GetLastChild(pan).Location.X, GetLastChild(pan).Location.Y + GetLastChild(pan).Size.Height + 5); } pan.Controls.Add(vector); vector.Name = e.Vector.Name; vector.Text = e.Vector.Label; } vector = (GroupBox)ctl.Controls.Find(e.Vector.Name, false)[0]; if (vector.Controls.Count >= e.Vector.Values.Count) { goto setNumbers; } Int32 y = 20; vector.Size = new Size(455, 20 + e.Vector.Values.Count * 28); for (int k = 1; k < vector.Parent.Controls.Count; k++) { vector.Parent.Controls[k].Location = new Point(vector.Parent.Controls[k].Location.X, vector.Parent.Controls[k - 1].Location.Y + vector.Parent.Controls[k - 1].Size.Height + 5); } foreach (INDINumber n in e.Vector.Values) { Label l = new Label(); l.AutoSize = true; l.Text = n.Label; TextBox t = new TextBox(); t.BorderStyle = BorderStyle.FixedSingle; t.Text = n.value.ToString(); t.Name = "NUMBER_" + n.Name; t.Enabled = (e.Vector.Permission != "ro"); l.Location = new Point(30, y); t.Location = new Point(330, y - 5); l.Size = new Size(100, 18); t.Size = new Size(100, 18); t.TextChanged += valueChanged; y += 26; vector.Controls.Add(l); vector.Controls.Add(t); } setNumbers: foreach (INDINumber n in e.Vector.Values) { vector.Controls.Find("NUMBER_" + n.Name, false)[0].TextChanged -= valueChanged; string text = n.value.ToString(); if (e.Vector.Name == "TIME_LST" || (e.Vector.Name.Contains("COORD") && n.Name == "RA")) { text = (Math.Floor(n.value) % 24).ToString() + ":" + (Math.Floor(n.value * 60) % 60).ToString() + ":" + (Math.Floor(n.value * 3600) % 60).ToString(); } if (e.Vector.Name.Contains("COORD") && (n.Name == "DEC" || n.Name == "ALT" || n.Name == "AZ")) { text = (Math.Floor(n.value) % 360).ToString() + ":" + (Math.Abs(Math.Floor(n.value * 60)) % 60).ToString() + ":" + (Math.Abs(Math.Floor(n.value * 3600)) % 60).ToString(); } vector.Controls.Find("NUMBER_" + n.Name, false)[0].Text = text; vector.Controls.Find("NUMBER_" + n.Name, false)[0].TextChanged += valueChanged; } } } }); } } catch (Exception ex) { Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace); } } }