/// <summary> /// Read takes the input file path and reads in the /// data into a filled ISHArKFile interface. /// </summary> /// <param name="filePath">The path of the specified file</param> /// <returns>Valid ISHArKFile interface if successful, null otherwise</returns> public static ISHArKFile Read(String filePath) { //Declare a variable to return ISHArKFile rtn = null; //Create the appropriate File Reader and return it switch (SpectrumExtension.ToType(Path.GetExtension(filePath))) { case SpectrumType.R3D: rtn = new R3DFile(filePath); break; case SpectrumType.TXT: rtn = new TXTFile(filePath); break; } //Return the result return(rtn); }
/// <summary> /// FileOpen opens the FileSaveDialog and returns /// the value to the FileName property. /// </summary> /// <param name="parameter">Null parameter</param> private void FileOpen(Object parameter) { //Open a FileSaveDialog SaveFileDialog sfd = new SaveFileDialog(); sfd.AddExtension = true; sfd.CheckPathExists = true; sfd.OverwritePrompt = true; sfd.Filter = SpectrumExtension.ToString(SpectrumType.R3D, SpectrumType.TXT); sfd.ValidateNames = true; //Show the Dialog Nullable <Boolean> result = sfd.ShowDialog(); //If the user didn't cancel, update the //FileName property if (result == true) { this.FileName = sfd.FileName; } }
/// <summary> /// OnSaveAs opens the Save Dialog box so that the user /// can save the active Spectrum as something else. /// </summary> private void OnSaveAs() { //Create a SaveFileDialog and set it up SaveFileDialog sfd = new SaveFileDialog(); sfd.AddExtension = true; sfd.CheckPathExists = true; sfd.Filter = ImageExtension.ToString() + "|" + SpectrumExtension.ToString(SpectrumType.R3D); sfd.OverwritePrompt = true; sfd.Title = Strings.SaveSHArKFile; sfd.ValidateNames = true; //Open the Dialog and get the result Nullable <Boolean> result = sfd.ShowDialog(); //If the user clicked OK, save the file by firing //the SaveSpectrumAsEvent. if (result == true) { this._eventAggregator.GetEvent <SaveSpectrumAsEvent>().Publish(sfd.FileName); } }
/// <summary> /// OnOpen opens the OpenFileDialog and returns the /// results by firing an OpenSpectrumEvent. /// </summary> private void OnOpen() { //Create an OpenFileDialog and set it up OpenFileDialog ofd = new OpenFileDialog(); ofd.AddExtension = true; ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.Filter = SpectrumExtension.ToString(SpectrumType.R3D, SpectrumType.TXT); ofd.Multiselect = false; ofd.Title = Strings.OpenSHArKFile; ofd.ValidateNames = true; //Open the Dialog and get the result Nullable <Boolean> result = ofd.ShowDialog(); //If the user clicked OK, open the file by firing //the OpenSpectrumEvent. if (result == true) { this._eventAggregator.GetEvent <OpenSpectrumEvent>().Publish(ofd.FileName); } }