public Form2()
        {
            InitializeComponent();

            CommPort com = CommPort.Instance;

            int found = 0;

            string[] portList = com.GetAvailablePorts();
            for (int i = 0; i < portList.Length; ++i)
            {
                string name = portList[i];
                comboBox1.Items.Add(name);
                if (name == Settings.Port.PortName)
                {
                    found = i;
                }
            }
            if (portList.Length > 0)
            {
                comboBox1.SelectedIndex = found;
            }

            Int32[] baudRates =
            {
                100,     300,   600,   1200,   2400,   4800, 9600, 14400, 19200,
                38400, 56000, 57600, 115200, 128000, 256000, 0
            };
            found = 0;
            for (int i = 0; baudRates[i] != 0; ++i)
            {
                comboBox2.Items.Add(baudRates[i].ToString());
                if (baudRates[i] == Settings.Port.BaudRate)
                {
                    found = i;
                }
            }
            comboBox2.SelectedIndex = found;

            comboBox3.Items.Add("5");
            comboBox3.Items.Add("6");
            comboBox3.Items.Add("7");
            comboBox3.Items.Add("8");
            comboBox3.SelectedIndex = Settings.Port.DataBits - 5;

            foreach (string s in Enum.GetNames(typeof(Parity)))
            {
                comboBox4.Items.Add(s);
            }
            comboBox4.SelectedIndex = (int)Settings.Port.Parity;

            foreach (string s in Enum.GetNames(typeof(StopBits)))
            {
                comboBox5.Items.Add(s);
            }
            comboBox5.SelectedIndex = (int)Settings.Port.StopBits;

            foreach (string s in Enum.GetNames(typeof(Handshake)))
            {
                comboBox6.Items.Add(s);
            }
            comboBox6.SelectedIndex = (int)Settings.Port.Handshake;

            switch (Settings.Option.AppendToSend)
            {
            case Settings.Option.AppendType.AppendNothing:
                radioButton1.Checked = true;
                break;

            case Settings.Option.AppendType.AppendCR:
                radioButton2.Checked = true;
                break;

            case Settings.Option.AppendType.AppendLF:
                radioButton3.Checked = true;
                break;

            case Settings.Option.AppendType.AppendCRLF:
                radioButton4.Checked = true;
                break;
            }

            checkBox1.Checked = Settings.Option.HexOutput;
            checkBox2.Checked = Settings.Option.MonoFont;
            checkBox3.Checked = Settings.Option.LocalEcho;
            checkBox4.Checked = Settings.Option.StayOnTop;
            checkBox5.Checked = Settings.Option.FilterUseCase;

            textBox1.Text = Settings.Option.LogFileName;

            //See if any printers are installed
            if (PrinterSettings.InstalledPrinters.Count <= 0)
            {
                MessageBox.Show("Printer not found!");
                Settings.s_printer_name = "";
                return;
            }

            //Get all available printers and add them to the combo box
            foreach (String printer in PrinterSettings.InstalledPrinters)
            {
                cbb_printer.Items.Add(printer.ToString());
            }
            cbb_printer.SelectedIndex = 0;
            //Settings.s_printer_name = cbb_printer.SelectedItem.ToString();
        }
Beispiel #2
0
        public Form2(string inPort, Settings settings, CommPort com)
        {
            InitializeComponent();
            this._com    = com;
            this._inPort = inPort;

            this._settings = settings;
            this.Text      = "Settings for " + this._inPort;

            int found = 0;

            string[] portList = com.GetAvailablePorts();
            for (int i = 0; i < portList.Length; ++i)
            {
                string name = portList[i];
                comboBox1.Items.Add(name);
                if (name == settings.port.PortName)
                {
                    found = i;
                }
            }
            if (portList.Length > 0)
            {
                comboBox1.SelectedIndex = found;
            }

            Int32[] baudRates =
            {
                9600,  14400, 19200,
                38400, 56000, 57600, 115200, 128000, 256000, 0
            };
            found = 0;
            for (int i = 0; baudRates[i] != 0; ++i)
            {
                comboBox2.Items.Add(baudRates[i].ToString());
                if (baudRates[i] == settings.port.BaudRate)
                {
                    found = i;
                }
            }
            comboBox2.SelectedIndex = found;

            comboBox3.Items.Add("5");
            comboBox3.Items.Add("6");
            comboBox3.Items.Add("7");
            comboBox3.Items.Add("8");
            comboBox3.SelectedIndex = settings.port.DataBits - 5;

            foreach (string s in Enum.GetNames(typeof(Parity)))
            {
                comboBox4.Items.Add(s);
            }
            comboBox4.SelectedIndex = (int)settings.port.Parity;

            foreach (string s in Enum.GetNames(typeof(StopBits)))
            {
                comboBox5.Items.Add(s);
            }
            comboBox5.SelectedIndex = (int)settings.port.StopBits;

            foreach (string s in Enum.GetNames(typeof(Handshake)))
            {
                comboBox6.Items.Add(s);
            }
            comboBox6.SelectedIndex = (int)settings.port.Handshake;

            //switch (_settings.option.AppendToSend)
            //    {
            //    case Settings.Option.AppendType.AppendNothing:
            //        radioButton1.Checked = true;
            //        break;
            //    case Settings.Option.AppendType.AppendCR:
            //        radioButton2.Checked = true;
            //        break;
            //    case Settings.Option.AppendType.AppendLF:
            //        radioButton3.Checked = true;
            //        break;
            //    case Settings.Option.AppendType.AppendCRLF:
            //        radioButton4.Checked = true;
            //        break;
            //    }

            //checkBox1.Checked = this._settings.option.HexOutput;
            //checkBox2.Checked = this._settings.option.MonoFont;
            //checkBox3.Checked = this._settings.option.LocalEcho;
            //checkBox4.Checked = this._settings.option.StayOnTop;
            //checkBox5.Checked = this._settings.option.FilterUseCase;

            textBox2.Text = this._settings.option.ReadTimeOut;


            textBox1.Text     = this._settings.option.LogFileName;
            checkBox1.Checked = this._settings.option.Logging;
        }