public static void Init(int mount, int com) { StatusUpdater.DoWork += new DoWorkEventHandler(StatusUpdater_DoWork); StatusUpdater.ProgressChanged += new ProgressChangedEventHandler(StatusUpdater_ProgressChanged); StatusUpdater.RunWorkerCompleted += new RunWorkerCompletedEventHandler(StatusUpdater_RunWorkerCompleted); StatusUpdater.WorkerSupportsCancellation = true; StatusUpdater.WorkerReportsProgress = true; GotoWorker.DoWork += new DoWorkEventHandler(GotoWorker_DoWork); GotoWorker.ProgressChanged += new ProgressChangedEventHandler(GotoWorker_ProgressChanged); GotoWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(GotoWorker_RunWorkerCompleted); GotoWorker.WorkerSupportsCancellation = true; GotoWorker.WorkerReportsProgress = true; pMount = new Mount_Skywatcher(); pMount.Connect_COM(com); pMount.MCInit(); StatusUpdater.RunWorkerAsync(); EventInvoker += new EventHandler(Controller_EventInvoker); UnLock(); }
private void buttonConnect_Click(object sender, EventArgs e) { try { mount = new Mount_Skywatcher(); var PortNumber = comboBoxPortSelect.SelectedItem.ToString().Replace("COM", ""); int COM = Convert.ToInt16(PortNumber); mount.Connect_COM(COM); mount.MCOpenTelescopeConnection(); groupBox1.Enabled = groupBox2.Enabled = groupBox3.Enabled = true; timer1.Start(); } catch (MountControlException exception) { textBoxStatus.Text = exception.Message; } catch(Exception exception) { textBoxStatus.Text = exception.Message; } }