Beispiel #1
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);
        }