Exemple #1
0
        /// <summary>
        /// настраиваем порт
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            PortOptions options = new PortOptions();

            options.SizeOfReadBuffer  = serialPort.ReadBufferSize;
            options.SizeOfWriteBuffer = serialPort.WriteBufferSize;
            options.BaudRate          = serialPort.BaudRate;
            options.DataBits          = serialPort.DataBits;
            options.Parity            = serialPort.Parity;
            options.StopBits          = serialPort.StopBits;
            options.ComName           = serialPort.PortName;

            if (options.ShowDialog(this) == DialogResult.OK)
            {
                serialPort.ReadBufferSize  = options.SizeOfReadBuffer;
                serialPort.WriteBufferSize = options.SizeOfWriteBuffer;
                serialPort.BaudRate        = options.BaudRate;
                serialPort.DataBits        = options.DataBits;
                serialPort.Parity          = options.Parity;
                serialPort.StopBits        = options.StopBits;
                serialPort.PortName        = options.ComName;
            }
        }
Exemple #2
0
        /// <summary>
        /// настраиваем порт
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            PortOptions options = new PortOptions();

            options.SizeOfReadBuffer = serialPort.ReadBufferSize;
            options.SizeOfWriteBuffer = serialPort.WriteBufferSize;
            options.BaudRate = serialPort.BaudRate;
            options.DataBits = serialPort.DataBits;
            options.Parity = serialPort.Parity;
            options.StopBits = serialPort.StopBits;
            options.ComName = serialPort.PortName;

            if (options.ShowDialog(this) == DialogResult.OK)
            {
                serialPort.ReadBufferSize = options.SizeOfReadBuffer;
                serialPort.WriteBufferSize = options.SizeOfWriteBuffer;
                serialPort.BaudRate = options.BaudRate;
                serialPort.DataBits = options.DataBits;
                serialPort.Parity = options.Parity;
                serialPort.StopBits = options.StopBits;
                serialPort.PortName = options.ComName;
            }
        }