private void cmdFP_Click(object sender, RoutedEventArgs e) { try { //dynamic outlook = AutomationFactory.GetObject("Outlook.Application"); ////dynamic com = AutomationFactory.CreateObject("Zfpcom.ZekaFP"); ////dynamic zfp = AutomationFactory.CreateObject("Zfpcom.ZekaFP"); ////zfp.Setup(4, 9600, 3, 1000); ////string sdsd = zfp.GetVersion(); ////byte oper = byte.Parse("1"); ////zfp.OpenFiscalBon(oper, "0000", 0, 1); ////if (0 != zfp.errorCode) ////{ //// string err = zfp.GetErrorString(zfp.errorCode, 0); //// MessageBox.Show(err); ////} ////zfp.SellFree("Cooking fat", Convert.ToByte("1"), 5, 3, 0); ////if (0 != zfp.errorCode) ////{ //// string err = zfp.GetErrorString(zfp.errorCode, 0); //// MessageBox.Show(err); ////} ////zfp.Payment(Single.Parse("200"), Convert.ToByte("0"), 0); ////if (0 != zfp.errorCode) ////{ //// string err = zfp.GetErrorString(zfp.errorCode, 0); //// MessageBox.Show(err); ////} ////zfp.CloseFiscalBon(); ////if (0 != zfp.errorCode) ////{ //// string err = zfp.GetErrorString(zfp.errorCode, 0); //// MessageBox.Show(err); ////} //bool isopen = com.Open("COM4"); // string ss = com.Read((char)(3)); //bool isClosed = com.Close(); // dynamic com1 = AutomationFactory.CreateObject("FPRinter"); ////string dg= com1.test(); // com1.OpenPort("COM4", 9600); // //test.PrintLogo(); // //test.TerminateReceipt(false); // com1.PrintText("Test 1..."); // com1.PrintText("Test Silverlight..."); // com1.ClosePort(); //dynamic count = com.GetDeviceCount(); //StringBuilder sb = new StringBuilder(); //SerialPort c = new SerialPort(); //List<dynamic> devices = new List<dynamic>(); //for (int i = 1; i <= 9; i++) //{ // devices.Add("COM" + i); //} //for (int i = 0; i < count; i++) //{ // devices.Add(com.GetDevice(i)); //} //com.device = devices[9]; //com.Open(); //MessageBox.Show(com.GetErrorDescription(com.LastError)); //string buffer = ""; //string tb = ""; //com.WriteLine("dsdsdsdsdsadsad"); //System.Threading.Thread t = new Thread(new ThreadStart(delegate() // { // while (1 == 1) // { // com.Sleep(200); // buffer = com.ReadString(); // if (buffer == "") { com.Close(); return; } // tb += "\r\n" + com.ReadString(); // } //})); //t.Start(); //com.Close(); using (FP test = new FP()) { test.OpenPort("COM4", 9600); //test.PrintLogo(); //test.TerminateReceipt(false); test.PrintText("Test 1..."); test.ClosePort(); } } catch (Exception ex) { if (ex.GetType() == typeof(FPException)) { int err = ((FPException)ex).ErrorCode; MessageBox.Show(ex.Message, "Error " + err.ToString(), MessageBoxButton.OK); } else { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK); } } }