Esempio n. 1
0
        public ModBarCodeFile(FrmMainForm mf)
        {
            //传递主窗体指针
            this.mf = mf;
            //获取计算机名
            computerName = System.Net.Dns.GetHostName().ToString();
            //if (computerName.Length == 0)
            //{
            //    MessageBox.Show("无效计算机名,请检查!");
            //    Application.Exit();
            //}留待后续使用
            if (!IsShareFolderExist())
            {
                MessageBox.Show("共享文件夹不存在,请检查!");
#if !DEBUG
                Environment.Exit(0);
#endif
            }
        }
Esempio n. 2
0
        //窗口加载时执行
        private void SetupPort_Load(object sender, EventArgs e)
        {
            try
            {
                mf = (FrmMainForm)Owner;
            }catch (InvalidCastException ex)
            {
                MessageBox.Show("窗口打开失败!" + ex.Message);
            }
            cbPortName.Items.Clear();                                 //清除所有下拉栏内容
            string[] PortNameItem = SerialPort.GetPortNames();        //获取所有可用端口号
            Array.Sort(PortNameItem, delegate(string lhs, string rhs) //匿名委托
            {
                //长度相等按数值比较
                if (lhs.Length == rhs.Length)
                {
                    return(lhs.CompareTo(rhs));
                }
                //否则按长度比较
                else
                {
                    return(lhs.Length.CompareTo(rhs.Length));
                }
            });
            //端口号赋值
            cbPortName.Items.AddRange(PortNameItem);
            //下拉栏默认显示的值
            int n = cbPortName.Items.IndexOf(mf.Scanner.PortName.ToString());

            cbPortName.SelectedIndex = n == -1 ? 0 : n;
            cbBaudRate.SelectedIndex = cbBaudRate.Items.IndexOf(mf.Scanner.BaudRate.ToString());
            cbDataBits.SelectedIndex = cbDataBits.Items.IndexOf(mf.Scanner.DataBits.ToString());
            cbParity.SelectedIndex   = cbParity.Items.IndexOf(mf.Scanner.Parity.ToString());
            cbStopBits.SelectedIndex = cbStopBits.Items.IndexOf(mf.Scanner.StopBits.ToString());
            //cbHandshake.SelectedIndex = cbHandshake.Items.IndexOf(mf.Scanner.Handshake.ToString());
        }
Esempio n. 3
0
 public ModLogFile(FrmMainForm mf)
 {
     //传递主窗体指针
     this.mf = mf;
 }