From dc68bb0b4ca0f3289bc8935e5944cc02b9a00228 Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Thu, 28 Apr 2022 23:55:35 +0100 Subject: [PATCH] Added Focal Length property to telescope setup screen --- .../TelescopeUnitTests.cs | 14 +- Meade.net.Telescope/Telescope.cs | 72 +++---- .../SharedResourcesUnitTests.cs | 21 ++ Meade.net.focuser/Focuser.cs | 10 +- Meade.net/MeadeTelescopeBase.cs | 79 +++---- Meade.net/ProfileProperties.cs | 1 + Meade.net/Properties/Resources.Designer.cs | 9 + Meade.net/Properties/Resources.resx | 3 + Meade.net/SetupDialogForm.cs | 21 +- Meade.net/SetupDialogForm.designer.cs | 25 +++ Meade.net/SetupDialogForm.resx | 203 ++++++++++++------ Meade.net/SharedResources.cs | 4 + 12 files changed, 313 insertions(+), 149 deletions(-) diff --git a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs index a088691..9cc12d8 100644 --- a/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs +++ b/Meade.net.Telescope.UnitTests/TelescopeUnitTests.cs @@ -84,7 +84,8 @@ namespace Meade.net.Telescope.UnitTests SendDateTime = false, ParkedBehaviour = ParkedBehaviour.NoCoordinates, ParkedAlt = 0, - ParkedAz = 180 + ParkedAz = 180, + FocalLength = 2000 }; _utilMock = new Mock(); @@ -1429,16 +1430,11 @@ namespace Meade.net.Telescope.UnitTests } [Test] - public void FocalLength_Get_ThenThrowsException() + public void FocalLength_Get_ThenReturnsValue() { - var excpetion = Assert.Throws(() => - { - var result = _telescope.FocalLength; - Assert.Fail($"{result} should not have returned"); - }); + var result = _telescope.FocalLength; - Assert.That(excpetion.Property, Is.EqualTo("FocalLength")); - Assert.That(excpetion.AccessorSet, Is.False); + Assert.That(result, Is.EqualTo(_profileProperties.FocalLength)); } [Test] diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index 902a2a8..26e0428 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -419,12 +419,12 @@ namespace ASCOM.Meade.net { ReadProfile(); - LogMessage("Connected Set", "Connecting to port {0}", ComPort); + LogMessage("Connected Set", "Connecting to port {0}", _ComPort); var connectionInfo = SharedResourcesWrapper.Connect("Serial", DriverId, Tl); try { LogMessage("Connected Set", - $"Connected to port {ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}"); + $"Connected to port {_ComPort}. Product: {SharedResourcesWrapper.ProductName} Version:{SharedResourcesWrapper.FirmwareVersion}"); _userNewerPulseGuiding = IsNewPulseGuidingSupported(); @@ -444,7 +444,7 @@ namespace ASCOM.Meade.net if (CanSetGuideRates) { - SetNewGuideRate(GuideRate, "Connect"); + SetNewGuideRate(_GuideRate, "Connect"); } SetTelescopePrecision("Connect"); @@ -454,28 +454,28 @@ namespace ASCOM.Meade.net SharedResourcesWrapper.TargetDeclination = InvalidParameter; SharedResourcesWrapper.TargetRightAscension = InvalidParameter; - LogMessage("Connected Set", $"SendDateTime: {SendDateTime}"); - if (SendDateTime) + LogMessage("Connected Set", $"SendDateTime: {_SendDateTime}"); + if (_SendDateTime) { if (SharedResourcesWrapper.ProductName == TelescopeList.LX200GPS) { LogMessage("Connected Set", - $"LX200GPS Detecting if daylight savings message on screen: {SendDateTime}"); + $"LX200GPS Detecting if daylight savings message on screen: {_SendDateTime}"); var displayText = Action("Handbox", "readdisplay"); LogMessage("Connected Set", $"Current Handset display: {displayText}"); if (displayText.Contains("Daylight")) { LogMessage("Connected Set", - $"LX200GPS Setting Date time and bypassing settings screens: {SendDateTime}"); + $"LX200GPS Setting Date time and bypassing settings screens: {_SendDateTime}"); BypassHandboxEntryForAutostarII(); } else { LogMessage("Connected Set", - $"LX200GPS Sending current date and time: {SendDateTime}"); + $"LX200GPS Sending current date and time: {_SendDateTime}"); SendCurrentDateTime("Connect"); LogMessage("Connected Set", - $"LX200GPS Attempting manual bypass of prompts: {SendDateTime}"); + $"LX200GPS Attempting manual bypass of prompts: {_SendDateTime}"); ApplySkipAutoStarPrompts("Connect"); } @@ -514,12 +514,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", _ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); + LogMessage("Connected Set", "Disconnecting from port {0}", _ComPort); SharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -528,7 +528,7 @@ namespace ASCOM.Meade.net private void SendCurrentDateTime(string connect) { - if (SendDateTime) + if (_SendDateTime) { UTCDate = _clock.UtcNow; } @@ -570,7 +570,7 @@ namespace ASCOM.Meade.net private void SetTelescopePrecision(string propertyName) { - switch (Precision.ToLower()) + switch (_Precision.ToLower()) { case "high": TelescopePointingPrecision(true); @@ -588,7 +588,7 @@ namespace ASCOM.Meade.net public bool IsNewPulseGuidingSupported() { - switch (GuidingStyle) + switch (_GuidingStyle) { case "guide rate slew": return false; @@ -1501,7 +1501,7 @@ namespace ASCOM.Meade.net get { LogMessage("FocalLength Get", "Not implemented"); - throw new PropertyNotImplementedException("FocalLength", false); + return _focalLength; } } @@ -1528,7 +1528,7 @@ namespace ASCOM.Meade.net //info from RickB says that 15.04107 is a better value for - GuideRate = value; + _GuideRate = value; WriteProfile(); } @@ -1547,8 +1547,8 @@ namespace ASCOM.Meade.net { get { - var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate); - LogMessage("GuideRateDeclination Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + var degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_GuideRate); + LogMessage("GuideRateDeclination Get", $"{_GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1562,8 +1562,8 @@ namespace ASCOM.Meade.net { get { - double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(GuideRate); - LogMessage("GuideRateRightAscension Get", $"{GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); + double degreesPerSecond = ArcSecondPerSecondToDegreesPerSecond(_GuideRate); + LogMessage("GuideRateRightAscension Get", $"{_GuideRate} arc seconds / second = {degreesPerSecond} degrees per second"); return degreesPerSecond; } set @@ -1698,7 +1698,7 @@ namespace ASCOM.Meade.net return; ParkedPosition parkedPosition; - switch (ParkedBehaviour) + switch (_ParkedBehaviour) { case ParkedBehaviour.LastGoodPosition: parkedPosition = new ParkedPosition @@ -1715,12 +1715,12 @@ namespace ASCOM.Meade.net var utcDateTime = UTCDate; var latitude = SiteLatitude; var longitude = SiteLongitude; - var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, ParkedAltAz); + var raDec = _astroMaths.ConvertHozToEq(utcDateTime, latitude, longitude, _ParkedAltAz); parkedPosition = new ParkedPosition { - Altitude = ParkedAltAz.Altitude, - Azimuth = ParkedAltAz.Azimuth, + Altitude = _ParkedAltAz.Altitude, + Azimuth = _ParkedAltAz.Azimuth, RightAscension = raDec.RightAscension, Declination = raDec.Declination, SiteLatitude = latitude, @@ -1975,14 +1975,14 @@ namespace ASCOM.Meade.net } } - public new double SiteElevation + public double SiteElevation { get { CheckConnected("SiteElevation Get"); - LogMessage("SiteElevation", $"Get {base.SiteElevation}"); - return base.SiteElevation; + LogMessage("SiteElevation", $"Get {_SiteElevation}"); + return _SiteElevation; } // ReSharper disable once ValueParameterNotUsed set @@ -1990,14 +1990,14 @@ namespace ASCOM.Meade.net CheckConnected("SiteElevation Set"); LogMessage("SiteElevation", $"Set: {value}"); - if (Math.Abs(value - base.SiteElevation) < 0.1) + if (Math.Abs(value - _SiteElevation) < 0.1) { LogMessage("SiteElevation", "Set: no change detected"); return; } - LogMessage("SiteElevation", $"Set: {value} was {base.SiteElevation}"); - base.SiteElevation = value; + LogMessage("SiteElevation", $"Set: {value} was {_SiteElevation}"); + _SiteElevation = value; UpdateSiteElevation(); } } @@ -2025,7 +2025,7 @@ namespace ASCOM.Meade.net throw new InvalidOperationException("unable to get site latitude from telescope."); } - catch (ParkedException) when (ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) + catch (ParkedException) when (_ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) { return parkedPosition.SiteLatitude; } @@ -2083,7 +2083,7 @@ namespace ASCOM.Meade.net return siteLongitude; } - catch (ParkedException) when (ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) + catch (ParkedException) when (_ParkedBehaviour != ParkedBehaviour.NoCoordinates && SharedResourcesWrapper.ParkedPosition is var parkedPosition) { return parkedPosition.SiteLongitude; } @@ -2354,7 +2354,7 @@ namespace ASCOM.Meade.net private TimeSpan GetTotalSlewingSettleTime() { - return TimeSpan.FromSeconds( SlewSettleTime + ProfileSettleTime ); + return TimeSpan.FromSeconds( SlewSettleTime + _ProfileSettleTime ); } private bool GetSlewing() @@ -2779,7 +2779,7 @@ namespace ASCOM.Meade.net } catch (ParkedException) { - if (ParkedBehaviour == ParkedBehaviour.NoCoordinates) + if (_ParkedBehaviour == ParkedBehaviour.NoCoordinates) throw; return _clock.UtcNow; @@ -2962,10 +2962,10 @@ namespace ASCOM.Meade.net var profileProperties = SharedResourcesWrapper.ReadProfile(); - if (Math.Abs(profileProperties.GuideRateArcSecondsPerSecond - GuideRate) > 0.0000001) + if (Math.Abs(profileProperties.GuideRateArcSecondsPerSecond - _GuideRate) > 0.0000001) { changed = true; - profileProperties.GuideRateArcSecondsPerSecond = GuideRate; + profileProperties.GuideRateArcSecondsPerSecond = _GuideRate; } if (changed) diff --git a/Meade.net.UnitTests/SharedResourcesUnitTests.cs b/Meade.net.UnitTests/SharedResourcesUnitTests.cs index b9becdf..518c59c 100644 --- a/Meade.net.UnitTests/SharedResourcesUnitTests.cs +++ b/Meade.net.UnitTests/SharedResourcesUnitTests.cs @@ -171,6 +171,7 @@ namespace Meade.net.UnitTests string ParkedBehaviourDefault = "No Coordinates"; string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; + string FocalLengthDefault = "2000"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -222,6 +223,10 @@ namespace Meade.net.UnitTests x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) + .Returns(() => FocalLengthDefault); + profileWrapperMock.Setup(x => x.GetValue(DriverId, "Send Date and time on connect", string.Empty, "false")) .Returns(() => SendDateTimeDefault); @@ -295,6 +300,7 @@ namespace Meade.net.UnitTests string ParkedBehaviourDefault = "No Coordinates"; string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; + string FocalLengthDefault = "2000"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -337,6 +343,9 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) + .Returns(() => FocalLengthDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -375,6 +384,7 @@ namespace Meade.net.UnitTests string ParkedBehaviourDefault = "No Coordinates"; string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; + string FocalLengthDefault = "2000"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -416,6 +426,9 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) + .Returns(() => FocalLengthDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -468,6 +481,7 @@ namespace Meade.net.UnitTests string ParkedBehaviourDefault = "No Coordinates"; string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; + string FocalLengthDefault = "2000"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -509,6 +523,9 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) + .Returns(() => FocalLengthDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); @@ -558,6 +575,7 @@ namespace Meade.net.UnitTests string ParkedBehaviourDefault = "No Coordinates"; string ParkedAltDefault = "0"; string ParkedAzimuthDefault = "180"; + string FocalLengthDefault = "2000"; Mock profileWrapperMock = new Mock(); profileWrapperMock.SetupAllProperties(); @@ -598,6 +616,9 @@ namespace Meade.net.UnitTests profileWrapperMock.Setup(x => x.GetValue(DriverId, "Parked Azimuth", string.Empty, ParkedAzimuthDefault)) .Returns(() => ParkedAzimuthDefault); + profileWrapperMock.Setup(x => + x.GetValue(DriverId, "Focal Length (mm)", string.Empty, FocalLengthDefault)) + .Returns(() => FocalLengthDefault); Mock profileFactoryMock = new Mock(); profileFactoryMock.Setup(x => x.Create()).Returns(profileWrapperMock.Object); diff --git a/Meade.net.focuser/Focuser.cs b/Meade.net.focuser/Focuser.cs index d547177..0ef3771 100644 --- a/Meade.net.focuser/Focuser.cs +++ b/Meade.net.focuser/Focuser.cs @@ -176,12 +176,12 @@ namespace ASCOM.Meade.net } catch (Exception ex) { - LogMessage("Connected Set", "Error connecting to port {0} - {1}", ComPort, ex.Message); + LogMessage("Connected Set", "Error connecting to port {0} - {1}", _ComPort, ex.Message); } } else { - LogMessage("Connected Set", "Disconnecting from port {0}", ComPort); + LogMessage("Connected Set", "Disconnecting from port {0}", _ComPort); SharedResourcesWrapper.Disconnect("Serial", DriverId); IsConnected = false; } @@ -295,11 +295,11 @@ namespace ASCOM.Meade.net return; var direction = position > 0; - if (ReverseFocusDirection) + if (_ReverseFocusDirection) direction = !direction; //backlash compensation. - var backlashCompensationSteps = direction ? Math.Abs(BacklashCompensation) : 0; + var backlashCompensationSteps = direction ? Math.Abs(_BacklashCompensation) : 0; var steps = Math.Abs(position) + backlashCompensationSteps; @@ -322,7 +322,7 @@ namespace ASCOM.Meade.net private void DynamicBreaking(bool directionOut) { - if (!UseDynamicBreaking) + if (!_UseDynamicBreaking) return; Tl.LogMessage("Move", "Applying dynamic breaking"); diff --git a/Meade.net/MeadeTelescopeBase.cs b/Meade.net/MeadeTelescopeBase.cs index 5e4c942..a9bfca7 100644 --- a/Meade.net/MeadeTelescopeBase.cs +++ b/Meade.net/MeadeTelescopeBase.cs @@ -20,18 +20,19 @@ namespace ASCOM.Meade.net /// protected static readonly string DriverDescription = "Meade Generic"; - protected static string ComPort; // Variables to hold the currrent device configuration - protected static int BacklashCompensation; - protected static bool ReverseFocusDirection; - protected static bool UseDynamicBreaking; - protected double GuideRate; - protected string Precision; - protected string GuidingStyle; - protected double SiteElevation; - protected short ProfileSettleTime; - protected bool SendDateTime; - protected ParkedBehaviour ParkedBehaviour; - protected HorizonCoordinates ParkedAltAz; + protected static string _ComPort; // Variables to hold the currrent device configuration + protected static int _BacklashCompensation; + protected static bool _ReverseFocusDirection; + protected static bool _UseDynamicBreaking; + protected double _GuideRate; + protected string _Precision; + protected string _GuidingStyle; + protected double _SiteElevation; + protected short _ProfileSettleTime; + protected bool _SendDateTime; + protected ParkedBehaviour _ParkedBehaviour; + protected HorizonCoordinates _ParkedAltAz; + protected double _focalLength; protected readonly ISharedResourcesWrapper SharedResourcesWrapper; @@ -64,37 +65,41 @@ namespace ASCOM.Meade.net { var profileProperties = SharedResourcesWrapper.ReadProfile(); Tl.Enabled = profileProperties.TraceLogger; - ComPort = profileProperties.ComPort; - BacklashCompensation = profileProperties.BacklashCompensation; - ReverseFocusDirection = profileProperties.ReverseFocusDirection; - UseDynamicBreaking = profileProperties.DynamicBreaking; - GuideRate = profileProperties.GuideRateArcSecondsPerSecond; - Precision = profileProperties.Precision; - GuidingStyle = profileProperties.GuidingStyle.ToLower(); - SiteElevation = profileProperties.SiteElevation; - ProfileSettleTime = profileProperties.SettleTime; - SendDateTime = profileProperties.SendDateTime; - ParkedBehaviour = profileProperties.ParkedBehaviour; + _ComPort = profileProperties.ComPort; + _BacklashCompensation = profileProperties.BacklashCompensation; + _ReverseFocusDirection = profileProperties.ReverseFocusDirection; + _UseDynamicBreaking = profileProperties.DynamicBreaking; + _GuideRate = profileProperties.GuideRateArcSecondsPerSecond; + _Precision = profileProperties.Precision; + _GuidingStyle = profileProperties.GuidingStyle.ToLower(); + _SiteElevation = profileProperties.SiteElevation; + _ProfileSettleTime = profileProperties.SettleTime; + _SendDateTime = profileProperties.SendDateTime; + _ParkedBehaviour = profileProperties.ParkedBehaviour; - ParkedAltAz = new HorizonCoordinates + _ParkedAltAz = new HorizonCoordinates { Altitude = profileProperties.ParkedAlt, Azimuth = profileProperties.ParkedAz }; + _focalLength = profileProperties.FocalLength; + LogMessage("ReadProfile", $"Trace logger enabled: {Tl.Enabled}"); - LogMessage("ReadProfile", $"Com Port: {ComPort}"); - LogMessage("ReadProfile", $"Backlash Steps: {BacklashCompensation}"); - LogMessage("ReadProfile", $"Dynamic breaking: {UseDynamicBreaking}"); - LogMessage("ReadProfile", $"Guide Rate: {GuideRate}"); - LogMessage("ReadProfile", $"Precision: {Precision}"); - LogMessage("ReadProfile", $"Guiding Style: {GuidingStyle}"); - LogMessage("ReadProfile", $"Site Elevation: {SiteElevation}"); - LogMessage("ReadProfile", $"Settle Time after slew: {ProfileSettleTime}"); - LogMessage("ReadProfile", $"Send date and time on connect: {SendDateTime}"); - LogMessage("ReadProfile", $"Parked Behaviour: {ParkedBehaviour}"); - LogMessage("ReadProfile", $"Parked Alt: {ParkedAltAz.Altitude}"); - LogMessage("ReadProfile", $"Parked Az: {ParkedAltAz.Azimuth}"); + LogMessage("ReadProfile", $"Com Port: {_ComPort}"); + LogMessage("ReadProfile", $"Backlash Steps: {_BacklashCompensation}"); + LogMessage("ReadProfile", $"Dynamic breaking: {_UseDynamicBreaking}"); + LogMessage("ReadProfile", $"Guide Rate: {_GuideRate}"); + LogMessage("ReadProfile", $"Precision: {_Precision}"); + LogMessage("ReadProfile", $"Guiding Style: {_GuidingStyle}"); + LogMessage("ReadProfile", $"Site Elevation: {_SiteElevation}"); + LogMessage("ReadProfile", $"Settle Time after slew: {_ProfileSettleTime}"); + LogMessage("ReadProfile", $"Send date and time on connect: {_SendDateTime}"); + LogMessage("ReadProfile", $"Parked Behaviour: {_ParkedBehaviour}"); + LogMessage("ReadProfile", $"Parked Alt: {_ParkedAltAz.Altitude}"); + LogMessage("ReadProfile", $"Parked Az: {_ParkedAltAz.Azimuth}"); + LogMessage("ReadProfile", $"Focal Length: {_focalLength}"); + } /// @@ -159,7 +164,7 @@ namespace ASCOM.Meade.net protected void UpdateSiteElevation() { var profileProperties = SharedResourcesWrapper.ReadProfile(); - profileProperties.SiteElevation = SiteElevation; + profileProperties.SiteElevation = _SiteElevation; SharedResourcesWrapper.WriteProfile(profileProperties); } } diff --git a/Meade.net/ProfileProperties.cs b/Meade.net/ProfileProperties.cs index 8cd29c5..0e75d6b 100644 --- a/Meade.net/ProfileProperties.cs +++ b/Meade.net/ProfileProperties.cs @@ -23,5 +23,6 @@ namespace ASCOM.Meade.net public ParkedBehaviour ParkedBehaviour { get; set; } public double ParkedAlt { get; set; } public double ParkedAz { get; set; } + public double FocalLength { get; set; } } } \ No newline at end of file diff --git a/Meade.net/Properties/Resources.Designer.cs b/Meade.net/Properties/Resources.Designer.cs index c735eec..782d4a9 100644 --- a/Meade.net/Properties/Resources.Designer.cs +++ b/Meade.net/Properties/Resources.Designer.cs @@ -144,5 +144,14 @@ namespace ASCOM.Meade.net.Properties { return ResourceManager.GetString("SetupDialogForm_txtElevation_TextChanged_1_Please_enter_only_numbers_", resourceCulture); } } + + /// + /// Looks up a localized string similar to Please enter only numbers.. + /// + internal static string SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_ { + get { + return ResourceManager.GetString("SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_", resourceCulture); + } + } } } diff --git a/Meade.net/Properties/Resources.resx b/Meade.net/Properties/Resources.resx index 9de5db4..355a3f1 100644 --- a/Meade.net/Properties/Resources.resx +++ b/Meade.net/Properties/Resources.resx @@ -147,4 +147,7 @@ Valid are : -register, -unregister and -embedding Please enter only numbers. + + Please enter only numbers. + \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 3b7b039..fd661a4 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -188,6 +188,15 @@ namespace ASCOM.Meade.net txtParkedAz.Text = "180"; } + try + { + txtFocalLength.Text = profileProperties.FocalLength.ToString(CultureInfo.CurrentCulture); + } + catch (Exception) + { + txtFocalLength.Text = "2000"; + } + UpdateParkedItemsEnabled(); } @@ -214,7 +223,8 @@ namespace ASCOM.Meade.net SendDateTime = cbxSendDateTime.Checked, ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription(cboParkedBehaviour.SelectedItem.ToString()), ParkedAlt = double.Parse(txtParkedAlt.Text), - ParkedAz = double.Parse(txtParkedAz.Text) + ParkedAz = double.Parse(txtParkedAz.Text), + FocalLength = double.Parse(txtFocalLength.Text) }; return profileProperties; @@ -320,6 +330,15 @@ namespace ASCOM.Meade.net txtParkedAz.Text = txtParkedAz.Text.Remove(txtParkedAz.Text.Length - 1); } } + + private void txt_FocalLength_TextChanged_1(object sender, EventArgs e) + { + if (System.Text.RegularExpressions.Regex.IsMatch(txtFocalLength.Text, "[^0-9]")) + { + MessageBox.Show(Resources.SetupDialogForm_txtFocalLength_TextChanged_1_Please_enter_only_numbers_); + txtFocalLength.Text = txtFocalLength.Text.Remove(txtFocalLength.Text.Length - 1); + } + } } } diff --git a/Meade.net/SetupDialogForm.designer.cs b/Meade.net/SetupDialogForm.designer.cs index b401604..f710e6a 100644 --- a/Meade.net/SetupDialogForm.designer.cs +++ b/Meade.net/SetupDialogForm.designer.cs @@ -82,6 +82,9 @@ namespace ASCOM.Meade.net this.label24 = new System.Windows.Forms.Label(); this.txtParkedAlt = new System.Windows.Forms.TextBox(); this.txtParkedAz = new System.Windows.Forms.TextBox(); + this.label25 = new System.Windows.Forms.Label(); + this.txtFocalLength = new System.Windows.Forms.TextBox(); + this.label26 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.picASCOM)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.nudSettleTime)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numDatabits)).BeginInit(); @@ -389,10 +392,29 @@ namespace ASCOM.Meade.net this.txtParkedAz.Name = "txtParkedAz"; this.txtParkedAz.TextChanged += new System.EventHandler(this.txtParkedAz_TextChanged); // + // label25 + // + resources.ApplyResources(this.label25, "label25"); + this.label25.Name = "label25"; + // + // txtFocalLength + // + resources.ApplyResources(this.txtFocalLength, "txtFocalLength"); + this.txtFocalLength.Name = "txtFocalLength"; + this.txtFocalLength.TextChanged += new System.EventHandler(this.txt_FocalLength_TextChanged_1); + // + // label26 + // + resources.ApplyResources(this.label26, "label26"); + this.label26.Name = "label26"; + // // SetupDialogForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label26); + this.Controls.Add(this.txtFocalLength); + this.Controls.Add(this.label25); this.Controls.Add(this.txtParkedAz); this.Controls.Add(this.txtParkedAlt); this.Controls.Add(this.label24); @@ -507,5 +529,8 @@ namespace ASCOM.Meade.net private Label label24; private TextBox txtParkedAlt; private TextBox txtParkedAz; + private Label label25; + private TextBox txtFocalLength; + private Label label26; } } \ No newline at end of file diff --git a/Meade.net/SetupDialogForm.resx b/Meade.net/SetupDialogForm.resx index 2e52c51..706338b 100644 --- a/Meade.net/SetupDialogForm.resx +++ b/Meade.net/SetupDialogForm.resx @@ -145,7 +145,7 @@ $this - 47 + 50 Bottom, Right @@ -172,7 +172,7 @@ $this - 46 + 49 12, 9 @@ -196,7 +196,7 @@ $this - 45 + 48 Top, Right @@ -223,7 +223,7 @@ $this - 44 + 47 True @@ -250,7 +250,7 @@ $this - 43 + 46 True @@ -277,7 +277,7 @@ $this - 42 + 45 97, 87 @@ -298,13 +298,13 @@ $this - 41 + 44 True - 290, 169 + 290, 187 61, 13 @@ -325,13 +325,13 @@ $this - 40 + 43 17, 17 - 375, 166 + 375, 184 46, 20 @@ -355,13 +355,13 @@ $this - 39 + 42 True - 427, 169 + 427, 187 122, 13 @@ -382,13 +382,13 @@ $this - 38 + 41 True - 427, 182 + 427, 200 105, 13 @@ -409,13 +409,13 @@ $this - 37 + 40 True - 290, 201 + 290, 219 50, 13 @@ -436,7 +436,7 @@ $this - 36 + 39 Unchanged @@ -448,7 +448,7 @@ High - 375, 198 + 375, 216 90, 21 @@ -466,7 +466,7 @@ $this - 35 + 38 True @@ -475,7 +475,7 @@ NoControl - 290, 228 + 290, 246 67, 13 @@ -496,7 +496,7 @@ $this - 34 + 37 Auto @@ -508,7 +508,7 @@ Pulse guiding - 375, 225 + 375, 243 90, 21 @@ -526,7 +526,7 @@ $this - 33 + 36 True @@ -556,7 +556,7 @@ $this - 32 + 35 True @@ -589,7 +589,7 @@ $this - 31 + 34 375, 302 @@ -613,7 +613,7 @@ $this - 29 + 32 True @@ -643,7 +643,7 @@ $this - 30 + 33 True @@ -673,7 +673,7 @@ $this - 28 + 31 True @@ -706,7 +706,7 @@ $this - 27 + 30 True @@ -733,7 +733,7 @@ $this - 26 + 29 True @@ -760,7 +760,7 @@ $this - 25 + 28 True @@ -793,7 +793,7 @@ $this - 24 + 27 17, 17 @@ -829,13 +829,13 @@ $this - 6 + 9 True - 290, 96 + 290, 114 72, 13 @@ -856,10 +856,10 @@ $this - 23 + 26 - 375, 93 + 375, 111 100, 20 @@ -877,13 +877,13 @@ $this - 22 + 25 True - 481, 96 + 481, 114 38, 13 @@ -904,13 +904,13 @@ $this - 21 + 24 True - 290, 127 + 290, 145 56, 13 @@ -931,10 +931,10 @@ $this - 20 + 23 - 375, 125 + 375, 143 120, 20 @@ -952,13 +952,13 @@ $this - 19 + 22 True - 501, 127 + 501, 145 47, 13 @@ -979,7 +979,7 @@ $this - 18 + 21 True @@ -1006,7 +1006,7 @@ $this - 17 + 20 97, 163 @@ -1027,7 +1027,7 @@ $this - 16 + 19 97, 137 @@ -1048,7 +1048,7 @@ $this - 15 + 18 97, 190 @@ -1069,7 +1069,7 @@ $this - 14 + 17 97, 217 @@ -1090,7 +1090,7 @@ $this - 13 + 16 97, 244 @@ -1111,7 +1111,7 @@ $this - 12 + 15 True @@ -1138,7 +1138,7 @@ $this - 11 + 14 True @@ -1165,7 +1165,7 @@ $this - 10 + 13 True @@ -1192,7 +1192,7 @@ $this - 9 + 12 True @@ -1219,7 +1219,7 @@ $this - 8 + 11 True @@ -1252,7 +1252,7 @@ $this - 7 + 10 No Coordinates @@ -1282,7 +1282,7 @@ $this - 5 + 8 True @@ -1309,7 +1309,7 @@ $this - 4 + 7 True @@ -1336,7 +1336,7 @@ $this - 3 + 6 True @@ -1363,7 +1363,7 @@ $this - 2 + 5 697, 151 @@ -1384,7 +1384,7 @@ $this - 1 + 4 697, 177 @@ -1405,6 +1405,87 @@ $this + 3 + + + True + + + NoControl + + + 290, 90 + + + 69, 13 + + + 48 + + + Focal Length + + + label25 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 375, 87 + + + 100, 20 + + + 49 + + + txtFocalLength + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + True + + + NoControl + + + 481, 90 + + + 23, 13 + + + 50 + + + mm + + + label26 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 diff --git a/Meade.net/SharedResources.cs b/Meade.net/SharedResources.cs index 2e51fdf..f813870 100644 --- a/Meade.net/SharedResources.cs +++ b/Meade.net/SharedResources.cs @@ -198,6 +198,7 @@ namespace ASCOM.Meade.net private const string ParkedBehaviourName = "Parked Behaviour"; private const string ParkedAltName = "Parked Altitude"; private const string ParkedAzimuthName = "Parked Azimuth"; + private const string FocalLengthName = "Focal Length (mm)"; public static void WriteProfile(ProfileProperties profileProperties) { @@ -226,6 +227,7 @@ namespace ASCOM.Meade.net driverProfile.WriteValue(DriverId, ParkedBehaviourName, profileProperties.ParkedBehaviour.GetDescription()); driverProfile.WriteValue(DriverId, ParkedAltName, profileProperties.ParkedAlt.ToString(CultureInfo.InvariantCulture)); driverProfile.WriteValue(DriverId, ParkedAzimuthName, profileProperties.ParkedAz.ToString(CultureInfo.InvariantCulture)); + driverProfile.WriteValue(DriverId, FocalLengthName, profileProperties.FocalLength.ToString(CultureInfo.InvariantCulture)); } } } @@ -250,6 +252,7 @@ namespace ASCOM.Meade.net private const string ParkedBehaviourDefault = "No Coordinates"; private const string ParkedAltDefault = "0"; private const string ParkedAzimuthDefault = "180"; + private const string FocalLengthDefault = "2000"; public static ProfileProperties ReadProfile() { @@ -280,6 +283,7 @@ namespace ASCOM.Meade.net profileProperties.ParkedBehaviour = EnumExtensionMethods.GetValueFromDescription(driverProfile.GetValue(DriverId, ParkedBehaviourName, string.Empty, ParkedBehaviourDefault)); profileProperties.ParkedAlt = double.Parse(driverProfile.GetValue(DriverId, ParkedAltName, string.Empty, ParkedAltDefault), NumberFormatInfo.InvariantInfo); profileProperties.ParkedAz = double.Parse(driverProfile.GetValue(DriverId, ParkedAzimuthName, string.Empty, ParkedAzimuthDefault), NumberFormatInfo.InvariantInfo); + profileProperties.FocalLength = double.Parse(driverProfile.GetValue(DriverId, FocalLengthName, string.Empty, FocalLengthDefault), NumberFormatInfo.InvariantInfo); } return profileProperties;