private void AddFilter_Click(object sender, RoutedEventArgs e) { try { WorkBookManager manager = WorkBookManager.Manager(); Models.WindowedSyncFilter newFilter = new Models.WindowedSyncFilter(); newFilter.IsActive = true; newFilter.Name = FilterName.Text; newFilter.CutoffFrequencySamplingFrequencyPercentage = double.Parse(CutoffFrequencyPercentage.Text); newFilter.FilterLength = int.Parse(FilterLength.Text); newFilter.FilterType = (FILTERTYPE)Enum.Parse(typeof(FILTERTYPE), FilterType.SelectedItem.ToString()); FilterViewModel model = DataContext as FilterViewModel; model?.AddFilter(newFilter); FilterName.Text = String.Empty; CutoffFrequencyPercentage.Text = String.Empty; FilterLength.Text = String.Empty; FilterType.SelectedIndex = 0; } catch (Exception ex) { Log.Warning(ex, ex.Message); // TODO warn the user } }
private void SetActiveWorkbookTitle() { if (this.DataContext != null) { MainWindowViewModel model = this.DataContext as MainWindowViewModel; model.WorkBookTitle = WorkBookManager.Manager().ActiveWorkBook().Name; } }
public FilterViewModel() { manager = WorkBookManager.Manager(); manager.PropertyChanged += ActiveWorkBookChangedHandler; SumModeActive = true; ConvolveModeActive = !SumModeActive; LoadFilterData(); }
/// <summary> /// Delete the specified filters from the workbook then reload filter data (refreshing the display) /// </summary> /// <param name="deleteItems">List of filters to delete</param> public void DeleteFilters(List <IFilterIdentifier> deleteItems) { foreach (IFilterIdentifier deleteMe in deleteItems) { WorkBookManager.Manager().ActiveWorkBook().DeleteFilter(deleteMe); } LoadFilterData(); }
public SignalGeneratorViewModel() { Signals = new ObservableCollection <Signal>(); SignalViews = new ObservableCollection <SignalItemView>(); Title = Properties.Resources.SIGNAL_PLOT_TITLE; workBookManager = WorkBookManager.Manager(); workBookManager.PropertyChanged += ActiveWorkBookChangedHandler; CreateCommands(); }
private void MenuItemSave_Click(object sender, RoutedEventArgs e) { WorkBook activeWorkBook = WorkBookManager.Manager().ActiveWorkBook(); if (activeWorkBook.FilePath != null) { WorkBookManager.Manager().Update(WorkBookManager.Manager().ActiveWorkBook()); } else { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = $"{Properties.Resources.DATABASE_FILES} (*{Properties.Resources.WORKBOOK_FILE_EXTENSION})|*{Properties.Resources.WORKBOOK_FILE_EXTENSION}|{Properties.Resources.ALL_FILES} (*.*)|*.*"; if (saveFileDialog.ShowDialog() == true) { activeWorkBook.Name = saveFileDialog.SafeFileName; activeWorkBook.FilePath = saveFileDialog.FileName; WorkBookManager.Manager().SaveWorkBook(activeWorkBook); SetActiveWorkbookTitle(); } } }
private void Application_Startup(object sender, StartupEventArgs e) { string logParentPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string logPath = Path.Combine(logParentPath, ConfigurationManager.AppSettings["relativeLogPath"]); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File(logPath, rollingInterval: RollingInterval.Day) .CreateLogger(); DispatcherUnhandledException += Application_DispatcherUnhandledException; MainWindow window = new MainWindow(); if (e.Args.Length == 1) { WorkBookManager.Manager().Load(e.Args[0], true); } window.Show(); }
private void ImportButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = $"{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION} (*{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION})|*{Properties.Resources.FILTER_IMPORT_EXPORT_FILE_EXTENSION}|{Properties.Resources.ALL_FILES} (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { try { using (StreamReader fileReader = File.OpenText(openFileDialog.FileName)) { fileReader.ReadLine(); // Skip the header row List <Tuple <double, double> > magPhaseList = new List <Tuple <double, double> >(); while (!fileReader.EndOfStream) { string[] magPhaseData = fileReader.ReadLine().Split(','); double magnitude = double.Parse(magPhaseData[0]); double phase = double.Parse(magPhaseData[1]); magPhaseList.Add(new Tuple <double, double>(magnitude, phase)); } WorkBookManager manager = WorkBookManager.Manager(); SignalsAndTransforms.Models.CustomFilter customFilter = new SignalsAndTransforms.Models.CustomFilter(magPhaseList); customFilter.Name = System.IO.Path.GetFileNameWithoutExtension(openFileDialog.FileName); customFilter.IsActive = true; FilterViewModel context = DataContext as FilterViewModel; context?.AddFilter(customFilter); } } catch (Exception ex) { Log.Warning(ex, ex.Message); // TODO warn user } } }
public ConvolutionViewModel() { manager = WorkBookManager.Manager(); manager.PropertyChanged += ActiveWorkBookChangedHandler; convolver = new Convolution(); }
/// <summary> /// Open the workbook specified in the file pathname variable and set to active workbook /// </summary> /// <param name="file"></param> private void SetActiveWorkbook(string file) { WorkBookManager.Manager().Load(file, true); SetActiveWorkbookTitle(); }
public FilterView() { InitializeComponent(); FilterType.ItemsSource = Enum.GetValues(typeof(FILTERTYPE)).Cast <FILTERTYPE>(); manager = WorkBookManager.Manager(); }