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; }
/// <summary> /// Настройки при загрузке /// </summary> public C_Logic() { V_Command_D01 = new C_CommandD01( "", C_PortOptions.F_GetStopBits()[1], C_PortOptions.F_GetParity()[2], C_PortOptions.F_GetBaudRate()[3], "OptionsD01.dat", true); V_Command_D01.F_LoadOptions(); V_Command_D02 = new C_CommandD02( "", C_PortOptions.F_GetStopBits()[1], C_PortOptions.F_GetParity()[2], C_PortOptions.F_GetBaudRate()[3], "OptionsD02.dat", true); V_Command_D02.F_LoadOptions(); V_WindowMeasument = new W_Measurements(this); V_WindowMeasument.Closed += delegate(object s, EventArgs e1) { if (V_w_D01 != null && V_w_D01.Activate()) { V_w_D01.Close(); } }; V_WindowMeasument.Closed += delegate(object s, EventArgs e1) { if (V_w_D02 != null && V_w_D02.Activate()) { V_w_D02.Close(); } }; V_WindowMeasument.Closed += delegate(object s, EventArgs e1) { if (V_w_correction != null && V_w_correction.Activate()) { V_w_correction.Close(); } }; V_WindowMeasument.Closed += delegate(object s, EventArgs e1) { if (V_w_Calibration != null && V_w_Calibration.Activate()) { V_w_Calibration.Close(); } }; V_WindowMeasument.Show(); }
private void B_UsePorts_Click(object sender, RoutedEventArgs e) { V_Port.Fv_BaudRate = C_PortOptions.F_GetBaudRate()[CB_BaudRate.SelectedIndex]; V_Port.Fv_Parity = C_PortOptions.F_GetParity()[CB_Parity.SelectedIndex]; int v_index; if ((v_index = CB_NamePort.SelectedIndex) != -1) { V_Port.Fv_PortName = CB_NamePort.Items[CB_NamePort.SelectedIndex].ToString(); } V_Port.Fv_StopBits = C_PortOptions.F_GetStopBits()[CB_StopBits.SelectedIndex]; V_Port.V_Status = (bool)Cb_OnOff.IsChecked; if (Event_UseSettings != null) { Event_UseSettings(V_Port); } this.Close(); }