private void Load(object obj) { if (obj is string s) { try { var ts = new Col2Importer().Import(s); foreach (var d in ts.Where(t => t.Key.Component == FieldComponent.Hx && !ts.Any(b => b.Key.Name == t.Key.Name && b.Key.Component == FieldComponent.Dx)).ToArray()) { ts.Add(new ChannelInfo(d.Key.Name, FieldComponent.Dx), TsUtil.GetDerivate(d.Value)); } foreach (var d in ts.Where(t => t.Key.Component == FieldComponent.Hy && !ts.Any(b => b.Key.Name == t.Key.Name && b.Key.Component == FieldComponent.Dy)).ToArray()) { ts.Add(new ChannelInfo(d.Key.Name, FieldComponent.Dy), TsUtil.GetDerivate(d.Value)); } DataRepository.SetData(s, ts); Status.RaiseValidation(); SpectraStatus.RaiseValidation(); SaveDataCommand.RaiseCanExecuteChanged(); } catch (Exception e) { MessageBox.Show(@"При чтении временных рядов произошла ошибка. " + e.Message); } } else { OpenFileDialog d = new OpenFileDialog(); var df = d.ShowDialog(); if (df.HasValue && df.Value) { Load(d.FileName); } } }
private void SelectedSites_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Status.RaiseValidation(); SpectraStatus.RaiseValidation(); }