private void RemoveParam_Click(object sender, RoutedEventArgs e) { if (SelectedParam == null) { return; } if ((settingUnits.ParamsTypes[0] == SelectedParam) && (SelectedParam.Title == "Длина трубы")) { new Service.MessageView("Нельзя удалить параметр \"Длина трубы\"", "Внимание", Service.MessageViewMode.Attention).ShowDialog(); return; } if ((settingUnits.ParamsTypes[1] == SelectedParam) && (SelectedParam.Title == "Кол-во труб")) { new Service.MessageView("Нельзя удалить параметр \"Кол-во труб\"", "Внимание", Service.MessageViewMode.Attention).ShowDialog(); return; } if ((settingUnits.ParamsTypes[2] == SelectedParam) && (SelectedParam.Title == "Уровень(A114)")) { new Service.MessageView("Нельзя удалить параметр \"Уровень(А114)\"", "Внимание", Service.MessageViewMode.Attention).ShowDialog(); return; } settingUnits.ParamsTypes.Remove(SelectedParam); SelectedParam = null; SelectedUnit = null; }
private void dgUnit_CurrentCellChanged(object sender, EventArgs e) { if (dgUnit.CurrentItem != null) { SelectedUnit = (Service.ParamUnit)dgUnit.CurrentItem; } }
private void RemoveUnit_Click(object sender, RoutedEventArgs e) { if (SelectedUnit == null) { return; } SelectedParam.ListUnits.Remove(SelectedUnit); SelectedUnit = null; dgUnit.Items.Refresh(); }
private void Import_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.Filter = "Params file (*.dat)|*.dat"; ofd.Title = "Открыть"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string input = (string)Service.WorkFile.Do(ofd.FileName, Service.WorkFileMode.ReadAllText); settingUnits = Core.Deserialize.Units(input); SelectedUnit = null; SelectedParam = null; DataContext = settingUnits.ParamsTypes; } }
public Service.ParamUnit GetUnitByTitle(Service.ParamType paramType, string title) { foreach (Service.ParamType type in ParamsTypes) { if (type.Title == paramType.Title) { foreach (Service.ParamUnit unit in type.ListUnits) { if (unit.Title == title) { return(unit); } } } } Service.ParamUnit pu = new Service.ParamUnit { Title = title }; paramType.ListUnits.Add(pu); return(pu); }