Example #1
0
 public override void isNewText(Object sender, IsNewTextEventArgs e)
 {
     base.isNewText(sender, e);
     Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
     Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
     try
     {
         if (e.Vector.Device == Name)
         {
             IsNewText?.Invoke(this, new INDICameraTextEventArgs(e.Vector, e.Device));
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #2
0
 void IsNewText(Object sender, IsNewTextEventArgs 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 setTexts;
                             }
                             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 (INDIText 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;
                                 t.Name         = "TEXT_" + n.Name;
                                 t.Enabled      = (e.Vector.Permission != "ro");
                                 l.Location     = new Point(30, y);
                                 t.Location     = new Point(330, y - 5);
                                 t.TextChanged += valueChanged;
                                 y             += 26;
                                 vector.Controls.Add(l);
                                 vector.Controls.Add(t);
                             }
                             setTexts:
                             foreach (INDIText n in e.Vector.Values)
                             {
                                 vector.Controls.Find("TEXT_" + n.Name, false)[0].TextChanged -= valueChanged;
                                 vector.Controls.Find("TEXT_" + n.Name, false)[0].Text         = n.value;
                                 vector.Controls.Find("TEXT_" + n.Name, false)[0].TextChanged += valueChanged;
                             }
                         }
                     }
                 });
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
         }
     }
 }