private void SetVirtualPortDialog_Load(object sender, EventArgs e) { portDialog = new SetVirtualPortNameDialog(); setOffBtnStatus = new VoidString(SetOffBtnStatus); MainUnit mainform = this.Owner as MainUnit; if (mainform.VirtualPort.ComPort != 0) { portNameLbl.Text = String.Format("COM{0}", mainform.VirtualPort.ComPort); } onBtn.Enabled = !mainform.VirtualPort.Created; if (mainform.DummyTimerEnabled || mainform.WorkingTimerEnabled) { } else { offBtn.Enabled = !onBtn.Enabled; } selectNewPortBtn.Enabled = onBtn.Enabled; onOpenedHandler = new SerialNET.OnOpened(VirtualPort_OnOpened); onClosedHandler = new SerialNET.OnClosed(VirtualPort_OnClosed); mainform.VirtualPort.OnOpened += onOpenedHandler; mainform.VirtualPort.OnClosed += onClosedHandler; //if (mainform.DummyTimer.Enabled) // offBtn.Enabled = false; }
private void SetVirtualPortDialog_FormClosing(object sender, FormClosingEventArgs e) { MainUnit mainform = this.Owner as MainUnit; mainform.VirtualPort.OnOpened -= onOpenedHandler; mainform.VirtualPort.OnClosed -= onClosedHandler; }
private void offBtn_Click(object sender, EventArgs e) { MainUnit mainform = this.Owner as MainUnit; mainform.VirtualPort.Created = false; onBtn.Enabled = true; offBtn.Enabled = false; selectNewPortBtn.Enabled = true; }
private void onBtn_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(portNameLbl.Text)) { MessageBox.Show("Сначала выберите новый порт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { onBtn.Enabled = false; selectNewPortBtn.Enabled = false; MainUnit mainform = this.Owner as MainUnit; mainform.VirtualPort.ComPort = int.Parse(portNameLbl.Text.Substring(3)); mainform.VirtualPort.Created = true; offBtn.Enabled = true; } }
void GetDistanceRecInterval(MainUnit owner) { owner.SendCommand("PCGDM"); }
void GetTimeRecInterval(MainUnit owner) { owner.SendCommand("PCGDT"); }