ActiveX

يوضح كيفية إضافة والوصول وإزالة وتكوين عناصر التحكم ActiveX في عرض تقديمي باستخدام Aspose.Slides for .NET.

إضافة عنصر تحكم ActiveX

إدراج عنصر تحكم ActiveX جديد وتعيين خصائصه اختياريًا.

static void Add_ActiveX()
{
    using var pres = new Presentation();
    var slide = pres.Slides[0];

    // إضافة عنصر تحكم ActiveX جديد (TextBox)
    var control = slide.Controls.AddControl(ControlType.WindowsMediaPlayer, 50, 50, 100, 50);

    // اختياريًا تعيين بعض الخصائص
    control.Properties["Value"] = "Default text";

    pres.Save("add_activex.pptm", SaveFormat.Pptm);
}

الوصول إلى عنصر تحكم ActiveX

قراءة المعلومات من أول عنصر تحكم ActiveX على الشريحة.

static void Access_ActiveX()
{
    using var pres = new Presentation("add_activex.pptm");
    var slide = pres.Slides[0];

    // الوصول إلى أول عنصر تحكم ActiveX
    var control = slide.Controls.FirstOrDefault();
    if (control != null)
    {
        Console.WriteLine($"Control Name: {control.Name}");
        Console.WriteLine($"Value: {control.Properties["Value"]}");
    }
}

إزالة عنصر تحكم ActiveX

حذف عنصر تحكم ActiveX موجود من الشريحة.

static void Remove_ActiveX()
{
    using var pres = new Presentation("add_activex.pptm");
    var slide = pres.Slides[0];

    if (slide.Controls.Count > 0)
    {
        // إزالة أول عنصر تحكم ActiveX
        slide.Controls.RemoveAt(0);
    }

    pres.Save("removed_activex.pptm", SaveFormat.Pptm);
}

تعيين خصائص ActiveX

إضافة عنصر تحكم وتكوين عدة خصائص لـ ActiveX.

static void Set_ActiveX_Properties()
{
    using var pres = new Presentation();
    var slide = pres.Slides[0];

    // إضافة زر أمر وتكوين الخصائص
    var control = slide.Controls.AddControl(ControlType.WindowsMediaPlayer, 50, 50, 150, 50);
    control.Properties["Caption"] = "Click Me";
    control.Properties["Enabled"] = "true";

    pres.Save("set_activex_props.pptm", SaveFormat.Pptm);
}