Exemple #1
0
        private void LoadPara()
        {
            this.cb_parity.SelectedIndex   = 2;
            this.cb_stopbits.SelectedIndex = 0;
            this.cb_databits.SelectedIndex = 6;
            string str  = Regedit.ReadDevicePara("Irda", "InUse");
            string str2 = Regedit.ReadDevicePara("Irda", "DeviceType");

            if (str != null)
            {
                this.checkBox1.Checked = str == "1";
            }
            this.comboBox1.Enabled       = this.checkBox1.Checked;
            this.comboBox1.SelectedIndex = (str2 == "1") ? 1 : 0;
            string s    = Regedit.ReadDevicePara("Scale", "Type");
            string str4 = Regedit.ReadDevicePara("Scale", "Port");
            string str5 = Regedit.ReadDevicePara("Scale", "BaudRate");
            string str6 = Regedit.ReadDevicePara("Scale", "DataBits");
            string str7 = Regedit.ReadDevicePara("Scale", "StopBits");
            string str8 = Regedit.ReadDevicePara("Scale", "Parity");

            if (s != null)
            {
                this.cb_scaletype.SelectedIndex = int.Parse(s);
            }
            if (str4 != null)
            {
                this.cb_port.Text = "COM" + str4;
            }
            if (str5 != null)
            {
                this.cb_bautrate.Text = str5;
            }
            if (str6 != null)
            {
                this.cb_databits.Text = str6;
            }
            if (str7 != null)
            {
                this.cb_stopbits.SelectedIndex = int.Parse(str7);
            }
            if (str8 != null)
            {
                this.cb_parity.SelectedIndex = int.Parse(str8);
            }
        }
Exemple #2
0
 private static bool LoadPara()
 {
     try
     {
         string str  = Regedit.ReadDevicePara("Irda", "InUse");
         string str2 = Regedit.ReadDevicePara("Irda", "DeviceType");
         string s    = Regedit.ReadDevicePara("Scale", "Type");
         string str4 = Regedit.ReadDevicePara("Scale", "Port");
         string str5 = Regedit.ReadDevicePara("Scale", "BaudRate");
         string str6 = Regedit.ReadDevicePara("Scale", "DataBits");
         string str7 = Regedit.ReadDevicePara("Scale", "StopBits");
         string str8 = Regedit.ReadDevicePara("Scale", "Parity");
         if ((((str == null) || (s == null)) || (str4 == null)) || (str5 == null))
         {
             MessageBox.Show("请先进行参数设置!");
             return(false);
         }
         if (Irda == null)
         {
             Irda = new IrdaDevice((str2 == "1") ? IrdaType.AC6652 : IrdaType.PCL730);
         }
         if (Scale == null)
         {
             Scale = new ScalesDevice();
         }
         Irda.InUse         = str == "1";
         Irda.IrdaType      = (str2 == "1") ? IrdaType.AC6652 : IrdaType.PCL730;
         Scale.TypeOfScale  = (ScaleType)int.Parse(s);
         Scale.COM_Port     = "COM" + str4 + ":";
         Scale.COM_BautRate = int.Parse(str5);
         Scale.COM_DataBits = int.Parse(str6);
         Scale.COM_StopBits = (CommBase.StopBits) int.Parse(str7);
         Scale.COM_Parity   = (CommBase.Parity) int.Parse(str8);
         return(true);
     }
     catch (Exception exception)
     {
         MessageBox.Show("加载或设置参数时出错!\r\n" + exception.ToString());
         return(false);
     }
 }