Beispiel #1
0
 public static void Dispose()
 {
     try
     {
         CloseDevice();
         Scale.Dispose();
         Irda  = null;
         Scale = null;
     }
     catch
     {
     }
 }
Beispiel #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);
     }
 }