public void FinishedLightCurveEventTimeExtraction() { if (m_EventTimesReport != null && !string.IsNullOrEmpty(m_EventTimesReport.Provider)) { m_EventTimesReport.SaveReport(); #if WIN32 if (TangraConfig.Settings.Generic.OWEventTimesExportMode != TangraConfig.OWExportMode.DontExportEventTimes) { if (m_EventTimesReport.NoTimeBaseAvailable) { MessageBox.Show( this, "The results cannot be provided to OccultWatcher because a time base is not available for this light curve and event times cannot be determined.", "Tangra3", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (m_EventTimesReport.TimestampDiscrepencyFlag) { MessageBox.Show( this, "The results cannot be provided to OccultWatcher because the time base is not reliable.", "Tangra3", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { bool export = true; if (TangraConfig.Settings.Generic.OWEventTimesExportMode == TangraConfig.OWExportMode.AskBeforeExportingEventTimes) { export = MessageBox.Show( string.Format("Would you like to make the results provided by {0} available for Occult Watcher's IOTA Reporting Add-in?", m_EventTimesReport.Provider), "Tangra3 - " + m_EventTimesReport.AddinAction, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes; } if (export) OccultWatcherHelper.NotifyOccultWatcherIfInstalled(m_EventTimesReport, this); } } #endif } m_EventTimesReport = null; }
public bool PrepareForLightCurveEventTimeExtraction(string addinName, bool binningOk) { m_EventTimesReport = null; bool lcFileSaved = EnsureLCFileSaved(); if (lcFileSaved) { m_LCFile.Header.LcFile = m_LCFile; if (m_Header.TimingType == MeasurementTimingType.EmbeddedTimeForEachFrame && m_LCFile.Header.HasNonEqualySpacedDataPoints()) { MessageBox.Show( this, "This light curve contains non equally spaced data points. Before you continue make sure that this addin supports that type of light curves.", "Tangra3 - " + addinName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } m_EventTimesReport = new EventTimesReport() { TangraVersion = string.Format("Tangra v{0}", VersionHelper.AssemblyFileVersion), AddinAction = addinName, LcFilePath = m_LCFilePath, VideoFilePath = m_LCFile.Header.PathToVideoFile, SourceInfo = m_LCFile.Header.SourceInfo, TimingType = m_LCFile.Header.TimingType.ToString(), HasEmbeddedTimeStamps = m_LCFile.Footer.ReductionContext.HasEmbeddedTimeStamps, ReductionMethod = m_LCFile.Footer.ReductionContext.ReductionMethod.ToString(), NoiseMethod = m_LCFile.Footer.ReductionContext.NoiseMethod.ToString(), BitPix = m_LCFile.Footer.ReductionContext.BitPix, AveragedFrameHeight = m_LCFile.Footer.AveragedFrameHeight, AveragedFrameWidth = m_LCFile.Footer.AveragedFrameWidth, }; if (m_LCFile.Header.FirstTimedFrameNo == 0 && m_LCFile.Header.LastTimedFrameNo == 0 && m_LCFile.Header.TimingType == MeasurementTimingType.UserEnteredFrameReferences) { m_EventTimesReport.NoTimeBaseAvailable = true; } m_EventTimesReport.TimestampDiscrepencyFlag = m_TimestampDiscrepencyFlag; m_EventTimesReport.CameraName = m_LCFile.Footer.CameraName; if (string.IsNullOrEmpty(m_EventTimesReport.CameraName)) m_EventTimesReport.CameraName = m_LCFile.Footer.InstrumentalDelayConfigName; m_EventTimesReport.RecordedFromUT = m_LCFile.Header.GetVideoRecordStartTimeUT(); m_EventTimesReport.RecordedToUT = m_LCFile.Header.GetVideoRecordEndTimeUT(); m_EventTimesReport.AnalysedFromUT = m_LCFile.Header.GetFirstAnalysedFrameTimeUT(); m_EventTimesReport.AnalysedToUT = m_LCFile.Header.GetLastAnalysedFrameTimeUT(); VideoFileFormat fileFormat = m_LCFile.Header.GetVideoFileFormat(); m_EventTimesReport.VideoFileFormat = fileFormat.ToString(); m_EventTimesReport.VideoFormat = m_LCFile.Header.GetVideoFormat(fileFormat); double duration; string mode; m_LCFile.Header.GetExposureModeAndDuration(m_EventTimesReport.VideoFileFormat, out duration, out mode); m_EventTimesReport.ExposureDuration = duration; m_EventTimesReport.ExposureUnit = mode; m_EventTimesReport.TangraCanApplyInstrumentalDelays = m_LCFile.Header.GetInstrumentalDelaysApplied(m_EventTimesReport.VideoFileFormat); } if (m_LightCurveController.Context.Binning > 1 && !binningOk) { MessageBox.Show(this, "This add-in cannot run when binning is in use.", "Tangra3", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } else return lcFileSaved; }
public static void NotifyOccultWatcherIfInstalled(EventTimesReport report, IWin32Window parentForm) { bool owNotified = false; if (!report.ReportFileSaved || report.ReportFileName == null) return; var usedReports = new List<string>(); try { RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(REGKEY_USED_EVENTS, true); if (registryKey != null) { string[] allValueNames = registryKey.GetValueNames(); foreach (string valName in allValueNames) { string savedReportLocation = Convert.ToString(registryKey.GetValue(valName)); if (File.Exists(savedReportLocation)) usedReports.Add(savedReportLocation); } } } catch (Exception ex) { Trace.WriteLine(ex); } try { RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(REGKEY_INCOMING_EVENTS, true); if (registryKey != null) { var availableList = new List<string>(); string[] allValueNames = registryKey.GetValueNames(); foreach (string valName in allValueNames) { string savedReportLocation = Convert.ToString(registryKey.GetValue(valName)); if (usedReports.IndexOf(savedReportLocation) > -1) { // File already used. We need to delete the value from the incoming events registryKey.DeleteValue(valName); } else { availableList.Add(savedReportLocation); if (report.ReportFileName.Equals(savedReportLocation, StringComparison.InvariantCultureIgnoreCase)) { // File has been saved already and hasn't been used yet. Nothing to do. owNotified = true; } } } if (!owNotified) { availableList.Add(report.ReportFileName); owNotified = true; } for (int i = 0; i < allValueNames.Length; i++) { registryKey.DeleteValue(allValueNames[0], false); } for (int i = 0; i < availableList.Count; i++) { registryKey.SetValue(i.ToString(), availableList[i]); } } } catch (Exception ex) { Trace.WriteLine(ex.GetFullStackTrace()); } finally { if (owNotified) { // TODO: Display additional information about the event such as: Asteroid, Times, ETC MessageBox.Show( parentForm, "The light curve analysis results have been saved and made available for the OccultWatcher IOTA Reporting Add-in.\r\n\r\nRight click in OccultWatcher on the corresponding event and choose 'Report Observation'. Once you have submitted your report press 'Prefill Report File' to pre-populate your report with the information made available by Tangra.", "Tangra3 - " + report.AddinAction, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }