/// <summary> /// Вводит данные о новом конденсаторе /// </summary> /// <returns></returns> private Capacitor GetNewCapacitor() { var newCapacitor = new Capacitor(); var actions = new List <Action>() { new Action(() => { ReadingAndParsing.ReadAndParse( PassiveElementParameter1_textBox.Text, TranslateParameter(NamesOfPassiveElementParameters. Frecuency.ToString()), out double frecuency); newCapacitor.Frecuency = frecuency; }), new Action(() => { ReadingAndParsing.ReadAndParse( PassiveElementParameter2_textBox.Text, TranslateParameter(NamesOfPassiveElementParameters. Capacity.ToString()), out double capacity); newCapacitor.Сapacity = capacity; }) }; actions.ForEach(SetValue); return(newCapacitor); }
/// <summary> /// Вводит данные о новом резисторе /// </summary> /// <returns></returns> private Resistor GetNewResistor() { var newResistor = new Resistor(); var actions = new List <Action>() { new Action(() => { ReadingAndParsing.ReadAndParse( PassiveElementParameter1_textBox.Text, TranslateParameter(NamesOfPassiveElementParameters. Resistance.ToString()), out double resistance); newResistor.Resistance = resistance; }) }; actions.ForEach(SetValue); return(newResistor); }
/// <summary> /// Ищет необходимый пассивный элемент в листе /// </summary> private void Search() { _passiveElementsSearch.Clear(); CreateView(_passiveElementsSearch, dataPassiveElementView); try { if (TypesOfPassiveElementsComboBox.SelectedIndex != -1 && string.IsNullOrEmpty(searchTextBox.Text)) { foreach (var row in _passiveElements) { if (row.PassiveElementType == TypesOfPassiveElementsComboBox.SelectedItem. ToString()) { _passiveElementsSearch.Add(row); } } } else if (!string.IsNullOrEmpty(searchTextBox.Text)) { if (TypesOfPassiveElementsComboBox.SelectedIndex == 2) { foreach (var row in _passiveElements) { double partOfEmpidence; partOfEmpidence = ReadingAndParsing.ReadAndParse( searchTextBox.Text, "Действительное сопротивление", out partOfEmpidence); if (searchComboBox.SelectedIndex == 0) { if (row.ComplexResistance.Real >= partOfEmpidence && row.PassiveElementType == TypesOfPassiveElementsComboBox. SelectedItem.ToString()) { _passiveElementsSearch.Add(row); } } else { if (row.ComplexResistance.Real <= partOfEmpidence && row.PassiveElementType == TypesOfPassiveElementsComboBox. SelectedItem.ToString()) { _passiveElementsSearch.Add(row); } } } } else { foreach (var row in _passiveElements) { double partOfEmpidence; partOfEmpidence = ReadingAndParsing.ReadAndParse( searchTextBox.Text, "Мнимое сопротивление", out partOfEmpidence); if (searchComboBox.SelectedIndex == 0) { if (row.ComplexResistance.Imaginary >= partOfEmpidence && row.PassiveElementType == TypesOfPassiveElementsComboBox.SelectedItem. ToString()) { _passiveElementsSearch.Add(row); } } else { if (row.ComplexResistance.Imaginary <= partOfEmpidence && row.PassiveElementType == TypesOfPassiveElementsComboBox.SelectedItem. ToString()) { _passiveElementsSearch.Add(row); } } } } } else if (!_passiveElementsSearch.Any()) { MessageBox.Show("Ничего не найдено!"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }