コード例 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var filter = ConfigurationManager.AppSettings["PipeNameFilter"];
            var files  = Directory.GetFiles(@"\\.\pipe\").Where(x => Regex.IsMatch(x, filter) == true);

            namedPipeComboBox.Items.AddRange(files.ToArray());
            serialPortComboBox.Items.AddRange(SerialPort.GetPortNames());
            parityComboBox.Items.AddRange(Enum.GetNames(typeof(Parity)));
            stopBitsComboBox.Items.AddRange(Enum.GetNames(typeof(StopBits)));
            if (namedPipeComboBox.Items.Count > 0)
            {
                namedPipeComboBox.SelectedIndex = 0;
            }
            if (serialPortComboBox.Items.Count > 0)
            {
                serialPortComboBox.SelectedIndex = 0;
            }
            baudRateComboBox.SelectedIndex = 10;
            parityComboBox.SelectedIndex   = 0;
            dataBitsComboBox.SelectedIndex = 3;
            stopBitsComboBox.SelectedIndex = 1;

            var rtbAppender = new RichTextBoxAppender {
                RichTextBox = richTextBox1
            };

            log4net.Config.BasicConfigurator.Configure(rtbAppender);
            rtbAppender.Layout = new PatternLayout("%-5p %d{HH:mm:ss,fff} %-22.22c{1} %-18.18M - %m%n");
        }
コード例 #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            namedPipeComboBox.Items.AddRange(Directory.GetFiles(@"\\.\pipe\"));
            serialPortComboBox.Items.AddRange(SerialPort.GetPortNames());
            parityComboBox.Items.AddRange(Enum.GetNames(typeof(Parity)));
            stopBitsComboBox.Items.AddRange(Enum.GetNames(typeof(StopBits)));
            if (namedPipeComboBox.Items.Count > 0)
            {
                namedPipeComboBox.SelectedIndex = 0;
            }
            if (serialPortComboBox.Items.Count > 0)
            {
                serialPortComboBox.SelectedIndex = 0;
            }
            baudRateComboBox.SelectedIndex = 10;
            parityComboBox.SelectedIndex   = 0;
            dataBitsComboBox.SelectedIndex = 3;
            stopBitsComboBox.SelectedIndex = 1;

            var rtbAppender = new RichTextBoxAppender {
                RichTextBox = richTextBox1
            };

            log4net.Config.BasicConfigurator.Configure(rtbAppender);
            rtbAppender.Layout = new PatternLayout("%-5p %d{HH:mm:ss,fff} %-22.22c{1} %-18.18M - %m%n");
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: irtnog/PipeToCom
        private void Form1_Load (object sender, EventArgs e)
        {
            namedPipeComboBox.Items.AddRange(Directory.GetFiles(@"\\.\pipe\"));
            serialPortComboBox.Items.AddRange(SerialPort.GetPortNames());
            parityComboBox.Items.AddRange(Enum.GetNames(typeof(Parity)));
            stopBitsComboBox.Items.AddRange(Enum.GetNames(typeof(StopBits)));
            if (namedPipeComboBox.Items.Count > 0) namedPipeComboBox.SelectedIndex = 0;
            if (serialPortComboBox.Items.Count > 0) serialPortComboBox.SelectedIndex = 0;
            baudRateComboBox.SelectedIndex = 10;
            parityComboBox.SelectedIndex = 0;
            dataBitsComboBox.SelectedIndex = 3;
            stopBitsComboBox.SelectedIndex = 1;

            var rtbAppender = new RichTextBoxAppender { RichTextBox = richTextBox1 };
            log4net.Config.BasicConfigurator.Configure(rtbAppender);
            rtbAppender.Layout = new PatternLayout("%-5p %d{HH:mm:ss,fff} %-22.22c{1} %-18.18M - %m%n");
        }