internal static void SlideWithComments3(IPresentation presentation)
        {
            #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);

            Assembly assembly = Assembly.GetExecutingAssembly();
            //Adds picture in the shape
            string resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg";
            Stream fileStream   = assembly.GetManifestResourceStream(resourcePath);

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

            slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now);
            #endregion
        }
Beispiel #2
0
        private void SlideWithComments(IPresentation presentation)
        {
            #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.5, 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
        }
Beispiel #3
0
        private void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Presentation.Samples.Templates.Images.pptx";
            Assembly assembly     = typeof(Comments).GetTypeInfo().Assembly;
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(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);
            #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", "All 3D-chart types are supported 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 = "SampleBrowser.Presentation.Samples.Templates.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();

            slide3.Comments.Add(0.14, 0.04, "Author3", "A3", "Can we use a different font family for this text?", DateTime.Now);
            #endregion

            MemoryStream memoryStream = new MemoryStream();

            presentation.Save(memoryStream);
            presentation.Close();
            memoryStream.Position = 0;
            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("CommentsSamples.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", memoryStream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("CommentsSamples.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", memoryStream);
            }
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            string resourcePath = "";

                        #if COMMONSB
            resourcePath = "SampleBrowser.Samples.Presentation.Samples.Templates.HelloWorld.pptx";
            #else
            resourcePath = "SampleBrowser.Presentation.Samples.Templates.HelloWorld.pptx";
#endif
            Assembly assembly   = typeof(GettingStarted).GetTypeInfo().Assembly;
            Stream   fileStream = assembly.GetManifestResourceStream(resourcePath);

            //Open a PowerPoint presentation
            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            #region Slide1
            //Get the first slide from Presentation
            ISlide slide1 = presentation.Slides[0];
            //Get the shape from slide and set bounds
            IShape titleShape = slide1.Shapes[0] as IShape;
            titleShape.Left   = 0.33 * 72;
            titleShape.Top    = 0.58 * 72;
            titleShape.Width  = 12.5 * 72;
            titleShape.Height = 1.75 * 72;
            //Set a content to the text box and apply text formatting
            ITextBody   textFrame1  = (slide1.Shapes[0] as IShape).TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph   = paragraphs1.Add();
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart1 = paragraph.AddTextPart();
            textPart1.Text          = "Essential Presentation";
            textPart1.Font.CapsType = TextCapsType.All;
            textPart1.Font.FontName = "Arial";
            textPart1.Font.Bold     = true;
            textPart1.Font.FontSize = 40;

            IShape subtitle = slide1.Shapes[1] as IShape;
            subtitle.Left   = 0.5 * 72;
            subtitle.Top    = 3 * 72;
            subtitle.Width  = 11.8 * 72;
            subtitle.Height = 1.7 * 72;

            ITextBody textFrame2 = (slide1.Shapes[1] as IShape).TextBody;
            textFrame2.VerticalAlignment = VerticalAlignmentType.Top;
            IParagraphs paragraphs2 = textFrame2.Paragraphs;
            IParagraph  para        = paragraphs2.Add();
            para.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textPart2 = para.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.Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textPart2.Font.FontName = "Arial";
            textPart2.Font.FontSize = 21;

            para = paragraphs2.Add();
            para.HorizontalAlignment = HorizontalAlignmentType.Left;
            textPart2               = para.AddTextPart();
            textPart2.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet. 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.For more details please ";
            textPart2.Font.FontName = "Arial";
            textPart2.Font.FontSize = 21;

            //Add hyperlink to the paragraph
            ITextPart textPart3 = para.AddTextPart();
            textPart3.Font.FontName = "Arial";
            textPart3.Text          = "click here";
            textPart3.SetHyperlink("https://msdn.microsoft.com/en-in/library/mt299001.aspx");
            #endregion

            //Save the Presentation to stream
            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (Device.RuntimePlatform == Device.WinPhone || (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.WinRT))
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("GettingStartedSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("GettingStartedSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
        private void SlideWithComments3(IPresentation presentation)
        {
            xValue = 0.14;
            yValue = 0.04;
            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
            string   dataPath    = ResolveApplicationImagePath("tablet.jpg");
            Stream   imageStream = System.IO.File.Open(dataPath, FileMode.Open);
            IPicture picture1    = slide3.Shapes.AddPicture(imageStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72);

            imageStream.Close();

            //Add comment to the slide
            IComment comment = slide3.Comments.Add(xValue, yValue, "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, comment);
        }
        void OnButtonClicked(object sender, EventArgs e)
        {
            string resourcePath = "";

#if COMMONSB
            resourcePath = "SampleBrowser.Samples.Presentation.Samples.Templates.Images.pptx";
#else
            resourcePath = "SampleBrowser.Presentation.Samples.Templates.Images.pptx";
#endif
            Assembly assembly   = typeof(Images).GetTypeInfo().Assembly;
            Stream   fileStream = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.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 = "";
#if COMMONSB
            resourcePath = "SampleBrowser.Samples.Presentation.Samples.Templates.tablet.jpg";
#else
            resourcePath = "SampleBrowser.Presentation.Samples.Templates.tablet.jpg";
#endif
            assembly   = typeof(Images).GetTypeInfo().Assembly;
            fileStream = assembly.GetManifestResourceStream(resourcePath);
            slide2.Shapes.AddPicture(fileStream, 5.18 * 72, 1.15 * 72, 7.3 * 72, 5.31 * 72);
            fileStream.Dispose();
            #endregion

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (Device.RuntimePlatform == Device.WinPhone || (Device.RuntimePlatform == Device.UWP || Device.RuntimePlatform == Device.WinRT))
            {
                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);
            }
        }
Beispiel #7
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.HelloWorld.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Presentation.Open(fileStream);

            #region Slide1
            ISlide slide1     = presentation.Slides[0];
            IShape titleShape = slide1.Shapes[0] as IShape;
            titleShape.Left   = 0.33 * 72;
            titleShape.Top    = 0.58 * 72;
            titleShape.Width  = 12.5 * 72;
            titleShape.Height = 1.75 * 72;

            ITextBody   textFrame1  = (slide1.Shapes[0] as IShape).TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph   = paragraphs1.Add();
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart1 = paragraph.AddTextPart();
            textPart1.Text          = "Essential Presentation";
            textPart1.Font.CapsType = TextCapsType.All;
            textPart1.Font.FontName = "Adobe Garamond Pro";
            textPart1.Font.Bold     = true;
            textPart1.Font.FontSize = 40;

            IShape subtitle = slide1.Shapes[1] as IShape;
            subtitle.Left   = 0.5 * 72;
            subtitle.Top    = 3 * 72;
            subtitle.Width  = 11.8 * 72;
            subtitle.Height = 1.7 * 72;

            ITextBody textFrame2 = (slide1.Shapes[1] as IShape).TextBody;
            textFrame2.VerticalAlignment = VerticalAlignmentType.Top;
            IParagraphs paragraphs2 = textFrame2.Paragraphs;
            IParagraph  para        = paragraphs2.Add();
            para.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textPart2 = para.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.Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textPart2.Font.FontName = "Adobe Garamond Pro";
            textPart2.Font.FontSize = 21;

            para = paragraphs2.Add();
            para.HorizontalAlignment = HorizontalAlignmentType.Left;
            textPart2               = para.AddTextPart();
            textPart2.Text          = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet. 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 = "Adobe Garamond Pro";
            textPart2.Font.FontSize = 21;
            #endregion

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;

            if (stream != null)
            {
                SaveiOS iOSSave = new SaveiOS();
                iOSSave.Save("GettingStartedPresentation.pptx", "application/mspowerpoint", stream);
            }
        }
        private void ExportTemplate(int fieldId, string filePath)
        {
            try
            {
                IPresentation pptxDoc = Presentation.Open(@"Templates\Report.pptx");

                Syncfusion.Drawing.Image image = null;

                List <FieldResultDetail> fieldResultDetail = fieldResultDetails.Where(p => p.RestaurantFieldId == fieldId &&
                                                                                      !string.IsNullOrWhiteSpace(p.AttachPath)).ToList();
                //Adds a blank slide to Presentation
                int    idxImg    = 0;
                var    field     = fieldResults.FirstOrDefault(p => p.RestaurantFieldId == fieldId);
                string shiftWork = "C";
                if (field.StartTime.Hour < 12)
                {
                    shiftWork = "S";
                }
                for (int idx = 1; idx < pptxDoc.Slides.Count; idx++)
                {
                    ISlide itmSlide = pptxDoc.Slides[idx];
                    if (idx < pptxDoc.Slides.Count - 1)
                    {
                        //Adds normal shape to slide
                        foreach (IShape itmShap in itmSlide.Shapes.OrderBy(p => p.ShapeName))
                        {
                            if (itmShap.ShapeName.Contains("header"))
                            {
                                //xu ly replace
                                ITextBody textBody = itmShap.TextBody;
                                textBody.Text = textBody.Text.Replace("Localtion", field.LocationName);
                                textBody.Text = textBody.Text.Replace("ActionDate", field.StartTime.ToString("yyyy-MM-dd"));
                                if (field.StartTime.Hour < 13)
                                {
                                    textBody.Text = textBody.Text.Replace("Shift", "Ca Sáng");
                                }
                                else
                                {
                                    textBody.Text = textBody.Text.Replace("Shift", "Ca Chiều");
                                }

                                textBody.Text = textBody.Text.Replace("WorkingTime", $"{field.StartTime.ToString("HH:mm")} - {field.StartTime.ToString("HH:mm")}");
                            }
                            else
                            {
                                if (idxImg <= fieldResultDetail.Count - 1 && !string.IsNullOrEmpty(fieldResultDetail[idxImg].AttachPath))
                                {
                                    using (Stream stream = new FileStream(fieldResultDetail[idxImg].AttachPath, FileMode.Open))
                                    {
                                        image = Syncfusion.Drawing.Image.FromStream(stream);
                                    }
                                    IFill lineFormat = itmShap.Fill;
                                    lineFormat.FillType = FillType.Picture;
                                    lineFormat.PictureFill.ImageBytes = image.ImageData;
                                }
                                else
                                {
                                    break;
                                }
                                idxImg++;
                            }
                        }
                    }
                    else
                    {
                        //lay duong dan folder.
                        //search image
                        string   folder      = fieldResultDetail[0].AttachPath.Substring(0, fieldResultDetail[0].AttachPath.LastIndexOf(@"\"));
                        string[] fileResults = Directory.GetFiles(folder, $"ketqua_{shiftWork}*");
                        idxImg = 0;
                        foreach (IShape itmShap in itmSlide.Shapes.OrderBy(p => p.ShapeName))
                        {
                            if (itmShap.ShapeName.Contains("header"))
                            {
                                ITextBody textBody = itmShap.TextBody;
                                textBody.Text = textBody.Text.Replace("Localtion", field.LocationName);
                                textBody.Text = textBody.Text.Replace("ActionDate", field.StartTime.ToString("yyyy-MM-dd"));
                                if (field.StartTime.Hour < 13)
                                {
                                    textBody.Text = textBody.Text.Replace("Shift", "Ca Sáng");
                                }
                                else
                                {
                                    textBody.Text = textBody.Text.Replace("Shift", "Ca Chiều");
                                }
                                textBody.Text = textBody.Text.Replace("WorkingTime", $"{field.StartTime.ToString("HH:mm")} - {field.StartTime.ToString("HH:mm")}");

                                //xu ly replace
                            }
                            else
                            {
                                using (Stream stream = new FileStream(fileResults[idxImg], FileMode.Open))
                                {
                                    image = Syncfusion.Drawing.Image.FromStream(stream);
                                }
                                IFill lineFormat = itmShap.Fill;
                                lineFormat.FillType = FillType.Picture;
                                lineFormat.PictureFill.ImageBytes = image.ImageData;
                                idxImg++;
                            }
                        }
                    }
                }

                pptxDoc.Save(filePath);
                pptxDoc.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Assembly assembly     = typeof(SlidesPresentation).GetTypeInfo().Assembly;
            string   resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.Slides.pptx";
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = await Presentation.OpenAsync(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;
            ITextPart textpart3 = 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 = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.tablet.jpg";
            fileStream   = assembly.GetManifestResourceStream(resourcePath);
            IPicture picture1 = slide2.Shapes.AddPicture(fileStream, 0.81 * 72, 1.96 * 72, 6.63 * 72, 4.43 * 72);
            fileStream.Dispose();
            #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 ms = new MemoryStream();

            SavePPTX(presentation);
        }
        private void SlideWithNotes1(IPresentation presentation)
        {
            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;

            //Adding Notes
            INotesSlide notesSlide    = slide1.AddNotesSlide();
            ITextPart   notesTextPart = notesSlide.NotesTextBody.Paragraphs[0].TextParts.Add();

            notesTextPart.Text = "The slide represents the title content of the presentation";

            IPresentationChart chart = notesSlide.Shapes.AddChart(1.24 * 72, 5.71 * 72, 5 * 72, 3.33 * 72);


            //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;

            chart.ChartTitle = "Chart inside Notes section";
        }
Beispiel #11
0
        /// <summary>
        /// Creates fourth slide in PowerPoint Presentation file.
        /// </summary>
        private static void CreateFourthSlide(IPresentation presentation)
        {
            ISlide slide4 = presentation.Slides.Add(SlideLayoutType.TwoContent);
            IShape 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;

            ITextBody textFrame1 = shape1.TextBody;

            //Adds a new paragraph and text.
            IParagraphs paragraphs1 = textFrame1.Paragraphs;

            paragraphs1.Add();
            IParagraph paragraph1 = paragraphs1[0];
            ITextPart  textpart1  = paragraph1.AddTextPart();

            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Left;

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

            //Removes the shape.
            IShape shape2 = slide4.Shapes[1] as IShape;

            slide4.Shapes.Remove(shape2);

            //Adds a new table to the shape collection with the specified number of rows and columns.
            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;

            #region First Row
            //Adds text to the first cell in first row.
            ICell  cell1 = table.Rows[0].Cells[0];
            string text  = "ID";
            AddParaInCell(cell1, text);

            //Adds text to the second cell in first row.
            ICell cell2 = table.Rows[0].Cells[1];
            text = "Company Name";
            AddParaInCell(cell2, text);

            //Adds text to the third cell in first row.
            ICell cell3 = table.Rows[0].Cells[2];
            text = "Contact Name";
            AddParaInCell(cell3, text);

            //Adds text to the fourth cell in first row.
            ICell cell4 = table.Rows[0].Cells[3];
            text = "Address";
            AddParaInCell(cell4, text);

            //Adds text to the fifth cell in first row.
            ICell cell5 = table.Rows[0].Cells[4];
            text = "City";
            AddParaInCell(cell5, text);

            //Adds text to the sixth cell in first row.
            ICell cell6 = table.Rows[0].Cells[5];
            text = "Country";
            AddParaInCell(cell6, text);
            #endregion

            #region Second Row
            //Adds text to the first cell in second row.
            cell1 = table.Rows[1].Cells[0];
            text  = "1";
            AddParaInCell(cell1, text);

            //Adds text to the second cell in second row.
            cell1 = table.Rows[1].Cells[1];
            text  = "New Orleans Cajun Delights";
            AddParaInCell(cell1, text);

            //Adds text to the third cell in second row.
            cell1 = table.Rows[1].Cells[2];
            text  = "Shelley Burke";
            AddParaInCell(cell1, text);

            //Adds text to the fourth cell in second row.
            cell1 = table.Rows[1].Cells[3];
            text  = "P.O. Box 78934";
            AddParaInCell(cell1, text);

            //Adds text to the fifth cell in second row.
            cell1 = table.Rows[1].Cells[4];
            text  = "New Orleans";
            AddParaInCell(cell1, text);

            //Adds text to the sixth cell in second row.
            cell1 = table.Rows[1].Cells[5];
            text  = "USA";
            AddParaInCell(cell1, text);
            #endregion

            #region Third Row
            //Adds text to the first cell in third row.
            cell1 = table.Rows[2].Cells[0];
            text  = "2";
            AddParaInCell(cell1, text);

            //Adds text to the second cell in third row.
            cell1 = table.Rows[2].Cells[1];
            text  = "Cooperativa de Quesos 'Las Cabras";
            AddParaInCell(cell1, text);

            //Adds text to the third cell in third row.
            cell1 = table.Rows[2].Cells[2];
            text  = "Antonio del Valle Saavedra";
            AddParaInCell(cell1, text);

            //Adds text to the fourth cell in third row.
            cell1 = table.Rows[2].Cells[3];
            text  = "Calle del Rosal 4";
            AddParaInCell(cell1, text);

            //Adds text to the fifth cell in third row.
            cell1 = table.Rows[2].Cells[4];
            text  = "Oviedo";
            AddParaInCell(cell1, text);

            //Adds text to the sixth cell in third row.
            cell1 = table.Rows[2].Cells[5];
            text  = "Spain";
            AddParaInCell(cell1, text);
            #endregion

            #region Fourth Row
            //Adds text to the first cell in fourth row.
            cell1 = table.Rows[3].Cells[0];
            text  = "3";
            AddParaInCell(cell1, text);

            //Adds text to the second cell in fourth row.
            cell1 = table.Rows[3].Cells[1];
            text  = "Mayumi";
            AddParaInCell(cell1, text);

            //Adds text to the third cell in fourth row.
            cell1 = table.Rows[3].Cells[2];
            text  = "Mayumi Ohno";
            AddParaInCell(cell1, text);

            //Adds text to the fourth cell in fourth row.
            cell1 = table.Rows[3].Cells[3];
            text  = "92 Setsuko Chuo-ku";
            AddParaInCell(cell1, text);

            //Adds text to the fifth cell in fourth row.
            cell1 = table.Rows[3].Cells[4];
            text  = "Osaka";
            AddParaInCell(cell1, text);

            //Adds text to the sixth cell in fourth row.
            cell1 = table.Rows[3].Cells[5];
            text  = "Japan";
            AddParaInCell(cell1, text);
            #endregion

            #region Fifth Row
            //Adds text to the first cell in fifth row.
            cell1 = table.Rows[4].Cells[0];
            text  = "4";
            AddParaInCell(cell1, text);

            //Adds text to the second cell in fifth row.
            cell1 = table.Rows[4].Cells[1];
            text  = "Pavlova, Ltd.";
            AddParaInCell(cell1, text);

            //Adds text to the third cell in fifth row.
            cell1 = table.Rows[4].Cells[2];
            text  = "Ian Devling";
            AddParaInCell(cell1, text);

            //Adds text to the fourth cell in fifth row.
            cell1 = table.Rows[4].Cells[3];
            text  = "74 Rose St. Moonie Ponds";
            AddParaInCell(cell1, text);

            //Adds text to the fifth cell in fifth row.
            cell1 = table.Rows[4].Cells[4];
            text  = "Melbourne";
            AddParaInCell(cell1, text);

            //Adds text to the sixth cell in fifth row.
            cell1 = table.Rows[4].Cells[5];
            text  = "Australia";
            AddParaInCell(cell1, text);
            #endregion

            #region Sixth Region
            //Adds text to the first cell in sixth row.
            cell1 = table.Rows[5].Cells[0];
            text  = "5";
            AddParaInCell(cell1, text);

            //Adds text to the second cell in sixth row.
            cell1 = table.Rows[5].Cells[1];
            text  = "Specialty Biscuits, Ltd.";
            AddParaInCell(cell1, text);

            //Adds text to the third cell in sixth row.
            cell1 = table.Rows[5].Cells[2];
            text  = "Peter Wilson";
            AddParaInCell(cell1, text);

            //Adds text to the fourth cell in sixth row.
            cell1 = table.Rows[5].Cells[3];
            text  = "29 King's Way";
            AddParaInCell(cell1, text);

            //Adds text to the fifth cell in sixth row.
            cell1 = table.Rows[5].Cells[4];
            text  = "Manchester";
            AddParaInCell(cell1, text);

            //Adds text to the sixth cell in sixth row.
            cell1 = table.Rows[5].Cells[5];
            text  = "UK";
            AddParaInCell(cell1, text);
            #endregion

            //Removes the shape.
            slide4.Shapes.RemoveAt(1);
        }
Beispiel #12
0
        /// <summary>
        /// Creates second slide in PowerPoint Presentation file.
        /// </summary>
        private static void CreateSecondSlide(IPresentation presentation)
        {
            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.SectionHeader);
            IShape 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;

            //Adds content for first shape.
            ITextBody textFrame1 = shape1.TextBody;

            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  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;

            //Adds content for second shape.
            ITextBody textFrame2 = shape2.TextBody;
            string    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.";

            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            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.";
            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            text = "Vestibulum duis integer diam mi libero felis, sollicitudin id dictum etiam blandit lacus, ac condimentum magna dictumst interdum et,";
            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            text = "nam commodo mi habitasse enim fringilla nunc, amet aliquam sapien per tortor luctus. Conubia voluptates at nunc, congue lectus, malesuada nulla.";
            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            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,";
            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            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.";
            AddTextInSecondSlide(textFrame2, text);

            //Adds a new paragraph and text.
            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.";
            AddTextInSecondSlide(textFrame2, text);
        }
Beispiel #13
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 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 = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.tablet.jpg";
            fileStream   = assembly.GetManifestResourceStream(resourcePath);

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

            MemoryStream ms = new MemoryStream();

            SavePPTX(presentation);
        }
Beispiel #14
0
        /// <summary>
        /// Create slide with table in presentation.
        /// </summary>
        /// <param name="presentation">Represents the presentation instance.</param>
        private void CreateSlideWithTable(IPresentation presentation)
        {
            #region Slide4
            ISlide slide = presentation.Slides.Add(SlideLayoutType.TwoContent);
            IShape shape = slide.Shapes[0] as IShape;
            SetShapeBounds(shape, 36.72, 24.48, 815.04, 76.32);

            ITextBody textFrame = shape.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs = textFrame.Paragraphs;
            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];
            ITextPart  textpart  = paragraph.AddTextPart();
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;

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

            shape = slide.Shapes[1] as IShape;
            slide.Shapes.Remove(shape);

            ITable table = (ITable)slide.Shapes.AddTable(6, 6, 58.32, 154.08, 822.96, 273.6);
            foreach (IRow row in table.Rows)
            {
                row.Height = 61.2;
            }
            table.HasBandedRows    = true;
            table.HasHeaderRow     = true;
            table.HasBandedColumns = false;
            table.BuiltInStyle     = BuiltInTableStyle.MediumStyle2Accent1;

            AddTableCellContent(table.Rows[0].Cells[0], "ID");
            AddTableCellContent(table.Rows[0].Cells[1], "Company Name");
            AddTableCellContent(table.Rows[0].Cells[2], "Contact Name");
            AddTableCellContent(table.Rows[0].Cells[3], "Address");
            AddTableCellContent(table.Rows[0].Cells[4], "City");
            AddTableCellContent(table.Rows[0].Cells[5], "Country");
            AddTableCellContent(table.Rows[1].Cells[0], "1");
            AddTableCellContent(table.Rows[1].Cells[1], "New Orleans Cajun Delights");
            AddTableCellContent(table.Rows[1].Cells[2], "Shelley Burke");
            AddTableCellContent(table.Rows[1].Cells[3], "P.O. Box 78934");
            AddTableCellContent(table.Rows[1].Cells[4], "New Orleans");
            AddTableCellContent(table.Rows[1].Cells[5], "USA");
            AddTableCellContent(table.Rows[2].Cells[0], "2");
            AddTableCellContent(table.Rows[2].Cells[1], "Cooperativa de Quesos 'Las Cabras");
            AddTableCellContent(table.Rows[2].Cells[2], "Antonio del Valle Saavedra");
            AddTableCellContent(table.Rows[2].Cells[3], "Calle del Rosal 4");
            AddTableCellContent(table.Rows[2].Cells[4], "Oviedo");
            AddTableCellContent(table.Rows[2].Cells[5], "Spain");
            AddTableCellContent(table.Rows[3].Cells[0], "3");
            AddTableCellContent(table.Rows[3].Cells[1], "Mayumi");
            AddTableCellContent(table.Rows[3].Cells[2], "Mayumi Ohno");
            AddTableCellContent(table.Rows[3].Cells[3], "92 Setsuko Chuo-ku");
            AddTableCellContent(table.Rows[3].Cells[4], "Osaka");
            AddTableCellContent(table.Rows[3].Cells[5], "Japan");
            AddTableCellContent(table.Rows[4].Cells[0], "4");
            AddTableCellContent(table.Rows[4].Cells[1], "Pavlova, Ltd.");
            AddTableCellContent(table.Rows[4].Cells[2], "Ian Devling");
            AddTableCellContent(table.Rows[4].Cells[3], "74 Rose St. Moonie Ponds");
            AddTableCellContent(table.Rows[4].Cells[4], "Melbourne");
            AddTableCellContent(table.Rows[4].Cells[5], "Australia");
            AddTableCellContent(table.Rows[5].Cells[0], "5");
            AddTableCellContent(table.Rows[5].Cells[1], "Specialty Biscuits, Ltd.");
            AddTableCellContent(table.Rows[5].Cells[2], "Peter Wilson");
            AddTableCellContent(table.Rows[5].Cells[3], "29 King's Way");
            AddTableCellContent(table.Rows[5].Cells[4], "Manchester");
            AddTableCellContent(table.Rows[5].Cells[5], "UK");

            slide.Shapes.RemoveAt(1);
            #endregion
        }
        private void CreateDefaultSlide(IPresentation presentation)
        {
            //Retrieve the first slide of the presentation.
            ISlide slide1 = presentation.Slides[0];
            //Retrieve the first shape of the slide.
            IShape titleShape = slide1.Shapes[0] as IShape;

            //Set the size and position of the shape.
            titleShape.Left   = 0.33 * 72;
            titleShape.Top    = 0.58 * 72;
            titleShape.Width  = 12.5 * 72;
            titleShape.Height = 1.75 * 72;

            //Retrieve the text body of the shape.
            ITextBody   textFrame1  = (slide1.Shapes[0] as IShape).TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            //Add a new paragraph.
            IParagraph paragraph = paragraphs1.Add();

            //Set the horizontal alignment type for the paragraph.
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            //Add a text part.
            ITextPart textPart1 = paragraph.AddTextPart();

            //Add text to the text part.
            textPart1.Text = "Essential Presentation";
            //Set the font properties for the text part.
            textPart1.Font.CapsType = TextCapsType.All;
            textPart1.Font.FontName = "Adobe Garamond Pro";
            textPart1.Font.Bold     = true;
            textPart1.Font.FontSize = 40;

            //Retrieve the second shape of the slide.
            IShape subtitle = slide1.Shapes[1] as IShape;

            //Set the size and position of the shape.
            subtitle.Left   = 1.33 * 72;
            subtitle.Top    = 2.67 * 72;
            subtitle.Width  = 10 * 72;
            subtitle.Height = 1.7 * 72;

            //Retrieve the text body of the shape.
            ITextBody textFrame2 = (slide1.Shapes[1] as IShape).TextBody;

            textFrame2.VerticalAlignment = VerticalAlignmentType.Top;
            IParagraphs paragraphs2 = textFrame2.Paragraphs;
            //Add a new paragraph.
            IParagraph para = paragraphs2.Add();

            //Set the horizontal alignment type for the paragraph.
            para.HorizontalAlignment = HorizontalAlignmentType.Left;
            //Add a text part.
            ITextPart textPart2 = para.AddTextPart();

            //Add text to the text part.
            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.Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet.";
            textPart2.Font.FontName = "Adobe Garamond Pro";
            textPart2.Font.FontSize = 21;

            //Add a new paragraph.
            para = paragraphs2.Add();
            //Set the horizontal alignment type for the paragraph.
            para.HorizontalAlignment = HorizontalAlignmentType.Left;
            //Add a text part.
            textPart2 = para.AddTextPart();
            //Add text to the text part.
            textPart2.Text = "Turpis facilisis vitae consequat, cum a a, turpis dui consequat massa in dolor per, felis non amet. 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.";
            //Set the font properties.
            textPart2.Font.FontName = "Adobe Garamond Pro";
            textPart2.Font.FontSize = 21;
        }
Beispiel #16
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            string   resourcePath = "SampleBrowser.Samples.Presentation.Templates.Slides.pptx";
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = Syncfusion.Presentation.Presentation.Open(fileStream);

            #region Slide1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = slide1.Shapes[0] as IShape;
            shape1.Left   = 108;
            shape1.Top    = 139.68;
            shape1.Width  = 743.04;
            shape1.Height = 144;

            ITextBody   textFrame1  = shape1.TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            paragraphs1[0].IndentLevelNumber = 0;

            AddParagraphData(paragraph1, "ESSENTIAL PRESENTATION", "Calibri", 48, true);
            paragraph1.HorizontalAlignment = HorizontalAlignmentType.Center;
            slide1.Shapes.RemoveAt(1);
            #endregion

            #region Slide2
            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.SectionHeader);
            shape1        = slide2.Shapes[0] as IShape;
            shape1.Left   = 55;
            shape1.Top    = 23;
            shape1.Width  = 573;
            shape1.Height = 71;
            textFrame1    = shape1.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraph1  = paragraphs1.Add();
            AddParagraphData(paragraph1, "Slide with simple text", "Calibri", 40, false);
            paragraphs1[0].HorizontalAlignment = HorizontalAlignmentType.Left;

            IShape shape2 = slide2.Shapes[1] as IShape;
            shape2.Left   = 87;
            shape2.Top    = 119;
            shape2.Width  = 725;
            shape2.Height = 355;
            ITextBody textFrame2 = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            IParagraphs paragraphs2 = textFrame2.Paragraphs;

            //Add paragrpah text
            IParagraph paragraph_1 = paragraphs2.Add();
            AddParagraphData(paragraph_1, "Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.", "Calibri", 15, false);

            IParagraph paragraph_2 = paragraphs2.Add();
            AddParagraphData(paragraph_2, "In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.", "Calibri", 15, false);
            #endregion

            #region Slide3
            slide2        = presentation.Slides.Add(SlideLayoutType.TwoContent);
            shape1        = slide2.Shapes[0] as IShape;
            shape1.Left   = 26;
            shape1.Top    = 37;
            shape1.Width  = 815;
            shape1.Height = 76;

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

            //Instance to hold paragraphs in textframe
            paragraphs1 = textFrame1.Paragraphs;
            paragraphs1.Add();
            paragraph1 = paragraphs1[0];
            AddParagraphData(paragraph1, "Slide with Image", "Calibri", 44, false);

            //Adds shape in slide
            shape2        = slide2.Shapes[1] as IShape;
            shape2.Left   = 578;
            shape2.Top    = 141;
            shape2.Width  = 316;
            shape2.Height = 326;
            textFrame2    = shape2.TextBody;

            //Instance to hold paragraphs in textframe
            paragraphs2 = textFrame2.Paragraphs;
            IParagraph paragraph2 = paragraphs2.Add();

            AddParagraphData(paragraph2, "The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases.", "Calibri", 16, false);
            IParagraph paragraph3 = paragraphs2.Add();

            AddParagraphData(paragraph3, "Using Northwind, you can become familiar with how a relational database is structured and how the database objects work together to help you enter, store, manipulate, and print your data.", "Calibri", 16, false);
            IParagraph paragraph4 = paragraphs2.Add();

            //           AddParagraphData(paragraph4, ref textpart1, "While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.", "Calibri", 16);
            IShape shape3 = (IShape)slide2.Shapes[2];
            slide2.Shapes.RemoveAt(2);


            //Adds picture in the shape
            resourcePath = "SampleBrowser.Samples.Presentation.Templates.tablet.jpg";
            assembly     = Assembly.GetExecutingAssembly();
            fileStream   = assembly.GetManifestResourceStream(resourcePath);
            IPicture picture1 = slide2.Shapes.AddPicture(fileStream, 58, 141, 477, 318);
            fileStream.Close();
            #endregion

            #region Slide4
            ISlide slide4 = presentation.Slides.Add(SlideLayoutType.TwoContent);
            shape1        = slide4.Shapes[0] as IShape;
            shape1.Left   = 37;
            shape1.Top    = 24;
            shape1.Width  = 815;
            shape1.Height = 76;
            textFrame1    = shape1.TextBody;

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

            AddParagraphData(paragraph1, "Slide with Table", "Calibri", 44, false);
            shape2 = slide4.Shapes[1] as IShape;
            slide4.Shapes.Remove(shape2);

            ITable table = (ITable)slide4.Shapes.AddTable(6, 6, 58, 154, 823, 273);
            table.Rows[0].Height   = 61.2;
            table.Rows[1].Height   = 30;
            table.Rows[2].Height   = 61;
            table.Rows[3].Height   = 61;
            table.Rows[4].Height   = 61;
            table.Rows[5].Height   = 61;
            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;
            IParagraph 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;
            IParagraph 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;
            IParagraph paragraph7 = textFrame7.Paragraphs.Add();
            paragraph7.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart7 = paragraph7.AddTextPart();
            textPart7.Text = "Country";

            //Add data in table
            AddTableData(cell1, table, textFrame1, paragraph1);
            slide4.Shapes.RemoveAt(1);
            #endregion

            MemoryStream stream = new MemoryStream();
            presentation.Save(stream);
            presentation.Close();
            stream.Position = 0;
            if (stream != null)
            {
                SaveAndroid androidSave = new SaveAndroid();
                androidSave.Save("Charts.pptx", "application/powerpoint", stream, m_context);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Reads the list of articles from the stream and returns the feed item.
        /// </summary>
        /// <param name="f">Information about the feed. This information is updated based
        /// on the results of processing the feed.</param>
        /// <param name="newsgroupListStream">A stream containing an nntp news group list.</param>
        /// <param name="response">The response.</param>
        /// <param name="cacheDataService">The cache data service to store embedded binary content.</param>
        /// <param name="cachedStream">Flag states update last retrieved date on feed only
        /// if the item was not cached. Indicates whether the lastretrieved date is updated
        /// on the NewsFeed object passed in.</param>
        /// <returns>
        /// A FeedInfo containing the NewsItem objects
        /// </returns>
        internal static FeedInfo GetItemsForNewsGroup(INewsFeed f, Stream newsgroupListStream, WebResponse response, IUserCacheDataService cacheDataService, bool cachedStream)
        {
            int readItems          = 0;
            List <INewsItem> items = new List <INewsItem>();
            NewsItem         item;

            StringBuilder content = new StringBuilder();

#if DEBUG
            // just to have the source for the item to build to track down issues:
            StringBuilder itemSource = new StringBuilder();
#endif
            NntpWebResponse nntpResponse = (NntpWebResponse)response;

            FeedInfo fi = new FeedInfo(f.id, f.cacheurl, items, f.title, f.link, String.Empty);

            try
            {
                foreach (MimeMessage msg in nntpResponse.Articles)
                {
                    string   parentId;
                    string   id;
                    string   author  = parentId = id = null;
                    DateTime pubDate = DateTime.UtcNow;

                    content.Length = 0;

                    string title;
                    if (msg.Subject != null)
                    {
                        title = EscapeXML(msg.Subject.Value);
                    }
                    else
                    {
                        title = "";
                    }

                    UnstructuredField fld = msg.Header.GetField(MimeField.MessageID) as UnstructuredField;
                    if (fld != null)
                    {
                        id = fld.Value;
                    }

                    MailboxListField mfld = msg.Header.GetField(MimeField.From) as MailboxListField;
                    if (mfld != null && mfld.MailboxList.Count > 0)
                    {
                        author = mfld.MailboxList[0].AddressString;
                    }

                    fld = msg.Header.GetField(MimeField.References) as UnstructuredField;
                    if (fld != null)
                    {
                        // returns the hierarchy path: the last one is our real parent:
                        string[] singleRefs = fld.Value.Split(' ');
                        if (singleRefs.Length > 0)
                        {
                            parentId = CreateGoogleUrlFromID(singleRefs[singleRefs.Length - 1]);
                        }
                    }
                    DateTimeField dfld = msg.Header.GetField(MimeField.Date) as DateTimeField;
                    if (dfld != null)
                    {
                        pubDate = dfld.DateValue;
                    }

                    ITextBody txtBody = msg.Body as ITextBody;
                    if (txtBody != null)
                    {
                        content.Append(txtBody.Reader.ReadToEnd());

                        content = NntpClient.DecodeBody(content,
                                                        (fileName, bytes) =>
                        {
                            string name = PrepareEmbeddedFileUrl(fileName, id, nntpResponse.ResponseUri);
                            // we replace the uuencoded/yencoded binary content with a clickable link:
                            if (IsImage(fileName))
                            {
                                return(String.Format("<img src='{1}' alt='{0}'></img>", fileName,
                                                     cacheDataService.SaveBinaryContent(name, bytes).AbsoluteUri));
                            }
                            return(String.Format("<a href='{1}'>{0}</a>", fileName,
                                                 cacheDataService.SaveBinaryContent(name, bytes).AbsoluteUri));
                        },
                                                        line =>
                        {
                            // escape HTML/XML special chars:
                            return(line.Replace("<", "&lt;").Replace("]]>", "]]&gt;"));
                        });

                        content = content.Replace(Environment.NewLine, "<br>");
                    }

                    if (id != null)
                    {
                        item              = new NewsItem(f, title, CreateGoogleUrlFromID(id), content.ToString(), author, pubDate, id, parentId);
                        item.FeedDetails  = fi;
                        item.CommentStyle = SupportedCommentStyle.NNTP;
                        item.Enclosures   = Collections.GetList <IEnclosure> .Empty;
                        items.Add(item);
                        FeedSource.ReceivingNewsChannelServices.ProcessItem(item);
                    }
                    else
                    {
#if DEBUG
                        _log.Warn("No message-id header found for item:\r\n" + itemSource.ToString());
#else
                        _log.Warn("No message-id header found for item.");
#endif
                    }
                }


                //update last retrieved date on feed only if the item was not cached.)
                if (!cachedStream)
                {
                    f.lastretrieved          = new DateTime(DateTime.Now.Ticks);
                    f.lastretrievedSpecified = true;
                }

                //any new items in feed?
                if ((items.Count == 0) || (readItems == items.Count))
                {
                    f.containsNewMessages = false;
                }
                else
                {
                    f.containsNewMessages = true;
                }

                FeedSource.ReceivingNewsChannelServices.ProcessItem(fi);
                FeedSource.RelationCosmosAddRange(items);
                fi.itemsList.AddRange(items);
            }
            catch (Exception e)
            {
                _log.Error("Retriving NNTP articles from " + nntpResponse.ResponseUri + " caused an exception", e);
            }


            return(fi);
        }