public Form1() { InitializeComponent(); splitContainer1.FixedPanel = FixedPanel.Panel1; splitContainer2.FixedPanel = FixedPanel.Panel2; CancelButton = button4; //Close Settings.Read(); TopMost = Settings.Option.StayOnTop; // let form use multiple fonts origFont = Font; FontFamily ff = new FontFamily("Courier New"); monoFont = new Font(ff, 8, FontStyle.Regular); Font = Settings.Option.MonoFont ? monoFont : origFont; CommPort com = CommPort.Instance; com.StatusChanged += OnStatusChanged; com.DataReceived += OnDataReceived; com.Open(); }
// Close Port private void closePort1_Click(object sender, EventArgs e) { //updateTemp1_click_Click(sender, e); Frame = 0; if (com1.IsOpen) { closePort1.Enabled = false; this.closePort1.BackColor = System.Drawing.Color.LightGray; this.masterLED1.BackgroundImage = global::DCUTester.Properties.Resources.amberLED; if (settings1.option.Logging) { logFile_writeLine1("Close Port1", settings1.option.LogFileName); } //byte[] cmd1 = command1.Get(); //cmd1[1] = 1; //command1.Set(cmd1); com1.Close(); } else { this.closePort1.BackColor = System.Drawing.Color.Green; string status = com1.Open(settings1); if (!com1.IsOpen) { this.closePort1.BackColor = System.Drawing.Color.Yellow; } if (settings1.option.Logging) { logFile_writeLine1("Start Port1", settings1.option.LogFileName); } } }
public MainForm() { this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); InitializeComponent(); _bLogging = false; Settings.Read(); //Settings.setLogPathFile(ref this.LogPathBox); TopMost = Settings.Option.StayOnTop; CommPort com = CommPort.Instance; com.StatusChanged += OnStatusChanged; com.DataReceived += OnDataReceived; com.Open(); int[] Interval = { 1, 10, 100, 200, 1000, 0 }; for (int i = 0; Interval[i] != 0; ++i) { IntervalComboBox.Items.Add(Interval[i].ToString()); } IntervalComboBox.SelectedIndex = 1; // stopwatch m_sw = new Stopwatch(); m_sw.Reset(); m_sw.Start(); m_sw2 = new Stopwatch(); m_sw2.Reset(); m_sw2.Start(); InitializeGraph(); }
// OK private void button1_Click(object sender, EventArgs e) { Settings.s_printer_name = cbb_printer.SelectedItem.ToString(); string old_PortName = Settings.Port.PortName; Settings.Port.PortName = comboBox1.Text; Settings.Port.BaudRate = Int32.Parse(comboBox2.Text); Settings.Port.DataBits = comboBox3.SelectedIndex + 5; Settings.Port.Parity = (Parity)comboBox4.SelectedIndex; Settings.Port.StopBits = (StopBits)comboBox5.SelectedIndex; Settings.Port.Handshake = (Handshake)comboBox6.SelectedIndex; if (radioButton2.Checked) { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendCR; } else if (radioButton3.Checked) { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendLF; } else if (radioButton4.Checked) { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendCRLF; } else { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendNothing; } Settings.Option.HexOutput = checkBox1.Checked; Settings.Option.MonoFont = checkBox2.Checked; Settings.Option.LocalEcho = checkBox3.Checked; Settings.Option.StayOnTop = checkBox4.Checked; Settings.Option.FilterUseCase = checkBox5.Checked; Settings.Option.LogFileName = textBox1.Text; Settings.Write(); CommPort com = CommPort.Instance; if (!old_PortName.Equals(Settings.Port.PortName)) { if (com.IsOpen) { Thread CloseDown = new Thread(new ThreadStart(CloseSerialOnExit)); //close port in new thread to avoid hang CloseDown.Start(); //close port in new thread to avoid hang } } else { if (!com.IsOpen) { com.Open(); } } this.Close(); }
private void button1_Click(object sender, EventArgs e) { CommPort com = CommPort.Instance; if (com.IsOpen) { com.Close(); } com.Open(); }
private void CloseSerialOnExit() { CommPort com = CommPort.Instance; try { com.Close(); //close the serial port } catch (Exception ex) { MessageBox.Show(ex.Message); //catch any serial port closing error messages } com.Open(); }
/// <summary> /// toggle connection status /// </summary> private void textBox1_Click(object sender, MouseEventArgs e) { CommPort com = CommPort.Instance; if (com.IsOpen) { com.Close(); } else { com.Open(); } outputList.Focus(); }
private void button1_Click_1(object sender, EventArgs e) { Settings.Port.PortName = comboBox1.Text; Settings.Port.BaudRate = Int32.Parse(comboBox2.Text); Settings.Port.DataBits = comboBox3.SelectedIndex + 5; Settings.Port.Parity = (Parity)comboBox4.SelectedIndex; Settings.Port.StopBits = (StopBits)comboBox5.SelectedIndex; Settings.Port.Handshake = (Handshake)comboBox6.SelectedIndex; CommPort com = CommPort.Instance; com.Open(); Settings.Write(); Close(); }
public Scale() { InitializeComponent(); this.WindowState = FormWindowState.Maximized; SqlHelper.Initialize(); Settings.Read(); // let form use multiple fonts origFont = Font; FontFamily ff = new FontFamily("Courier New"); monoFont = new Font(ff, 8, FontStyle.Regular); Font = Settings.Option.MonoFont ? monoFont : origFont; CommPort com = CommPort.Instance; com.StatusChanged += OnStatusChanged; com.DataReceived += OnDataReceived; com.Open(); }
// OK private void button1_Click(object sender, EventArgs e) { Settings.Port.PortName = comboBox1.Text; Settings.Port.BaudRate = Int32.Parse(comboBox2.Text); Settings.Port.DataBits = comboBox3.SelectedIndex + 5; Settings.Port.Parity = (Parity)comboBox4.SelectedIndex; Settings.Port.StopBits = (StopBits)comboBox5.SelectedIndex; Settings.Port.Handshake = (Handshake)comboBox6.SelectedIndex; if (radioButton2.Checked) { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendCR; } else if (radioButton3.Checked) { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendLF; } else if (radioButton4.Checked) { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendCRLF; } else { Settings.Option.AppendToSend = Settings.Option.AppendType.AppendNothing; } Settings.Option.HexOutput = checkBox1.Checked; Settings.Option.MonoFont = checkBox2.Checked; Settings.Option.LocalEcho = checkBox3.Checked; Settings.Option.StayOnTop = checkBox4.Checked; Settings.Option.FilterUseCase = checkBox5.Checked; Settings.Option.LogFileName = textBox1.Text; CommPort com = CommPort.Instance; com.Open(); Settings.Write(); Close(); }