private void btnLoadPrintConfig_Click(object sender, RoutedEventArgs e) { try { string errorInfo = string.Empty; if (string.IsNullOrWhiteSpace(configModel.DialogValue)) { MessageBox.Show("请选择配置模板."); return; } printTemplet = XmlHelper.GetPrintTemplet(configModel.DialogValue, out errorInfo); if (!string.IsNullOrWhiteSpace(errorInfo)) { MessageBox.Show(errorInfo); return; } //PES测试 //Dictionary<string,string> Values=new Dictionary<string,string>(); //Values.Add("Hello","41545454"); //Values.Add("World","World"); //PrintHelper.StartPrintForPES(Values, printTemplet.Clone(),"PrintStudioPrintFunction", "PrintStudioDataFunction", cbPrintName.SelectedValue.ToString(), int.Parse(txtQCNumber.Text), int.Parse(txtPrintX.Text), int.Parse(txtPrintY.Text)); //printTemplet.Clone()不行,因为主程序下无PrintFactoryModel的dll。因为Deserialize时,会在主程序下查找对应Model。 PrintFactoryModel p = printTemplet; p.PrintItems.ForEach(item => { item.PrintFunctionName = string.Format("{0}{1}", item.PrintFunctionName, (PrintClientType)(cbPrintType.SelectedItem)); }); if ((PrintClientType)(cbPrintType.SelectedItem) == PrintClientType.CommonPrinter) { PrintHelper.CommonStartPrint(this, p, "PrintStudioPrintFunction", "PrintStudioDataFunction", cbPrintName.SelectedValue.ToString(), int.Parse(txtQCNumber.Text), int.Parse(txtPrintX.Text), int.Parse(txtPrintY.Text)); } else if ((PrintClientType)(cbPrintType.SelectedItem) == PrintClientType.ZebraPrinter) { PrintHelper.ZebraStartPrint(this, p, "PrintStudioPrintFunction", "PrintStudioDataFunction", cbPrintName.SelectedValue.ToString(), int.Parse(txtQCNumber.Text), int.Parse(txtPrintX.Text), int.Parse(txtPrintY.Text)); } else if ((PrintClientType)(cbPrintType.SelectedItem) == PrintClientType.ZebraPrinter600) { PrintHelper.ZebraStartPrint(this, p, "PrintStudioPrintFunction", "PrintStudioDataFunction", cbPrintName.SelectedValue.ToString(), int.Parse(txtQCNumber.Text), int.Parse(txtPrintX.Text), int.Parse(txtPrintY.Text)); } else { PrintHelper.StartPrint(this, p, "PrintStudioPrintFunction", "PrintStudioDataFunction", cbPrintName.SelectedValue.ToString(), int.Parse(txtQCNumber.Text), int.Parse(txtPrintX.Text), int.Parse(txtPrintY.Text)); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }