Beispiel #1
0
        public void RefreshDeviceList()
        {
            MeadowSettings settings = new MeadowSettings(Globals.SettingsFilePath);

            Devices.Items.Clear();
            Devices.Items.Add(new SerialDevice {
                Caption = "Select Target Device Port"
            });
            Devices.SelectedIndex = 0;

            var index    = 1;
            var captions = MeadowDeviceManager.GetSerialDeviceCaptions();

            foreach (var c in captions.Distinct())
            {
                var port = Regex.Match(c, @"(?<=\().+?(?=\))").Value;
                Devices.Items.Add(new SerialDevice()
                {
                    Caption = c,
                    Port    = port
                });

                if (port == settings.DeviceTarget)
                {
                    Devices.SelectedIndex = index;
                }
                index++;
            }
        }