Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        public static void Save(string fileName, SpectraFileHeader header, MasterSpectra data)
        {
            using (FileStream fileStr = new FileStream(fileName, FileMode.Create, FileAccess.Write))
                using (DeflateStream deflateStream = new DeflateStream(fileStr, CompressionMode.Compress, true))
                    using (BinaryWriter writer = new BinaryWriter(deflateStream))
                    {
                        writer.Write(SPECTRA_FILE_VERSION);

                        header.WriteTo(writer);

                        if (data != null)
                        {
                            ThreadingHelper.RunTaskWaitAndDoEvents(
                                delegate()
                            {
                                data.WriteTo(writer);
                            },
                                150);
                        }

                        writer.Flush();
                        deflateStream.Flush();
                    }
        }
Ejemplo n.º 3
0
 public static bool IsEmpty(SpectraFileHeader compareTo)
 {
     return(Empty.Equals(compareTo));
 }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
0
 public static bool IsEmpty(SpectraFileHeader compareTo)
 {
     return Empty.Equals(compareTo);
 }
Ejemplo n.º 6
0
        public static void Save(string fileName, SpectraFileHeader header, MasterSpectra data)
        {
            using (FileStream fileStr = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            using (DeflateStream deflateStream = new DeflateStream(fileStr, CompressionMode.Compress, true))
            using (BinaryWriter writer = new BinaryWriter(deflateStream))
            {
                writer.Write(SPECTRA_FILE_VERSION);

                header.WriteTo(writer);

                if (data != null)
                {
                    ThreadingHelper.RunTaskWaitAndDoEvents(
                        delegate()
                            {
                                data.WriteTo(writer);
                            },
                            150);
                }

                writer.Flush();
                deflateStream.Flush();
            }
        }
Ejemplo n.º 7
0
        public SpectraFileHeader GetSpectraFileHeader()
        {
            var rv = new SpectraFileHeader()
            {
                PathToVideoFile = m_VideoController.CurrentVideoFileName,
                Width = TangraContext.Current.FrameWidth,
                Height = TangraContext.Current.FrameHeight,
                BitPix = m_VideoController.VideoBitPix,
                DataAav16NormVal = m_VideoController.VideoAav16NormVal,
                SourceInfo = string.Format("Video ({0})", m_VideoController.CurrentVideoFileType),
                ObjectName = "",
                Telescope =  "",
                Instrument = "",
                Recorder = "",
                Observer = "",
                RA = float.NaN,
                DEC = float.NaN,
                Longitude = float.NaN,
                Latitude = float.NaN
            };

            VideoFileFormat fileFormat = m_VideoController.GetVideoFileFormat();
            if (fileFormat.IsAAV())
            {
                Dictionary<string, string> tags = m_VideoController.GetVideoFileTags();
                tags.TryGetValue("ObjectName", out rv.ObjectName);
                tags.TryGetValue("Telescope", out rv.Telescope);
                tags.TryGetValue("Instrument", out rv.Instrument);
                tags.TryGetValue("Recorder", out rv.Recorder);
                tags.TryGetValue("Observer", out rv.Observer);

                string ra, dec, lng, lat;
                tags.TryGetValue("RA", out ra);
                tags.TryGetValue("DEC", out dec);
                tags.TryGetValue("Longitude", out lng);
                tags.TryGetValue("Latitude", out lat);

                if (!string.IsNullOrEmpty(ra)) float.TryParse(ra, NumberStyles.Float, CultureInfo.InvariantCulture, out rv.RA);
                if (!string.IsNullOrEmpty(dec)) float.TryParse(ra, NumberStyles.Float, CultureInfo.InvariantCulture, out rv.DEC);
                if (!string.IsNullOrEmpty(lng)) float.TryParse(ra, NumberStyles.Float, CultureInfo.InvariantCulture, out rv.Longitude);
                if (!string.IsNullOrEmpty(lat)) float.TryParse(ra, NumberStyles.Float, CultureInfo.InvariantCulture, out rv.Latitude);
            }

            return rv;
        }