private void Form2_Load(object sender, EventArgs e) { imeiInput1.Focus(); if (!OEControl.connect()) { MessageBox.Show("Fail to connect UI", "Error"); } }
private void Form1_Load(object sender, EventArgs e) { this.UseWaitCursor = false; //Bitmap b = new Bitmap(AviaFlowControl.Properties.Resources.AVIA_RGB_web); //pictureBox3.Paint += PictureBox3_Paint; //wizardControl1.Paint += WizardControl1_Paint; //Task.Run(() => //{ // while (true) // { // System.Threading.Thread.Sleep(1000); // this.Invoke(new Action(() => { this.Invalidate(); })); // } //}); #if false Task.Run(() => { // start oe app utility.IniFile config = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "config.ini")); string s = config.GetString("ui", "rect", ""); if (string.IsNullOrEmpty(s)) { try { string[] ss = s.Split(','); int x = Int32.Parse(ss[0]); int y = Int32.Parse(ss[1]); int w = Int32.Parse(ss[2]); int h = Int32.Parse(ss[3]); Rectangle theRect = new Rectangle(x, y, w, h); } catch (Exception) { } } s = config.GetString("ui", "app", @"evaoi-3.1.0.3\evaoi-3.1.0.3.exe"); string ui_exe = System.IO.Path.GetFullPath(s); s = System.IO.Path.GetFileNameWithoutExtension(ui_exe); Process[] p = Process.GetProcessesByName(s); if (p.Length > 0) { ShowWindow(p[0].MainWindowHandle, 2); theApp = p[0]; } else { if (System.IO.File.Exists(ui_exe)) { try { Process ui = new Process(); ui.StartInfo.FileName = ui_exe; ui.StartInfo.Arguments = "-ControlMode"; ui.StartInfo.UseShellExecute = true; ui.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(ui_exe); theApp = ui; ui.Start(); ui.WaitForInputIdle(); } catch (Exception) { } } } // connect to OE server if (!OEControl.connect()) { // fail to connect the OE server this.Invoke(new Action(() => { MessageBox.Show("Fail to connect UI", "Error"); })); } else { // connected // load models s = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(ui_exe), "evaoi.xml"); if (System.IO.File.Exists(s)) { XmlDocument doc = new XmlDocument(); try { doc.Load(s); if (doc.DocumentElement != null) { s = doc.DocumentElement["system"]?["ModelDir"]?.InnerText; if (System.IO.Directory.Exists(s)) { foreach (string m in System.IO.Directory.GetDirectories(s)) { models.Add(System.IO.Path.GetFileName(m)); } } } } catch (Exception) { } } } }); #endif // connect to OE server if (!OEControl.connect()) { // fail to connect the OE server this.Invoke(new Action(() => { MessageBox.Show("Fail to connect UI", "Error"); this.Close(); })); } }