static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string srcFileName = FilePath + "User Defined Thumbnail.pptx";
            string destFileName = FilePath + "User Defined Thumbnail.jpg";
            
            //Instantiate a Presentation class that represents the presentation file
            using (Presentation pres = new Presentation(srcFileName))
            {

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

                //User defined dimension
                int desiredX = 1200;
                int desiredY = 800;

                //Getting scaled value  of X and Y
                float ScaleX = (float)(1.0 / pres.SlideSize.Size.Width) * desiredX;
                float ScaleY = (float)(1.0 / pres.SlideSize.Size.Height) * desiredY;

                //Create a full scale image
                Bitmap bmp = sld.GetThumbnail(ScaleX, ScaleY);

                //Save the image to disk in JPEG format
                bmp.Save(destFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

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

            // Instantiate a Presentation object that represents a presentation file
            using (Presentation presentation = new Presentation(dataDir + "EmbeddedFonts.pptx"))
            {
                // render a slide that contains a text frame that uses embedded "FunSized"
                presentation.Slides[0].GetThumbnail(new Size(960, 720)).Save(dataDir + "picture1_out.png", ImageFormat.Png);

                IFontsManager fontsManager = presentation.FontsManager;

                // get all embedded fonts
                IFontData[] embeddedFonts = fontsManager.GetEmbeddedFonts();

                // find "Calibri" font
                IFontData funSizedEmbeddedFont = Array.Find(embeddedFonts, delegate(IFontData data)
                {
                    return data.FontName == "Calibri";
                });

                // remove "Calibri" font
                fontsManager.RemoveEmbeddedFont(funSizedEmbeddedFont);

                // render the presentation; removed "Calibri" font is replaced to an existing one
                presentation.Slides[0].GetThumbnail(new Size(960, 720)).Save(dataDir + "picture2_out.png", ImageFormat.Png);

                // save the presentation without embedded "Calibri" font
                presentation.Save(dataDir + "WithoutManageEmbeddedFonts_out.ppt", SaveFormat.Ppt);
            }
        }
        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);
                        
        }
        // Get all the text in a slide.
        public static List<string> GetAllTextInSlide(string presentationFile, int slideIndex)
        {
            // Create a new linked list of strings.
            List<string> texts = new List<string>();

            //Instantiate PresentationEx class that represents PPTX
            using (Presentation pres = new Presentation(presentationFile))
            {

                //Access the slide
                ISlide sld = pres.Slides[slideIndex];

                //Iterate through shapes to find the placeholder
                foreach (Shape shp in sld.Shapes)
                    if (shp.Placeholder != null)
                    {
                        //get the text of each placeholder
                        texts.Add(((AutoShape)shp).TextFrame.Text);
                    }

            }

            // Return an array of strings.
            return texts;
        }
        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 + "AccessSmartArt.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 Aspose.Slides.SmartArt.SmartArt)
                {

                    // Typecast shape to SmartArt
                    Aspose.Slides.SmartArt.SmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape;

                    // Traverse through all nodes inside SmartArt
                    for (int i = 0; i < smart.AllNodes.Count; i++)
                    {
                        // Accessing SmartArt node at index i
                        Aspose.Slides.SmartArt.SmartArtNode node = (Aspose.Slides.SmartArt.SmartArtNode)smart.AllNodes[i];

                        // Printing the SmartArt node parameters
                        string outString = string.Format("i = {0}, Text = {1},  Level = {2}, Position = {3}", i, node.TextFrame.Text, node.Level, node.Position);
                        Console.WriteLine(outString);
                    }
                }
            }
            
            
        }
Exemplo n.º 6
0
        public void Import(Presentation presentation, ResourceDescriptor[] resourceDescriptors,
            DeviceResourceDescriptor[] deviceResourceDescriptors, 
            Func<Slide, Slide> addSlideDelegate, Func<IEnumerable<Slide>, bool> addLinkDelegate,
            Func<string, string, bool> isSlideUniqueName,
            int indent, int height)
        {
            _addSlideDelegate = addSlideDelegate;
            _addLinkDelegate = addLinkDelegate;
            _isSlideUniqueName = isSlideUniqueName;
            string selectedFile = null;
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Filter = "XML Files (*.xml) | *.xml";
                openFileDialog.Multiselect = false;
                if (DialogResult.OK == openFileDialog.ShowDialog())
                {
                    selectedFile = openFileDialog.FileName;
                }
            }
            if (string.IsNullOrEmpty(selectedFile)) return;
            ImportSlide importSlide = new ImportSlide(DesignerClient.Instance.StandalonePresentationWorker,
                this);

            importSlide.Import(selectedFile, presentation, resourceDescriptors, deviceResourceDescriptors, indent, height);
        }
        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 + "RemoveNodeSpecificPosition.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 Aspose.Slides.SmartArt.SmartArt)
                {
                    // Typecast shape to SmartArt
                    Aspose.Slides.SmartArt.SmartArt smart = (Aspose.Slides.SmartArt.SmartArt)shape;

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

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

                    }
                }
            }

            // Save Presentation
            pres.Save(dataDir + "RemoveSmartArtNodeByPosition_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD();

            // Instantiate a Presentation class that represents the presentation file

            using (Presentation pres = new Presentation(dataDir + "CreateSlidesSVGImage.pptx"))
            {

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

                // Create a memory stream object
                MemoryStream SvgStream = new MemoryStream();

                // Generate SVG image of slide and save in memory stream
                sld.WriteAsSvg(SvgStream);
                SvgStream.Position = 0;

                // Save memory stream to file
                using (Stream fileStream = System.IO.File.OpenWrite(dataDir + "Aspose_out.svg"))
                {
                    byte[] buffer = new byte[8 * 1024];
                    int len;
                    while ((len = SvgStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        fileStream.Write(buffer, 0, len);
                    }

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

            // Instantiate presentation object
            using (Presentation presentation = new Presentation())
            {

                // Load Image to be added in presentaiton image collection
                Image img = new Bitmap(dataDir + "aspose-logo.jpg");
                IPPImage image = presentation.Images.AddImage(img);

                // Add picture frame to slide
                IPictureFrame pf = presentation.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 50, 100, 100, image);

                // Setting relative scale width and height
                pf.RelativeScaleHeight = 0.8f;
                pf.RelativeScaleWidth = 1.35f;

                // Save presentation
                presentation.Save(dataDir + "Adding Picture Frame with Relative Scale_out.pptx", SaveFormat.Pptx);
            }
           

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

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

            // Instantiate Prseetation class that represents the PPTX
            using (Presentation pres = new Presentation())
            {

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

                // Add autoshape of ellipse type
                IShape shp = sld.Shapes.AddAutoShape(ShapeType.Ellipse, 50, 150, 150, 50);

                // Apply some formatting to ellipse shape
                shp.FillFormat.FillType = FillType.Solid;
                shp.FillFormat.SolidFillColor.Color = Color.Chocolate;

                // Apply some formatting to the line of Ellipse
                shp.LineFormat.FillFormat.FillType = FillType.Solid;
                shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Black;
                shp.LineFormat.Width = 5;

                //Write the PPTX file to disk
                pres.Save(dataDir + "EllipseShp2_out.pptx", SaveFormat.Pptx);
            }

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

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

            // Instantiate PrseetationEx class that represents the PPTX
            using (Presentation pres = new Presentation())
            {

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

                // Add Video Frame
                IVideoFrame vf = sld.Shapes.AddVideoFrame(50, 150, 300, 150, dataDir+ "video1.avi");

                // Set Play Mode and Volume of the Video
                vf.PlayMode = VideoPlayModePreset.Auto;
                vf.Volume = AudioVolumeMode.Loud;

                //Write the PPTX file to disk
                pres.Save(dataDir + "VideoFrame_out.pptx", SaveFormat.Pptx);
            }

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

            // Instantiate Presentation class that represents PPTX// Instantiate Presentation class that represents PPTX
            using (Presentation pres = new Presentation(dataDir + "ReplacingText.pptx"))
            {

                // Access first slide
                ISlide sld = pres.Slides[0];

                // Iterate through shapes to find the placeholder
                foreach (IShape shp in sld.Shapes)
                    if (shp.Placeholder != null)
                    {
                        // Change the text of each placeholder
                        ((IAutoShape)shp).TextFrame.Text = "This is Placeholder";
                    }

                // Save the PPTX to Disk
                pres.Save(dataDir + "output_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            }

        }
Exemplo n.º 13
0
        ///<summary>Shows the JournalProperties form for a presentation, allowing the user to change the year.</summary>
        public void ShowProperties(Presentation presentation)
        {
            if (presentation == null) throw new ArgumentNullException("presentation");
            Program.Initialize();
            using (var form = new Forms.JournalProperties(presentation)) {
                var oldYear = form.JournalYear;
                if (form.ShowDialog(presentation.Application.Window()) != DialogResult.OK) return;
                if (oldYear == form.JournalYear) return;

                openJournals.Remove(presentation);
                if (form.JournalYear.HasValue) {
                    JournalPresentation.MakeJournal(presentation, form.JournalYear.Value);

                    var jp = RegisterJournal(presentation, createTaskPane: oldYear == null);    //Only create a new taskpane if it wasn't already a journal

                    if (oldYear != null)
                        ((AdPane)GetTaskPane(presentation).Control).ReplaceJournal(jp);
                } else {
                    JournalPresentation.KillJournal(presentation);
                    UnregisterJournal(presentation);
                }

                //Force UI to invalidate
                //presentation.Windows[1].ActivePane.ViewType = PpViewType.ppViewNormal;
                presentation.Windows[1].View.GotoSlide(1);
                ((Slide)presentation.Windows[1].View.Slide).Shapes.SelectAll();
                presentation.Windows[1].Selection.Unselect();
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_Background();

            // Instantiate the Presentation class that represents the presentation file
            using (Presentation pres = new Presentation(dataDir + "SetImageAsBackground.pptx"))
            {

                // Set the background with Image
                pres.Slides[0].Background.Type = BackgroundType.OwnBackground;
                pres.Slides[0].Background.FillFormat.FillType = FillType.Picture;
                pres.Slides[0].Background.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;

                // Set the picture
                System.Drawing.Image img = (System.Drawing.Image)new Bitmap(dataDir + "Tulips.jpg");

                // Add image to presentation's images collection
                IPPImage imgx = pres.Images.AddImage(img);

                pres.Slides[0].Background.FillFormat.PictureFillFormat.Picture.Image = imgx;

                // Write the presentation to disk
                pres.Save(dataDir + "ContentBG_Img_out.pptx", SaveFormat.Pptx);
            } 
        }
        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.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
Exemplo n.º 16
0
        // Get a list of the titles of all the slides in the presentation.
        public static IList<string> GetSlideTitles(string presentationFile)
        {
            // Create a new linked list of strings.
            List<string> texts = new List<string>();

            //Instantiate PresentationEx class that represents PPTX
            using (Presentation pres = new Presentation(presentationFile))
            {

                //Access all the slides
                foreach (ISlide sld in pres.Slides)
                {

                    //Iterate through shapes to find the placeholder
                    foreach (Shape shp in sld.Shapes)
                        if (shp.Placeholder != null)
                        {
                            if (IsTitleShape(shp))
                            {
                                //get the text of placeholder
                                texts.Add(((AutoShape)shp).TextFrame.Text);
                            }
                        }
                }
            }

            // Return an array of strings.
            return texts;
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

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

            // Instantiate Prseetation class that represents the PPTX
            using (Presentation pres = new Presentation())
            {

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

                // Load the wav sound file to stram
                FileStream fstr = new FileStream(dataDir+ "sampleaudio.wav", FileMode.Open, FileAccess.Read);

                // Add Audio Frame
                IAudioFrame af = sld.Shapes.AddAudioFrameEmbedded(50, 150, 100, 100, fstr);

                // Set Play Mode and Volume of the Audio
                af.PlayMode = AudioPlayModePreset.Auto;
                af.Volume = AudioVolumeMode.Loud;

                //Write the PPTX file to disk
                pres.Save(dataDir + "AudioFrameEmbed_out.pptx", SaveFormat.Pptx);
            }

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

            // Load the PPTX to Presentation object
            Presentation pres = new Presentation(dataDir + "AccessingOLEObjectFrame.pptx");

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

            // Cast the shape to OleObjectFrame
            OleObjectFrame oof = (OleObjectFrame)sld.Shapes[0];

            // Read the OLE Object and write it to disk
            if (oof != null)
            {
                FileStream fstr = new FileStream(dataDir+ "excelFromOLE_out.xlsx", FileMode.Create, FileAccess.Write);
                byte[] buf = oof.ObjectData;
                fstr.Write(buf, 0, buf.Length);
                fstr.Flush();
                fstr.Close();
            }
            
            
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();


            // Load the presentation file
            using (Presentation pres = new Presentation(dataDir + "ExportingHTMLText.pptx"))
            {

                // Acesss the default first slide of presentation
                ISlide slide = pres.Slides[0];

                // Desired index
                int index = 0;

                // Accessing the added shape
                IAutoShape ashape = (IAutoShape)slide.Shapes[index];

                // Extracting first paragraph as HTML
                StreamWriter sw = new StreamWriter(dataDir + "output_out.html", false, Encoding.UTF8);

                //Writing Paragraphs data to HTML by providing paragraph starting index, total paragraphs to be copied
                sw.Write(ashape.TextFrame.Paragraphs.ExportToHtml(0, ashape.TextFrame.Paragraphs.Count, null));

                sw.Close();
            }

            
        }
Exemplo n.º 20
0
        public static void ApplyThemeToPresentation(string presentationFile, string outputFile)
        {
            //Instantiate Presentation class to load the source presentation file
            Presentation srcPres = new Presentation(presentationFile);

            //Instantiate Presentation class for destination presentation (where slide is to be cloned)
            Presentation destPres = new Presentation(outputFile);

            //Instantiate ISlide from the collection of slides in source presentation along with
            //master slide
            ISlide SourceSlide = srcPres.Slides[0];

            //Clone the desired master slide from the source presentation to the collection of masters in the
            //destination presentation
            IMasterSlideCollection masters = destPres.Masters;
            IMasterSlide SourceMaster = SourceSlide.LayoutSlide.MasterSlide;

            //Clone the desired master slide from the source presentation to the collection of masters in the
            //destination presentation
            IMasterSlide iSlide = masters.AddClone(SourceMaster);

            //Clone the desired slide from the source presentation with the desired master to the end of the
            //collection of slides in the destination presentation
            ISlideCollection slds = destPres.Slides;
            slds.AddClone(SourceSlide, iSlide, true);

            //Clone the desired master slide from the source presentation to the collection of masters in the//destination presentation
            //Save the destination presentation to disk
            destPres.Save(outputFile, SaveFormat.Pptx);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

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

            // Instantiate Prseetation class that represents the PPTX
            using (Presentation pres = new Presentation())
            {

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

                // Add autoshape of rectangle type
                IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);

                // Set the fill type to Pattern
                shp.FillFormat.FillType = FillType.Pattern;

                // Set the pattern style
                shp.FillFormat.PatternFormat.PatternStyle = PatternStyle.Trellis;

                // Set the pattern back and fore colors
                shp.FillFormat.PatternFormat.BackColor.Color = Color.LightGray;
                shp.FillFormat.PatternFormat.ForeColor.Color = Color.Yellow;

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectShpPatt_out.pptx", SaveFormat.Pptx);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Conversion();

            // Loading a presentation
            using (Presentation pres = new Presentation(dataDir + "Media File.pptx"))
            {
                string path = dataDir;
                const string fileName = "ExportMediaFiles_out.html";
                const string baseUri = "http://www.example.com/";

                VideoPlayerHtmlController controller = new VideoPlayerHtmlController(path, fileName, baseUri);

                // Setting HTML options
                HtmlOptions htmlOptions = new HtmlOptions(controller);
                SVGOptions svgOptions = new SVGOptions(controller);

                htmlOptions.HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller);
                htmlOptions.SlideImageFormat = SlideImageFormat.Svg(svgOptions);

                // Saving the file
                pres.Save(Path.Combine(path, fileName), SaveFormat.Html, htmlOptions);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            // Create Empty presentation instance// Create Empty presentation instance
            using (Presentation pres = new Presentation())
            {
                // Acesss the default first slide of presentation
                ISlide slide = pres.Slides[0];

                // Adding the AutoShape to accomodate the HTML content
                IAutoShape ashape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, pres.SlideSize.Size.Width - 20, pres.SlideSize.Size.Height - 10);

                ashape.FillFormat.FillType = FillType.NoFill;

                // Adding text frame to the shape
                ashape.AddTextFrame("");

                // Clearing all paragraphs in added text frame
                ashape.TextFrame.Paragraphs.Clear();

                // Loading the HTML file using stream reader
                TextReader tr = new StreamReader(dataDir + "file.html");

                // Adding text from HTML stream reader in text frame
                ashape.TextFrame.Paragraphs.AddFromHtml(tr.ReadToEnd());

                // Saving Presentation
                pres.Save(dataDir + "output_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

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

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

            // Instantiate PrseetationEx class that represents the PPTX
            using (Presentation pres = new Presentation())
            {

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

                // Add autoshape of rectangle type
                IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);

                // Rotate the shape to 90 degree
                shp.Rotation = 90;

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectShpRot_out.pptx", SaveFormat.Pptx);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD();

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

            // Instantiate Presentation class that represents the presentation file
            using (Presentation pres = new Presentation())
            {
                // Instantiate SlideCollection calss
                ISlideCollection slds = pres.Slides;

                for (int i = 0; i < pres.LayoutSlides.Count; i++)
                {
                    // Add an empty slide to the Slides collection
                    slds.AddEmptySlide(pres.LayoutSlides[i]);

                }

                // Save the PPTX file to the Disk
                pres.Save(dataDir + "EmptySlide_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

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

            // ExStart:AddVBAMacros
            // Instantiate Presentation
            using (Presentation presentation = new Presentation())
            {
                // Create new VBA Project
                presentation.VbaProject = new VbaProject();

                // Add empty module to the VBA project
                IVbaModule module = presentation.VbaProject.Modules.AddEmptyModule("Module");
              
                // Set module source code
                module.SourceCode = @"Sub Test(oShape As Shape) MsgBox ""Test"" End Sub";

                // Create reference to <stdole>
                VbaReferenceOleTypeLib stdoleReference =
                    new VbaReferenceOleTypeLib("stdole", "*\\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\\Windows\\system32\\stdole2.tlb#OLE Automation");

                // Create reference to Office
                VbaReferenceOleTypeLib officeReference =
                    new VbaReferenceOleTypeLib("Office", "*\\G{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}#2.0#0#C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE14\\MSO.DLL#Microsoft Office 14.0 Object Library");

                // Add references to the VBA project
                presentation.VbaProject.References.Add(stdoleReference);
                presentation.VbaProject.References.Add(officeReference);

                // ExStart:AddVBAMacros
                // Save Presentation
                presentation.Save(dataDir + "AddVBAMacros_out.pptm", SaveFormat.Pptm);
            }
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Presentations();

            //Instanciate the Presentation class that represents the PPTX
            Presentation pres = new Presentation(dataDir + "AccessModifyingProperties.pptx");

            //Create a reference to DocumentProperties object associated with Prsentation
            IDocumentProperties dp = pres.DocumentProperties;

            //Access and modify custom properties
            for (int i = 0; i < dp.Count; i++)
            {
                //Display names and values of custom properties
                System.Console.WriteLine("Custom Property Name : " + dp.GetPropertyName(i));
                System.Console.WriteLine("Custom Property Value : " + dp[dp.GetPropertyName(i)]);

                //Modify values of custom properties
                dp[dp.GetPropertyName(i)] = "New Value " + (i + 1);
            }

            //Save your presentation to a file
            pres.Save(dataDir + "CustomDemoModified.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
        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
                }

                // ExEnd:CheckSmartArtHiddenProperty
                // Saving Presentation
                presentation.Save(dataDir + "CheckSmartArtHiddenProperty_out.pptx", SaveFormat.Pptx);
            }
        }
Exemplo n.º 29
0
 public PptBuilder()
 {
     Presentations presentations = this.ppt.Presentations;
     this.presentation = presentations.Add();
     this.presentation.PageSetup.SlideSize = PpSlideSizeType.ppSlideSizeOnScreen16x10;
     this.slides = this.presentation.Slides;
 }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tables();

            // Instantiate Presentation class that represents PPTX// Instantiate Presentation class that represents PPTX
            using (Presentation presentation = new Presentation(dataDir + "UpdateExistingTable.pptx"))
            {
                // Access the first slide
                ISlide sld = presentation.Slides[0];

                // Initialize null TableEx
                ITable table = null;

                // Iterate through the shapes and set a reference to the table found
                foreach (IShape shape in sld.Shapes)
                    if (shape is ITable)
                        table = (ITable)shape;

                // Set the text of the first column of second row
                table[0, 1].TextFrame.Text = "New";

                // Write the PPTX to Disk
                presentation.Save(dataDir + "UpdateTable_out.pptx", SaveFormat.Pptx);
            }
        }
        public static void AppendStrategy(this PowerPointProcessor target, DigitalInfoStrategyOutputModel source, Theme theme, Presentation destinationPresentation = null)
        {
            try
            {
                var thread = new Thread(delegate()
                {
                    var presentationTemplatePath = source.TemplatePath;
                    if (string.IsNullOrEmpty(presentationTemplatePath))
                    {
                        return;
                    }
                    if (!File.Exists(presentationTemplatePath))
                    {
                        return;
                    }

                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                var shapeTagName = shape.Tags.Name(i);
                                switch (shapeTagName)
                                {
                                case "MONTHDIGINV":
                                    shape.TextFrame.TextRange.Text = source.Total2;
                                    break;

                                case "TOTALDIGINV":
                                    shape.TextFrame.TextRange.Text = source.Total1;
                                    break;

                                default:
                                    for (var j = 0; j < BaseDigitalInfoOneSheetOutputModel.MaxRecords; j++)
                                    {
                                        if (shapeTagName.Equals(String.Format("DIGITAL_GRAPHIC{0}", j + 1)))
                                        {
                                            var fileName = source.Logos.Length > j ? source.Logos[j] : String.Empty;
                                            if (!String.IsNullOrEmpty(fileName) && File.Exists(fileName))
                                            {
                                                var newShape = slide.Shapes.AddPicture(fileName, MsoTriState.msoFalse, MsoTriState.msoCTrue, shape.Left, shape.Top,
                                                                                       shape.Width, shape.Height);
                                                newShape.Top    = shape.Top;
                                                newShape.Left   = shape.Left;
                                                newShape.Width  = shape.Width;
                                                newShape.Height = shape.Height;
                                            }
                                            shape.Visible = MsoTriState.msoFalse;
                                        }
                                        if (shapeTagName.Equals(String.Format("DIGITAL_TAG{0}", j + 1)))
                                        {
                                            shape.TextFrame.TextRange.Text = source.Records.Count > j ? source.Records[j].Text1 : String.Empty;
                                        }
                                        if (shapeTagName.Equals(String.Format("DIGITAL_DETAILS{0}", j + 1)))
                                        {
                                            shape.TextFrame.TextRange.Text = source.Records.Count > j ? source.Records[j].Text2 : String.Empty;
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    if (theme != null)
                    {
                        presentation.ApplyTheme(theme.GetThemePath());
                    }
                    target.AppendSlide(presentation, -1, destinationPresentation);
                    presentation.Close();
                });
                thread.Start();

                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch
            {
            }
            finally
            {
                MessageFilter.Revoke();
            }
        }
        private static void AppendSlideSummary(this PowerPointProcessor target, ISummaryControl summary, Presentation destinationPresentation = null)
        {
            var itemsCount            = summary.ItemsCount;
            var mainFileTemplateIndex = itemsCount >= SummaryConstants.MaxOneSheetItems ? SummaryConstants.MaxOneSheetItems : itemsCount;

            var additionalFileTemplateIndex = itemsCount > SummaryConstants.MaxOneSheetItems ? itemsCount % SummaryConstants.MaxOneSheetItems : 0;

            var mainFilesCount = itemsCount / SummaryConstants.MaxOneSheetItems;

            if (mainFilesCount == 0 && itemsCount > 0)
            {
                mainFilesCount++;
            }

            try
            {
                var thread = new Thread(delegate()
                {
                    var mainPresentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetSimpleSummaryTemlateFile(String.Format(MasterWizardManager.SimpleSummarySlideTemplate, mainFileTemplateIndex));
                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(mainPresentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    for (int j = 0; j < (itemsCount - additionalFileTemplateIndex); j += mainFileTemplateIndex)
                    {
                        foreach (Slide slide in presentation.Slides)
                        {
                            foreach (Shape shape in slide.Shapes)
                            {
                                for (int i = 1; i <= shape.Tags.Count; i++)
                                {
                                    switch (shape.Tags.Name(i))
                                    {
                                    case "HEADER":
                                        shape.TextFrame.TextRange.Text = summary.Title;
                                        break;

                                    case "SUMMARYDATA":
                                        shape.TextFrame.TextRange.Text = summary.SummaryData;
                                        break;

                                    case "MNTHLY1":
                                        shape.Visible = summary.ShowMonthlyHeader && summary.ShowTotalHeader ? MsoTriState.msoTrue : MsoTriState.msoFalse;
                                        shape.TextFrame.TextRange.Text = String.Format("Monthly{0}Investment", (char)13);
                                        break;

                                    case "TOTAL2":
                                        if ((summary.ShowMonthlyHeader && summary.ShowTotalHeader) || summary.ShowTotalHeader)
                                        {
                                            shape.TextFrame.TextRange.Text = "Total Investment";
                                        }
                                        else if (summary.ShowMonthlyHeader)
                                        {
                                            shape.TextFrame.TextRange.Text = "Monthly Investment";
                                        }
                                        else
                                        {
                                            shape.Visible = MsoTriState.msoFalse;
                                        }
                                        break;

                                    default:
                                        for (int k = 0; k < mainFileTemplateIndex; k++)
                                        {
                                            if (shape.Tags.Name(i).Equals(string.Format("SHAPE{0}", k)))
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                                if (summary.ItemTitles == null)
                                                {
                                                    continue;
                                                }
                                                if ((j + k) < itemsCount)
                                                {
                                                    if (!string.IsNullOrEmpty(summary.ItemTitles[j + k]))
                                                    {
                                                        shape.Visible = MsoTriState.msoTrue;
                                                    }
                                                }
                                            }
                                            else if (shape.Tags.Name(i).Equals(string.Format("SUBHEADER{0}", k)))
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                                if (summary.ItemTitles == null)
                                                {
                                                    continue;
                                                }
                                                if ((j + k) >= itemsCount)
                                                {
                                                    continue;
                                                }
                                                shape.TextFrame.TextRange.Text = summary.ItemTitles[j + k];
                                                shape.Visible = MsoTriState.msoTrue;
                                            }
                                            else if (shape.Tags.Name(i).Equals(string.Format("SELECT{0}", k)))
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                                if (summary.ItemDetails == null)
                                                {
                                                    continue;
                                                }
                                                if ((j + k) >= itemsCount)
                                                {
                                                    continue;
                                                }
                                                shape.TextFrame.TextRange.Text = summary.ItemDetails[j + k];
                                                shape.Visible = MsoTriState.msoTrue;
                                            }
                                            else if (shape.Tags.Name(i).Equals(string.Format("TINVEST{0}", k)))
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                                if (summary.MonthlyValues == null)
                                                {
                                                    continue;
                                                }
                                                if ((j + k) >= itemsCount)
                                                {
                                                    continue;
                                                }
                                                shape.TextFrame.TextRange.Text = summary.MonthlyValues[j + k];
                                                shape.Visible = MsoTriState.msoTrue;
                                            }
                                            else if (shape.Tags.Name(i).Equals(string.Format("MWINVEST{0}", k)))
                                            {
                                                shape.Visible = MsoTriState.msoFalse;
                                                if (summary.TotalValues == null)
                                                {
                                                    continue;
                                                }
                                                if ((j + k) >= itemsCount)
                                                {
                                                    continue;
                                                }
                                                shape.TextFrame.TextRange.Text = summary.TotalValues[j + k];
                                                shape.Visible = MsoTriState.msoTrue;
                                            }
                                        }
                                        break;
                                    }
                                }
                            }

                            if (summary.ContractSettings.IsConfigured &&
                                summary.ContractTemplateFolder != null &&
                                summary.ContractTemplateFolder.ExistsLocal())
                            {
                                target.FillContractInfo(slide, summary.ContractSettings, summary.ContractTemplateFolder);
                            }
                        }
                        var selectedTheme = summary.SelectedTheme;
                        if (selectedTheme != null)
                        {
                            presentation.ApplyTheme(selectedTheme.GetThemePath());
                        }
                        target.AppendSlide(presentation, -1, destinationPresentation);
                    }
                    presentation.Close();
                });
                thread.Start();

                while (thread.IsAlive)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
            finally
            {
                MessageFilter.Revoke();
            }

            if (additionalFileTemplateIndex == 0)
            {
                return;
            }
            try
            {
                var thread = new Thread(delegate()
                {
                    var additionalPresentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetSimpleSummaryTemlateFile(String.Format(MasterWizardManager.SimpleSummarySlideTemplate, (additionalFileTemplateIndex + mainFileTemplateIndex)));

                    MessageFilter.Register();
                    var presentation = target.PowerPointObject.Presentations.Open(additionalPresentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    foreach (Slide slide in presentation.Slides)
                    {
                        foreach (Shape shape in slide.Shapes)
                        {
                            for (int i = 1; i <= shape.Tags.Count; i++)
                            {
                                switch (shape.Tags.Name(i))
                                {
                                case "HEADER":
                                    shape.TextFrame.TextRange.Text = summary.Title;
                                    break;

                                case "SUMMARYDATA":
                                    shape.TextFrame.TextRange.Text = summary.SummaryData;
                                    break;

                                case "MNTHLY1":
                                    shape.Visible = summary.ShowMonthlyHeader && summary.ShowTotalHeader ? MsoTriState.msoTrue : MsoTriState.msoFalse;
                                    shape.TextFrame.TextRange.Text = String.Format("Monthly{0}Investment", (char)13);
                                    break;

                                case "TOTAL2":
                                    if ((summary.ShowMonthlyHeader && summary.ShowTotalHeader) || summary.ShowTotalHeader)
                                    {
                                        shape.TextFrame.TextRange.Text = "Total Investment";
                                    }
                                    else if (summary.ShowMonthlyHeader)
                                    {
                                        shape.TextFrame.TextRange.Text = "Monthly Investment";
                                    }
                                    else
                                    {
                                        shape.Visible = MsoTriState.msoFalse;
                                    }
                                    break;

                                default:
                                    int j = mainFileTemplateIndex * mainFilesCount;
                                    for (int k = 0; k < additionalFileTemplateIndex; k++)
                                    {
                                        if (shape.Tags.Name(i).Equals(string.Format("SHAPE{0}", k)))
                                        {
                                            shape.Visible = MsoTriState.msoFalse;
                                            if (summary.ItemTitles == null)
                                            {
                                                continue;
                                            }
                                            if ((j + k) < itemsCount)
                                            {
                                                if (!string.IsNullOrEmpty(summary.ItemTitles[j + k]))
                                                {
                                                    shape.Visible = MsoTriState.msoTrue;
                                                }
                                            }
                                        }
                                        else if (shape.Tags.Name(i).Equals(string.Format("SUBHEADER{0}", k)))
                                        {
                                            shape.Visible = MsoTriState.msoFalse;
                                            if (summary.ItemTitles == null)
                                            {
                                                continue;
                                            }
                                            if ((j + k) >= itemsCount)
                                            {
                                                continue;
                                            }
                                            shape.TextFrame.TextRange.Text = summary.ItemTitles[j + k];
                                            shape.Visible = MsoTriState.msoTrue;
                                        }
                                        else if (shape.Tags.Name(i).Equals(string.Format("SELECT{0}", k)))
                                        {
                                            shape.Visible = MsoTriState.msoFalse;
                                            if (summary.ItemDetails == null)
                                            {
                                                continue;
                                            }
                                            if ((j + k) >= itemsCount)
                                            {
                                                continue;
                                            }
                                            shape.TextFrame.TextRange.Text = summary.ItemDetails[j + k];
                                            shape.Visible = MsoTriState.msoTrue;
                                        }
                                        else if (shape.Tags.Name(i).Equals(string.Format("TINVEST{0}", k)))
                                        {
                                            shape.Visible = MsoTriState.msoFalse;
                                            if (summary.MonthlyValues == null)
                                            {
                                                continue;
                                            }
                                            if ((j + k) >= itemsCount)
                                            {
                                                continue;
                                            }
                                            shape.TextFrame.TextRange.Text = summary.MonthlyValues[j + k];
                                            shape.Visible = MsoTriState.msoTrue;
                                        }
                                        else if (shape.Tags.Name(i).Equals(string.Format("MWINVEST{0}", k)))
                                        {
                                            shape.Visible = MsoTriState.msoFalse;
                                            if (summary.TotalValues == null)
                                            {
                                                continue;
                                            }
                                            if ((j + k) >= itemsCount)
                                            {
                                                continue;
                                            }
                                            shape.TextFrame.TextRange.Text = summary.TotalValues[j + k];
                                            shape.Visible = MsoTriState.msoTrue;
                                        }
                                    }
                                    break;
                                }
                            }
                        }

                        if (summary.ContractSettings.IsConfigured &&
                            summary.ContractTemplateFolder != null &&
                            summary.ContractTemplateFolder.ExistsLocal())
                        {
                            target.FillContractInfo(slide, summary.ContractSettings, summary.ContractTemplateFolder);
                        }
                    }
                    var selectedTheme = summary.SelectedTheme;
                    if (selectedTheme != null)
                    {
                        presentation.ApplyTheme(selectedTheme.GetThemePath());
                    }
                    target.AppendSlide(presentation, -1, destinationPresentation);
                    presentation.Close();
                });
                thread.Start();

                while (thread.IsAlive)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
            finally
            {
                MessageFilter.Revoke();
            }
        }
Exemplo n.º 33
0
        public DataSet ImportTablesToDataSet()
        {
            Application appPPT = new Application();

            appPPT.Visible = Microsoft.Office.Core.MsoTriState.msoFalse;
            appPPT.Activate();

            Presentation apPresentation = appPPT.Presentations.Open2007(FilePath,
                                                                        Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                        Microsoft.Office.Core.MsoTriState.msoFalse,
                                                                        Microsoft.Office.Core.MsoTriState.msoTrue,
                                                                        Microsoft.Office.Core.MsoTriState.msoFalse);

            int intTables = 0;

            foreach (Slide pSlide in apPresentation.Slides)
            {
                foreach (Shape pShape in pSlide.Shapes)
                {
                    if (pShape.HasTable.Equals(Microsoft.Office.Core.MsoTriState.msoTrue))
                    {
                        intTables++;

                        Table dt             = pShape.Table;
                        int   intRowsCounter = 1 + RowsToSkip;
                        System.Data.DataTable m_DataTable = new System.Data.DataTable("DT_" + intTables);
                        int intColumnsCounter             = 0;

                        if (intRowsCounter > dt.Rows.Count)
                        {
                            return(null);
                        }

                        if (HasHeader)
                        {
                            for (int i = 1; i == dt.Columns.Count; i++)
                            {
                                m_DataTable.Columns.Add(dt.Cell(intRowsCounter, i).Shape.TextFrame.HasText.Equals(Microsoft.Office.Core.MsoTriState.msoTrue) ?
                                                        dt.Cell(intRowsCounter, i).Shape.TextFrame.TextRange.Text.Trim() :
                                                        "F" + i.ToString());
                            }

                            intRowsCounter++;
                        }
                        else
                        {
                            for (int i = 1; i == dt.Columns.Count; i++)
                            {
                                m_DataTable.Columns.Add("F" + i.ToString());
                            }
                        }


                        while (intRowsCounter <= dt.Rows.Count)
                        {
                            DataRow drRow = m_DataTable.NewRow();

                            for (intColumnsCounter = 1; intColumnsCounter == dt.Columns.Count; intColumnsCounter++)
                            {
                                drRow[intColumnsCounter - 1] = dt.Cell(intRowsCounter, intColumnsCounter).Shape.TextFrame.HasText.Equals(Microsoft.Office.Core.MsoTriState.msoTrue) ?
                                                               dt.Cell(intRowsCounter, intColumnsCounter).Shape.TextFrame.TextRange.Text.Trim() : "";
                            }

                            m_DataTable.Rows.Add(drRow);
                            intRowsCounter++;
                        }

                        Maindataset.Tables.Add(m_DataTable);
                    }
                }
            }

            apPresentation.Close();
            appPPT.Quit();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(apPresentation);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(appPPT);

            return(Maindataset);
        }
Exemplo n.º 34
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            ((fhirCsR4.Models.BackboneElement) this).SerializeJson(writer, options, false);

            if (Presentation != null)
            {
                writer.WritePropertyName("presentation");
                Presentation.SerializeJson(writer, options);
            }

            if (PresentationLowLimit != null)
            {
                writer.WritePropertyName("presentationLowLimit");
                PresentationLowLimit.SerializeJson(writer, options);
            }

            if (Concentration != null)
            {
                writer.WritePropertyName("concentration");
                Concentration.SerializeJson(writer, options);
            }

            if (ConcentrationLowLimit != null)
            {
                writer.WritePropertyName("concentrationLowLimit");
                ConcentrationLowLimit.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(MeasurementPoint))
            {
                writer.WriteString("measurementPoint", (string)MeasurementPoint !);
            }

            if (_MeasurementPoint != null)
            {
                writer.WritePropertyName("_measurementPoint");
                _MeasurementPoint.SerializeJson(writer, options);
            }

            if ((Country != null) && (Country.Count != 0))
            {
                writer.WritePropertyName("country");
                writer.WriteStartArray();

                foreach (CodeableConcept valCountry in Country)
                {
                    valCountry.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((ReferenceStrength != null) && (ReferenceStrength.Count != 0))
            {
                writer.WritePropertyName("referenceStrength");
                writer.WriteStartArray();

                foreach (MedicinalProductIngredientSpecifiedSubstanceStrengthReferenceStrength valReferenceStrength in ReferenceStrength)
                {
                    valReferenceStrength.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Exemplo n.º 35
0
        public static void Run()
        {
            //ExStart:ScatteredChart
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

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

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

            Presentation pres = new Presentation();

            ISlide slide = pres.Slides[0];

            // Creating the default chart
            IChart chart = slide.Shapes.AddChart(ChartType.ScatterWithSmoothLines, 0, 0, 400, 400);

            // Getting the default chart data worksheet index
            int defaultWorksheetIndex = 0;

            // Getting the chart data worksheet
            IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

            // Delete demo series
            chart.ChartData.Series.Clear();

            // Add new series
            chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type);
            chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, "Series 2"), chart.Type);

            // Take first chart series
            IChartSeries series = chart.ChartData.Series[0];

            // Add new point (1:3) there.
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 1), fact.GetCell(defaultWorksheetIndex, 2, 2, 3));

            // Add new point (2:10)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 2), fact.GetCell(defaultWorksheetIndex, 3, 2, 10));

            // Edit the type of series
            series.Type = ChartType.ScatterWithStraightLinesAndMarkers;

            // Changing the chart series marker
            series.Marker.Size   = 10;
            series.Marker.Symbol = MarkerStyleType.Star;

            // Take second chart series
            series = chart.ChartData.Series[1];

            // Add new point (5:2) there.
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, 5), fact.GetCell(defaultWorksheetIndex, 2, 4, 2));

            // Add new point (3:1)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, 3), fact.GetCell(defaultWorksheetIndex, 3, 4, 1));

            // Add new point (2:2)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 3, 2), fact.GetCell(defaultWorksheetIndex, 4, 4, 2));

            // Add new point (5:1)
            series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 5, 3, 5), fact.GetCell(defaultWorksheetIndex, 5, 4, 1));

            // Changing the chart series marker
            series.Marker.Size   = 10;
            series.Marker.Symbol = MarkerStyleType.Circle;

            pres.Save(dataDir + "AsposeChart_out.pptx", SaveFormat.Pptx);
            //ExEnd:ScatteredChart
        }
Exemplo n.º 36
0
 public static void Main(string[] args)
 {
     Presentation.MainMenu();
 }
Exemplo n.º 37
0
        protected void GridviewPaylasimlar_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "aktif")
            {
                int userID = Convert.ToInt32(e.CommandArgument);



                Presentation c = sunumislem.TekGetir(userID);


                if (c.IsActive == true)
                {
                    if (sunumislem.DurumGuncelle(userID, false))
                    {
                        Doldur();
                    }
                }
                else
                {
                    if (sunumislem.DurumGuncelle(userID, true))
                    {
                        Doldur();
                    }
                }
            }

            GridViewRow secilenSatir;
            int         id;


            switch (e.CommandName)
            {
            case "duzenle":

                secilenSatir = (e.CommandSource as LinkButton).Parent.Parent as GridViewRow;
                id           = Convert.ToInt32(e.CommandArgument);
                GridviewPaylasimlar.EditIndex = secilenSatir.RowIndex;
                Doldur();


                break;

            case "kaydet":


                //int belgeId = Convert.ToInt32(e.CommandArgument);
                //PRESENTATION c = sunumislem.TekGetir(belgeId);
                //string yol = "";
                //yol = c.FileUrl;
                //string filePath = yol;
                //Response.ContentType = ContentType;
                //Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(yol));
                //Response.WriteFile(yol);
                //Response.End();

                break;

            case "guncelle":


                secilenSatir = (e.CommandSource as LinkButton).Parent.Parent as GridViewRow;
                id           = Convert.ToInt32(e.CommandArgument);

                System.Web.UI.WebControls.DropDownList ddl1 = (System.Web.UI.WebControls.DropDownList)(secilenSatir.FindControl("dropDownKonu"));
                System.Web.UI.WebControls.DropDownList ddl2 = (System.Web.UI.WebControls.DropDownList)(secilenSatir.FindControl("dropDownSinif"));
                System.Web.UI.WebControls.TextBox      txt5 = (System.Web.UI.WebControls.TextBox)(secilenSatir.FindControl("txtAcilis"));

                Presentation sunum2 = sunumislem.TekGetir(id);
                sunum2.CreatedDate = Convert.ToDateTime(txt5.Text);
                sunum2.ClassroomID = Convert.ToInt32(ddl2.SelectedValue);
                sunum2.SubjectID   = Convert.ToInt32(ddl1.SelectedValue);


                if (sunumislem.Guncelle(sunum2))
                {
                    GridviewPaylasimlar.EditIndex = -1;
                    Doldur();
                }



                break;

            case "iptal":

                GridviewPaylasimlar.EditIndex = -1;
                Doldur();

                break;

            default:
                break;
            }
        }
        private static void AppendTableSummary(this PowerPointProcessor target, ISummaryControl summary, Presentation destinationPresentation = null)
        {
            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var slidesCount = summary.OutputReplacementsLists.Count;
                    for (var k = 0; k < slidesCount; k++)
                    {
                        var presentationTemplatePath = MasterWizardManager.Instance.SelectedWizard.GetSimpleSummaryTableFile(String.Format(MasterWizardManager.SimpleSummaryTableTemplate, summary.ItemsPerTable));
                        if (!File.Exists(presentationTemplatePath))
                        {
                            continue;
                        }
                        var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                        foreach (Slide slide in presentation.Slides)
                        {
                            foreach (Shape shape in slide.Shapes)
                            {
                                for (var i = 1; i <= shape.Tags.Count; i++)
                                {
                                    switch (shape.Tags.Name(i))
                                    {
                                    case "HEADER":
                                        shape.TextFrame.TextRange.Text = summary.Title;
                                        break;

                                    case "SUMMARYDATA":
                                        shape.TextFrame.TextRange.Text = summary.SummaryData;
                                        break;

                                    default:
                                        var startIndex = k * summary.ItemsPerTable;
                                        for (var j = 0; j < summary.ItemsPerTable; j++)
                                        {
                                            if (shape.Tags.Name(i).Equals(String.Format("ICON{0}", j + 1)))
                                            {
                                                if (summary.ShowIcons &&
                                                    (j + startIndex) < summary.ItemsCount &&
                                                    !String.IsNullOrEmpty(summary.TableIcons[j + startIndex]))
                                                {
                                                    var filePath    = MasterWizardManager.Instance.SelectedWizard.GetSimpleSummaryIconFile(summary.TableIcons[j + startIndex]);
                                                    var newShape    = slide.Shapes.AddPicture(filePath, MsoTriState.msoFalse, MsoTriState.msoCTrue, shape.Left, shape.Top, shape.Width, shape.Height);
                                                    newShape.Top    = shape.Top;
                                                    newShape.Left   = shape.Left;
                                                    newShape.Width  = shape.Width;
                                                    newShape.Height = shape.Height;
                                                }
                                                shape.Visible = MsoTriState.msoFalse;
                                            }
                                        }
                                        break;
                                    }
                                }
                                if (shape.HasTable != MsoTriState.msoTrue)
                                {
                                    continue;
                                }
                                var table             = shape.Table;
                                var tableRowsCount    = table.Rows.Count;
                                var tableColumnsCount = table.Columns.Count;
                                for (var i = 1; i <= tableRowsCount; i++)
                                {
                                    for (var j = 1; j <= tableColumnsCount; j++)
                                    {
                                        if (j > table.Columns.Count)
                                        {
                                            continue;
                                        }
                                        var tableShape = table.Cell(i, j).Shape;
                                        if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                        {
                                            continue;
                                        }
                                        var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                        if (!cellText.Contains("Product") || summary.ShowIcons)
                                        {
                                            continue;
                                        }
                                        var prevColumnIndex = j - 1;
                                        if (prevColumnIndex < 1)
                                        {
                                            continue;
                                        }
                                        table.Cell(i, j).Merge(table.Cell(i, prevColumnIndex));
                                    }
                                }

                                tableRowsCount    = table.Rows.Count;
                                tableColumnsCount = table.Columns.Count;
                                for (var i = 1; i <= tableRowsCount; i++)
                                {
                                    for (var j = 1; j <= tableColumnsCount; j++)
                                    {
                                        var tableShape = table.Cell(i, j).Shape;
                                        if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                        {
                                            continue;
                                        }
                                        var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                        if (!summary.OutputReplacementsLists[k].ContainsKey(cellText))
                                        {
                                            continue;
                                        }
                                        tableShape.TextFrame.TextRange.Text = summary.OutputReplacementsLists[k][cellText];
                                        summary.OutputReplacementsLists[k].Remove(cellText);
                                    }
                                }

                                for (var i = tableRowsCount; i >= 1; i--)
                                {
                                    var tableShape = table.Cell(i, 1).Shape;
                                    if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                                    {
                                        continue;
                                    }
                                    var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                                    if (!cellText.Equals("DeleteRow"))
                                    {
                                        continue;
                                    }
                                    try { table.Rows[i].Delete(); }
                                    catch { shape.Visible = MsoTriState.msoFalse; }
                                }
                            }
                        }
                        var selectedTheme = summary.SelectedTheme;
                        if (selectedTheme != null)
                        {
                            presentation.ApplyTheme(selectedTheme.GetThemePath());
                        }
                        target.AppendSlide(presentation, -1, destinationPresentation);
                        presentation.Close();
                    }
                });
                thread.Start();

                while (thread.IsAlive)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
            catch { }
            finally
            {
                MessageFilter.Revoke();
            }
        }
Exemplo n.º 39
0
        private void btnCreateImage_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //Opens the existing presentation stream.
                using (IPresentation presentation = Presentation.Create())
                {
                    ISlide     slide     = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                    IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                    //Apply center alignment to the paragraph
                    paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                    //Add slide title
                    ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                    textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                    //Get chart data from xml file
                    DataSet dataSet = new DataSet();
#if !NETCore
                    dataSet.ReadXml(@"..\..\..\..\..\..\Common\Data\Presentation\Products.xml");
#else
                    dataSet.ReadXml(@"..\..\..\..\..\..\..\Common\Data\Presentation\Products.xml");
#endif
                    //Add a new chart to the presentation slide
                    IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                    //Set chart type
                    chart.ChartType = OfficeChartType.Pie;
                    //Set chart title
                    chart.ChartTitle = "Best Selling Products";
                    //Set chart properties font name and size
                    chart.ChartTitleArea.FontName = "Calibri (Body)";
                    chart.ChartTitleArea.Size     = 14;
                    for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                    {
                        chart.ChartData.SetValue(i + 2, 1, dataSet.Tables[0].Rows[i].ItemArray[1]);
                        chart.ChartData.SetValue(i + 2, 2, dataSet.Tables[0].Rows[i].ItemArray[2]);
                    }
                    //Create a new chart series with the name “Sales”
                    AddSeriesForChart(chart);
                    //Setting the font size of the legend.
                    chart.Legend.TextArea.Size = 14;
                    //Setting background color
                    chart.ChartArea.Fill.ForeColor           = System.Drawing.Color.FromArgb(242, 242, 242);
                    chart.PlotArea.Fill.ForeColor            = System.Drawing.Color.FromArgb(242, 242, 242);
                    chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                    chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                    //Saves the presentation instance to the stream.
                    presentation.Save("ChartCreationSample.pptx");
                    if (System.Windows.MessageBox.Show("Do you want to view the generated PowerPoint Presentation?", "Chart Creation",
                                                       MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                    {
#if !NETCore
                        System.Diagnostics.Process.Start("ChartCreationSample.pptx");
#else
                        System.Diagnostics.Process process = new System.Diagnostics.Process();
                        process.StartInfo = new System.Diagnostics.ProcessStartInfo("ChartCreationSample.pptx")
                        {
                            UseShellExecute = true
                        };
                        process.Start();
#endif
                        this.Close();
                    }
                }
            }
            catch (Exception exception)
            {
                System.Windows.MessageBox.Show("This Presentation could not be created, please contact Syncfusion Direct-Trac system at http://www.syncfusion.com/support/default.aspx for any queries. ", "OOPS..Sorry!",
                                               MessageBoxButton.OK);
                this.Close();
            }
        }
 public static void AppendSummary(this PowerPointProcessor target, ISummaryControl summary, bool tabelOutput, Presentation destinationPresentation = null)
 {
     if (tabelOutput)
     {
         summary.PopulateReplacementsList();
         target.AppendTableSummary(summary, destinationPresentation);
     }
     else
     {
         target.AppendSlideSummary(summary, destinationPresentation);
     }
 }
Exemplo n.º 41
0
        /// <summary>
        /// PPT产生缩略图
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="previewPath"></param>
        /// <returns></returns>
        private static bool GetThumbnailPpt(string filePath, string previewPath)
        {
            bool         result = false;
            Presentation ppt    = new Presentation();

            try
            {
                ppt.LoadFromFile(filePath);
                if (ppt.Slides.Count > 0)
                {
                    //生成图片
                    foreach (IShape s in ppt.Slides[0].Shapes)
                    {
                        if (s is SlidePicture)
                        {
                            SlidePicture ps = s as SlidePicture;
                            ps.PictureFill.Picture.EmbedImage.Image.Save(previewPath);
                            if (File.Exists(previewPath))
                            {
                                result = true;
                            }
                            ps.Dispose();
                        }
                        if (s is PictureShape)
                        {
                            PictureShape ps = s as PictureShape;
                            ps.EmbedImage.Image.Save(previewPath);
                            if (File.Exists(previewPath))
                            {
                                result = true;
                            }
                        }
                    }

                    if (!result)
                    {
                        string temImage = Path.GetDirectoryName(previewPath) + "\\" + Guid.NewGuid().ToString() + ".emf";
                        ppt.Slides[0].SaveAsEMF(temImage);
                        Image image = Bitmap.FromFile(temImage);
                        image.Save(previewPath);
                        image.Dispose();
                        File.Delete(temImage);
                        if (File.Exists(previewPath))
                        {
                            result = true;
                        }
                    }

                    if (!result)
                    {
                        result = GetThumbnailWritten("PPT", previewPath);
                    }
                }
                ppt.Dispose();
            }
            catch
            {
                ppt.Dispose();
                result = GetThumbnailWritten("PPT", previewPath);
            }


            return(result);
        }
Exemplo n.º 42
0
        public static void Run()
        {
            //ExStart:AddDoughnutCallout
            string             dataDir  = RunExamples.GetDataDir_Charts();
            Presentation       pres     = new Presentation(dataDir + "testc.pptx");
            ISlide             slide    = pres.Slides[0];
            IChart             chart    = slide.Shapes.AddChart(ChartType.Doughnut, 10, 10, 500, 500, false);
            IChartDataWorkbook workBook = chart.ChartData.ChartDataWorkbook;

            chart.ChartData.Series.Clear();
            chart.ChartData.Categories.Clear();
            chart.HasLegend = false;
            int seriesIndex = 0;

            while (seriesIndex < 15)
            {
                IChartSeries series = chart.ChartData.Series.Add(workBook.GetCell(0, 0, seriesIndex + 1, "SERIES " + seriesIndex), chart.Type);
                series.Explosion = 0;
                series.ParentSeriesGroup.DoughnutHoleSize = (byte)20;
                series.ParentSeriesGroup.FirstSliceAngle  = 351;
                seriesIndex++;
            }
            int categoryIndex = 0;

            while (categoryIndex < 15)
            {
                chart.ChartData.Categories.Add(workBook.GetCell(0, categoryIndex + 1, 0, "CATEGORY " + categoryIndex));
                int i = 0;
                while (i < chart.ChartData.Series.Count)
                {
                    IChartSeries    iCS       = chart.ChartData.Series[i];
                    IChartDataPoint dataPoint = iCS.DataPoints.AddDataPointForDoughnutSeries(workBook.GetCell(0, categoryIndex + 1, i + 1, 1));
                    dataPoint.Format.Fill.FillType                        = FillType.Solid;
                    dataPoint.Format.Line.FillFormat.FillType             = FillType.Solid;
                    dataPoint.Format.Line.FillFormat.SolidFillColor.Color = Color.White;
                    dataPoint.Format.Line.Width     = 1;
                    dataPoint.Format.Line.Style     = LineStyle.Single;
                    dataPoint.Format.Line.DashStyle = LineDashStyle.Solid;
                    if (i == chart.ChartData.Series.Count - 1)
                    {
                        IDataLabel lbl = dataPoint.Label;
                        lbl.TextFormat.TextBlockFormat.AutofitType                                   = TextAutofitType.Shape;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FontBold                        = NullableBool.True;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.LatinFont                       = new FontData("DINPro-Bold");
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FontHeight                      = 12;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.FillType             = FillType.Solid;
                        lbl.DataLabelFormat.TextFormat.PortionFormat.FillFormat.SolidFillColor.Color = Color.LightGray;
                        lbl.DataLabelFormat.Format.Line.FillFormat.SolidFillColor.Color              = Color.White;
                        lbl.DataLabelFormat.ShowValue        = false;
                        lbl.DataLabelFormat.ShowCategoryName = true;
                        lbl.DataLabelFormat.ShowSeriesName   = false;
                        //lbl.DataLabelFormat.ShowLabelAsDataCallout = true;
                        lbl.DataLabelFormat.ShowLeaderLines        = true;
                        lbl.DataLabelFormat.ShowLabelAsDataCallout = false;
                        chart.ValidateChartLayout();
                        lbl.AsILayoutable.X = (float)lbl.AsILayoutable.X + (float)0.5;
                        lbl.AsILayoutable.Y = (float)lbl.AsILayoutable.Y + (float)0.5;
                    }
                    i++;
                }
                categoryIndex++;
            }
            pres.Save(dataDir + "chart.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
Exemplo n.º 43
0
        private void btnCreatePresn_Click(object sender, EventArgs e)
        {
            //New Instance of PowerPoint is Created.[Equivalent to launching MS PowerPoint with no slides].
            IPresentation presentation = Presentation.Create();
            //Add slide with titleonly layout to presentation
            ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);
            //Get the title placeholder
            IShape titleShape = slide.Shapes[0] as IShape;

            //Set size and position of the title shape
            titleShape.Left   = 0.65 * 72;
            titleShape.Top    = 0.24 * 72;
            titleShape.Width  = 11.5 * 72;
            titleShape.Height = 1.45 * 72;

            //Add title content
            titleShape.TextBody.AddParagraph("Ole Object");
            //Set the title content as bold
            titleShape.TextBody.Paragraphs[0].Font.Bold = true;
            //Set the horizontal alignment as center
            titleShape.TextBody.Paragraphs[0].HorizontalAlignment = HorizontalAlignmentType.Left;
            //Add text box of specific size and position
            IShape heading = slide.Shapes.AddTextBox(0.84 * 72, 1.65 * 72, 2.23 * 72, 0.51 * 72);

            //Add paragraph to text box
            heading.TextBody.AddParagraph("MS Word Object");
            //Set the text content as italic
            heading.TextBody.Paragraphs[0].Font.Italic = true;
            //Set the text content as bold
            heading.TextBody.Paragraphs[0].Font.Bold = true;
            //Set the font size
            heading.TextBody.Paragraphs[0].Font.FontSize = 18;

            string mswordPath = @"Assets\Presentation\OleTemplate.docx";

            //Get the word file as stream
            Stream wordStream = File.Open(mswordPath, FileMode.Open);
            //Image to be displayed, This can be any image
            Stream imageStream = GetFileStream("OlePicture.png");
            //Add ole object to the slide
            IOleObject oleObject = slide.Shapes.AddOleObject(imageStream, "Word.Document.12", wordStream);

            //Set size and position of the ole object
            oleObject.Left   = 4.53 * 72;
            oleObject.Top    = 0.79 * 72;
            oleObject.Width  = 4.26 * 72;
            oleObject.Height = 5.92 * 72;

            //Save the presentation
            presentation.Save("OLEObject.pptx");
            //Close the presentation
            presentation.Close();

            if (System.Windows.MessageBox.Show("Do you want to view the generated Presentation?", "Presentation Created",
                                               MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo = new System.Diagnostics.ProcessStartInfo("OLEObject.pptx")
                {
                    UseShellExecute = true
                };
                process.Start();
            }
        }
Exemplo n.º 44
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Assembly assembly     = typeof(ImagesPresentation).GetTypeInfo().Assembly;
            string   resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.Images.pptx";
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = await Presentation.OpenAsync(fileStream);

            #region Slide 1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];
            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.85 * 72;
            shape1.Width  = 10.86 * 72;
            shape1.Height = 3.74 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;
            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;
            textParts.Add();
            ITextPart textPart = textParts[0];
            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;

            IComment comment = slide1.Comments.Add(0.35, 0.04, "Author1", "A1", "Essential Presentation is available from 13.1 versions of Essential Studio", DateTime.Now);
            //Author2 add reply to a parent comment
            slide1.Comments.Add("Author2", "A2", "Does it support rendering of slides as images or PDF?", DateTime.Now, comment);
            //Author1 add reply to a parent comment
            slide1.Comments.Add("Author1", "A1", "Yes, you may render slides as images and PDF.", DateTime.Now, comment);
            #endregion

            #region Slide2

            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.Blank);

            IPresentationChart chart = slide2.Shapes.AddChart(230, 80, 500, 400);

            //Specifies the chart title

            chart.ChartTitle = "Sales Analysis";

            //Sets chart data - Row1

            chart.ChartData.SetValue(1, 2, "Jan");

            chart.ChartData.SetValue(1, 3, "Feb");

            chart.ChartData.SetValue(1, 4, "March");

            //Sets chart data - Row2

            chart.ChartData.SetValue(2, 1, 2010);

            chart.ChartData.SetValue(2, 2, 60);

            chart.ChartData.SetValue(2, 3, 70);

            chart.ChartData.SetValue(2, 4, 80);

            //Sets chart data - Row3

            chart.ChartData.SetValue(3, 1, 2011);

            chart.ChartData.SetValue(3, 2, 80);

            chart.ChartData.SetValue(3, 3, 70);

            chart.ChartData.SetValue(3, 4, 60);

            //Sets chart data - Row4

            chart.ChartData.SetValue(4, 1, 2012);

            chart.ChartData.SetValue(4, 2, 60);

            chart.ChartData.SetValue(4, 3, 70);

            chart.ChartData.SetValue(4, 4, 80);

            //Creates a new chart series with the name

            IOfficeChartSerie serieJan = chart.Series.Add("Jan");

            //Sets the data range of chart serie � start row, start column, end row, end column

            serieJan.Values = chart.ChartData[2, 2, 4, 2];

            //Creates a new chart series with the name

            IOfficeChartSerie serieFeb = chart.Series.Add("Feb");

            //Sets the data range of chart serie � start row, start column, end row, end column

            serieFeb.Values = chart.ChartData[2, 3, 4, 3];

            //Creates a new chart series with the name

            IOfficeChartSerie serieMarch = chart.Series.Add("March");

            //Sets the data range of chart series � start row, start column, end row, end column

            serieMarch.Values = chart.ChartData[2, 4, 4, 4];

            //Sets the data range of the category axis

            chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];

            //Specifies the chart type

            chart.ChartType = OfficeChartType.Column_Clustered_3D;

            slide2.Comments.Add(0.35, 0.04, "Author2", "A2", "Do all 3D-chart types support in Presentation library?", DateTime.Now);
            #endregion

            #region Slide3
            ISlide slide3 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption);
            slide3.Background.Fill.FillType        = FillType.Solid;
            slide3.Background.Fill.SolidFill.Color = ColorObject.White;

            //Adds shape in slide
            IShape shape2 = (IShape)slide3.Shapes[0];
            shape2.Left   = 0.47 * 72;
            shape2.Top    = 1.15 * 72;
            shape2.Width  = 3.5 * 72;
            shape2.Height = 4.91 * 72;

            ITextBody textFrame1 = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textpart1 = paragraph1.AddTextPart();
            textpart1.Text          = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph2 = paragraphs1.Add();
            paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph2.AddTextPart();
            textpart1.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph3 = paragraphs1.Add();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph3.AddTextPart();
            textpart1.Text          = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph4 = paragraphs1.Add();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph4.AddTextPart();
            textpart1.Text          = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            slide3.Shapes.RemoveAt(1);
            slide3.Shapes.RemoveAt(1);

            //Adds picture in the shape
            resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.tablet.jpg";
            fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPicture picture1 = slide3.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72);
            fileStream.Dispose();

            //Add comment to the slide
            IComment comment1 = slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now);
            //Add reply to a parent comment
            slide3.Comments.Add("Author1", "A1", "Please specify the desired font for modification", DateTime.Now, comment1);
            #endregion

            MemoryStream ms = new MemoryStream();

            SavePPTX(presentation);
        }
Exemplo n.º 45
0
 /// <summary>
 /// Exports the external video media to a destination <see cref="Presentation"/>
 /// </summary>
 /// <param name="destPres">The destination presentation</param>
 /// <returns>The exported external video media</returns>
 public new ExternalVideoMedia Export(Presentation destPres)
 {
     return(ExportProtected(destPres) as ExternalVideoMedia);
 }
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.Images.pptx";
            Assembly assembly     = typeof(App).GetTypeInfo().Assembly;
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Presentation.Open(fileStream);

            #region Slide1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];
            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.56 * 72;
            shape1.Width  = 9.55 * 72;
            shape1.Height = 5.4 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;
            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;
            textParts.Add();
            ITextPart textPart = textParts[0];
            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;
            #endregion

            #region Slide2
            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.ContentWithCaption);
            slide2.Background.Fill.FillType        = FillType.Solid;
            slide2.Background.Fill.SolidFill.Color = ColorObject.White;

            //Adds shape in slide
            shape1        = (IShape)slide2.Shapes[0];
            shape1.Left   = 0.47 * 72;
            shape1.Top    = 1.15 * 72;
            shape1.Width  = 3.5 * 72;
            shape1.Height = 4.91 * 72;

            ITextBody textFrame1 = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textpart1 = paragraph1.AddTextPart();
            textpart1.Text          = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph2 = paragraphs1.Add();
            paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph2.AddTextPart();
            textpart1.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph3 = paragraphs1.Add();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph3.AddTextPart();
            textpart1.Text          = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            IParagraph paragraph4 = paragraphs1.Add();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph4.AddTextPart();
            textpart1.Text          = "Lorem tortor neque, purus taciti quis id. Elementum integer orci accumsan minim phasellus vel.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            paragraphs1.Add();

            slide2.Shapes.RemoveAt(1);
            slide2.Shapes.RemoveAt(1);

            //Adds picture in the shape
            resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg";
            assembly     = typeof(App).GetTypeInfo().Assembly;
            fileStream   = assembly.GetManifestResourceStream(resourcePath);
            slide2.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72);
            fileStream.Close();
            #endregion

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("ImagesSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("ImagesSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
Exemplo n.º 47
0
        private void btnGeneateDocument_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtFile.Text))
                {
                    MessageBox.Show("Please browse the files to generate document", "Input missing", MessageBoxButton.OK);
                }
                else
                {
                    if (this.radioDestination.IsChecked == true)
                    {
                        //Creates presentation instance for source
                        IPresentation sourcePresentation = Presentation.Open(txtFile.Tag.ToString());

                        //Clones the first slide of the presentation
                        ISlide slide = sourcePresentation.Slides[0].Clone();

                        //Creates instance for the destination presentation
                        IPresentation destinationPresentation = Presentation.Open(destTextBox.Tag.ToString());

                        //Adding the cloned slide to the destination presentation by using Destination option.
                        destinationPresentation.Slides.Add(slide, PasteOptions.UseDestinationTheme, sourcePresentation);

                        //Closing the Source presentation
                        sourcePresentation.Close();

                        //Saving the Destination presentaiton.
                        destinationPresentation.Save("ClonedUsingDestination.pptx");

                        //Closing the destination presentation
                        destinationPresentation.Close();

                        if (MessageBox.Show("First slide is cloned and added as last slide to the Presentation,Do you want to view the resultant Presentation?", "Finished Cloning",
                                            MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                        {
                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo = new System.Diagnostics.ProcessStartInfo("ClonedUsingDestination.pptx")
                            {
                                UseShellExecute = true
                            };
                            process.Start();
                        }
                    }
                    else
                    {
                        //Creates instance for the source presentation
                        IPresentation sourcePresentation = Presentation.Open(txtFile.Tag.ToString());

                        //Clones the first slide of the presentation
                        ISlide slide = sourcePresentation.Slides[0].Clone();

                        //Creates instance for the destination presentation
                        IPresentation destinationPresentation = Presentation.Open(destTextBox.Tag.ToString());

                        //Adding the cloned slide to the destination presentation by using Destination option.
                        destinationPresentation.Slides.Add(slide, PasteOptions.SourceFormatting, sourcePresentation);

                        //Closing the Source presentation
                        sourcePresentation.Close();

                        //Saving the Destination presentaiton.
                        destinationPresentation.Save("ClonedUsingSource.pptx");

                        //Closing the destinatin presentation
                        destinationPresentation.Close();

                        if (MessageBox.Show("First slide is cloned and added as last slide to the Presentation,Do you want to view the resultant Presentation?", "Finished Cloning",
                                            MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
                        {
                            System.Diagnostics.Process process = new System.Diagnostics.Process();
                            process.StartInfo = new System.Diagnostics.ProcessStartInfo("ClonedUsingSource.pptx")
                            {
                                UseShellExecute = true
                            };
                            process.Start();
                        }
                    }
                }
            }
            catch (IOException)
            {
                MessageBox.Show("Please close the generated Presentation", "File is open", MessageBoxButton.OK);
            }
            catch (Exception)
            {
                MessageBox.Show("This file could not be cloned , please contact Syncfusion Direct-Trac system at http://www.syncfusion.com/support/default.aspx for any queries. ", "OOPS..Sorry!",
                                MessageBoxButton.OK);
            }
        }
Exemplo n.º 48
0
        public string GetPreview([FromBody] FileManagerDirectoryContent args)
        {
            string baseFolder = this.basePath + "\\wwwroot\\Files";

            try
            {
                String fullPath    = baseFolder + args.Path;
                string extension   = Path.GetExtension(fullPath);
                Stream imageStream = null;
                if (extension == Constants.Pdf)
                {
                    try
                    {
                        FileStream  fileStream     = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
                        PdfRenderer pdfExportImage = new PdfRenderer();
                        //Loads the PDF document
                        pdfExportImage.Load(fileStream);
                        //Exports the PDF document pages into images
                        Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
                        imageStream = new MemoryStream();
                        bitmapimage[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
                        imageStream.Position = 0;
                        pdfExportImage.Dispose();
                        fileStream.Close();
                    }
                    catch
                    {
                        imageStream = null;
                    }
                }
                else if (extension == Constants.Docx || extension == Constants.Rtf || extension == Constants.Doc || extension == Constants.Txt)
                {
                    try
                    {
                        FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);
                        //Loads file stream into Word document
                        DocIO.WordDocument document = new DocIO.WordDocument(fileStream, GetDocIOFormatType(extension));
                        fileStream.Dispose();
                        //Instantiation of DocIORenderer for Word to PDF conversion
                        DocIORenderer render = new DocIORenderer();
                        //Converts Word document into PDF document
                        PdfDocument pdfDocument = render.ConvertToPDF(document);
                        //Releases all resources used by the Word document and DocIO Renderer objects
                        render.Dispose();
                        document.Dispose();
                        //Saves the PDF file
                        MemoryStream outputStream = new MemoryStream();
                        pdfDocument.Save(outputStream);
                        outputStream.Position = 0;
                        //Closes the instance of PDF document object
                        pdfDocument.Close();

                        PdfRenderer pdfExportImage = new PdfRenderer();
                        //Loads the PDF document
                        pdfExportImage.Load(outputStream);
                        //Exports the PDF document pages into images
                        Bitmap[] bitmapimage = pdfExportImage.ExportAsImage(0, 0);
                        imageStream = new MemoryStream();
                        bitmapimage[0].Save(imageStream, System.Drawing.Imaging.ImageFormat.Png);
                        imageStream.Position = 0;

                        fileStream.Close();
                    }
                    catch
                    {
                        imageStream = null;
                    }
                }
                else if (extension == Constants.Pptx)
                {
                    try
                    {
                        IPresentation presentation = Presentation.Open(fullPath);
                        //Initialize PresentationRenderer for image conversion
                        presentation.PresentationRenderer = new PresentationRenderer();
                        //Convert the first slide to image
                        imageStream = presentation.Slides[0].ConvertToImage(ExportImageFormat.Png);
                        presentation.Dispose();
                    }
                    catch
                    {
                        imageStream = null;
                    }
                }
                if (imageStream != null)
                {
                    byte[] bytes = new byte[imageStream.Length];
                    imageStream.Read(bytes);
                    string base64 = Convert.ToBase64String(bytes);
                    return("data:image/png;base64, " + base64);
                }
                else
                {
                    return("Error");
                }
            }
            catch
            {
                return("Error");
            }
        }
 /// <summary>
 /// Load the PowerPoint presentation to convert images
 /// </summary>
 /// <param name="pptxStream">The stream instance of PowerPoint file</param>
 private void LoadPresentation(Stream pptxStream)
 {
     _presentation = Presentation.Open(pptxStream);
     _slideCount   = _presentation.Slides.Count;
     _presentation.ChartToImageConverter = new ChartToImageConverter();
 }
        public static int PPTReorderSlides(string fileName, int originalPosition, int newPosition)
        {
            // Assume that no slide moves; return -1.
            int returnValue = -1;

            // Moving to and from same position? Get out now.
            if (newPosition == originalPosition)
            {
                return(returnValue);
            }

            using (PresentationDocument doc = PresentationDocument.Open(fileName, true))
            {
                // Get the presentation part of the document.
                PresentationPart presentationPart = doc.PresentationPart;
                // No presentation part? Something's wrong with the document.
                if (presentationPart == null)
                {
                    throw new ArgumentException("fileName");
                }

                // If you're here, you know that presentationPart exists.
                int slideCount = presentationPart.SlideParts.Count();

                // No slides? Just return -1 indicating that nothing  happened.
                if (slideCount == 0)
                {
                    return(returnValue);
                }

                // There are slides. Calculate real positions.
                int maxPosition = slideCount - 1;

                // Adjust the positions, if necessary.
                CalcPositions(ref originalPosition, ref newPosition, maxPosition);

                // The two positions could have ended up being the same
                // thing. There's nothing to do, in that case. Otherwise,
                // do the work.
                if (newPosition != originalPosition)
                {
                    Presentation presentation = presentationPart.Presentation;
                    SlideIdList  slideIdList  = presentation.SlideIdList;

                    // Get the slide ID of the source and target slides.
                    SlideId sourceSlide =
                        (SlideId)(slideIdList.ChildElements[originalPosition]);
                    SlideId targetSlide =
                        (SlideId)(slideIdList.ChildElements[newPosition]);

                    // Remove the source slide from its parent tree. You can't
                    // move a slide while it's part of an XML node tree.
                    sourceSlide.Remove();

                    if (newPosition > originalPosition)
                    {
                        slideIdList.InsertAfter(sourceSlide, targetSlide);
                    }
                    else
                    {
                        slideIdList.InsertBefore(sourceSlide, targetSlide);
                    }

                    // Set the return value.
                    returnValue = newPosition;

                    // Save the modified presentation.
                    presentation.Save();
                }
            }
            return(returnValue);
        }
Exemplo n.º 51
0
 private string GetCaptionFromNode(Node n)
 {
     return(Presentation.GetModule <ICaptionModule>().Get(n.Id).DisplayText);
 }
Exemplo n.º 52
0
        public GraphViewerModel(IEventAggregator eventAggregator)
        {
            HideNodeCommand   = new DelegateCommand <Node>(n => new ShowHideNodes(Presentation, false).Execute(GetRelevantNodes(n)));
            ShowNodeCommand   = new DelegateCommand <Node>(n => new ShowHideNodes(Presentation, true).Execute(GetRelevantNodes(n)));
            HideAllButCommand = new DelegateCommand <Node>(n => new ShowHideNodes(Presentation, false, true).Execute(GetRelevantNodes(n)));

            ShowNodeWithIncomingCommand   = new DelegateCommand <Node>(n => new ShowHideIncomings(Presentation).Execute(n, show: true));
            ShowNodeWithOutgoingCommand   = new DelegateCommand <Node>(n => new ShowHideOutgoings(Presentation).Execute(n, show: true));
            ShowNodeWithSiblingsCommand   = new DelegateCommand <Node>(n => new ShowSiblings(Presentation).Execute(n));
            ShowNodeWithReachablesCommand = new DelegateCommand <Node>(n => new TransitiveHull(Presentation)
            {
                Show = true
            }.Execute(GetRelevantNodes(n)));

            HideIncomingCommand           = new DelegateCommand <Node>(n => new ShowHideIncomings(Presentation).Execute(n, show: false));
            HideOutgoingCommand           = new DelegateCommand <Node>(n => new ShowHideOutgoings(Presentation).Execute(n, show: false));
            RemoveUnreachableNodesCommand = new DelegateCommand <Node>(n => new TransitiveHull(Presentation)
            {
                Show = false
            }.Execute(GetRelevantNodes(n)));

            SelectNodeCommand             = new DelegateCommand <Node>(n => Presentation.GetPropertySetFor <Selection>().Get(n.Id).IsSelected = true);
            SelectNodeWithIncomingCommand = new DelegateCommand <Node>(n => new ShowHideIncomings(Presentation).Select(n));
            SelectNodeWithOutgoingCommand = new DelegateCommand <Node>(n => new ShowHideOutgoings(Presentation).Select(n));
            SelectNodeWithSiblingsCommand = new DelegateCommand <Node>(n => new ShowSiblings(Presentation).Select(n));

            CaptionToClipboardCommand = new DelegateCommand <Node>(n => Clipboard.SetText(GetCaptionFromNode(n)));
            IdToClipboardCommand      = new DelegateCommand <Node>(n => Clipboard.SetText(n.Id));

            GoToEdgeSourceCommand = new DelegateCommand <Edge>(edge => Navigation.NavigateTo(edge.Source));
            GoToEdgeTargetCommand = new DelegateCommand <Edge>(edge => Navigation.NavigateTo(edge.Target));

            ToggleClusterFoldingCommand       = new DelegateCommand <Cluster>(c => new ChangeClusterFolding(Presentation).Execute(ToggleClusterFolding(c)));
            UnfoldAndHidePrivateNodesCommand  = new DelegateCommand <Cluster>(c => new UnfoldAndHide(Presentation).Execute(c, NodeType.AllSiblings), CanUnfold);
            UnfoldAndHideAllButTargetsCommand = new DelegateCommand <Cluster>(c => new UnfoldAndHide(Presentation).Execute(c, NodeType.Targets), CanUnfold);
            UnfoldAndHideAllButSourcesCommand = new DelegateCommand <Cluster>(c => new UnfoldAndHide(Presentation).Execute(c, NodeType.Sources), CanUnfold);

            CopyAllCaptionToClipboardCommand = new DelegateCommand <Cluster>(c => Clipboard.SetDataObject(GetCaptionOfAllVisibleNodesFrom(c)));

            ShowMostIncomingsCommand        = new DelegateCommand(() => new ShowMostIncomings(Presentation).Execute(5), () => Presentation != null);
            ShowCyclesCommand               = new DelegateCommand(() => new ShowCycles(Presentation).Execute(), () => Presentation != null);
            ShowNodesOutsideClustersCommand = new DelegateCommand(() => new ShowNodesOutsideClusters(Presentation).Execute(), () => Presentation != null);

            RemoveNodesWithoutEdgesCommand = new DelegateCommand(() => new RemoveNodesWithoutEdges(Presentation).Execute(), () => Presentation != null);
            RemoveNodesReachableFromMultipleClustersCommand = new DelegateCommand(() => new RemoveNodesReachableFromMultipleClusters(Presentation).Execute(), () => Presentation != null);

            FoldUnfoldAllClustersCommand = new DelegateCommand(() => new ChangeClusterFolding(Presentation).FoldUnfoldAllClusters(), () => Presentation != null);
            AddVisibleNodesOutsideClustersToClusterCommand = new DelegateCommand <string>(c => new AddVisibleNodesOutsideClustersToCluster(Presentation).Execute(c), c => Presentation != null);
            DeselectAllCommand      = new DelegateCommand(() => new SelectAll(Presentation).Execute(false), () => Presentation != null);
            HomeCommand             = new DelegateCommand(() => Navigation.HomeZoomPan(), () => Presentation != null);
            InvalidateLayoutCommand = new DelegateCommand(() => Presentation.InvalidateLayout(), () => Presentation != null);

            AddToClusterCommand             = new DelegateCommand <string>(c => new ChangeClusterAssignment(Presentation).Execute(t => t.AddToCluster(GraphItemForContextMenu.Id, c)));
            AddWithSelectedToClusterCommand = new DelegateCommand <string>(c => new ChangeClusterAssignment(Presentation)
                                                                           .Execute(t => t.AddToCluster(GetRelevantNodes(null)
                                                                                                        .Select(n => n.Id).ToArray(), c)));
            RemoveFromClusterCommand = new DelegateCommand <Node>(node => new ChangeClusterAssignment(Presentation)
                                                                  .Execute(t => t.RemoveFromClusters(GetRelevantNodes(node)
                                                                                                     .Select(n => n.Id).ToArray())));

            TraceToCommand = new DelegateCommand <Node>(n => new TracePath(Presentation).Execute((Node)GraphItemForContextMenu, n));

            PrintGraphRequest = new InteractionRequest <IConfirmation>();
            PrintGraphCommand = new DelegateCommand(OnPrintGrpah, () => Presentation != null);

            eventAggregator.GetEvent <NodeFocusedEvent>().Subscribe(OnEventFocused);

            Clusters      = new ObservableCollection <ClusterWithCaption>();
            SelectedNodes = new ObservableCollection <NodeWithCaption>();
        }
 public new AlternateContentProperty Export(Presentation destPres)
 {
     return(ExportProtected(destPres) as AlternateContentProperty);
 }
Exemplo n.º 54
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.Slides.pptx";
            Assembly assembly     = typeof(App).GetTypeInfo().Assembly;
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Presentation.Open(fileStream);

            #region Slide1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = slide1.Shapes[0] as IShape;
            shape1.Left   = 1.5 * 72;
            shape1.Top    = 1.94 * 72;
            shape1.Width  = 10.32 * 72;
            shape1.Height = 2 * 72;

            ITextBody   textFrame1  = shape1.TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            ITextPart   textPart1   = paragraph1.AddTextPart();
            paragraphs1[0].IndentLevelNumber = 0;
            textPart1.Text          = "ESSENTIAL PRESENTATION";
            textPart1.Font.FontName = "HelveticaNeue LT 65 Medium";
            textPart1.Font.FontSize = 48;
            textPart1.Font.Bold     = true;
            slide1.Shapes.RemoveAt(1);
            #endregion

            #region Slide2
            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.SectionHeader);
            shape1        = slide2.Shapes[0] as IShape;
            shape1.Left   = 0.77 * 72;
            shape1.Top    = 0.32 * 72;
            shape1.Width  = 7.96 * 72;
            shape1.Height = 0.99 * 72;

            textFrame1 = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraph1  = paragraphs1.Add();
            ITextPart textpart1 = paragraph1.AddTextPart();
            paragraphs1[0].HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1.Text          = "Slide with simple text";
            textpart1.Font.FontName = "Helvetica CE 35 Thin";
            textpart1.Font.FontSize = 40;

            IShape shape2 = slide2.Shapes[1] as IShape;
            shape2.Left   = 1.21 * 72;
            shape2.Top    = 1.66 * 72;
            shape2.Width  = 10.08 * 72;
            shape2.Height = 4.93 * 72;

            ITextBody textFrame2 = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs2 = textFrame2.Paragraphs;
            IParagraph  paragraph2  = paragraphs2.Add();
            paragraph2.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textpart2 = paragraph2.AddTextPart();
            textpart2.Text          = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus.";
            textpart2.Font.FontName = "Calibri (Body)";
            textpart2.Font.FontSize = 15;
            textpart2.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph3 = paragraphs2.Add();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph3.AddTextPart();
            textpart1.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            textpart1.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph4 = paragraphs2.Add();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph4.AddTextPart();
            textpart1.Text          = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula.";
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            textpart1.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph5 = paragraphs2.Add();
            paragraph5.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph5.AddTextPart();
            textpart1.Text          = "Vestibulum duis integer diam mi libero felis, sollicitudin id dictum etiam blandit lacus, ac condimentum magna dictumst interdum et,";
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            textpart1.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph6 = paragraphs2.Add();
            paragraph6.HorizontalAlignment = HorizontalAlignmentType.Left;
            paragraph6.AddTextPart();
            textpart1.Text          = "nam commodo mi habitasse enim fringilla nunc, amet aliquam sapien per tortor luctus. Conubia voluptates at nunc, congue lectus, malesuada nulla.";
            textpart1.Font.Color    = ColorObject.White;
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            textpart1.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph7 = paragraphs2.Add();
            paragraph7.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph7.AddTextPart();
            textpart1.Text          = "Rutrum quo morbi, feugiat sed mi turpis, ac cursus integer ornare dolor. Purus dui in et tincidunt, sed eros pede adipiscing tellus, est suscipit nulla,";
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            textpart1.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph8 = paragraphs2.Add();
            paragraph8.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph8.AddTextPart();
            textpart1.Text          = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula.";
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.FontSize = 15;
            textpart1.Font.Color    = ColorObject.Black;

            //Instance to hold paragraphs in textframe
            IParagraph paragraph9 = paragraphs2.Add();
            paragraph9.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart1               = paragraph9.AddTextPart();
            textpart1.Text          = "arcu nec fringilla vel aliquam, mollis lorem rerum hac vestibulum ante nullam. Volutpat a lectus, lorem pulvinar quis. Lobortis vehicula in imperdiet orci urna.";
            textpart1.Font.FontName = "Calibri (Body)";
            textpart1.Font.Color    = ColorObject.Black;
            textpart1.Font.FontSize = 15;
            #endregion

            #region Slide3
            slide2        = presentation.Slides.Add(SlideLayoutType.TwoContent);
            shape1        = slide2.Shapes[0] as IShape;
            shape1.Left   = 0.36 * 72;
            shape1.Top    = 0.51 * 72;
            shape1.Width  = 11.32 * 72;
            shape1.Height = 1.06 * 72;

            //Adds textframe in shape
            textFrame1 = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraphs1.Add();
            paragraph1 = paragraphs1[0];
            textpart1  = paragraph1.AddTextPart();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;

            //Assigns value to textpart
            textpart1.Text          = "Slide with Image";
            textpart1.Font.FontName = "Helvetica CE 35 Thin";

            //Adds shape in slide
            shape2        = slide2.Shapes[1] as IShape;
            shape2.Left   = 8.03 * 72;
            shape2.Top    = 1.96 * 72;
            shape2.Width  = 4.39 * 72;
            shape2.Height = 4.53 * 72;
            textFrame2    = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs2 = textFrame2.Paragraphs;
            paragraph2  = paragraphs2.Add();
            textpart2   = paragraph2.AddTextPart();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;

            textpart2.Text          = "Lorem ipsum dolor sit amet, lacus amet amet ultricies. Quisque mi venenatis morbi libero, orci dis, mi ut et class porta, massa ligula magna enim, aliquam orci vestibulum tempus.";
            textpart2.Font.FontName = "Helvetica CE 35 Thin";
            textpart2.Font.FontSize = 16;

            paragraph3 = paragraphs2.Add();
            textpart2  = paragraph3.AddTextPart();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Left;

            textpart2.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textpart2.Font.FontName = "Helvetica CE 35 Thin";
            textpart2.Font.FontSize = 16;


            paragraph4 = paragraphs2.Add();
            textpart2  = paragraph4.AddTextPart();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Left;

            textpart2.Text          = "Auctor eleifend in omnis elit vestibulum, donec non elementum tellus est mauris, id aliquam, at lacus, arcu pretium proin lacus dolor et. Eu tortor, vel ultrices amet dignissim mauris vehicula.";
            textpart2.Font.FontName = "Helvetica CE 35 Thin";
            textpart2.Font.FontSize = 16;

            IShape shape3 = (IShape)slide2.Shapes[2];
            slide2.Shapes.RemoveAt(2);

            //Adds picture in the shape
            resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg";
            assembly     = typeof(App).GetTypeInfo().Assembly;
            fileStream   = assembly.GetManifestResourceStream(resourcePath);
            slide2.Shapes.AddPicture(fileStream, 0.81 * 72, 1.96 * 72, 6.63 * 72, 4.43 * 72);
            fileStream.Close();
            #endregion

            #region Slide4
            ISlide slide4 = presentation.Slides.Add(SlideLayoutType.TwoContent);
            shape1        = slide4.Shapes[0] as IShape;
            shape1.Left   = 0.51 * 72;
            shape1.Top    = 0.34 * 72;
            shape1.Width  = 11.32 * 72;
            shape1.Height = 1.06 * 72;

            textFrame1 = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraphs1.Add();
            paragraph1 = paragraphs1[0];
            textpart1  = paragraph1.AddTextPart();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;

            //Assigns value to textpart
            textpart1.Text          = "Slide with Table";
            textpart1.Font.FontName = "Helvetica CE 35 Thin";

            shape2 = slide4.Shapes[1] as IShape;
            slide4.Shapes.Remove(shape2);

            ITable table = (ITable)slide4.Shapes.AddTable(6, 6, 0.81 * 72, 2.14 * 72, 11.43 * 72, 3.8 * 72);
            table.Rows[0].Height   = 0.85 * 72;
            table.Rows[1].Height   = 0.42 * 72;
            table.Rows[2].Height   = 0.85 * 72;
            table.Rows[3].Height   = 0.85 * 72;
            table.Rows[4].Height   = 0.85 * 72;
            table.Rows[5].Height   = 0.85 * 72;
            table.HasBandedRows    = true;
            table.HasHeaderRow     = true;
            table.HasBandedColumns = false;
            table.BuiltInStyle     = BuiltInTableStyle.MediumStyle2Accent1;

            ICell cell1 = table.Rows[0].Cells[0];
            textFrame2 = cell1.TextBody;
            paragraph2 = textFrame2.Paragraphs.Add();
            paragraph2.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart2 = paragraph2.AddTextPart();
            textPart2.Text = "ID";

            ICell     cell2      = table.Rows[0].Cells[1];
            ITextBody textFrame3 = cell2.TextBody;
            paragraph3 = textFrame3.Paragraphs.Add();
            paragraph3.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart3 = paragraph3.AddTextPart();
            textPart3.Text = "Company Name";

            ICell     cell3      = table.Rows[0].Cells[2];
            ITextBody textFrame4 = cell3.TextBody;
            paragraph4 = textFrame4.Paragraphs.Add();
            paragraph4.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart4 = paragraph4.AddTextPart();
            textPart4.Text = "Contact Name";

            ICell     cell4      = table.Rows[0].Cells[3];
            ITextBody textFrame5 = cell4.TextBody;
            paragraph5 = textFrame5.Paragraphs.Add();
            paragraph5.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart5 = paragraph5.AddTextPart();
            textPart5.Text = "Address";

            ICell     cell5      = table.Rows[0].Cells[4];
            ITextBody textFrame6 = cell5.TextBody;
            paragraph6 = textFrame6.Paragraphs.Add();
            paragraph6.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart6 = paragraph6.AddTextPart();
            textPart6.Text = "City";

            ICell     cell6      = table.Rows[0].Cells[5];
            ITextBody textFrame7 = cell6.TextBody;
            paragraph7 = textFrame7.Paragraphs.Add();
            paragraph7.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart7 = paragraph7.AddTextPart();
            textPart7.Text = "Country";

            cell1      = table.Rows[1].Cells[0];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "1";

            cell1      = table.Rows[1].Cells[1];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "New Orleans Cajun Delights";

            cell1      = table.Rows[1].Cells[2];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Shelley Burke";

            cell1      = table.Rows[1].Cells[3];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "P.O. Box 78934";

            cell1      = table.Rows[1].Cells[4];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "New Orleans";

            cell1      = table.Rows[1].Cells[5];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "USA";

            cell1      = table.Rows[2].Cells[0];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "2";

            cell1      = table.Rows[2].Cells[1];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Cooperativa de Quesos 'Las Cabras";

            cell1      = table.Rows[2].Cells[2];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Antonio del Valle Saavedra";

            cell1      = table.Rows[2].Cells[3];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Calle del Rosal 4";

            cell1      = table.Rows[2].Cells[4];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Oviedo";

            cell1      = table.Rows[2].Cells[5];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Spain";

            cell1      = table.Rows[3].Cells[0];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "3";

            cell1      = table.Rows[3].Cells[1];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Mayumi";

            cell1      = table.Rows[3].Cells[2];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Mayumi Ohno";

            cell1      = table.Rows[3].Cells[3];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "92 Setsuko Chuo-ku";

            cell1      = table.Rows[3].Cells[4];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Osaka";

            cell1      = table.Rows[3].Cells[5];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Japan";

            cell1      = table.Rows[4].Cells[0];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "4";

            cell1      = table.Rows[4].Cells[1];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Pavlova, Ltd.";

            cell1      = table.Rows[4].Cells[2];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Ian Devling";

            cell1      = table.Rows[4].Cells[3];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "74 Rose St. Moonie Ponds";

            cell1      = table.Rows[4].Cells[4];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Melbourne";

            cell1      = table.Rows[4].Cells[5];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Australia";

            cell1      = table.Rows[5].Cells[0];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "5";

            cell1      = table.Rows[5].Cells[1];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Specialty Biscuits, Ltd.";

            cell1      = table.Rows[5].Cells[2];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Peter Wilson";

            cell1      = table.Rows[5].Cells[3];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "29 King's Way";

            cell1      = table.Rows[5].Cells[4];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "Manchester";

            cell1      = table.Rows[5].Cells[5];
            textFrame1 = cell1.TextBody;
            paragraph1 = textFrame1.Paragraphs.Add();
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            textpart1      = paragraph1.AddTextPart();
            textpart1.Text = "UK";

            slide4.Shapes.RemoveAt(1);
            #endregion

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("SlidesSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("SlidesSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
Exemplo n.º 55
0
 public void PublishTest_With_Varying_PcmFormat()
 {
     Project      proj = new Project();
     Presentation pres = proj.AddNewPresentation();
     //TODO: Finish test
 }
Exemplo n.º 56
0
        public static string ConvertedFile(string filePath, Presentation pres)
        {
            AudioLib.WavFormatConverter audioConverter = new WavFormatConverter(true, true);
            int    samplingRate  = (int)pres.MediaDataManager.DefaultPCMFormat.Data.SampleRate;
            int    channels      = pres.MediaDataManager.DefaultPCMFormat.Data.NumberOfChannels;
            int    bitDepth      = pres.MediaDataManager.DefaultPCMFormat.Data.BitDepth;
            string directoryPath = pres.DataProviderManager.DataFileDirectoryFullPath;
            string convertedFile = null;

            try
            {
                if (Path.GetExtension(filePath).ToLower() == ".wav")
                {
                    Stream wavStream = null;
                    wavStream = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                    uint dataLength;
                    AudioLibPCMFormat newFilePCMInfo = AudioLibPCMFormat.RiffHeaderParse(wavStream, out dataLength);
                    if (wavStream != null)
                    {
                        wavStream.Close();
                    }
                    if (newFilePCMInfo.SampleRate == samplingRate && newFilePCMInfo.NumberOfChannels == channels && newFilePCMInfo.BitDepth == bitDepth)
                    {
                        convertedFile = filePath;
                    }
                    else
                    {
                        AudioLibPCMFormat pcmFormat         = new AudioLibPCMFormat((ushort)channels, (uint)samplingRate, (ushort)bitDepth);
                        AudioLibPCMFormat originalPCMFormat = null;
                        convertedFile = audioConverter.ConvertSampleRate(filePath, directoryPath, pcmFormat, out originalPCMFormat);
                    }
                }
                else if (Path.GetExtension(filePath).ToLower() == ".mp3")
                {
                    AudioLibPCMFormat pcmFormat         = new AudioLibPCMFormat((ushort)channels, (uint)samplingRate, (ushort)bitDepth);
                    AudioLibPCMFormat originalPCMFormat = null;
                    convertedFile = audioConverter.UnCompressMp3File(filePath, directoryPath, pcmFormat, out originalPCMFormat);
                }
                else if (Path.GetExtension(filePath).ToLower() == ".mp4" || Path.GetExtension(filePath).ToLower() == ".m4a")
                {
                    AudioLibPCMFormat pcmFormat         = new AudioLibPCMFormat((ushort)channels, (uint)samplingRate, (ushort)bitDepth);
                    AudioLibPCMFormat originalPCMFormat = null;
                    convertedFile = audioConverter.UnCompressMp4_AACFile(filePath, directoryPath, pcmFormat, out originalPCMFormat);
                }
                else
                {
                    //MessageBox.Show(string.Format(Localizer.Message("AudioFormatConverter_Error_FileExtentionNodSupported"), filePath), Localizer.Message("Caption_Error"));
                    return(null);
                }
                // rename converted file to original file if names are different
                if (Path.GetFileName(filePath) != Path.GetFileName(convertedFile))
                {
                    string newConvertedFilePath = Path.Combine(Path.GetDirectoryName(convertedFile), Path.GetFileNameWithoutExtension(filePath) + ".wav");
                    for (int i = 0; i < 99999 && File.Exists(newConvertedFilePath); i++)
                    {
                        newConvertedFilePath = Path.Combine(Path.GetDirectoryName(convertedFile), i.ToString() + Path.GetFileNameWithoutExtension(filePath) + ".wav");
                        if (!File.Exists(newConvertedFilePath))
                        {
                            m_FilesThatAreRenamed.Add(Path.GetFileNameWithoutExtension(filePath) + ".wav", Path.GetFileName(newConvertedFilePath));

                            //MessageBox.Show(string.Format(Localizer.Message("Import_AudioFormat_RenameFile"), Path.GetFileNameWithoutExtension(filePath) + ".wav", Path.GetFileName(newConvertedFilePath)),
                            //    Localizer.Message("Caption_Information"),
                            //    MessageBoxButtons.OK);

                            if (!m_IsFileExists)
                            {
                                m_IsFileExists = true;
                                MessageBox.Show(Localizer.Message("Import_AudioFormat_FilesWillBeRenamed"),
                                                Localizer.Message("Caption_Information"), MessageBoxButtons.OK);
                            }
                            break;
                        }
                    }
                    File.Move(convertedFile, newConvertedFilePath);
                    convertedFile = newConvertedFilePath;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(null);
            }
            return(convertedFile);
        }
        private async Task <OperationStatus> ModifyPresentationByCopying(string userId, Presentation p, UploadPresentationModel updateModel)
        {
            var newPresentation = new Presentation
            {
                CategoryId       = p.CategoryId,
                Name             = p.Name,
                Description      = p.Description,
                IsPublic         = p.IsPublic,
                FileID           = p.FileID,
                PresentationTags = new List <PresentationTag>()
            };

            var list = await _context.UserPresentations.Where(u => u.UserId == userId && u.PresentationId == p.Id).ToListAsync();

            _context.UserPresentations.Remove(list.First());

            _context.Presentations.Add(newPresentation);
            var rows = await _context.SaveChangesAsync();

            if (rows == 0)
            {
                return(new OperationStatus
                {
                    ErrorMessageIfAny = "Error while trying to update the database"
                });
            }

            var newUP = new UserPresentation
            {
                UserId         = userId,
                PresentationId = newPresentation.Id
            };

            _context.UserPresentations.Add(newUP);

            return(await ModifyPresentationInPlace(userId, newPresentation, updateModel));
        }
Exemplo n.º 58
0
 public static void OnPresentationStart(Presentation presentation)
 {
     ((SharePService)SelfHost.SingletonInstance).OnPresentationStart(presentation);
 }
        private async Task <OperationStatus> ModifyPresentationInPlace(string userId, Presentation p, UploadPresentationModel updateModel)
        {
            p.Name             = updateModel.Name;
            p.Description      = updateModel.Description;
            p.CategoryId       = updateModel.CategoryId;
            p.IsPublic         = updateModel.IsPublic;
            p.PresentationTags = new List <PresentationTag>();

            var associatedPTs = await _context.PresentationTags.Where(pt => pt.PresentationId == p.Id).ToListAsync();

            _context.PresentationTags.RemoveRange(associatedPTs);

            var newTagsResult = await _tagsRepository.CreateOrGetTags(updateModel.Tags);

            if (newTagsResult.ErrorMessageIfAny != null)
            {
                return(newTagsResult);
            }

            foreach (var tag in newTagsResult.Value)
            {
                var pt = new PresentationTag
                {
                    Tag          = tag,
                    Presentation = p
                };

                tag.PresentationTags.Add(pt);
                p.PresentationTags.Add(pt);
            }

            if (updateModel.SourceStream != null)
            {
                await _filesRepository.DeleteFileWithId(p.FileID);

                var createResult = await _filesRepository.SaveFile(updateModel.SourceStream);

                if (createResult.ErrorMessageIfAny != null)
                {
                    return(createResult);
                }

                p.FileID = createResult.Value;
            }

            _context.Presentations.Update(p);
            var rows = await _context.SaveChangesAsync();

            if (rows == 0)
            {
                return(new OperationStatus
                {
                    ErrorMessageIfAny = "An error ocurred while trying to update the database"
                });
            }

            return(new OperationStatus());
        }
        public static void AppendDigitalOneSheet(this PowerPointProcessor target, StandaloneDigitalInfoOneSheetOutputModel dataModel, Theme selectedTheme, bool pasteToSlideMaster, Presentation destinationPresentation = null)
        {
            try
            {
                var thread = new Thread(delegate()
                {
                    MessageFilter.Register();
                    var copyOfReplacementList    = new Dictionary <string, string>(dataModel.ReplacementsList);
                    var presentationTemplatePath = dataModel.TemplateFilePath;
                    if (!File.Exists(presentationTemplatePath))
                    {
                        return;
                    }
                    var presentation = target.PowerPointObject.Presentations.Open(presentationTemplatePath, WithWindow: MsoTriState.msoFalse);
                    var taggedSlide  = presentation.Slides.Count > 0 ? presentation.Slides[1] : null;

                    var logoShapes = new List <Shape>();
                    foreach (var shape in taggedSlide.Shapes.OfType <Shape>().Where(s => s.HasTable != MsoTriState.msoTrue))
                    {
                        for (var i = 1; i <= shape.Tags.Count; i++)
                        {
                            var shapeTagName = shape.Tags.Name(i);
                            for (var j = 0; j < BaseDigitalInfoOneSheetOutputModel.MaxRecords; j++)
                            {
                                if (shapeTagName.Equals(String.Format("DIGLOGO{0}", j + 1)))
                                {
                                    var fileName = dataModel.Logos.Length > j ? dataModel.Logos[j] : String.Empty;
                                    if (!String.IsNullOrEmpty(fileName) && File.Exists(fileName))
                                    {
                                        var newShape = taggedSlide.Shapes.AddPicture(fileName, MsoTriState.msoFalse, MsoTriState.msoCTrue, shape.Left,
                                                                                     shape.Top, shape.Width, shape.Height);
                                        newShape.Top    = shape.Top;
                                        newShape.Left   = shape.Left;
                                        newShape.Width  = shape.Width;
                                        newShape.Height = shape.Height;
                                        logoShapes.Add(newShape);
                                    }
                                    shape.Visible = MsoTriState.msoFalse;
                                }
                            }
                        }
                    }

                    var tableContainer = taggedSlide.Shapes.Cast <Shape>().FirstOrDefault(s => s.HasTable == MsoTriState.msoTrue);
                    if (tableContainer == null)
                    {
                        return;
                    }
                    var table             = tableContainer.Table;
                    var tableRowsCount    = table.Rows.Count;
                    var tableColumnsCount = table.Columns.Count;
                    for (var i = 1; i <= tableRowsCount; i++)
                    {
                        for (var j = 1; j <= tableColumnsCount; j++)
                        {
                            var tableShape = table.Cell(i, j).Shape;
                            if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                            {
                                continue;
                            }
                            var cellText = tableShape.TextFrame.TextRange.Text.Replace(" ", "");
                            var key      = copyOfReplacementList.Keys.FirstOrDefault(k => k.Replace(" ", "").ToLower().Equals(cellText.ToLower()));
                            if (String.IsNullOrEmpty(key))
                            {
                                continue;
                            }
                            tableShape.TextFrame.TextRange.Text = copyOfReplacementList[key];
                            copyOfReplacementList.Remove(cellText);
                        }
                    }
                    tableColumnsCount = table.Columns.Count;
                    for (var i = tableColumnsCount; i >= 1; i--)
                    {
                        var tableShape = table.Cell(3, i).Shape;
                        if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                        {
                            continue;
                        }
                        var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                        if (!cellText.Equals("Delete Column"))
                        {
                            continue;
                        }
                        table.Columns[i].Delete();
                    }
                    tableRowsCount = table.Rows.Count;
                    for (var i = tableRowsCount; i >= 1; i--)
                    {
                        for (var j = 1; j < 3; j++)
                        {
                            var tableShape = table.Cell(i, j).Shape;
                            if (tableShape.HasTextFrame != MsoTriState.msoTrue)
                            {
                                continue;
                            }
                            var cellText = tableShape.TextFrame.TextRange.Text.Trim();
                            if (!cellText.Equals("Delete Row"))
                            {
                                continue;
                            }
                            table.Rows[i].Delete();
                            break;
                        }
                    }
                    if (pasteToSlideMaster)
                    {
                        var newSlide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);
                        Design design;
                        if (selectedTheme != null)
                        {
                            presentation.ApplyTheme(selectedTheme.GetThemePath());
                            design      = presentation.Designs[presentation.Designs.Count];
                            design.Name = DateTime.Now.ToString("MMddyy-hhmmsstt");
                        }
                        else
                        {
                            design = presentation.Designs.Add(DateTime.Now.ToString("MMddyy-hhmmsstt"));
                        }
                        tableContainer.Copy();
                        design.SlideMaster.Shapes.Paste();
                        foreach (var logoShape in logoShapes)
                        {
                            logoShape.Copy();
                            design.SlideMaster.Shapes.Paste();
                        }

                        if (dataModel.ContractSettings.IsConfigured)
                        {
                            target.FillContractInfo(design, dataModel.ContractSettings, BusinessObjects.Instance.OutputManager.ContractTemplateFolder);
                        }

                        newSlide.Design = design;
                    }
                    else
                    {
                        if (selectedTheme != null)
                        {
                            presentation.ApplyTheme(selectedTheme.GetThemePath());
                        }

                        if (dataModel.ContractSettings.IsConfigured)
                        {
                            target.FillContractInfo(taggedSlide, dataModel.ContractSettings, BusinessObjects.Instance.OutputManager.ContractTemplateFolder);
                        }
                    }
                    target.AppendSlide(presentation, 1, destinationPresentation);
                    presentation.Close();
                });
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
            }
            catch
            {
            }
            finally
            {
                MessageFilter.Revoke();
            }
        }