Aspose.Slides.Examples.CSharp.Shapes.RemoveShape.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

             // Create Presentation object
            Presentation pres = new Presentation();
            
            // Get the first slide
            ISlide sld = pres.Slides[0];

            // Add autoshape of rectangle type
            IShape shp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 40, 150, 50);
            IShape shp2 = sld.Shapes.AddAutoShape(ShapeType.Moon, 160, 40, 150, 50);
            String alttext = "User Defined";
            int iCount = sld.Shapes.Count;
            for (int i = 0; i < iCount; i++)
            {
                    AutoShape ashp = (AutoShape)sld.Shapes[0];
                    if (String.Compare(ashp.AlternativeText, alttext, StringComparison.Ordinal) == 0)
                    {
                        sld.Shapes.Remove(ashp);
                    }
            }

            // Save presentation to disk
            pres.Save(dataDir + "RemoveShape_out.pptx", SaveFormat.Pptx);

        }
    }
RemoveShape