Skip to content

Instantly share code, notes, and snippets.

@facilita-tecnologia
Created August 22, 2020 12:30
Show Gist options
  • Save facilita-tecnologia/dee02d3a21490c8202ce7e1ac03ebc3a to your computer and use it in GitHub Desktop.
Save facilita-tecnologia/dee02d3a21490c8202ce7e1ac03ebc3a to your computer and use it in GitHub Desktop.
#region Configurações para Balanças
public void Carregar_Config_Balanca()
{
// Modelo da Balança
string Modelo_B = ini.IniReadValue("PESO", "Modelo");
if (string.IsNullOrEmpty(Modelo_B))
{
modeloComboBox.Items.Clear();
foreach (var modelo in Enum.GetValues(typeof(ModeloBal)))
{
modeloComboBox.Items.Add(modelo);
}
modeloComboBox.SelectedIndex = 0;
}
else
{
modeloComboBox.Items.Clear();
ModeloBal _Modelo = (ModeloBal)Enum.Parse(typeof(ModeloBal), Modelo_B);
modeloComboBox.Items.Add(_Modelo);
foreach (var modelo in Enum.GetValues(typeof(ModeloBal)))
{
modeloComboBox.Items.Add(modelo);
}
modeloComboBox.SelectedIndex = 0;
}
// Porta de Comunicação
string Porta_B = ini.IniReadValue("PESO", "Porta");
if (string.IsNullOrEmpty(Porta_B))
{
txt_Porta.Text = "0";
}
else
{
txt_Porta.Text = Porta_B;
}
// Velocidade
string Velocidade_B = ini.IniReadValue("PESO", "Velocidade");
if (string.IsNullOrEmpty(Velocidade_B))
{
velocidadeComboBox.Items.Add(1200);
velocidadeComboBox.Items.Add(2400);
velocidadeComboBox.Items.Add(4800);
velocidadeComboBox.Items.Add(9600);
velocidadeComboBox.Items.Add(19200);
velocidadeComboBox.Items.Add(38400);
velocidadeComboBox.Items.Add(57600);
velocidadeComboBox.Items.Add(115200);
velocidadeComboBox.SelectedIndex = 0;
}
else
{
velocidadeComboBox.Items.Add(Velocidade_B);
velocidadeComboBox.Items.Add(1200);
velocidadeComboBox.Items.Add(2400);
velocidadeComboBox.Items.Add(4800);
velocidadeComboBox.Items.Add(9600);
velocidadeComboBox.Items.Add(19200);
velocidadeComboBox.Items.Add(38400);
velocidadeComboBox.Items.Add(57600);
velocidadeComboBox.Items.Add(115200);
velocidadeComboBox.SelectedIndex = 0;
}
// Status
string Status_B = ini.IniReadValue("PESO", "Status");
if (string.IsNullOrEmpty(Status_B))
{
checkBoxAtivo.Checked = false;
}
else
{
if (Status_B == "S")
{
checkBoxAtivo.Checked = true;
}
if (Status_B == "N")
{
checkBoxAtivo.Checked = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment