private void btnEditConfiguration_Click(object sender, EventArgs e) { TangraConfig.ScopeRecorderConfiguration entry = cbxSavedConfigurations.SelectedItem as TangraConfig.ScopeRecorderConfiguration; VideoCamera camera = cbxSavedCameras.SelectedItem as VideoCamera; Rectangle plateRect = new Rectangle(0, 0, TangraContext.Current.FrameWidth, TangraContext.Current.FrameHeight); TangraConfig.PersistedPlateConstants pltConst = TangraConfig.Settings.PlateSolve.GetPlateConstants(camera, entry, plateRect); if (entry != null && camera != null) { frmEditConfigName frmNewConfig = new frmEditConfigName(entry, camera, FrameWidth, FrameHeight, pltConst); if (frmNewConfig.ShowDialog(this) == DialogResult.OK) { m_SelectedScopeRecorder = frmNewConfig.Config.Title; if (frmNewConfig.UpdatePlateConstants && frmNewConfig.PltConst != null) { pltConst = frmNewConfig.PltConst; TangraConfig.Settings.PlateSolve.SetPlateConstants(camera, entry, plateRect, pltConst); } ReloadScopeRecorders(); CheckSolvedPlateConstants(camera, entry); } } }
private void btnNewConfig_Click(object sender, EventArgs e) { if (cbxSavedCameras.SelectedItem != null) { VideoCamera camera = cbxSavedCameras.SelectedItem as VideoCamera; frmEditConfigName frmNewConfig = new frmEditConfigName(null, camera, FrameWidth, FrameHeight, null); if (frmNewConfig.ShowDialog(this) == DialogResult.OK) { m_SelectedScopeRecorder = frmNewConfig.Config.Title; TangraConfig.ScopeRecorderConfiguration entry = TangraConfig.Settings.PlateSolve.ScopeRecorders.FirstOrDefault(r => r.Title == m_SelectedScopeRecorder); if (frmNewConfig.PltConst != null) { Rectangle plateRect = new Rectangle(0, 0, TangraContext.Current.FrameWidth, TangraContext.Current.FrameHeight); TangraConfig.PersistedPlateConstants pltConst = new TangraConfig.PersistedPlateConstants(); pltConst.EffectiveFocalLength = frmNewConfig.PltConst.EffectiveFocalLength; pltConst.EffectivePixelWidth = frmNewConfig.PltConst.EffectivePixelWidth; pltConst.EffectivePixelHeight = frmNewConfig.PltConst.EffectivePixelHeight; TangraConfig.Settings.PlateSolve.SetPlateConstants(camera, entry, plateRect, pltConst); TangraConfig.Settings.Save(); } ReloadScopeRecorders(); CheckSolvedPlateConstants(camera, entry); } } else { cbxSavedCameras.Focus(); } }
public frmEditConfigName( TangraConfig.ScopeRecorderConfiguration config, VideoCamera camera, int frameWidth, int frameHeight, TangraConfig.PersistedPlateConstants pltConst) { InitializeComponent(); m_FrameWidth = frameWidth; m_FrameHeight = frameHeight; if (config == null) { config = new TangraConfig.ScopeRecorderConfiguration(camera.Model, frameWidth, frameHeight); tbxConfigName.Enabled = true; m_New = true; Height = 260; pnlSolvedPlateConf.Visible = false; cbxEditConfig.Visible = false; pnlOSDAreaConf.Visible = false; cbxEditOSDArea.Visible = false; } else { tbxConfigName.Enabled = false; Height = 396; pnlSolvedPlateConf.Visible = true; cbxEditConfig.Visible = true; if (pltConst != null) { tbxSolvedCellX.Text = pltConst.EffectivePixelWidth.ToString(); tbxSolvedCellY.Text = pltConst.EffectivePixelHeight.ToString(); tbxSolvedFocalLength.Text = pltConst.EffectiveFocalLength.ToString(); } } cbxAreaType.SelectedIndex = config.IsInclusionArea ? 1 : 0; if (config.IsInclusionArea) { SetOSDDimentions(config.InclusionArea); } else { SetOSDDimentions(config.OSDExclusionArea); } m_Config = config; m_Camera = camera; tbxConfigName.Text = config.Title; m_PltConst = pltConst; }
private void CheckSolvedPlateConstants(VideoCamera camera, TangraConfig.ScopeRecorderConfiguration config) { TangraConfig.PersistedPlateConstants pltCopnst = TangraConfig.Settings.PlateSolve.GetPlateConstants( camera, config, new Rectangle(0, 0, TangraContext.Current.FrameWidth, TangraContext.Current.FrameHeight)); if (pltCopnst == null) { gbxSolved.Visible = false; pnlNotSolved.Visible = true; cbxSolveConstantsNow.Checked = true; cbxSolveConstantsNow.Visible = true; } else { gbxSolved.Visible = true; cbxSolveConstantsNow.Checked = false; pnlNotSolved.Visible = false; tbxSolvedCellX.Text = pltCopnst.EffectivePixelWidth.ToString("0.000"); tbxSolvedCellY.Text = pltCopnst.EffectivePixelHeight.ToString("0.000"); tbxSolvedFocalLength.Text = pltCopnst.EffectiveFocalLength.ToString("0.0"); Rectangle rect = config.IsInclusionArea ? config.InclusionArea : config.OSDExclusionArea; lblConfigAreaInfo.Text = string.Format("{0} Area [({1},{2})-({3},{4})]", config.IsInclusionArea ? "Inclusion" : "Exclusion", rect.Left, rect.Top, rect.Right, rect.Bottom); } pnlEditableConfigSettings.Visible = true; toolTip.SetToolTip(lblLimitingMagnitude, string.Format(" The limiting magnitude when {0}\r\nis used with this configuration", camera.Model)); toolTip.SetToolTip(nudLimitMagnitude, string.Format(" The limiting magnitude when {0}\r\nis used with this configuration", camera.Model)); m_Setting = true; try { nudLimitMagnitude.Value = (decimal)config.LimitingMagnitudes[camera.Model]; m_LimitingMagnitudeChanged = false; cbxFlipVertically.Checked = config.FlipVertically; cbxFlipHorizontally.Checked = config.FlipHorizontally; } finally { m_Setting = false; } }
public frmEditConfigName( TangraConfig.ScopeRecorderConfiguration config, VideoCamera camera, int frameWidth, int frameHeight, TangraConfig.PersistedPlateConstants pltConst) { InitializeComponent(); m_FrameWidth = frameWidth; m_FrameHeight = frameHeight; if (config == null) { config = new TangraConfig.ScopeRecorderConfiguration(camera.Model, frameWidth, frameHeight); tbxConfigName.Enabled = true; m_New = true; Height = 260; pnlSolvedPlateConf.Visible = false; cbxEditConfig.Visible = false; pnlOSDAreaConf.Visible = false; cbxEditOSDArea.Visible = false; } else { tbxConfigName.Enabled = false; Height = 396; pnlSolvedPlateConf.Visible = true; cbxEditConfig.Visible = true; if (pltConst != null) { tbxSolvedCellX.Text = pltConst.EffectivePixelWidth.ToString(); tbxSolvedCellY.Text = pltConst.EffectivePixelHeight.ToString(); tbxSolvedFocalLength.Text = pltConst.EffectiveFocalLength.ToString(); } } cbxAreaType.SelectedIndex = config.IsInclusionArea ? 1 : 0; if (config.IsInclusionArea) SetOSDDimentions(config.InclusionArea); else SetOSDDimentions(config.OSDExclusionArea); m_Config = config; m_Camera = camera; tbxConfigName.Text = config.Title; m_PltConst = pltConst; }
private void btnOK_Click(object sender, EventArgs e) { if (m_New) { if (tbxConfigName.Text.Length == 0) { MessageBox.Show(this, "Specify config name", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxConfigName.Focus(); tbxConfigName.SelectAll(); return; } if (TangraConfig.Settings.PlateSolve.ScopeRecorders.Exists((c) => c.Title == tbxConfigName.Text)) { MessageBox.Show(this, "This name already exists. Specify a different config name", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxConfigName.Focus(); tbxConfigName.SelectAll(); return; } } else if (cbxEditConfig.Checked) { if (tbxSolvedCellX.Text.Length != 0 && tbxSolvedCellY.Text.Length != 0 && tbxSolvedFocalLength.Text.Length != 0) { if (!double.TryParse(tbxSolvedCellX.Text, out m_EffectiveCellX)) { MessageBox.Show(this, "Enter a valid number for Pixel Width", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxSolvedCellX.Focus(); tbxSolvedCellX.SelectAll(); return; } if (!double.TryParse(tbxSolvedCellY.Text, out m_EffectiveCellY)) { MessageBox.Show(this, "Enter a valid number for Pixel Height", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxSolvedCellY.Focus(); tbxSolvedCellY.SelectAll(); return; } if (!double.TryParse(tbxSolvedFocalLength.Text, out m_EffectiveFocalLength)) { MessageBox.Show(this, "Enter a valid number for Focal Length", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxSolvedFocalLength.Focus(); tbxSolvedFocalLength.SelectAll(); return; } if (m_PltConst == null) { m_PltConst = new TangraConfig.PersistedPlateConstants() { CameraModel = m_Camera.Model, ScopeRecoderConfig = tbxConfigName.Text, PlateWidth = m_FrameWidth, PlateHeight = m_FrameHeight }; } m_PltConst.EffectiveFocalLength = m_EffectiveFocalLength; m_PltConst.EffectivePixelWidth = m_EffectiveCellX; m_PltConst.EffectivePixelHeight = m_EffectiveCellY; m_UpdatePlateConstants = true; } else if (tbxSolvedCellX.Text.Length != 0 || tbxSolvedCellY.Text.Length != 0 || tbxSolvedFocalLength.Text.Length != 0) { MessageBox.Show(this, "When manually enterring the effective plate constants all three values must be entered", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (tbxSolvedCellX.Text.Length == 0) { tbxSolvedCellX.Focus(); tbxSolvedCellX.SelectAll(); } else if (tbxSolvedCellY.Text.Length == 0) { tbxSolvedCellY.Focus(); tbxSolvedCellY.SelectAll(); } else if (tbxSolvedFocalLength.Text.Length == 0) { tbxSolvedFocalLength.Focus(); tbxSolvedFocalLength.SelectAll(); } return; } } if (cbxEditOSDArea.Checked) { m_Config.IsInclusionArea = cbxAreaType.SelectedIndex == 1; if (cbxAreaType.SelectedIndex == 1) m_Config.InclusionArea = GetOSDDimentions(); else m_Config.OSDExclusionArea = GetOSDDimentions(); } m_Config.Title = tbxConfigName.Text; if (m_New) TangraConfig.Settings.PlateSolve.ScopeRecorders.Add(m_Config); else { // This will be edited elsewhere } TangraConfig.Settings.Save(); DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { if (m_New) { if (tbxConfigName.Text.Length == 0) { MessageBox.Show(this, "Specify config name", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxConfigName.Focus(); tbxConfigName.SelectAll(); return; } if (TangraConfig.Settings.PlateSolve.ScopeRecorders.Exists((c) => c.Title == tbxConfigName.Text)) { MessageBox.Show(this, "This name already exists. Specify a different config name", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxConfigName.Focus(); tbxConfigName.SelectAll(); return; } } else if (cbxEditConfig.Checked) { if (tbxSolvedCellX.Text.Length != 0 && tbxSolvedCellY.Text.Length != 0 && tbxSolvedFocalLength.Text.Length != 0) { if (!double.TryParse(tbxSolvedCellX.Text, out m_EffectiveCellX)) { MessageBox.Show(this, "Enter a valid number for Pixel Width", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxSolvedCellX.Focus(); tbxSolvedCellX.SelectAll(); return; } if (!double.TryParse(tbxSolvedCellY.Text, out m_EffectiveCellY)) { MessageBox.Show(this, "Enter a valid number for Pixel Height", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxSolvedCellY.Focus(); tbxSolvedCellY.SelectAll(); return; } if (!double.TryParse(tbxSolvedFocalLength.Text, out m_EffectiveFocalLength)) { MessageBox.Show(this, "Enter a valid number for Focal Length", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbxSolvedFocalLength.Focus(); tbxSolvedFocalLength.SelectAll(); return; } if (m_PltConst == null) { m_PltConst = new TangraConfig.PersistedPlateConstants() { CameraModel = m_Camera.Model, ScopeRecoderConfig = tbxConfigName.Text, PlateWidth = m_FrameWidth, PlateHeight = m_FrameHeight }; } m_PltConst.EffectiveFocalLength = m_EffectiveFocalLength; m_PltConst.EffectivePixelWidth = m_EffectiveCellX; m_PltConst.EffectivePixelHeight = m_EffectiveCellY; m_UpdatePlateConstants = true; } else if (tbxSolvedCellX.Text.Length != 0 || tbxSolvedCellY.Text.Length != 0 || tbxSolvedFocalLength.Text.Length != 0) { MessageBox.Show(this, "When manually enterring the effective plate constants all three values must be entered", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (tbxSolvedCellX.Text.Length == 0) { tbxSolvedCellX.Focus(); tbxSolvedCellX.SelectAll(); } else if (tbxSolvedCellY.Text.Length == 0) { tbxSolvedCellY.Focus(); tbxSolvedCellY.SelectAll(); } else if (tbxSolvedFocalLength.Text.Length == 0) { tbxSolvedFocalLength.Focus(); tbxSolvedFocalLength.SelectAll(); } return; } } if (cbxEditOSDArea.Checked) { m_Config.IsInclusionArea = cbxAreaType.SelectedIndex == 1; if (cbxAreaType.SelectedIndex == 1) { m_Config.InclusionArea = GetOSDDimentions(); } else { m_Config.OSDExclusionArea = GetOSDDimentions(); } } m_Config.Title = tbxConfigName.Text; if (m_New) { TangraConfig.Settings.PlateSolve.ScopeRecorders.Add(m_Config); } else { // This will be edited elsewhere } TangraConfig.Settings.Save(); DialogResult = DialogResult.OK; Close(); }