private void SelectSerialPortByDeviceId(string deviceId)
 {
     SelectedSerialPort = SerialPorts.FirstOrDefault(p => string.Equals(p.DeviceID, deviceId, StringComparison.Ordinal));
     if (SelectedSerialPort == null)
     {
         SelectedSerialPortDeviceId = deviceId;
     }
 }
Exemple #2
0
 private void DeviceRemoved(object sender, DeviceChangeEventArgs e)
 {
     if ((e.Type == INTV.Core.Model.Device.ConnectionType.Serial) && DeviceChange.IsDeviceChangeFromSystem(e.State))
     {
         var removedDevice = SerialPorts.FirstOrDefault(p => p.PortName == e.Name);
         if ((removedDevice != null) && SerialPorts.Remove(removedDevice))
         {
             INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested();
         }
     }
     RaisePropertyChanged("IsPortValid");
 }
Exemple #3
0
        public void Initialize()
        {
            SerialPorts = SerialPortService.GetPortNames();
            if (SettingsService.PortName == null)
            {
                SerialPort = SerialPorts.FirstOrDefault();
            }
            else
            {
                SerialPort = SettingsService.PortName;
            }

            DataBitsItems = new[]
            {
                5, 6, 7, 8
            };
            DataBits = SettingsService.DataBits;

            BaudRateItems = new[]
            {
                9600,
                19200,
                38400,
                57600,
                115200,
                230400,
                460800,
                921600
            };
            BaudRate = SettingsService.BaudRate;

            ParityItems = (Parity[])Enum.GetValues(typeof(Parity));
            Parity      = SettingsService.Parity;

            StopBitsItems = ((StopBits[])Enum.GetValues(typeof(StopBits))).Skip(1);
            StopBits      = SettingsService.StopBits;

            HandshakesItems = (Handshake[])Enum.GetValues(typeof(Handshake));
            Handshake       = SettingsService.Handshake;

            DtrEnabled = SettingsService.DtrEnable;
            RtsEnabled = SettingsService.RtsEnable;

            Encodings = new[]
            {
                "ASCII",
                "UTF-8",
                "Unicode",
                "BigEndianUnicode"
            };
            Encoding = SettingsService.Encoding;

            OutputFormatList = (Format[])Enum.GetValues(typeof(Format));
            OutputFormat     = SettingsService.OutputFormat;

            IntputFormatList = (Format[])Enum.GetValues(typeof(Format));
            InputFormat      = SettingsService.InputFormat;

            PrintInputToScreen = SettingsService.PrintInput;

            LinePushDelay = SettingsService.LinePushDelay;

            NewLine = Regex.Escape(SettingsService.NewLine);
        }