//// This code is part of Document Solutions for Imaging demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Drawing;usingGrapeCity.Documents.Text;usingGrapeCity.Documents.Imaging;usingGrapeCity.Documents.Layout;usingGCTEXT = GrapeCity.Documents.Text; namespaceDsImagingWeb.Demos{// This example shows how to draw a table with cells containing rotated texts,// using the GrapeCity.Documents.Drawing.TableRenderer and related classes.publicclassRotatedTableText {publicGcBitmapGenerateImage(Size pixelSize, float dpi, bool opaque, string[] sampleParams = null) {var bmp = newGcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi);usingvar g = bmp.CreateGraphics(Color.White);DrawTable(g, pixelSize.Width, pixelSize.Height);return bmp; } staticvoidDrawTable(GcGraphics g, float pageWidth, float pageHeight) {var host = newLayoutHost();var view = host.CreateView(pageWidth, pageHeight); var rt = view.CreateRect(); rt.AnchorTopLeftRight(null, 30, 20, 20); var ta = newTableRenderer(g, rt, FixedTableSides.TopLeftRight, rowCount: 9, columnCount: 7, gridLineColor: Color.Transparent, gridLineWidth: 1, rowMinHeight: 20, columnMinWidth: 20); // We set a "star" (weighted) width for the seventh column so that the table// can expand since both the left and right sides of the table are fixed. ta.ColumnRects[6].SetStarWidth(1f); ta.RowRects[8].AppendMinHeight(70); var fmtNorm = newTextFormat {Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeSans.ttf")),FontSize = 16f,FontSizeInGraphicUnits = true }; var cs = newCellStyle {LineWidth = 1,LineColor = Color.Coral,LinePaddingAll = 1,CornerRadius = 5,FillColor = Color.Snow,PaddingLeftRight = 10,PaddingTop = 2,PaddingBottom = 5,TextAlignment = TextAlignment.Center,TextFormat = fmtNorm }; ta.DefaultCellStyle = cs; ta.TableFrameStyle = newFrameStyle {LineWidth = 1,LineColor = Color.CornflowerBlue,LinePaddingAll = -3,CornerRadius = 5,FillColor = Color.MistyRose }; // To adjust a column width automatically we need to set// the FixedWidth property the CellStyle to false.var csFlexW = newCellStyle(cs) {FixedWidth = false };var cs270 = newCellStyle(cs) {RotationAngle = 270 };// A rotated cell also has a fixed width (which is actually a height) by default.// If we set FixedWidth to false, the row height will be adjusted automatically.var cs270FlexH = newCellStyle(cs) {RotationAngle = 270,ParagraphAlignment = ParagraphAlignment.Center,FixedWidth = false,MaxWidth = 120 }; ta.AddCell(0, 1, 1, 3, "Title 1 with a long text"); ta.AddCell(newCellStyle(cs) { ParagraphAlignment = ParagraphAlignment.Center },0, 4, 1, 3, "Title 2"); ta.AddCell(cs270, 1, 1, 2, 1, "Vertical Title 1"); ta.AddCell(cs270, 1, 2, 2, 1, "Vertical Title 2 with additional text"); ta.AddCell(cs270, 1, 3, 2, 1, "Vertical Title 3"); ta.AddCell(1, 4, 1, 2, "Subtitle 2.1"); ta.AddCell(cs270FlexH, 2, 4, "Vertical Subtitle 2.1.1"); ta.AddCell(cs270FlexH, 2, 5, "Vertical Subtitle 2.1.2 with a long, long, long, and even longer text"); ta.AddCell(cs270, 3, 0, 3, 1, "Side Title 1"); ta.AddCell(cs270, 6, 0, 2, 1, "Side Title 2"); for (int r = 3; r < 8; r++)for (int c = 1; c < 4; c++) ta.AddCell(csFlexW, r, c, (r * c).ToString()); for (int r = 3; r < 8; r++)for (int c = 4; c < 6; c++) ta.AddCell(csFlexW, r, c, $"row {r} column {c}"); ta.AddCell(newCellStyle(cs) {RotationAngle = 90,ParagraphAlignment = ParagraphAlignment.Far,TextAlignment = TextAlignment.Leading },1, 6, 7, 1, "Other Side"); ta.AddCell(newCellStyle(cs) {TextAlignment = TextAlignment.Trailing,ParagraphAlignment = ParagraphAlignment.Far },8, 0, 1, 7, "Bottom Side"); ta.Render(); } }}