Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO.Ports;
- namespace Tutorial_select_0
- {
- public partial class Config_Serial : Form
- {
- Form1 janela1;
- string[] portas = {""};
- bool reset2 = false;
- public Config_Serial(Form1 x)
- {
- InitializeComponent();
- janela1 = x;
- }
- void busca_de_portas(bool x)
- {
- int num = portas.Length;
- portas = SerialPort.GetPortNames();
- if (num != portas.Length || x)
- {
- comboBox1.Items.Clear();
- for (int i = 0; i < portas.Length; i++)
- {
- comboBox1.Items.Add(portas[i]);
- }
- }
- }
- private void Config_Serial_Load(object sender, EventArgs e)
- {
- busca_de_portas(true);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- busca_de_portas(false);
- }
- private void Config_Serial_FormClosing(object sender, FormClosingEventArgs e)
- {
- try
- {
- janela1.Porta.BaudRate = Convert.ToInt32(comboBox2.Text);
- janela1.Porta.PortName = comboBox1.Text;
- janela1.Text = comboBox1.Text + "/" + comboBox2.Text;
- janela1.reset = reset2;
- }
- catch
- {
- DialogResult escolha;
- escolha = MessageBox.Show("Prencha todos os campos ", "Aviso", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
- if (escolha == System.Windows.Forms.DialogResult.OK)
- {
- e.Cancel = true;
- }
- }
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if(checkBox1.Checked)
- {
- reset2 = true;
- }
- else
- {
- reset2 = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement