public void LoadFilters() { EmissionsFilterList = new ObservableCollection <FilterContainer>(); ExcitationFilterList = new ObservableCollection <FilterContainer>(); WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.GetAllFilters(); if (success) { foreach (FilterContainer filter in wgDB.m_filterList) { if (filter.FilterChanger == (int)FilterChangerEnum.Emission) { EmissionsFilterList.Add(filter); } else if (filter.FilterChanger == (int)FilterChangerEnum.Excitation) { ExcitationFilterList.Add(filter); } } } LoadSignalTypes(); }
private void SavePB_Click(object sender, RoutedEventArgs e) { WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.GetAllFilters(); if (success) { bool goodData = true; string errStr = "No Error"; // check to make sure that the FilterChanger/FilterPosition combination is not already occupied for (int i = 0; i < wgDB.m_filterList.Count(); i++) { if (FilterVM.Filter.FilterChanger == wgDB.m_filterList[i].FilterChanger && FilterVM.Filter.PositionNumber == wgDB.m_filterList[i].PositionNumber) { goodData = false; errStr = ((FilterPositionEnum)FilterVM.Filter.PositionNumber).ToString() + " already taken in " + ((FilterChangerEnum)FilterVM.Filter.FilterChanger).ToString() + " Filter Changer"; } } if (goodData) { if (m_addingNew) { // adding new filter, so call insert FilterContainer fc = FilterVM.Filter; success = wgDB.InsertFilter(ref fc); } else { // updating existing filter, so call update FilterContainer fc = FilterVM.Filter; success = wgDB.UpdateFilter(fc); } if (success) { m_OK = true; Close(); } else { errStr = wgDB.GetLastErrorMsg(); MessageBox.Show(errStr, "Database Error", MessageBoxButton.OK, MessageBoxImage.Error); } } if (!goodData) { MessageBox.Show(errStr, "Error in Filter Data", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public void Refresh() { WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.GetAllFilters(); if (success) { Filters.Clear(); for (int i = 0; i < wgDB.m_filterList.Count(); i++) { Filters.Add(wgDB.m_filterList[i]); } } }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string filterDesc = "No Filter"; WaveguideDB wgDB = new WaveguideDB(); bool success = wgDB.GetAllFilters(); foreach (FilterContainer filter in wgDB.m_filterList) { if (filter.PositionNumber == (int)value && filter.FilterChanger == (int)parameter) { filterDesc = filter.Description; break; } } return(filterDesc); }