private void InitializeBarcodeControl() { BarCodeGeneratorBase generator = this.Symbology; if (generator is QRCodeGenerator) { ((QRCodeGenerator)generator).CompactionMode = QRCodeCompactionMode.Byte; } if (generator is Code128Generator) { ((Code128Generator)generator).CharacterSet = Code128Charset.CharsetAuto; ((Code128Generator)generator).AddLeadingZero = false; Config.Width = Config.Height * 2; } BarCodeControl ctrl = new BarCodeControl() { AutoModule = true, HorizontalAlignment = DevExpress.Utils.HorzAlignment.Center, Location = new System.Drawing.Point(3, 3), Name = Guid.NewGuid().ToString(), Padding = new System.Windows.Forms.Padding(10, 2, 10, 0), /*ctrl.Size = new System.Drawing.Size(100, 77);*/ Size = new System.Drawing.Size(Convert.ToInt32(Math.Round(Config.Width)), Convert.ToInt32(Math.Round(Config.Height))), Symbology = this.Symbology, TabIndex = 0, ShowText = false, Text = Config.Content, Dock = DockStyle.Fill }; //ctrl.MouseDoubleClick += Ctrl_MouseDoubleClick; //ctrl.MouseDown += Control_MouseDown; this.Controls.Add(ctrl); }
private void XtraReport1_AfterPrint(object sender, EventArgs e) { foreach (Page page in this.PrintingSystem.Pages) { Size myPageSize = new System.Drawing.Size((int)(page.PageSize.Width / 3), (int)(page.PageSize.Height / 3)); Image im = new Bitmap(myPageSize.Width, myPageSize.Height); BarCodeControl bcc = new BarCodeControl(); bcc.Orientation = DevExpress.XtraPrinting.BarCode.BarCodeOrientation.RotateLeft; Size barcodesize = new Size((int)(myPageSize.Width * 0.1), (int)(myPageSize.Height * 0.8)); bcc.Size = barcodesize; bcc.AutoModule = true; bcc.Text = ht[this.PrintingSystem.Pages.IndexOf(page)].ToString(); DevExpress.XtraPrinting.BarCode.Code93ExtendedGenerator symb = new DevExpress.XtraPrinting.BarCode.Code93ExtendedGenerator(); bcc.Symbology = symb; Bitmap im2 = new Bitmap(barcodesize.Width, barcodesize.Height); bcc.DrawToBitmap(im2, new Rectangle(0, 0, barcodesize.Width, barcodesize.Height)); using (Graphics gr = Graphics.FromImage(im)) { gr.DrawImage(im2, new Rectangle((int)(myPageSize.Width * 0.75), (int)(myPageSize.Height * 0.1), barcodesize.Width, barcodesize.Height)); } page.AssignWatermark(new DevExpress.XtraPrinting.Drawing.PageWatermark() { Image = im, ImageViewMode = DevExpress.XtraPrinting.Drawing.ImageViewMode.Zoom }); } }
private void makeQRcode() { if (qrImageStream == null) { BarCodeControl bcc = new BarCodeControl(); bcc.Symbology = KeepAutomation.Barcode.Symbology.QRCode; bcc.CodeToEncode = URL; bcc.X = 15; bcc.Y = 15; bcc.BottomMargin = 10; bcc.LeftMargin = 10; bcc.RightMargin = 10; bcc.TopMargin = 10; //bcc.DisplayText = true; bcc.ChecksumEnabled = true; bcc.DisplayChecksum = true; bcc.Orientation = KeepAutomation.Barcode.Orientation.Degree0; bcc.BarcodeUnit = KeepAutomation.Barcode.BarcodeUnit.Pixel; bcc.DPI = 72; qrImageStream = new System.IO.MemoryStream(); bcc.SaveAsImage(qrImageStream); } imgQR.Image = Image.FromStream(qrImageStream); }
void barCodecontrol_Completed(object sender, string e) { Deployment.Current.Dispatcher.BeginInvoke(() => { barCodecontrol.StopReadingBarcode(); barCodecontrol.ReadComplete -= barCodecontrol_Completed; PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; PhoneApplicationPage page = null; if (frame != null) { page = frame.Content as PhoneApplicationPage; } if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { page.OrientationChanged -= page_OrientationChanged; grid.Children.Remove(barCodecontrol); barCodecontrol = null; // user hit back button if (e == null) { string js = "var e=document.createEvent('Events');e.initEvent('intel.xdk.device.barcode.scan',true,true);e.success=false;e.codetype='';e.codedata='';document.dispatchEvent(e);"; InvokeCustomScript(new ScriptCallback("eval", new string[] { js }), true); } else { e = e.Replace(System.Environment.NewLine, "\\n"); string format = "QR_CODE"; string js = "var e=document.createEvent('Events');e.initEvent('intel.xdk.device.barcode.scan',true,true);e.success=true;e.codetype='" + format + "';e.codedata='" + e + "';document.dispatchEvent(e);"; InvokeCustomScript(new ScriptCallback("eval", new string[] { js }), true); } } } else { string js = "var e=document.createEvent('Events');e.initEvent('intel.xdk.device.barcode.scan',true,true);e.success=false;e.codetype='';e.codedata='';document.dispatchEvent(e);"; InvokeCustomScript(new ScriptCallback("eval", new string[] { js }), true); } }); }
private bool GeneraEtiArticulo() { bool bPrint = false; try { int iCopy = 1; PupOp pCant = new PupOp(); pCant.ShowDialog(); iCopy = pCant._iCant; if (iCopy < 1) { return(false); } dtsDataFields ds = new dtsDataFields(); DataTable t = ds.Tables.Add("dtFields"); t.Columns.Add("clave3", Type.GetType("System.Byte[]")); t.Columns.Add("DataColumn4", Type.GetType("System.String")); t.Columns.Add("DataColumn5", Type.GetType("System.String")); t.Columns.Add("DataColumn6", Type.GetType("System.String")); t.Columns.Add("DataColumn7", Type.GetType("System.String")); DataRow r; r = t.NewRow(); r["DataColumn4"] = cbbbArticulo.Text.ToString().ToUpper(); r["DataColumn5"] = txtDesc.Text.ToString().ToUpper(); r["DataColumn6"] = Double.Parse(txtCant.Text).ToString("N0"); r["DataColumn7"] = txtUM.Text.ToString(); if (_lsCodBar2 == "1") { BarCodeControl cont = new BarCodeControl(); cont.Type = BarCodeType.Code128; cont.Height = 80; cont.ShowText = false; cont.ShowCheckSumChar = false; cont.Code128SetMode = Code128SetMode.Auto; cont.Data = cbbbArticulo.Text.ToString().ToUpper(); cont.ShowTopText = false; BarCodeGenerator bar = new BarCodeGenerator(cont); Image im = bar.GenerateImage(); r["clave3"] = imageToByteArray(im); } t.Rows.Add(r); ReportDocument rptAgenda = new ReportDocument(); string sArchivo = _lsPath + @"\" + _lsArtPath; rptAgenda.Load(sArchivo); rptAgenda.SetDataSource(t); rptAgenda.PrintOptions.PrinterName = _lsPrinter; //rptAgenda.PrintOptions.PaperOrientation= PaperOrientation.Landscape; rptAgenda.PrintToPrinter(iCopy, true, 0, 0); Cursor = Cursors.Arrow; bPrint = true; } catch (FileNotFoundException ex) { MessageBox.Show("Favor de notificar al administrador del sistema, se cerrará el programa: " + ex, "Error al cargar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (TypeInitializationException ex) { MessageBox.Show("Favor de notificar al administrador del sistema, se cerrará el programa: " + ex, "Error al cargar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (Exception ex) { Cursor = Cursors.Arrow; MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); bPrint = false; } return(bPrint); }
private bool GeneraEtiqueta(string _asRecibo, string _asOrden, string _asFecha, string _asArt, string _asDescrip, double _adCant, string _asUM, string _asUsuario) { bool bPrint = false; try { dtsDataFields ds = new dtsDataFields(); DataTable t = ds.Tables.Add("dtFields"); t.Columns.Add("clave", Type.GetType("System.Byte[]")); t.Columns.Add("clave2", Type.GetType("System.Byte[]")); t.Columns.Add("clave3", Type.GetType("System.Byte[]")); t.Columns.Add("DataColumn1", Type.GetType("System.String")); t.Columns.Add("DataColumn2", Type.GetType("System.String")); t.Columns.Add("DataColumn3", Type.GetType("System.String")); t.Columns.Add("DataColumn4", Type.GetType("System.String")); t.Columns.Add("DataColumn5", Type.GetType("System.String")); t.Columns.Add("DataColumn6", Type.GetType("System.String")); t.Columns.Add("DataColumn7", Type.GetType("System.String")); t.Columns.Add("DataColumn8", Type.GetType("System.String")); DataRow r; r = t.NewRow(); r["DataColumn1"] = _asRecibo; r["DataColumn2"] = _asOrden; r["DataColumn3"] = _asFecha; r["DataColumn4"] = _asArt.ToUpper(); r["DataColumn5"] = _asDescrip; r["DataColumn6"] = _adCant.ToString("N0"); r["DataColumn7"] = _asUM.ToString(); r["DataColumn8"] = _asUsuario.ToString(); BarCodeControl cont = new BarCodeControl(); cont.Type = BarCodeType.Code128; cont.Height = 50; cont.ShowText = false; cont.ShowCheckSumChar = false; cont.Code128SetMode = Code128SetMode.Auto; cont.Data = _asRecibo; cont.ShowTopText = false; BarCodeGenerator bar = new BarCodeGenerator(cont); Image im = bar.GenerateImage(); r["clave"] = imageToByteArray(im); cont.Data = _asOrden.ToString(); Image im2 = bar.GenerateImage(); r["clave2"] = imageToByteArray(im2); cont.Data = _asArt.ToString(); Image im3 = bar.GenerateImage(); r["clave3"] = imageToByteArray(im3); t.Rows.Add(r); ReportDocument rptAgenda = new ReportDocument(); //throw new TypeInitializationException("Error",new Exception()); //throw new FileNotFoundException("Error"); string sDir = _lsPath; string sArchivo = sDir + @"\" + _lsRecPath; rptAgenda.Load(sArchivo); rptAgenda.SetDataSource(t); //PrintDialog dialog = new PrintDialog(); //DialogResult result = dialog.ShowDialog(); //if (result == DialogResult.OK) //{ rptAgenda.PrintOptions.PrinterName = _lsPrinter; //rptAgenda.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape; rptAgenda.PrintOptions.PaperSource = PaperSource.Auto; rptAgenda.PrintToPrinter(1, true, 1, 1); Cursor = Cursors.Arrow; bPrint = true; } catch (FileNotFoundException ex) { MessageBox.Show("Favor de notificar al administrador del sistema, se cerrará el programa: " + ex, "Error al cargar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (TypeInitializationException ex) { MessageBox.Show("Favor de notificar al administrador del sistema, se cerrará el programa: " + ex, "Error al cargar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } catch (Exception ex) { Cursor = Cursors.Arrow; MessageBox.Show(ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); bPrint = false; } return(bPrint); }
private void InitializeLayout(List <Sys_Layout> sys_Layouts, Control parentControl) { try { DataTable dt = (DataTable)gdb.DataSource; parentControl.Visible = false; parentControl.Controls.Clear(); foreach (Sys_Layout sys_Layout in sys_Layouts.OrderBy(s => s.Layout_Sort)) { Control contain = parentControl; if (!string.IsNullOrEmpty(sys_Layout.Layout_Parent)) { Control[] cks = parentControl.Controls.Find(sys_Layout.Layout_Parent, true); if (cks.Length > 0) { contain = cks[0]; } } contain.ControlAdded += delegate(object sender, ControlEventArgs e) { e.Control.Paint += Layout_SizeChanged; e.Control.Click += Layout_Select; }; switch (sys_Layout.Layout_Type) { case 0: //Query GroupControl qry = new GroupControl(); InitializeControl(qry, sys_Layout); contain.Controls.Add(qry); qry.BringToFront(); //this.QueryControl = qry; break; case 12: //GroupControl GroupControl grp = new GroupControl(); InitializeControl(grp, sys_Layout); contain.Controls.Add(grp); grp.BringToFront(); break; case 14: //PanelControl PanelControl panel = new PanelControl(); InitializeControl(panel, sys_Layout); contain.Controls.Add(panel); panel.BorderStyle = BorderStyles.NoBorder; panel.BringToFront(); break; case 13: SplitterControl OneSpli = new SplitterControl(); OneSpli.Dock = (DockStyle)sys_Layout.Layout_Dock; OneSpli.Name = sys_Layout.Layout_Name; contain.Controls.Add(OneSpli); OneSpli.BringToFront(); break; case 1: //Grid case 6: //Submit case 7: //Tree 这三个都只有Grid 是在Grid上覆盖控件实现 Submit 和 Tree 效果 GridControl gd = new GridControl(); InitializeControl(gd, sys_Layout); GridView gv = (GridView)gd.CreateView("GridView"); gv.Name = gd.Name.Replace("d", "v"); gv.OptionsView.ShowGroupPanel = false; gv.OptionsView.ShowFooter = true; gv.OptionsSelection.MultiSelect = true; gd.MainView = gv; contain.Controls.Add(gd); gd.BringToFront(); break; case 9: //TabPage TabEx ntabs = new TabEx(); InitializeControl(ntabs, sys_Layout); ntabs.BorderStyle = BorderStyles.NoBorder; ntabs.BorderStylePage = BorderStyles.NoBorder; contain.Controls.Add(ntabs); ntabs.BringToFront(); break; case 10: DevExpress.XtraTab.XtraTabPage tab = new DevExpress.XtraTab.XtraTabPage(); tab.Name = sys_Layout.Layout_Name; tab.Text = sys_Layout.Layout_Nick; if (contain.GetType() == typeof(TabEx)) { TabEx tabs = (TabEx)contain; tabs.TabPages.Add(tab); } break; case 11: Pagination pagination = new Pagination(); pagination.Name = sys_Layout.Layout_Name; pagination.Dock = (DockStyle)sys_Layout.Layout_Dock; contain.Controls.Add(pagination); pagination.BringToFront(); break; case 2: //Chart ChartControl chart = new ChartControl(); InitializeControl(chart, sys_Layout); chart.BorderOptions.Visibility = DevExpress.Utils.DefaultBoolean.False; contain.Controls.Add(chart); chart.BringToFront(); break; case 3: //text MemoEdit memoEdit = new MemoEdit(); InitializeControl(memoEdit, sys_Layout); memoEdit.BorderStyle = BorderStyles.NoBorder; contain.Controls.Add(memoEdit); memoEdit.BringToFront(); break; case 4: //RichText RichEditControl rtf = new RichEditControl(); InitializeControl(rtf, sys_Layout); rtf.BorderStyle = BorderStyles.NoBorder; rtf.ActiveViewType = RichEditViewType.Simple; contain.Controls.Add(rtf); rtf.BringToFront(); break; case 5: //image PictureEdit pictureEdit = new PictureEdit(); InitializeControl(pictureEdit, sys_Layout); pictureEdit.BorderStyle = BorderStyles.NoBorder; pictureEdit.Properties.PictureStoreMode = PictureStoreMode.ByteArray; pictureEdit.Properties.SizeMode = PictureSizeMode.Squeeze; contain.Controls.Add(pictureEdit); pictureEdit.BringToFront(); break; case 8: //BarCode BarCodeControl barCodeControl = new BarCodeControl(); InitializeControl(barCodeControl, sys_Layout); barCodeControl.BorderStyle = BorderStyles.NoBorder; barCodeControl.BackColor = Color.White; barCodeControl.AutoModule = true; barCodeControl.ShowText = false; //QRCodeGenerator DevExpress.XtraPrinting.BarCode.QRCodeGenerator qrCodeGenerator1 = new DevExpress.XtraPrinting.BarCode.QRCodeGenerator(); qrCodeGenerator1.CompactionMode = DevExpress.XtraPrinting.BarCode.QRCodeCompactionMode.Byte; qrCodeGenerator1.ErrorCorrectionLevel = DevExpress.XtraPrinting.BarCode.QRCodeErrorCorrectionLevel.H; qrCodeGenerator1.Version = DevExpress.XtraPrinting.BarCode.QRCodeVersion.Version1; //Code128Generator DevExpress.XtraPrinting.BarCode.Code128Generator code128Generator1 = new DevExpress.XtraPrinting.BarCode.Code128Generator(); //根据长宽比切换二维码 条码显示 if (barCodeControl.Width > barCodeControl.Height * 2) { barCodeControl.Symbology = code128Generator1; } else { barCodeControl.Symbology = qrCodeGenerator1; } contain.Controls.Add(barCodeControl); barCodeControl.BringToFront(); break; default: break; } } parentControl.Visible = true; } catch (Exception ex) { SharedFunc.RaiseError(ex); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.tbxData = new System.Windows.Forms.TextBox(); this.cboBarCodeType = new System.Windows.Forms.ComboBox(); this.btnGenerate = new System.Windows.Forms.Button(); this.printDocument = new System.Drawing.Printing.PrintDocument(); this.btnPrint = new System.Windows.Forms.Button(); this.printDialog = new System.Windows.Forms.PrintDialog(); this.barCodeControl1 = new NBarCodes.Forms.BarCodeControl(); this.SuspendLayout(); // // tbxData // this.tbxData.Location = new System.Drawing.Point(16, 8); this.tbxData.Name = "tbxData"; this.tbxData.Size = new System.Drawing.Size(256, 20); this.tbxData.TabIndex = 0; this.tbxData.Text = "NBarCodes"; // // cboBarCodeType // this.cboBarCodeType.Location = new System.Drawing.Point(16, 40); this.cboBarCodeType.Name = "cboBarCodeType"; this.cboBarCodeType.Size = new System.Drawing.Size(168, 21); this.cboBarCodeType.TabIndex = 1; // // btnGenerate // this.btnGenerate.Location = new System.Drawing.Point(16, 219); this.btnGenerate.Name = "btnGenerate"; this.btnGenerate.Size = new System.Drawing.Size(75, 23); this.btnGenerate.TabIndex = 2; this.btnGenerate.Text = "&OK"; this.btnGenerate.Click += new System.EventHandler(this.btnGenerate_Click); // // printDocument // this.printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument_PrintPage); // // btnPrint // this.btnPrint.Location = new System.Drawing.Point(104, 219); this.btnPrint.Name = "btnPrint"; this.btnPrint.Size = new System.Drawing.Size(75, 23); this.btnPrint.TabIndex = 3; this.btnPrint.Text = "&Print"; this.btnPrint.Click += new System.EventHandler(this.btnPrint_Click); // // printDialog // this.printDialog.Document = this.printDocument; // // barCodeControl1 // this.barCodeControl1.BackColor = System.Drawing.Color.WhiteSmoke; this.barCodeControl1.BarColor = System.Drawing.Color.DimGray; this.barCodeControl1.Data = "NBarCodes"; this.barCodeControl1.Font = new System.Drawing.Font("Verdana", 15F, System.Drawing.FontStyle.Bold); this.barCodeControl1.FontColor = System.Drawing.Color.DarkOliveGreen; this.barCodeControl1.Location = new System.Drawing.Point(16, 91); this.barCodeControl1.Name = "barCodeControl1"; this.barCodeControl1.Size = new System.Drawing.Size(144, 97); this.barCodeControl1.TabIndex = 0; // // BarCodeForm // this.AcceptButton = this.btnGenerate; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(353, 261); this.Controls.Add(this.btnPrint); this.Controls.Add(this.btnGenerate); this.Controls.Add(this.cboBarCodeType); this.Controls.Add(this.tbxData); this.Controls.Add(this.barCodeControl1); this.Name = "BarCodeForm"; this.Text = "BarCode Form"; this.Load += new System.EventHandler(this.BarCodeForm_Load); this.ResumeLayout(false); this.PerformLayout(); }