From 4489a91eb7b045ee8dda54c820e0991fbca6f759 Mon Sep 17 00:00:00 2001 From: Colin Date: Sun, 29 Sep 2019 19:38:56 +0100 Subject: [PATCH] Code inspections --- .../Properties/Resources.Designer.cs | 27 +++++++++++++++++++ Meade.net.Telescope/Properties/Resources.resx | 9 +++++++ Meade.net.Telescope/Telescope.cs | 15 ++++++----- Meade.net/ClassFactory.cs | 4 +-- Meade.net/SetupDialogForm.cs | 6 +++++ 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Meade.net.Telescope/Properties/Resources.Designer.cs b/Meade.net.Telescope/Properties/Resources.Designer.cs index 7df2b0c..659e1a1 100644 --- a/Meade.net.Telescope/Properties/Resources.Designer.cs +++ b/Meade.net.Telescope/Properties/Resources.Designer.cs @@ -79,5 +79,32 @@ namespace ASCOM.Meade.net.Properties { return ((System.Drawing.Icon)(obj)); } } + + /// + /// Looks up a localized string similar to Site out of range. + /// + internal static string Telescope_GetSiteName_Site_out_of_range { + get { + return ResourceManager.GetString("Telescope_GetSiteName_Site_out_of_range", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Site cannot be higher than 4. + /// + internal static string Telescope_SelectSite_Site_cannot_be_higher_than_4 { + get { + return ResourceManager.GetString("Telescope_SelectSite_Site_cannot_be_higher_than_4", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Site cannot be lower than 1. + /// + internal static string Telescope_SelectSite_Site_cannot_be_lower_than_1 { + get { + return ResourceManager.GetString("Telescope_SelectSite_Site_cannot_be_lower_than_1", resourceCulture); + } + } } } diff --git a/Meade.net.Telescope/Properties/Resources.resx b/Meade.net.Telescope/Properties/Resources.resx index e522d9e..7c00377 100644 --- a/Meade.net.Telescope/Properties/Resources.resx +++ b/Meade.net.Telescope/Properties/Resources.resx @@ -124,4 +124,13 @@ ..\ASCOM.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Site cannot be lower than 1 + + + Site cannot be higher than 4 + + + Site out of range + \ No newline at end of file diff --git a/Meade.net.Telescope/Telescope.cs b/Meade.net.Telescope/Telescope.cs index d98a724..406cb34 100644 --- a/Meade.net.Telescope/Telescope.cs +++ b/Meade.net.Telescope/Telescope.cs @@ -9,6 +9,7 @@ using System.Collections; using System.Globalization; using System.Reflection; using ASCOM.Meade.net.AstroMaths; +using ASCOM.Meade.net.Properties; using ASCOM.Meade.net.Wrapper; using ASCOM.Utilities.Interfaces; @@ -536,9 +537,9 @@ namespace ASCOM.Meade.net CheckConnected("SelectSite"); if (site < 1) - throw new ArgumentOutOfRangeException(nameof(site),site,"Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site),site,Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); else if (site > 4) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); _sharedResourcesWrapper.SendBlind($":W{site}#"); //:W# @@ -551,9 +552,9 @@ namespace ASCOM.Meade.net CheckConnected("SetSiteName"); if (site < 1) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); else if (site > 4) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); string command = String.Empty; switch (site) @@ -605,9 +606,9 @@ namespace ASCOM.Meade.net CheckConnected("GetSiteName"); if (site < 1) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be lower than 1"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_lower_than_1); else if (site > 4) - throw new ArgumentOutOfRangeException(nameof(site), site, "Site cannot be higher than 4"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_SelectSite_Site_cannot_be_higher_than_4); switch (site) { @@ -633,7 +634,7 @@ namespace ASCOM.Meade.net //A ‘#’ terminated string with the name of the requested site. } - throw new ArgumentOutOfRangeException(nameof(site), site, "Site out of range"); + throw new ArgumentOutOfRangeException(nameof(site), site, Resources.Telescope_GetSiteName_Site_out_of_range); } public string Description diff --git a/Meade.net/ClassFactory.cs b/Meade.net/ClassFactory.cs index a02a47a..4626a2f 100644 --- a/Meade.net/ClassFactory.cs +++ b/Meade.net/ClassFactory.cs @@ -113,7 +113,7 @@ namespace ASCOM.Meade.net private Guid _mClassId; private readonly ArrayList _mInterfaceTypes; private uint _mCookie; - private readonly string _mProgid; + //private readonly string _mProgid; public ClassFactory(Type type) { @@ -122,7 +122,7 @@ namespace ASCOM.Meade.net _mClassType = type; //PWGS Get the ProgID from the MetaData - _mProgid = Marshal.GenerateProgIdForType(type); + //_mProgid = Marshal.GenerateProgIdForType(type); _mClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)] ClassContext = (uint)Clsctx.ClsctxLocalServer; // Default Flags = (uint)Regcls.RegclsMultipleuse | // Default diff --git a/Meade.net/SetupDialogForm.cs b/Meade.net/SetupDialogForm.cs index 290485d..21516b5 100644 --- a/Meade.net/SetupDialogForm.cs +++ b/Meade.net/SetupDialogForm.cs @@ -18,6 +18,12 @@ namespace ASCOM.Meade.net Text = $"{assemblyInfo.Product} Settings ({assemblyInfo.AssemblyVersion})"; } + public sealed override string Text + { + get { return base.Text; } + set { base.Text = value; } + } + private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler { Close();