private void btnOK_Click(object sender, EventArgs e) { m_ConfirmedDate = null; bool dayConfirmationRequired = (rbJulianDays.Checked || (rbMagnitude.Checked && cbxAtmExtExport.Checked)); if (dayConfirmationRequired) { DateTime firstTimestamp = LCFile.GetTimeForFrame(LCFile.Header.MinFrame); if (firstTimestamp.Year > 1900 && LCFile.Header.TimingType == MeasurementTimingType.EmbeddedTimeForEachFrame) { // No need to confirm the date. This is either an ADV file or an AAV file with time OCR-ed on the flly during the recording or AAV file with NTP timestamp } else { var frm = new frmConfirmDay(); frm.SelectedDay = firstTimestamp; frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog(this) != DialogResult.OK) { return; } DateTime?selectedDate = frm.SelectedDay; if (selectedDate.HasValue) { m_ConfirmedDate = selectedDate.Value; } } } if (Binning && (nudExportStartFromFrame.Value != nudExportStartFromFrame.Minimum || cbxSpacingOptions.SelectedIndex > 0)) { MessageBox.Show(this, "When binning is used 'spacing' and a specific starting frame cannot be used as export options.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxRA.Focus(); return; } if (cbxAtmExtExport.Checked) { try { if (string.IsNullOrWhiteSpace(tbxRA.Text)) { throw new FormatException(); } m_RAHours = AstroConvert.ToRightAcsension(tbxRA.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Right Ascension value (e.g. 23 03 12)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxRA.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxDec.Text)) { throw new FormatException(); } m_DEDeg = AstroConvert.ToDeclination(tbxDec.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Declination value (e.g. +76 13 18)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxDec.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxLatitude.Text)) { throw new FormatException(); } m_Latitude = AstroConvert.ToDeclination(tbxLatitude.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Latitude value (e.g. -33 12 12)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxLatitude.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxLongitude.Text)) { throw new FormatException(); } m_Longitude = AstroConvert.ToDeclination(tbxLongitude.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Longitude value (e.g. -86 09 12)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxLongitude.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxHeightKm.Text)) { throw new FormatException(); } m_HeightKm = double.Parse(tbxHeightKm.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Height value (e.g. 0.150)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxHeightKm.Focus(); return; } var calc = new AtmosphericExtinctionCalculator(m_RAHours, m_DEDeg, m_Longitude, m_Latitude, m_HeightKm); DateTime firstTimestamp = LCFile.GetTimeForFrame(LCFile.Header.MinFrame); if (m_ConfirmedDate != null) { firstTimestamp = m_ConfirmedDate.Value.Date.AddTicks(firstTimestamp.Ticks - firstTimestamp.Date.Ticks); } double zenithAngle = calc.CalculateZenithAngle(firstTimestamp); if (zenithAngle > 90) { MessageBox.Show(this, "The object is below the horizon.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); } var savedSettings = new CoordsAndLocation() { RAHours = m_RAHours, DEDeg = m_DEDeg, LatitudeDeg = m_Latitude, LongitudeDeg = m_Longitude, HeightKM = m_HeightKm }; try { Properties.Settings.Default.AtmExtRememberedConfig = savedSettings.AsSerialized(); Properties.Settings.Default.Save(); } catch { } } // TODO: Confirm object is above horizon DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { m_ConfirmedDate = null; bool dayConfirmationRequired = (rbJulianDays.Checked || (rbMagnitude.Checked && cbxAtmExtExport.Checked)); if (dayConfirmationRequired) { DateTime firstTimestamp = LCFile.GetTimeForFrame(LCFile.Header.MinFrame); if (firstTimestamp.Year > 1900 && LCFile.Header.TimingType == MeasurementTimingType.EmbeddedTimeForEachFrame) { // No need to confirm the date. This is either an ADV file or an AAV file with time OCR-ed on the flly during the recording or AAV file with NTP timestamp } else { var frm = new frmConfirmDay(); frm.SelectedDay = firstTimestamp; frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog(this) != DialogResult.OK) return; DateTime? selectedDate = frm.SelectedDay; if (selectedDate.HasValue) m_ConfirmedDate = selectedDate.Value; } } if (Binning && (nudExportStartFromFrame.Value != nudExportStartFromFrame.Minimum || cbxSpacingOptions.SelectedIndex > 0)) { MessageBox.Show(this, "When binning is used 'spacing' and a specific starting frame cannot be used as export options.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxRA.Focus(); return; } if (cbxAtmExtExport.Checked) { try { if (string.IsNullOrWhiteSpace(tbxRA.Text)) throw new FormatException(); m_RAHours = AstroConvert.ToRightAcsension(tbxRA.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Right Ascension value (e.g. 23 03 12)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxRA.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxDec.Text)) throw new FormatException(); m_DEDeg = AstroConvert.ToDeclination(tbxDec.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Declination value (e.g. +76 13 18)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxDec.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxLatitude.Text)) throw new FormatException(); m_Latitude = AstroConvert.ToDeclination(tbxLatitude.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Latitude value (e.g. -33 12 12)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxLatitude.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxLongitude.Text)) throw new FormatException(); m_Longitude = AstroConvert.ToDeclination(tbxLongitude.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Longitude value (e.g. -86 09 12)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxLongitude.Focus(); return; } try { if (string.IsNullOrWhiteSpace(tbxHeightKm.Text)) throw new FormatException(); m_HeightKm = double.Parse(tbxHeightKm.Text); } catch (FormatException) { MessageBox.Show(this, "Please enter a valid Height value (e.g. 0.150)", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxHeightKm.Focus(); return; } var calc = new AtmosphericExtinctionCalculator(m_RAHours, m_DEDeg, m_Longitude, m_Latitude, m_HeightKm); DateTime firstTimestamp = LCFile.GetTimeForFrame(LCFile.Header.MinFrame); if (m_ConfirmedDate != null) firstTimestamp = m_ConfirmedDate.Value.Date.AddTicks(firstTimestamp.Ticks - firstTimestamp.Date.Ticks); double zenithAngle = calc.CalculateZenithAngle(firstTimestamp); if (zenithAngle > 90) { MessageBox.Show(this, "The object is below the horizon.", "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error); } var savedSettings = new CoordsAndLocation() { RAHours = m_RAHours, DEDeg = m_DEDeg, LatitudeDeg = m_Latitude, LongitudeDeg = m_Longitude, HeightKM = m_HeightKm }; try { Properties.Settings.Default.AtmExtRememberedConfig = savedSettings.AsSerialized(); Properties.Settings.Default.Save(); } catch { } } // TODO: Confirm object is above horizon DialogResult = DialogResult.OK; Close(); }