private StiBorderSides ConvertBorderSide(DevExpress.XtraPrinting.BorderSide side) { if (side == DevExpress.XtraPrinting.BorderSide.All) { return(StiBorderSides.All); } if (side == DevExpress.XtraPrinting.BorderSide.None) { return(StiBorderSides.None); } StiBorderSides sides = 0; if ((side & DevExpress.XtraPrinting.BorderSide.Left) > 0) { sides |= StiBorderSides.Left; } if ((side & DevExpress.XtraPrinting.BorderSide.Right) > 0) { sides |= StiBorderSides.Right; } if ((side & DevExpress.XtraPrinting.BorderSide.Top) > 0) { sides |= StiBorderSides.Top; } if ((side & DevExpress.XtraPrinting.BorderSide.Bottom) > 0) { sides |= StiBorderSides.Bottom; } return(sides); }
//绘制标准 条形码。 public void DrawBarCode(DevExpress.XtraPrinting.BrickGraphics g, RptBarCode codeInfo, string barCode, Rectangle realDrawRect) { if (barCode == null || barCode.Length == 0) { return; } DevExpress.XtraPrinting.BorderSide borSide = DevExpress.XtraPrinting.BorderSide.None; Barcode.IBarcode barCodeObj = null; if (codeInfo.CodeType == BarCodeType.Code128) { barCodeObj = new DIYReport.Barcode.Code128(barCode); } else { barCodeObj = new DIYReport.Barcode.Code39(barCode); } string encodedString = barCodeObj.Encoded_Value; if (encodedString == null || encodedString.Length == 0) { g.DrawString("INVALID BAR CODE TEXT", Color.Red, new RectangleF(realDrawRect.X, realDrawRect.Y, realDrawRect.Width, realDrawRect.Height), borSide); } int encodedStringLength = encodedString.Length; float widthOfBarCodeString = 0f; //float wideToNarrowRatio = 1.67f; //float wid = codeInfo.WID * wideToNarrowRatio; float pound = codeInfo.LinePound; if (codeInfo.VertAlign != AlignType.Left) { for (int i = 0; i < encodedStringLength; i++) { //if ( encodedString[i]=='1' ) widthOfBarCodeString += pound; } } float xLeft = 0f; int yTop = 0; g.Font = codeInfo.HeaderFont; SizeF hSize = g.MeasureString(codeInfo.HeaderText); g.Font = codeInfo.FooterFont; SizeF fSize = g.MeasureString(barCode); int headerX = 0; int footerX = 0; if (codeInfo.VertAlign == AlignType.Left) { xLeft = realDrawRect.X + codeInfo.LeftMargin; headerX = realDrawRect.X + codeInfo.LeftMargin; footerX = realDrawRect.X + codeInfo.LeftMargin; } else if (codeInfo.VertAlign == AlignType.Center) { // xLeft = realDrawRect.X + (realDrawRect.Width - widthOfBarCodeString * pound) / 2; xLeft = realDrawRect.X + (realDrawRect.Width - widthOfBarCodeString) / 2; headerX = realDrawRect.X + (realDrawRect.Width - (int)hSize.Width) / 2; footerX = realDrawRect.X + (realDrawRect.Width - (int)fSize.Width) / 2; } else { xLeft = realDrawRect.X + realDrawRect.Width - widthOfBarCodeString * pound - codeInfo.LeftMargin; headerX = realDrawRect.X + realDrawRect.Width - (int)hSize.Width - codeInfo.LeftMargin; footerX = realDrawRect.X + realDrawRect.Width - (int)fSize.Width - codeInfo.LeftMargin; } if (codeInfo.ShowHeader) { yTop = (int)hSize.Height + codeInfo.TopMargin; g.Font = codeInfo.HeaderFont; g.DrawString(codeInfo.HeaderText, Color.Black, new RectangleF(headerX, realDrawRect.Y + codeInfo.TopMargin, realDrawRect.Width, hSize.Height - 4), borSide); } else { yTop = codeInfo.TopMargin; } float px = xLeft; // +realDrawRect.X; for (int i = 0; i < encodedStringLength; i++) { Color c = encodedString[i] == '1' ? Color.Black : Color.White; px += pound; var brick = g.DrawLine(new PointF(px, yTop + realDrawRect.Y), new PointF(px, yTop + realDrawRect.Y + codeInfo.BarCodeHeight), c, pound); brick.Sides = DevExpress.XtraPrinting.BorderSide.None; //x++; } yTop += codeInfo.BarCodeHeight; if (codeInfo.ShowFooter) { //g.BackColor = codeInfo.BackgroundColor ; g.Font = codeInfo.FooterFont; //g.DrawString(codeInfo.BarCode, codeInfo.FooterFont, Brushes.Black, footerX, yTop); var rec = g.DrawString(barCode, codeInfo.ForeColor, new RectangleF(footerX, realDrawRect.Y + yTop, realDrawRect.Width, hSize.Height - 4), borSide); //rec.HorzAlignment = DevExpress.Utils.HorzAlignment.Center; } }
public bool UpdateControlStyle(ref ReportSetting setting) { if (setting.WebbReport == null) { return(false); } WebbReport webbReport = setting.WebbReport; if (!this.StyleName.ToLower().StartsWith("basic")) { if (this._SerializableWatermark != null && setting.WaterMarkOption.UseWaterMark) { setting.WebbReport.Watermark = this._SerializableWatermark.ConvertTo(); } } Band band = webbReport.Bands[BandKind.Detail]; foreach (XRControl xrControl in band.Controls) { if (!(xrControl is WinControlContainer)) { continue; } Control c = (xrControl as WinControlContainer).WinControl; if (setting.TemplateType == TemplateType.PlayList) { if (!(c is GridControl)) { continue; } if (this.ExcontrolStyles != null) { GridView gridView = (c as GridControl).GridView; Font rowFont = gridView.Styles.RowStyle.Font; if (!this.ExcontrolStyles.IsAllStyleFontEdited()) { this.ExcontrolStyles.RowStyle.Font = (Font)rowFont.Clone(); this.ExcontrolStyles.AlternateStyle.Font = (Font)rowFont.Clone(); this.ExcontrolStyles.HeaderStyle.Font = (Font)rowFont.Clone(); } if (!this.ExcontrolStyles.IsFontEdit(this.ExcontrolStyles.SectionStyle.Font)) { this.ExcontrolStyles.SectionStyle.Font = new Font(this.ExcontrolStyles.RowStyle.Font.FontFamily.Name, this.ExcontrolStyles.RowStyle.Font.Size + 2, this.ExcontrolStyles.RowStyle.Font.Style | FontStyle.Bold); } this.ExcontrolStyles.SectionStyle.HorzAlignment = DevExpress.Utils.HorzAlignment.Near; DevExpress.XtraPrinting.BorderSide sides = this.ExcontrolStyles.RowStyle.Sides; if (sides == DevExpress.XtraPrinting.BorderSide.None) { foreach (GridColumn column in gridView.GridInfo.Columns) { if (column.Style.IsEdited()) { column.Style.Sides = DevExpress.XtraPrinting.BorderSide.None; } } } gridView.Styles.ApplyStyle(this.ExcontrolStyles); } return(true); } else if (setting.TemplateType == TemplateType.Group) { if (!(c is GroupingControl)) { continue; } if (this.ExcontrolStyles != null) { GroupView groupView = (c as GroupingControl)._GroupView; Font rowFont = groupView.Styles.RowStyle.Font; if (!this.ExcontrolStyles.IsAllStyleFontEdited()) { this.ExcontrolStyles.RowStyle.Font = (Font)rowFont.Clone(); this.ExcontrolStyles.AlternateStyle.Font = (Font)rowFont.Clone(); this.ExcontrolStyles.HeaderStyle.Font = (Font)rowFont.Clone(); } if (!this.ExcontrolStyles.IsFontEdit(this.ExcontrolStyles.SectionStyle.Font)) { this.ExcontrolStyles.SectionStyle.Font = new Font(this.ExcontrolStyles.RowStyle.Font.FontFamily.Name, this.ExcontrolStyles.RowStyle.Font.Size + 2, this.ExcontrolStyles.RowStyle.Font.Style | FontStyle.Bold); } this.ExcontrolStyles.SectionStyle.HorzAlignment = DevExpress.Utils.HorzAlignment.Near; DevExpress.XtraPrinting.BorderSide sides = this.ExcontrolStyles.RowStyle.Sides; if (sides == DevExpress.XtraPrinting.BorderSide.None) { RemoveSides(groupView.RootGroupInfo); } groupView.Styles.ApplyStyle(this.ExcontrolStyles); } } } return(true); }