新增形狀
形狀是 PowerPoint 中的一個基本元素,有助於組織內容、強調重點和增強視覺吸引力。 有效運用形狀可以讓演講者組織訊息、創造圖表並引導觀眾的注意力。 無論是表示方向的箭頭、表示文字方塊的矩形,或是表示突出顯示的圓形,各種形狀都能使簡報更具吸引力和專業性。
有了 IronPPT,開發人員可以無縫整合和修改圖形,讓他們完全掌控 PowerPoint 投影片。 這種靈活性使得簡報能夠生動、精煉,有效地傳達思想,並留下持久的影響。
五步驟代碼即可新增形狀
Shapeshape = newShape();- shape.
Type=IronPPT.Enums.ShapeType.Triangle; - shape.
Width= 100; - shape.
OutlineColor=Color.Black; - shape.
Position= (200, 200);
程式碼解釋
To add a new shape to our empty PowerPoint presentation, we start by creating a new Shape object using the constructor. Next, we define the type of shape we want to create by modifying the Type property and assigning it one of the values from the ShapeType enum. For example, to create a triangle, we would set the Type to ShapeType.Triangle. After that, we can set the dimensions of the shape by assigning an integer value to the Width property, which specifies the shape's width. To customize the appearance of the shape, we can adjust the OutlineColor property; 在這個例子中,我們將顏色設定為黑色。 最後,我們透過指定 x 和 y 座標將形狀定位在投影片上,在本例中,座標將設定為 (200, 200)。 這樣就能將圖形放置在簡報中的所需位置。






