Beispiel #1
0
        public void ConnectScope_Click(object sender, EventArgs e)
        {
            if (!platformInstalled || !ConnectScope.Enabled)
            {
                return;
            }

            if (telescopeConnected)
            {
                scope.Connected = false;
                scope.Dispose();
                scope = null;
                telescopeConnected = false;
                SetControlEnableState(false);
                ConnectScope.Text   = Language.GetLocalizedText(386, "Connect");
                telescopeGroup.Text = Language.GetLocalizedText(389, "Telescope Control - Disconnected");
                Choose.Enabled      = true;
            }
            else
            {
                if (string.IsNullOrEmpty(Properties.Settings.Default.TelescopeID))
                {
                    ChooseScope();
                }

                if (!string.IsNullOrEmpty(Properties.Settings.Default.TelescopeID))
                {
                    try
                    {
                        scope              = new AscomTelescope(Properties.Settings.Default.TelescopeID);
                        scope.Connected    = true;
                        telescopeConnected = true;
                        SetControlEnableState(true);
                        ConnectScope.Text   = Language.GetLocalizedText(390, "Disconnect");
                        telescopeGroup.Text = Language.GetLocalizedText(391, "Telescope Control - Connected");
                        Choose.Enabled      = false;
                    }
                    catch
                    {
                        MessageBox.Show(Language.GetLocalizedText(392, "The telescope failed to connect. Please ensure the correct telescope is chosen, and that its settings are correct."), Language.GetLocalizedText(393, "Telescope control"));
                    }
                }
                else
                {
                    MessageBox.Show(Language.GetLocalizedText(394, "Before you can connect, you need to choose a telescope."), Language.GetLocalizedText(393, "Telescope control"));
                }
            }
        }