-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetupDialogForm.cs
72 lines (64 loc) · 2.33 KB
/
SetupDialogForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using ASCOM.Utilities;
using ASCOM.camfiZF;
namespace ASCOM.camfiZF
{
[ComVisible(false)] // Form not registered for COM!
public partial class SetupDialogForm : Form
{
TraceLogger tl; // Holder for a reference to the driver's trace logger
public SetupDialogForm(TraceLogger tlDriver)
{
InitializeComponent();
// Save the provided trace logger for use within the setup dialogue
tl = tlDriver;
// Initialise current values of user settings from the ASCOM Profile
InitUI();
}
private void cmdOK_Click(object sender, EventArgs e) // OK button event handler
{
// Place any validation constraint checks here
// Update the state variables with results from the dialogue
Focuser.comPort = (string)comboBoxComPort.SelectedItem;
tl.Enabled = chkTrace.Checked;
}
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("http://ascom-standards.org/");
}
catch (System.ComponentModel.Win32Exception noBrowser)
{
if (noBrowser.ErrorCode == -2147467259)
MessageBox.Show(noBrowser.Message);
}
catch (System.Exception other)
{
MessageBox.Show(other.Message);
}
}
private void InitUI()
{
chkTrace.Checked = tl.Enabled;
// set the list of com ports to those that are currently available
comboBoxComPort.Items.Clear();
comboBoxComPort.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); // use System.IO because it's static
// select the current port if possible
if (comboBoxComPort.Items.Contains(Focuser.comPort))
{
comboBoxComPort.SelectedItem = Focuser.comPort;
}
}
}
}