Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        public SettingsWindow(MainWindow _mainForm)
        {
            InitializeComponent();
            this.mainForm = _mainForm;

            CommPort com = CommPort.Instance;

            int found = 0;

            string[] portList = com.GetAvailablePorts();
            for (int i = 0; i < portList.Length; ++i)
            {
                string name = portList[i];
                comboboxPort.Items.Add(name);
                if (name == Settings.Port.PortName)
                {
                    found = i;
                }
            }
            if (portList.Length > 0)
            {
                comboboxPort.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)
            {
                comboboxBaudRate.Items.Add(baudRates[i].ToString());
                if (baudRates[i] == Settings.Port.BaudRate)
                {
                    found = i;
                }
            }
            comboboxBaudRate.SelectedIndex = found;

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

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

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

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

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

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

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

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

            checkboxHexOutput.Checked           = Settings.Option.HexOutput;
            checkboxLocalEcho.Checked           = Settings.Option.LocalEcho;
            checkboxStayOnTop.Checked           = Settings.Option.StayOnTop;
            checkboxFilterCaseSensitive.Checked = Settings.Option.FilterUseCase;

            textboxLogFileLocation.Text = Settings.Option.LogFileLocation;
        }
Esempio n. 3
0
        public SettingForm()
        {
            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;
        }
Esempio n. 4
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;
        }