From 2cc27788c8ff072382de8c65612f7b1ed1195c99 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 25 Aug 2019 19:45:54 +0100 Subject: [PATCH] Added feature where setup dialog controls are disabled when the telescope or focuser is attached --- Meade.net/SetupDialogForm.cs | 16 +++++++++++++++- Meade.net/SharedResources.cs | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 52bd2d5..6815a09 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -116,5 +115,20 @@ namespace ASCOM.Meade.net { UpdateOKButton(); } + + public void SetReadOnlyMode() + { + foreach (Control control in Controls) + { + control.Enabled = false; + } + + cmdCancel.Enabled = true; + //cmdOK.Enabled = false; + //comboBoxComPort.Enabled = false; + //chkTrace.Enabled = false; + //txtGuideRate.Enabled = false; + //cboPrecision.Enabled = false; + } } } \ No newline at end of file diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index cd5209f..8ed30b9 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -15,6 +15,7 @@ // using System; using System.Collections.Generic; +using System.Linq; using ASCOM.Utilities; namespace ASCOM.Meade.net @@ -226,7 +227,12 @@ namespace ASCOM.Meade.net using (SetupDialogForm f = new SetupDialogForm()) { f.SetProfile(profileProperties); - + + if (IsConnected()) + { + f.SetReadOnlyMode(); + } + var result = f.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { @@ -332,6 +338,17 @@ namespace ASCOM.Meade.net } } + public static bool IsConnected() + { + foreach (var device in _connectedDevices) + { + if (device.Value.Count > 0) + return true; + } + + return false; + } + public static bool IsConnected(string deviceId) { if (_connectedDevices.ContainsKey(deviceId))