using NetCorePpt; namespace NetCorePptxTest.Modules; using static Constants; using static NetCorePpt.CoreInterfaces.ShapePropsPoint; public class DemoShape { /// /// SLIDE 1= Misc Shape Types (no text) /// /// public static void genSlide01(PptxGen pptx) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Shapes" }); slide.addTable(new List { new TableRow { new TableCell { text = "Shape Examples 1: Misc Shape Types (no text)", options = BASE_TEXT_OPTS_L }, BASE_TEXT_OPTS_R } }, BASE_TABLE_OPTS); slide.addNotes("API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-shapes.html"); // TOP-ROW slide.addShape(ShapeType.rect, new ShapeProps { x = 0.5, y = 0.8, w = 1.5, h = 3.0, fill = (SCHEME_COLORS.accent1), line = new ShapeLineProps { type = ShapeFillType.none } }); slide.addShape(ShapeType.ellipse, new ShapeProps { x = 2.2, y = 0.8, w = 3.0, h = 1.5, fill = new ShapeFillProps(ShapeFillType.solid, SCHEME_COLORS.accent2) }); slide.addShape(ShapeType.custGeom, new ShapeProps { x = 2.5, y = 2.6, w = 2.0, h = 1.0, fill = (SCHEME_COLORS.accent3), line = new ShapeLineProps { color = "151515", width = 1 }, points = new List { new MoveToPoint(0.0, 0.0 ), new MoveToPoint(0.5, 1.0 ), new MoveToPoint(1.0, 0.8 ), new MoveToPoint(1.5, 1.0 ), new MoveToPoint(2.0, 0.0 ), new QuadraticCurvePoint(0.0, 0.0, new QuadraticCurvePoint.QuadraticCurve(1.0, 0.5)), new ClosePoint(true), }, }); slide.addShape(ShapeType.rect, new ShapeProps { x = 5.7, y = 0.8, w = 1.5, h = 3.0, rotate = 45, fill = (SCHEME_COLORS.accent4) }); slide.addShape(ShapeType.ellipse, new ShapeProps { x = 7.4, y = 1.5, w = 3.0, h = 1.5, rotate = 90, fill = (SCHEME_COLORS.accent6) }); // TEST= no type slide.addShape(ShapeType.roundRect, new ShapeProps { x = 10, y = 0.8, w = 3.0, h = 1.5, rectRadius = 1, fill = (SCHEME_COLORS.accent5), line = new ShapeLineProps { color = "151515" }, // lineSize = 1 }); // TEST= DEPRECATED= `fill`,`line`,`lineSize` slide.addShape(ShapeType.arc, new ShapeProps { x = 10.75, y = 2.45, w = 1.5, h = 1.45, fill = (SCHEME_COLORS.accent3), angleRange = Tuple.Create(45.0, 315.0) }); // BOTTOM ROW slide.addShape(ShapeType.line, new ShapeProps { x = 4.2, y = 4.4, w = 5.0, h = 0.0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 1, dashType = DashType.lgDash } }); slide.addShape(ShapeType.line, new ShapeProps { x = 4.2, y = 4.8, w = 5.0, h = 0.0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 2, dashType = DashType.dashDot, beginArrowType = ArrowType.arrow }, // lineHead = EnumArrowType.arrow, }); // TEST= DEPRECATED= lineHead slide.addShape(ShapeType.line, new ShapeProps { x = 4.2, y = 5.2, w = 5.0, h = 0.0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 3, endArrowType = ArrowType.triangle } }); slide.addShape(ShapeType.line, new ShapeProps { x = 4.2, y = 5.6, w = 5.0, h = 0.0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 4, beginArrowType = ArrowType.diamond, endArrowType = ArrowType.oval }, }); slide.addShape(ShapeType.rtTriangle, new ShapeProps { x = 0.4, y = 4.3, w = 6.0, h = 3.0, fill = (SCHEME_COLORS.accent5), line = new ShapeLineProps { color = SCHEME_COLORS.accent1, width = 3 }, // shapeName= "First Right Triangle", }); slide.addShape(ShapeType.rtTriangle, new ShapeProps { x = 7.0, y = 4.3, w = 6.0, h = 3.0, fill = (SCHEME_COLORS.accent5), line = new ShapeLineProps { color = SCHEME_COLORS.accent1, width = 2 }, flipH = true, }); } /// /// SLIDE 2= Misc Shape Types with text /// /// /// /// public static void genSlide02(PptxGen pptx, bool all = true) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Shapes" }); if (all) { slide.addTable(new List { new TableRow { new TableCell { text = "Shape Examples 2: Misc Shape Types (with text)", options = BASE_TEXT_OPTS_L }, BASE_TEXT_OPTS_R } }, BASE_TABLE_OPTS); slide.addNotes("API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-shapes.html"); slide.addText("RECTANGLE", new TextPropsOptions { shape = ShapeType.rect, x = 0.5, y = 0.8, w = 1.5, h = 3.0, fill = (SCHEME_COLORS.accent1), align = HAlign.center, fontSize = 14, }); slide.addText("OVAL (transparency:50)", new TextPropsOptions { shape = ShapeType.ellipse, x = 2.2, y = 0.8, w = 3.0, h = 1.5, fill = new ShapeFillProps(SCHEME_COLORS.accent2, 50, ShapeFillType.solid), align = HAlign.center, fontSize = 14, }); slide.addText("CUSTOM", new TextPropsOptions { shape = ShapeType.custGeom, x = 2.5, y = 2.6, w = 2.0, h = 1.0, fill = (SCHEME_COLORS.accent3), line = new ShapeLineProps { color = "151515", width = 1 }, shapeProps = new ShapeProps { points = new List { new MoveToPoint(0.0, 0.0 ), new MoveToPoint(0.5, 1.0 ), new MoveToPoint(1.0, 0.8 ), new MoveToPoint(1.5, 1.0 ), new MoveToPoint(2.0, 0.0 ), new QuadraticCurvePoint(0.0, 0.0, new QuadraticCurvePoint.QuadraticCurve(1.0, 0.5)), new ClosePoint (true), } }, align = HAlign.center, fontSize = 14, }); slide.addText("RECTANGLE (rotate:45)", new TextPropsOptions { shape = ShapeType.rect, x = 5.7, y = 0.8, w = 1.5, h = 3.0, fill = (SCHEME_COLORS.accent4), rotate = 45, align = HAlign.center, fontSize = 14, }); // TEST= DEPRECATED= `alpha` slide.addText("OVAL (rotate:90, transparency:75)", new TextPropsOptions { shape = ShapeType.ellipse, x = 7.4, y = 1.5, w = 3.0, h = 1.5, fill = new ShapeFillProps(SCHEME_COLORS.accent6, 75, ShapeFillType.solid), rotate = 90, align = HAlign.center, fontSize = 14, }); slide.addText("ROUNDED-RECTANGLE\ndashType:dash\nrectRadius:1", new TextPropsOptions { shape = ShapeType.roundRect, x = 10, y = 0.8, w = 3.0, h = 1.5, fill = (SCHEME_COLORS.accent5), align = HAlign.center, fontSize = 14, line = new ShapeLineProps { color = "151515", /* size = 1,*/ dashType = DashType.dash }, rectRadius = 1, }); slide.addText("ARC", new TextPropsOptions { shape = ShapeType.arc, x = 10.75, y = 2.45, w = 1.5, h = 1.45, fill = (SCHEME_COLORS.accent3), shapeProps = new ShapeProps { angleRange = Tuple.Create(45.0, 315.0) }, line = new ShapeLineProps { color = "151515", width = 1 }, fontSize = 14, }); } // slide.addText("LINE size=1", new TextPropsOptions { shape = ShapeType.line, align = HAlign.center, x = 4.15, y = 4.4, w = 5, h = 0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 1, dashType = DashType.lgDash }, }); if (all) { slide.addText("LINE size=2", new TextPropsOptions { shape = ShapeType.line, align = HAlign.left, x = 4.15, y = 4.8, w = 5, h = 0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 2, dashType = DashType.dashDot, endArrowType = ArrowType.arrow }, }); slide.addText("LINE size=3", new TextPropsOptions { shape = ShapeType.line, align = HAlign.right, x = 4.15, y = 5.2, w = 5, h = 0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 3, beginArrowType = ArrowType.triangle }, }); slide.addText("LINE size=4", new TextPropsOptions { shape = ShapeType.line, x = 4.15, y = 5.6, w = 5, h = 0, line = new ShapeLineProps { color = SCHEME_COLORS.accent2, width = 4, beginArrowType = ArrowType.diamond, endArrowType = ArrowType.oval, transparency = 50 }, }); // slide.addText("RIGHT-TRIANGLE", new TextPropsOptions { shape = ShapeType.rtTriangle, align = HAlign.center, x = 0.4, y = 4.3, w = 6, h = 3, fill = (SCHEME_COLORS.accent5), line = new ShapeLineProps { color = "696969", width = 3 }, }); } slide.addText("HYPERLINK-SHAPE", new TextPropsOptions { shape = ShapeType.rtTriangle, align = HAlign.center, x = 7.0, y = 4.3, w = 6, h = 3, fill = (SCHEME_COLORS.accent5), line = new ShapeLineProps { color = "696969", width = 2 }, flipH = true, hyperlink = new HyperlinkProps("https://github.com/gitbrent/pptxgenjs", "Visit Homepage"), }); } public static void genSlide03(PptxGen pptx) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Shapes" }); List textes = new List{ new TextProps { text = "test", options = new TextPropsOptions { hyperlink = new HyperlinkProps("https://sina.com", "Visit Sina" ) } }, // { text:"test", options: { hyperlink: { url: "https://github.com/gitbrent/pptxgenjs", tooltip: "Visit Homepage" } } } }; var options = new TextPropsOptions { hyperlink = new HyperlinkProps("https://baidu.com", "Visit Baidu") }; slide.addText(textes, options); List textes1 = new List{ new TextProps { text = "test", options = new TextPropsOptions { hyperlink = new HyperlinkProps("https://sina.com", "Visit Sina" ) } }, // { text:"test", options: { hyperlink: { url: "https://github.com/gitbrent/pptxgenjs", tooltip: "Visit Homepage" } } } }; var options1 = new TextPropsOptions { hyperlink = new HyperlinkProps("https://baidu.com", "Visit Baidu") }; slide.addText(textes1, options1); } }