private void ConnectForm_Load(object sender, EventArgs e) { ArrayList DeviceTypes = new ArrayList(); cmbDeviceType.SelectedIndexChanged += new EventHandler(cmbDeviceType_SelectedIndexChanged); // Add an event handler for devicetype combo box this.Resize += new EventHandler(ConnectForm_Resize); // Add an event handler for form resize. try { Util = new ASCOM.Utilities.Util(); // Get the currently define device types ASCOM.Utilities.Profile Profile = new ASCOM.Utilities.Profile(); DeviceTypes = Profile.RegisteredDeviceTypes; Profile.Dispose(); DefaultDevices = new SortedList <string, string>(); // Initialise the sorted array of default drivers for each device type foreach (string DeviceType in DeviceTypes) // Populate the sorted array and the UI combo boxwith the default driver values { cmbDeviceType.Items.Add(DeviceType); switch (DeviceType.ToUpperInvariant()) { case "TELESCOPE": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_TELESCOPE); break; case "FOCUSER": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_FOCUSER); break; case "FILTERWHEEL": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_FILTER_WHEEL); break; case "ROTATOR": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_ROTATOR); break; case "DOME": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_DOME); break; case "CAMERA": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_CAMERA); break; case "VIDEO": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_VIDEO); break; case "SWITCH": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_SWITCH); break; case "SAFETYMONITOR": DefaultDevices.Add(DeviceType.ToUpperInvariant(), DEFAULT_DEVICE_SAFETY_MONITOR); break; default: DefaultDevices.Add(DeviceType.ToUpperInvariant(), ""); break; } } CurrentDevice = DEFAULT_DEVICE_TELESCOPE; // Initialise current value variables and UI display CurrentDeviceType = DEFAULT_DEVICE_TYPE; cmbDeviceType.SelectedItem = CurrentDeviceType; txtDevice.Text = CurrentDevice; // Supply an appropriate title for the form depending on the OS and application bitness if (Environment.Is64BitOperatingSystem) // 64bit OS { if (Environment.Is64BitProcess) // 64bit process { this.Text = "Device Connection Tester - 64bit OS - Operating in 64bit mode"; } else // 32bit process { this.Text = "Device Connection Tester - 64bit OS - Operating in 32bit mode"; } } else // 32bit OS { this.Text = "Device Connection Tester - 32bit OS"; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }