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

            //Load the desired the presentation
            Presentation pres = new Presentation(dataDir + "RemoveNodesSpecificPosition.pptx");

            //Traverse through every shape inside first slide
            foreach (IShape shape in pres.Slides[0].Shapes)
            {
                //Check if shape is of SmartArt type
                if (shape is SmartArt)
                {
                    //Typecast shape to SmartArt
                    SmartArt smart = (SmartArt)shape;

                    if (smart.AllNodes.Count > 0)
                    {
                        //Accessing SmartArt node at index 0
                        ISmartArtNode node = smart.AllNodes[0];

                        if (node.ChildNodes.Count >= 2)
                        {
                            //Removing the child node at position 1
                            ((SmartArtNodeCollection)node.ChildNodes).RemoveNodeByPosition(1);
                        }
                    }
                }
            }

            //Save Presentation
            pres.Save(dataDir + "RemoveSmartArtNodeByPosition.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
Exemple #2
0
        public static void Run()
        {
            //ExStart:CheckSmartArtHiddenProperty
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            using (Presentation presentation = new Presentation())
            {
                // Add SmartArt BasicProcess
                ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.RadialCycle);

                // Add node on SmartArt
                ISmartArtNode node = smart.AllNodes.AddNode();

                // Check isHidden property
                bool hidden = node.IsHidden; // Returns true

                if (hidden)
                {
                    // Do some actions or notifications
                }
                // Saving Presentation
                presentation.Save(dataDir + "CheckSmartArtHiddenProperty_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:CheckSmartArtHiddenProperty
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Creating a presentation instance
            Presentation pres = new Presentation();

            // Access the presentation slide
            ISlide slide = pres.Slides[0];

            // Add Smart Art IShape
            ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList);

            // Accessing the SmartArt node at index 0
            ISmartArtNode node = smart.AllNodes[0];

            // Adding new child node at position 2 in parent node
            SmartArtNode chNode = (SmartArtNode)((SmartArtNodeCollection)node.ChildNodes).AddNodeByPosition(2);

            // Add Text
            chNode.TextFrame.Text = "Sample Text Added";

            // Save Presentation
            pres.Save(dataDir + "AddSmartArtNodeByPosition_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
Exemple #4
0
        public static void Run()
        {
            // ExStart:RemoveNode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            // Load the desired the presentation
            using (Presentation pres = new Presentation(dataDir + "RemoveNode.pptx"))
            {
                // Traverse through every shape inside first slide
                foreach (IShape shape in pres.Slides[0].Shapes)
                {
                    // Check if shape is of SmartArt type
                    if (shape is ISmartArt)
                    {
                        // Typecast shape to SmartArtEx
                        ISmartArt smart = (ISmartArt)shape;

                        if (smart.AllNodes.Count > 0)
                        {
                            // Accessing SmartArt node at index 0
                            ISmartArtNode node = smart.AllNodes[0];

                            // Removing the selected node
                            smart.AllNodes.RemoveNode(node);
                        }
                    }
                }

                // Save Presentation
                pres.Save(dataDir + "RemoveSmartArtNode_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            }
            // ExEnd:RemoveNode
        }
Exemple #5
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Instantiate the presentation
            Presentation pres = new Presentation();

            // Accessing the first slide
            ISlide slide = pres.Slides[0];

            // Adding the SmartArt shape in first slide
            ISmartArt smart = slide.Shapes.AddSmartArt(0, 0, 400, 400, SmartArtLayoutType.StackedList);

            // Accessing the SmartArt  node at index 0
            ISmartArtNode node = smart.AllNodes[0];

            // Accessing the child node at position 1 in parent node
            int          position = 1;
            SmartArtNode chNode   = (SmartArtNode)node.ChildNodes[position];

            // Printing the SmartArt child node parameters
            string outString = string.Format("j = {0}, Text = {1},  Level = {2}, Position = {3}", position, chNode.TextFrame.Text, chNode.Level, chNode.Position);

            Console.WriteLine(outString);
        }
        private void RecursiveNodeAssertion(ISmartArtNode node, string fontName, float fontSize)
        {
            if (node.TextFrame != null)
            {
                TextFrameAssert(node.TextFrame, fontName, fontSize);
            }

            if (node.ChildNodes != null)
            {
                foreach (ISmartArtNode childNode in node.ChildNodes)
                {
                    RecursiveNodeAssertion(childNode, fontName, fontSize);
                }
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Instantiate Presentation class that represents the PPTX file
            Presentation pres = new Presentation();

            // Add SmartArt
            ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicCycle);

            // Obtain the reference of a node by using its Index
            ISmartArtNode node = smart.Nodes[1];

            // Get thumbnail
            Bitmap bmp = node.Shapes[0].GetThumbnail();

            // Save thumbnail
            bmp.Save(dataDir + "SmartArt_ChildNote_Thumbnail_out.jpeg", ImageFormat.Jpeg);
        }
        private void CreateSlide1(IPresentation presentation)
        {
            ISlide        slide1   = presentation.Slides.Add(SlideLayoutType.Blank);
            ISmartArt     smartArt = slide1.Shapes.AddSmartArt(SmartArtType.BasicBlockList, 100, 100, 640, 427);
            ISmartArtNode node1    = smartArt.Nodes[0];

            node1.TextBody.AddParagraph("One");
            ISmartArtNode node2 = smartArt.Nodes[1];

            node2.TextBody.AddParagraph("Two");
            ISmartArtNode node3 = smartArt.Nodes[2];

            node3.TextBody.AddParagraph("Three");
            ISmartArtNode node4 = smartArt.Nodes[3];

            node4.TextBody.AddParagraph("Four");
            ISmartArtNode node5 = smartArt.Nodes[4];

            node5.TextBody.AddParagraph("Five");
        }
        public static void Run()
        {
            //ExStart:ChangeTextOnSmartArtNode
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            using (Presentation presentation = new Presentation())
            {
                // Add SmartArt BasicProcess
                ISmartArt smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 400, 300, SmartArtLayoutType.BasicCycle);

                // Obtain the reference of a node by using its Index
                ISmartArtNode node = smart.Nodes[1]; // select second root node

                // Setting the text of the TextFrame
                node.TextFrame.Text = "Second root node";

                // Saving Presentation
                presentation.Save(dataDir + "ChangeText_On_SmartArt_Node_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:ChangeTextOnSmartArtNode
        }
        private void btnRun_Click(object sender, EventArgs e)
        {
            //create PPT document
            Presentation presentation = new Presentation();

            //load the document from disk
            presentation.LoadFromFile(@"..\..\..\..\..\..\Data\SmartArt.pptx");

            //get the SmartArt
            ISmartArt sa = presentation.Slides[0].Shapes[0] as ISmartArt;

            //add a node
            ISmartArtNode node = sa.Nodes.AddNode();

            //add text and set the text style
            node.TextFrame.Text = "AddText";
            node.TextFrame.TextRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            node.TextFrame.TextRange.Fill.SolidColor.KnownColor = KnownColors.HotPink;


            presentation.SaveToFile("AddNode.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("AddNode.pptx");
        }
        public static void Run()
        {
            //ExStart:BulletFillFormat
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            using (Presentation presentation = new Presentation())
            {
                ISmartArt     smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 500, 400, SmartArtLayoutType.VerticalPictureList);
                ISmartArtNode node  = smart.AllNodes[0];

                if (node.BulletFillFormat != null)
                {
                    Image    img   = (Image) new Bitmap(dataDir + "aspose-logo.jpg");
                    IPPImage image = presentation.Images.AddImage(img);
                    node.BulletFillFormat.FillType = FillType.Picture;
                    node.BulletFillFormat.PictureFillFormat.Picture.Image   = image;
                    node.BulletFillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;
                }
                presentation.Save(dataDir + "out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:BulletFillFormat
        }
Exemple #12
0
        public static void Run()
        {
            //ExStart:CustomChildNodesInSmartArt
            string dataDir = RunExamples.GetDataDir_SmartArts();

            // Load the desired the presentation
            Presentation pres = new Presentation(dataDir + "AccessChildNodes.pptx");

            {
                ISmartArt smart = pres.Slides[0].Shapes.AddSmartArt(20, 20, 600, 500, SmartArtLayoutType.OrganizationChart);

                // Move SmartArt shape to new position
                ISmartArtNode  node  = smart.AllNodes[1];
                ISmartArtShape shape = node.Shapes[1];
                shape.X += (shape.Width * 2);
                shape.Y -= (shape.Height / 2);

                // Change SmartArt shape's widths
                node         = smart.AllNodes[2];
                shape        = node.Shapes[1];
                shape.Width += (shape.Width / 2);

                // Change SmartArt shape's height
                node          = smart.AllNodes[3];
                shape         = node.Shapes[1];
                shape.Height += (shape.Height / 2);

                // Change SmartArt shape's rotation
                node           = smart.AllNodes[4];
                shape          = node.Shapes[1];
                shape.Rotation = 90;

                pres.Save(dataDir + "SmartArt.pptx", SaveFormat.Pptx);
            }
            //ExEnd:CustomChildNodesInSmartArt
        }