public W_Port1(Device001.Port.C_MyPort v_Port, string V_NameDeice) { InitializeComponent(); this.Title = V_NameDeice; V_Port = v_Port; foreach (var v_n in C_PortOptions.F_GetPortNames()) { CB_NamePort.Items.Add(v_n); } if (C_PortOptions.F_GetPortNames().Count() != 0) { CB_NamePort.SelectedIndex = 0; } if (C_PortOptions.F_GetPortNames().Contains(v_Port.Fv_PortName)) { CB_NamePort.SelectedIndex = Array.FindIndex(C_PortOptions.F_GetPortNames(), x => x == v_Port.Fv_PortName); } foreach (var v_sb in C_PortOptions.F_GetStopBits()) { CB_StopBits.Items.Add(C_PortOptions.F_StopBits(v_sb)); } if (CB_StopBits.Items.Contains(C_PortOptions.F_StopBits(v_Port.Fv_StopBits))) { CB_StopBits.SelectedIndex = CB_StopBits.Items.IndexOf(C_PortOptions.F_StopBits(v_Port.Fv_StopBits)); } foreach (var v_sb in C_PortOptions.F_GetParity()) { CB_Parity.Items.Add(C_PortOptions.F_Parity(v_sb)); } if (CB_Parity.Items.Contains(C_PortOptions.F_Parity(v_Port.Fv_Parity))) { CB_Parity.SelectedIndex = CB_Parity.Items.IndexOf(C_PortOptions.F_Parity(v_Port.Fv_Parity)); } foreach (var v_sb in C_PortOptions.F_GetBaudRate()) { CB_BaudRate.Items.Add(C_PortOptions.F_BaudRate(v_sb)); } if (CB_BaudRate.Items.Contains(C_PortOptions.F_BaudRate(v_Port.Fv_BaudRate))) { CB_BaudRate.SelectedIndex = CB_BaudRate.Items.IndexOf(C_PortOptions.F_BaudRate(v_Port.Fv_BaudRate)); } Cb_OnOff.IsChecked = V_Port.V_Status; }
private void B_UpdatePorts_Click(object sender, RoutedEventArgs e) // Обновление портов переделать! { string v_NamePort = ""; int v_index; if ((v_index = CB_NamePort.SelectedIndex) != -1) { v_NamePort = CB_NamePort.Items[v_index].ToString(); } CB_NamePort.Items.Clear(); foreach (var v_n in C_PortOptions.F_GetPortNames()) { CB_NamePort.Items.Add(v_n); } if (C_PortOptions.F_GetPortNames().Count() != 0) { CB_NamePort.SelectedIndex = 0; } if (C_PortOptions.F_GetPortNames().Contains(v_NamePort)) { CB_NamePort.SelectedIndex = Array.FindIndex(C_PortOptions.F_GetPortNames(), x => x == v_NamePort); } }