mirror of
https://bitbucket.org/cjdskunkworks/lynxastrodewcontroller.git
synced 2026-05-03 17:28:52 +00:00
89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using System;
|
|
using System.IO.Ports;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Windows.Forms;
|
|
using ASCOM.LynxAstro.DewController.Properties;
|
|
|
|
namespace ASCOM.LynxAstro.DewController
|
|
{
|
|
|
|
[ComVisible(false)] // Form not registered for COM!
|
|
public partial class SetupDialogForm : Form
|
|
{
|
|
public SetupDialogForm()
|
|
{
|
|
InitializeComponent();
|
|
|
|
var assemblyInfo = new AssemblyInfo();
|
|
|
|
Text = string.Format(Resources.SetupDialogForm_SetupDialogForm__0__Settings___1__, assemblyInfo.Product, assemblyInfo.AssemblyVersion);
|
|
}
|
|
|
|
private void cmdOK_Click(object sender, EventArgs e) // OK button event handler
|
|
{
|
|
|
|
}
|
|
|
|
private void cmdCancel_Click(object sender, EventArgs e) // Cancel button event handler
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void BrowseToAscom(object sender, EventArgs e) // Click on ASCOM logo event handler
|
|
{
|
|
try
|
|
{
|
|
System.Diagnostics.Process.Start("https://ascom-standards.org/");
|
|
}
|
|
catch (System.ComponentModel.Win32Exception noBrowser)
|
|
{
|
|
if (noBrowser.ErrorCode == -2147467259)
|
|
MessageBox.Show(noBrowser.Message);
|
|
}
|
|
catch (System.Exception other)
|
|
{
|
|
MessageBox.Show(other.Message);
|
|
}
|
|
}
|
|
|
|
public void SetProfile(ProfileProperties profileProperties)
|
|
{
|
|
chkTrace.Checked = profileProperties.TraceLogger;
|
|
// set the list of com ports to those that are currently available
|
|
comboBoxComPort.Items.Clear();
|
|
comboBoxComPort.Items.AddRange(SerialPort.GetPortNames().ToArray<object>()); // use System.IO because it's static
|
|
// select the current port if possible
|
|
if (comboBoxComPort.Items.Contains(profileProperties.ComPort))
|
|
{
|
|
comboBoxComPort.SelectedItem = profileProperties.ComPort;
|
|
}
|
|
}
|
|
|
|
public ProfileProperties GetProfile()
|
|
{
|
|
var profileProperties = new ProfileProperties
|
|
{
|
|
TraceLogger = chkTrace.Checked,
|
|
ComPort = comboBoxComPort.SelectedItem.ToString(),
|
|
};
|
|
|
|
return profileProperties;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |