private void SetReportPageLayout(XmlItem labelParameters, ReportPage page) { float paperWidth = Converter.StringToFloat(labelParameters.GetProp("PaperWidth"), true) * 25.4f; float paperHeight = Converter.StringToFloat(labelParameters.GetProp("PaperHeight"), true) * 25.4f; float leftMargin = Converter.StringToFloat(labelParameters.GetProp("LeftMargin"), true) * 25.4f; float topMargin = Converter.StringToFloat(labelParameters.GetProp("TopMargin"), true) * 25.4f; float labelWidth = Converter.StringToFloat(labelParameters.GetProp("Width"), true) * 25.4f; float labelHeight = Converter.StringToFloat(labelParameters.GetProp("Height"), true) * 25.4f; int rows = (int)Converter.StringToFloat(labelParameters.GetProp("Rows"), true); if (rows == 0) { rows = 1; } int columns = (int)Converter.StringToFloat(labelParameters.GetProp("Columns"), true); if (columns == 0) { columns = 1; } float rowGap = Converter.StringToFloat(labelParameters.GetProp("RowGap"), true) * 25.4f; float columnGap = Converter.StringToFloat(labelParameters.GetProp("ColumnGap"), true) * 25.4f; // setup paper page.Clear(); page.Landscape = labelParameters.GetProp("Landscape") == "true"; page.PaperWidth = paperWidth; page.PaperHeight = paperHeight; page.LeftMargin = leftMargin; page.RightMargin = 0; page.TopMargin = topMargin; page.BottomMargin = 0; // setup columns page.Columns.Count = columns; page.Columns.Width = labelWidth; page.Columns.Positions.Clear(); for (int i = 0; i < columns; i++) { page.Columns.Positions.Add(i * (labelWidth + columnGap)); } // setup data band DataBand band = new DataBand(); page.Bands.Add(band); band.CreateUniqueName(); band.Width = labelWidth * Units.Millimeters; band.Height = labelHeight * Units.Millimeters; // setup row gap (use child band) if (rowGap > 0) { band.Child = new ChildBand(); band.Child.CreateUniqueName(); band.Child.Height = rowGap * Units.Millimeters; } }
public void EditPage() { if (Disabled) { return; } using (Report report = new Report()) { ReportPage page = FPreparedPages.GetPage(PageNo - 1); OverlayBand overlay = new OverlayBand(); overlay.Name = "Overlay"; overlay.Width = (page.PaperWidth - page.LeftMargin - page.RightMargin) * Units.Millimeters; overlay.Height = (page.PaperHeight - page.TopMargin - page.BottomMargin) * Units.Millimeters; // remove bands, convert them to Text objects if necessary ObjectCollection allObjects = page.AllObjects; foreach (Base c in allObjects) { if (c is BandBase) { BandBase band = c as BandBase; if (band.HasBorder || band.HasFill) { TextObject textObj = new TextObject(); textObj.Bounds = band.Bounds; textObj.Border = band.Border.Clone(); textObj.Fill = band.Fill.Clone(); overlay.Objects.Add(textObj); } for (int i = 0; i < band.Objects.Count; i++) { ReportComponentBase obj = band.Objects[i]; if (!(obj is BandBase)) { obj.Anchor = AnchorStyles.Left | AnchorStyles.Top; obj.Dock = DockStyle.None; obj.Left = obj.AbsLeft; obj.Top = obj.AbsTop; overlay.Objects.Add(obj); i--; } } } } page.Clear(); page.Overlay = overlay; report.Pages.Add(page); page.SetReport(report); page.SetRunning(false); if (report.DesignPreviewPage()) { page = report.Pages[0] as ReportPage; FPreparedPages.ModifyPage(PageNo - 1, page); Refresh(); } } }
private void UpdateSample() { float paperWidth = ConvertUnitsToInches(tbPaperWidth.Text); float paperHeight = ConvertUnitsToInches(tbPaperHeight.Text); float leftMargin = ConvertUnitsToInches(tbLeftMargin.Text); float topMargin = ConvertUnitsToInches(tbTopMargin.Text); float labelWidth = ConvertUnitsToInches(tbLabelWidth.Text); float labelHeight = ConvertUnitsToInches(tbLabelHeight.Text); int rows = (int)udRows.Value; int columns = (int)udColumns.Value; float rowGap = ConvertUnitsToInches(tbRowGap.Text); float columnGap = ConvertUnitsToInches(tbColumnGap.Text); FLabelParameters.Name = ""; FLabelParameters.Text = ""; FLabelParameters.SetProp("Name", Converter.ToXml(tbName.Text)); FLabelParameters.SetProp("Width", ConvertToXml(labelWidth)); FLabelParameters.SetProp("Height", ConvertToXml(labelHeight)); FLabelParameters.SetProp("PaperWidth", ConvertToXml(paperWidth)); FLabelParameters.SetProp("PaperHeight", ConvertToXml(paperHeight)); if (cbLandscape.Checked) { FLabelParameters.SetProp("Landscape", "true"); } FLabelParameters.SetProp("LeftMargin", ConvertToXml(leftMargin)); FLabelParameters.SetProp("TopMargin", ConvertToXml(topMargin)); FLabelParameters.SetProp("Rows", rows.ToString()); FLabelParameters.SetProp("Columns", columns.ToString()); FLabelParameters.SetProp("RowGap", ConvertToXml(rowGap)); FLabelParameters.SetProp("ColumnGap", ConvertToXml(columnGap)); ReportPage page = FSampleReport.Pages[0] as ReportPage; page.Clear(); page.Landscape = cbLandscape.Checked; page.PaperWidth = paperWidth * 25.4f; page.PaperHeight = paperHeight * 25.4f; page.LeftMargin = leftMargin * 25.4f; page.TopMargin = topMargin * 25.4f; DataBand band = new DataBand(); band.Parent = page; bool fit = true; for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { ShapeObject shape = new ShapeObject(); shape.Parent = band; shape.Shape = ShapeKind.RoundRectangle; shape.Border.Color = Color.Gray; shape.Bounds = new RectangleF(x * (labelWidth + columnGap) * 96, y * (labelHeight + rowGap) * 96, labelWidth * 96, labelHeight * 96); if (shape.Right / Units.Millimeters > page.PaperWidth - page.LeftMargin + 0.1f || shape.Bottom / Units.Millimeters > page.PaperHeight - page.TopMargin + 0.1f) { (shape.Fill as SolidFill).Color = Color.Red; fit = false; } } } rcSample.Report = FSampleReport; lblWarning.Visible = !fit; btnOk.Enabled = fit; }