//////////////////////////////////////// #region Constructor public AnalysisWorkspaceViewModel(string header, ref xrfSample sample) { base.Header = header; SampleData = sample; Elements = new ObservableCollection <elementData>(); PopulateElementsList(ref sample); }
//////////////////////////////////////// #region Constructor public SampleWorkspaceViewModel(string header, ref xrfSample sample) { base.Header = header; ImageAnalysisWorkspaces = new WorkspaceViewModelCollection(); InitializeDataManipulationWorkspaces(ref sample); SampleData = sample; }
void OpenDumpFile_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { DumpFileHandler handler = new DumpFileHandler(OpenDumpFile.FileName); xrfSample sample = handler.GetSampleData(); Samples.Add(new SampleWorkspaceViewModel(OpenDumpFile.SafeFileName, ref sample)); SelectedSample = Samples[Samples.Count - 1] as SampleWorkspaceViewModel; }
//////////////////////////////////////// #region Data Retrieval public xrfSample GetSampleData() { if (!_dataFile.Exists) { throw new ArgumentException("Path does not exist."); } xrfSample sample = ParseFileData(ReadTabularContentFromFile()); return(sample); }
//////////////////////////////////////// #region Supporting Methods private void PopulateElementsList(ref xrfSample sample) { List <string> labelData = new List <string>(sample.Labels); int startIndex = labelData.IndexOf("Deadtime (%)"); int endIndex = labelData.IndexOf("Full Counts"); for (int i = startIndex + 1; i < endIndex; i++) { Elements.Add(sample.GetElementData(sample.Labels[i])); } }
//////////////////////////////////////// #region Data Parsing private xrfSample ParseFileData(string[][] columnsData) { int columnLengthCutOff = 4; string[][] metaData = ExtractMetaData(columnsData, columnLengthCutOff); string[][] rawPixelData = ExtractRawPixelData(columnsData, columnLengthCutOff); double[][] convertedPixelData = ConvertPixelDataToDouble(rawPixelData, 1); string[] columnLabels = rawPixelData[0]; xrfSample sample = GenerateSampleObject(columnLabels, metaData, convertedPixelData); return(sample); }
//////////////////////////////////////// #region Supporting Methods private void PopulateElementWorkspaces(ref xrfSample sample) { if (AvailableElements.Count > 0) { AvailableElements.Clear(); } foreach (elementData item in Elements) { AvailableElements.Add(new SEWorkspaceViewModel(item)); } if (AvailableElements.Count > 0) { SelectedElement = AvailableElements[0] as SEWorkspaceViewModel; } }
//////////////////////////////////////// #region Constructor public SEAnalysisWorkspaceViewModel(string header, ref xrfSample sample) : base(header, ref sample) { AvailableElements = new WorkspaceViewModelCollection(); PopulateElementWorkspaces(ref sample); }
//////////////////////////////////////// #region Supporting Methods private void InitializeDataManipulationWorkspaces(ref xrfSample _sample) { ImageAnalysisWorkspaces.Add(new SEAnalysisWorkspaceViewModel("Single-Element Analysis", ref _sample)); SelectedImageAnalysisWorkspace = ImageAnalysisWorkspaces[0] as IAnalysisWorkspaceViewModel; }
//////////////////////////////////////// #region Constructor public MEAnalysisWorkspaceViewModel(string header, ref xrfSample sample) : base(header, ref sample) { SelectedElements = new ObservableCollection <ElementMarkerViewModel>(); }