Пример #1
0
        public static SpectraFile Load(string fileName)
        {
            var fileInfo = new FileInfo(fileName);

            using (var inFile = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                using (var deflateStream = new DeflateStream(inFile, CompressionMode.Decompress, true))
                    using (var reader = new BinaryReader(deflateStream))
                    {
                        short version = reader.ReadInt16();
                        if (version > SPECTRA_FILE_VERSION)
                        {
                            MessageBox.Show("This spectra file requires a newer version of Tangra.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(null);
                        }

                        var spectraFile = new SpectraFile
                        {
                            SpectraFileFormatVersion = version,
                            Header = new SpectraFileHeader(reader)
                        };

                        spectraFile.Data = new MasterSpectra(reader);

                        return(spectraFile);
                    }
        }
Пример #2
0
        private void SaveSpectraFile()
        {
            m_SpectroscopyController.ConfigureSaveSpectraFileDialog(saveFileDialog);

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                Update();

                Cursor = Cursors.WaitCursor;
                try
                {
                    m_Header = m_SpectroscopyController.GetSpectraFileHeader();

                    SpectraFile.Save(saveFileDialog.FileName, m_Header, m_Spectra);

                    m_SpectroscopyController.RegisterRecentSpectraFile(saveFileDialog.FileName);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }
Пример #3
0
        public static SpectraFile Load(string fileName)
        {
            var fileInfo = new FileInfo(fileName);

            using (var inFile = new FileStream(fileName, FileMode.Open, FileAccess.Read))
            using (var deflateStream = new DeflateStream(inFile, CompressionMode.Decompress, true))
            using (var reader = new BinaryReader(deflateStream))
            {
                short version = reader.ReadInt16();
                if (version > SPECTRA_FILE_VERSION)
                {
                    MessageBox.Show("This spectra file requires a newer version of Tangra.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return null;
                }

                var spectraFile = new SpectraFile
                {
                    SpectraFileFormatVersion = version,
                    Header = new SpectraFileHeader(reader)
                };

                spectraFile.Data = new MasterSpectra(reader);

                return spectraFile;
            }
        }