مستطيل

إنشاء مستطيل بسيط

مثل الموضوعات السابقة، هذا الموضوع أيضًا يتعلق بإضافة شكل وهذه المرة الشكل الذي سنناقشه هو المستطيل. في هذا الموضوع، وصفنا كيف يمكن للمطورين إضافة مستطيلات بسيطة أو منسقة إلى الشرائح الخاصة بهم باستخدام Aspose.Slides لـ C++. لإضافة مستطيل بسيط إلى الشريحة المحددة من العرض التقديمي، يرجى اتباع الخطوات أدناه:

  1. إنشاء مثيل من فئة Presentation.
  2. احصل على مرجع لشريحة باستخدام مؤشرها.
  3. أضف IAutoShape من نوع مستطيل باستخدام طريقة AddAutoShape المعروضة بواسطة كائن IShapes.
  4. اكتب العرض التقديمي المعدل كملف PPTX.

في المثال أدناه، أضفنا مستطيلًا بسيطًا إلى الشريحة الأولى من العرض التقديمي.

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/SimpleRectangle.pptx";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add autoshape of ellipse type
SharedPtr<IAutoShape> ashp = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 150, 150, 50);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

إنشاء مستطيل منسق

لإضافة مستطيل منسق إلى شريحة، يرجى اتباع الخطوات أدناه:

  1. إنشاء مثيل من فئة Presentation.
  2. احصل على مرجع لشريحة باستخدام مؤشرها.
  3. أضف IAutoShape من نوع مستطيل باستخدام طريقة AddAutoShape المعروضة بواسطة كائن IShapes.
  4. قم بتعيين نوع التعبئة للمستطيل إلى صلب.
  5. قم بتعيين لون المستطيل باستخدام خاصية SolidFillColor.Color المعروضة بواسطة كائن FillFormat المرتبط بكائن IShape.
  6. قم بتعيين لون خطوط المستطيل.
  7. قم بتعيين عرض خطوط المستطيل.
  8. اكتب العرض التقديمي المعدل كملف PPTX. يتم تنفيذ الخطوات أعلاه في المثال أدناه.
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/FormattedRectangle_out.pptx";
const String templatePath = u"../templates/AltText.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an autoshape of type line
SharedPtr<IAutoShape> shape = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 50, 150, 150, 75);
// Set the fill color of the rectangle shape
shape->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_White());
// Apply some formatting on the line
shape->get_LineFormat()->set_Style(LineStyle::ThickThin);
shape->get_LineFormat()->set_Width(7);
shape->get_LineFormat()->set_DashStyle(LineDashStyle::Dash);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Blue());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);