public GeneratorEmbeddedContentVisitor(IDocumentItemFactory itemFactory)
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);
            _parentParagraph = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create an instance of Presentation class
            Presentation presentation = new Presentation();

            ISlide slide = presentation.Slides[0];

            IChart         chart  = slide.Shapes.AddChart(ChartType.StackedColumn, 20, 20, 400, 400);
            IChartSeries   series = chart.ChartData.Series[0];
            IChartCategory cat;

            double[] total_for_Cat = new double[chart.ChartData.Categories.Count];

            for (int k = 0; k < chart.ChartData.Categories.Count; k++)
            {
                cat = chart.ChartData.Categories[k];

                for (int i = 0; i < chart.ChartData.Series.Count; i++)
                {
                    total_for_Cat[k] = total_for_Cat[k] + Convert.ToDouble(chart.ChartData.Series[i].DataPoints[k].Value.Data);
                }
            }

            double dataPontPercent = 0f;

            for (int x = 0; x < chart.ChartData.Series.Count; x++)
            {
                series = chart.ChartData.Series[x];
                series.Labels.DefaultDataLabelFormat.ShowLegendKey = false;

                for (int j = 0; j < series.DataPoints.Count; j++)
                {
                    IDataLabel lbl = series.DataPoints[j].Label;
                    dataPontPercent = (Convert.ToDouble(series.DataPoints[j].Value.Data) / total_for_Cat[j]) * 100;

                    IPortion port = new Portion();
                    port.Text = String.Format("{0:F2} %", dataPontPercent);
                    port.PortionFormat.FontHeight   = 8f;
                    lbl.TextFrameForOverriding.Text = "";
                    IParagraph para = lbl.TextFrameForOverriding.Paragraphs[0];
                    para.Portions.Add(port);

                    lbl.DataLabelFormat.ShowSeriesName   = false;
                    lbl.DataLabelFormat.ShowPercentage   = false;
                    lbl.DataLabelFormat.ShowLegendKey    = false;
                    lbl.DataLabelFormat.ShowCategoryName = false;
                    lbl.DataLabelFormat.ShowBubbleSize   = false;
                }
            }

            // Save presentation with chart
            presentation.Save(dataDir + "DisplayPercentageAsLabels_out.pptx", SaveFormat.Pptx);
        }
Example #3
0
        void OnButtonClicked(object sender, EventArgs e)
        {
            MemoryStream stream = new MemoryStream();

            //Create a Presentation instance
            using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create())
            {
                //Add a blank slide to the Presentation
                ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);
                //Add a empty paragraph to the slide
                IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add();
                //Apply center alignment to the paragraph
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                //Add slide title
                ITextPart textPart = paragraph.AddTextPart("Northwind Management Report");
                textPart.Font.Color = ColorObject.FromArgb(46, 116, 181);
                //Get chart data from xml file
                List <ProductDetails> Products = LoadXMLData();
                //Add a new chart to the presentation slide
                IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16);
                //Set chart type
                chart.ChartType = OfficeChartType.Pie;
                //Set chart title
                chart.ChartTitle = "Best Selling Products";
                //Set chart properties font name and size
                chart.ChartTitleArea.FontName = "Calibri (Body)";
                chart.ChartTitleArea.Size     = 14;
                //Itterate and set the values to chart
                for (int i = 0; i < Products.Count; i++)
                {
                    ProductDetails product = Products[i];
                    chart.ChartData.SetValue(i + 2, 1, product.ProductName);
                    chart.ChartData.SetValue(i + 2, 2, product.Sum);
                }
                //Create a new chart series with the name �Sales�
                AddSeriesForChart(chart);
                //Set the font size of the legend.
                chart.Legend.TextArea.Size = 14;
                //Set the color formatting to the chart
                chart.ChartArea.Fill.ForeColor           = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.PlotArea.Fill.ForeColor            = Syncfusion.Drawing.Color.FromArgb(242, 242, 242);
                chart.ChartArea.Border.LinePattern       = OfficeChartLinePattern.None;
                chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1];
                //Save the presentation instance to a stream.
                presentation.Save(stream);
            }
            stream.Position = 0;
            if (Device.RuntimePlatform == Device.UWP)
            {
                Xamarin.Forms.DependencyService.Get <ISaveWindowsPhone>().Save("ChartsSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
            else
            {
                Xamarin.Forms.DependencyService.Get <ISave>().Save("ChartsSample.pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation", stream);
            }
        }
Example #4
0
        /// <summary>
        /// Creates third slide in PowerPoint Presentation file.
        /// </summary>
        private static void CreateThirdSlide(IPresentation presentation)
        {
            ISlide slide2 = presentation.Slides.Add(SlideLayoutType.TwoContent);
            IShape 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.
            ITextBody   textFrame1  = shape1.TextBody;
            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 Image";
            textpart1.Font.FontName = "Helvetica CE 35 Thin";

            //Adds a shape in slide.
            IShape 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;
            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.";

            AddTextInThirdSlide(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.";
            AddTextInThirdSlide(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.";
            AddTextInThirdSlide(textFrame2, text);

            //Removes the shape.
            slide2.Shapes.RemoveAt(2);

            //Adds a picture to the slide.
            Assembly assembly     = typeof(Slide).GetTypeInfo().Assembly;
            string   resourcePath = "syncfusion.presentationdemos.winui.Assets.Presentation.tablet.jpg";
            Stream   imageStream  = assembly.GetManifestResourceStream(resourcePath);

            slide2.Shapes.AddPicture(imageStream, 0.81 * 72, 1.96 * 72, 6.63 * 72, 4.43 * 72);
            imageStream.Dispose();
        }
Example #5
0
        public static void Main()
        {
            /* Take in values for numbers of slides and images to parse from HTML */
            Console.WriteLine("How many items do you need?: ");
            string input = Console.ReadLine();
            int    number;

            Int32.TryParse(input, out number);

            /* Take in user response for image content */
            Console.WriteLine("What would you like to search for?: ");
            var search = Console.ReadLine();

            /* Load Shutterstock site and create new WebClient and scrape searching for <img src> tag */
            var       document = new HtmlWeb().Load("https://www.shutterstock.com/search/" + search);
            WebClient client   = new WebClient();
            var       urls     = document.DocumentNode.Descendants("img")
                                 .Select(e => e.GetAttributeValue("src", null))
                                 .Where(s => !String.IsNullOrEmpty(s));
            int x = 0;

            /* Initialize new PPT Presentation using SyncFusion */
            IPresentation pptxDoc = Presentation.Create();

            /* Iterate over urls of images, download to local directory number of specified images */
            foreach (string item in urls)
            {
                if (x == number)
                {
                    break;
                }
                client.DownloadFile(item, search + x + ".jpg");
                Console.WriteLine(item);

                /* Create new Blank slide, take in User title text */
                ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
                Console.WriteLine("Enter title text: ");
                var title = Console.ReadLine();

                /* Open local image files scraped from web and add to slide with user defined title of each slide */
                Stream pictureStream = File.Open("./" + search + x + ".jpg", FileMode.Open);
                slide.Pictures.AddPicture(pictureStream, slide.SlideSize.Width / 2, slide.SlideSize.Height / 2, 250, 250);
                IShape     titleTextBox = slide.AddTextBox(slide.SlideSize.Width / 2, 10, 500, 500);
                IParagraph paragraph    = titleTextBox.TextBody.AddParagraph();
                ITextPart  textPart     = paragraph.AddTextPart();
                textPart.Text = title;
                pictureStream.Dispose();
                x++;
            }

            /* Save PPT project */
            pptxDoc.Save("Sample.pptx");
            pptxDoc.Close();

            Console.ReadLine();
        }
Example #6
0
        public void ProcessParagraphSegment(IParagraph segment)
        {
            PlainText       = new StringBuilder("");
            SegmentSections = new List <SegmentSection>();
            Comments        = new List <Comment>();


            IncludeTagText = true;
            VisitChildren(segment);
        }
Example #7
0
        /// <summary>
        /// Adds text to the cell.
        /// </summary>
        private static void AddParaInCell(ICell cell, string text)
        {
            ITextBody  textFrame = cell.TextBody;
            IParagraph paragraph = textFrame.Paragraphs.Add();

            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            ITextPart textPart = paragraph.AddTextPart();

            textPart.Text = text;
        }
Example #8
0
        /// <summary>
        /// Sets the paragraph properties.
        /// </summary>
        /// <param name="paragraph">Represents the paragraph instance.</param>
        /// <param name="text">Represents the text content.</param>
        private void SetParagraphProperties(IParagraph paragraph, string text)
        {
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextPart textpart = paragraph.AddTextPart();

            textpart.Text          = text;
            textpart.Font.Color    = ColorObject.White;
            textpart.Font.FontName = "Calibri (Body)";
            textpart.Font.FontSize = 15;
        }
Example #9
0
 public void SetNewBook(IBook book, IHistory history)
 {
     if (history != null & book != null)
     {
         _book             = book;
         _history          = history;
         _currentParagraph = _book[_history.GetCurrentParagraphId];
     }
     CurrentParagraphChanged?.Invoke(this, new EventArgs());
 }
        public ProcessorEmbeddedContentVisitor(IDocumentItemFactory itemFactory, IContentEvaluator evaluator, List<MatchRule> matchRules )
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);
            _parentParagraph = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
            _contentEvaluator = evaluator;
            _matchRules = matchRules;
        }
 public IEmbeddedContentVisitor CreateVisitor(IDocumentItemFactory itemFactory,
                                              IPropertiesFactory propertiesFactory, ITextProcessor textProcessor)
 {
     _itemFactory       = itemFactory;
     _propertiesFactory = propertiesFactory;
     _textProcessor     = textProcessor;
     GeneratedParagraph = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked).Source;
     _currentContainer  = GeneratedParagraph;
     return(this);
 }
Example #12
0
        public void Back()
        {
            int i = _history.Back(_currentParagraph.Id);

            if (i != -1)
            {
                _currentParagraph = _book[i];
                CurrentParagraphChanged?.Invoke(this, new EventArgs());
            }
        }
 private static void CopyParagraphContents(IParagraph fromParagraph, IParagraph toParagraph)
 {
     toParagraph.Clear();
     while (fromParagraph.Count > 0)
     {
         var item = fromParagraph[0];
         fromParagraph.RemoveAt(0);
         toParagraph.Add(item);
     }
 }
Example #14
0
 public ReadingSession(IBook book, IHistory history)
 {
     if (book == null || history == null)
     {
         throw new Exception("book or history is null");
     }
     _book             = book;
     _history          = history;
     _currentParagraph = book[_history.GetCurrentParagraphId];
 }
Example #15
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            // Instantiate PresentationEx
            using (Presentation presentation = new Presentation(dataDir + "DefaultFonts.pptx"))
            {
                // ExStart:ManagParagraphFontProperties

                // Accessing a slide using its slide position
                ISlide slide = presentation.Slides[0];

                // Accessing the first and second placeholder in the slide and typecasting it as AutoShape
                ITextFrame tf1 = ((IAutoShape)slide.Shapes[0]).TextFrame;
                ITextFrame tf2 = ((IAutoShape)slide.Shapes[1]).TextFrame;

                // Accessing the first Paragraph
                IParagraph para1 = tf1.Paragraphs[0];
                IParagraph para2 = tf2.Paragraphs[0];

                // Justify the paragraph
                para2.ParagraphFormat.Alignment = TextAlignment.JustifyLow;

                // Accessing the first portion
                IPortion port1 = para1.Portions[0];
                IPortion port2 = para2.Portions[0];

                // Define new fonts
                FontData fd1 = new FontData("Elephant");
                FontData fd2 = new FontData("Castellar");

                // Assign new fonts to portion
                port1.PortionFormat.LatinFont = fd1;
                port2.PortionFormat.LatinFont = fd2;

                // Set font to Bold
                port1.PortionFormat.FontBold = NullableBool.True;
                port2.PortionFormat.FontBold = NullableBool.True;

                // Set font to Italic
                port1.PortionFormat.FontItalic = NullableBool.True;
                port2.PortionFormat.FontItalic = NullableBool.True;

                // Set font color
                port1.PortionFormat.FillFormat.FillType             = FillType.Solid;
                port1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Purple;
                port2.PortionFormat.FillFormat.FillType             = FillType.Solid;
                port2.PortionFormat.FillFormat.SolidFillColor.Color = Color.Peru;

                // ExEnd:ManagParagraphFontProperties
                // Write the PPTX to disk
                presentation.Save(dataDir + "ManagParagraphFontProperties_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            }
        }
        /// <summary>
        /// Manipulates the gettingstarted sample.
        /// </summary>
        private void ManipulateSample()
        {
            string       resourcePath = "SampleBrowser.Samples.Presentation.Templates.HelloWorld.pptx";
            Assembly     assembly     = typeof(App).GetTypeInfo().Assembly;
            Stream       fileStream   = assembly.GetManifestResourceStream(resourcePath);
            MemoryStream stream       = new MemoryStream();

            //Open the stream to the presentation instance.
            using (IPresentation presentation = Presentation.Open(fileStream))
            {
                #region Slide1
                ISlide slide      = presentation.Slides[0];
                IShape titleShape = slide.Shapes[0] as IShape;
                //Sets the shape size and position.
                SetShapeBounds(titleShape, 23.76, 41.76, 900, 126);

                //Sets the properties for the textbody of the shape.
                ITextBody   textFrame  = (slide.Shapes[0] as IShape).TextBody;
                IParagraphs paragraphs = textFrame.Paragraphs;
                IParagraph  paragraph  = paragraphs.Add();
                paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
                ITextPart textPart = paragraph.AddTextPart();
                textPart.Text          = "Essential Presentation";
                textPart.Font.CapsType = TextCapsType.All;
                textPart.Font.FontName = "Adobe Garamond Pro";
                textPart.Font.Bold     = true;
                textPart.Font.FontSize = 40;

                //Sets the shape size and position.
                IShape subtitle = slide.Shapes[1] as IShape;
                SetShapeBounds(subtitle, 36, 216, 849.6, 122.4);

                //Sets the properties for the textbody of the shape.
                textFrame = (slide.Shapes[1] as IShape).TextBody;
                textFrame.VerticalAlignment = VerticalAlignmentType.Top;
                paragraphs = textFrame.Paragraphs;
                AddParagraphProperties(paragraphs.Add(), "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.");

                //Add text content to the paragraph.
                AddParagraphProperties(paragraphs.Add(), "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.");
                #endregion

                //Saves the presentation into the stream.
                presentation.Save(stream);
            }
            stream.Position = 0;
            if (Device.OS == TargetPlatform.WinPhone || Device.OS == TargetPlatform.Windows)
            {
                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);
            }
        }
Example #17
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Assembly assembly     = typeof(GettingStartedPresentation).GetTypeInfo().Assembly;
            string   resourcePath = "Syncfusion.SampleBrowser.UWP.Presentation.Presentation.Assets.HelloWorld.pptx";
            Stream   fileStream   = assembly.GetManifestResourceStream(resourcePath);

            IPresentation presentation = await Presentation.OpenAsync(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 ms = new MemoryStream();

            SavePPTX(presentation);
        }
Example #18
0
        public ProcessorEmbeddedContentVisitor(IDocumentItemFactory itemFactory, IContentEvaluator evaluator, List <MatchRule> matchRules)
        {
            this._itemFactory = itemFactory;

            var paragraphUnit = _itemFactory.CreateParagraphUnit(LockTypeFlags.Unlocked);

            _parentParagraph  = paragraphUnit.Source;
            _currentContainer = _parentParagraph;
            _contentEvaluator = evaluator;
            _matchRules       = matchRules;
        }
Example #19
0
        void AddParagraphData(IParagraph paragraph, string text, string fontname, int fontsize, bool isBolt)
        {
            ITextPart textpart = paragraph.AddTextPart();

            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart.Text          = text;
            textpart.Font.FontName = fontname;
            textpart.Font.FontSize = fontsize;
            textpart.Font.Color    = ColorObject.Black;
            textpart.Font.Bold     = isBolt;
        }
Example #20
0
        //
        // GET: /AbstractFactory/Submit
        //
        // Process a submission.
        //
        public IActionResult Submit(string format, string headingText, string paragraphText)
        {
            // get the proper document factory for the output type
            IDocumentFactory factory = DocumentCreatorSingleton.GetInstance().GetDocumentFactory(format);

            // create the document parts
            IHeading   headingObj   = factory.CreateHeading(1, headingText);
            IParagraph paragraphObj = factory.CreateParagraph(paragraphText);

            return(View("~/Views/Shared/Results.cshtml", headingObj.GetString() + paragraphObj.GetString()));
        }
        public string GetText(IParagraph targetParagraph)
        {
            _textStringBuilder = new StringBuilder();

            foreach (var markupData in targetParagraph)
            {
                markupData.AcceptVisitor(this);
            }

            return(_textStringBuilder.ToString());
        }
Example #22
0
        public List <string> GetTagsColorCode(ISegment segment)
        {
            _tagPairStack = new Stack <ITagPair>();
            _colors       = new List <string>();
            _paragraph    = null;
            _segment      = segment;

            VisitChildren(segment);

            return(_colors);
        }
Example #23
0
        /// <summary>
        /// Sets the paragraph properties for the picture slide.
        /// </summary>
        /// <param name="paragraphs">Represents the paragraph collection instance.</param>
        /// <param name="text">Represents the text content.</param>
        private void SetParagraphPropertiesForPictureSlide(IParagraphs paragraphs, string text)
        {
            IParagraph paragraph = paragraphs.Add();
            ITextPart  textpart  = paragraph.AddTextPart();

            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;

            textpart.Text          = text;
            textpart.Font.FontName = "Helvetica CE 35 Thin";
            textpart.Font.FontSize = 16;
        }
        private static void CopyParagraph(IParagraph fromParagraph, IParagraph toParagraph)
        {
            toParagraph.Clear();

            while (fromParagraph.Count > 0)
            {
                IAbstractMarkupData markupData = fromParagraph[0];
                fromParagraph.RemoveAt(0);

                toParagraph.Add(markupData);
            }
        }
Example #25
0
        /// <summary>
        /// Adds a new paragraph and text.
        /// </summary>
        private static void AddTextInThirdSlide(ITextBody textFrame, string text)
        {
            //Adds a new paragraph and text.
            IParagraphs paragraphs = textFrame.Paragraphs;
            IParagraph  paragraph  = paragraphs.Add();
            ITextPart   textpart   = paragraph.AddTextPart();

            textpart.Text = text;
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            textpart.Font.FontName        = "Helvetica CE 35 Thin";
            textpart.Font.FontSize        = 16;
        }
Example #26
0
        public void Next(string answer)
        {
            int i = _currentParagraph.NextParagraphId(answer);

            if (i >= 0)
            {
                _history.AddInAlreadyRead(_currentParagraph.Id);
                _history.AddInHistory(i);
                _currentParagraph = _book[i];
                CurrentParagraphChanged?.Invoke(this, new EventArgs());
            }
        }
Example #27
0
        public void ChangeFirstSlide()
        {
            ISlide     slide     = this.PowerPoint.Slides[0];
            IShape     shape     = slide.Shapes[0] as IShape;
            IParagraph paragraph = shape.TextBody.Paragraphs[0];
            ITextPart  textPart  = paragraph.TextParts[0];

            textPart.Text = this.Opleiding;

            shape = slide.Shapes[1] as IShape;
            shape.TextBody.Text += $"\r{EHBFunctions.GetCurrentAcademicYear().Year} - {EHBFunctions.GetCurrentAcademicYear().AddYears(1).Year}";
        }
        /// <summary>
        /// Add a paragraph into the specified shape with specified text
        /// </summary>
        /// <param name="shape">Represent the shape</param>
        /// <param name="text">Represent the text to be added</param>
        private void AddParagraph(IShape shape, string text)
        {
            //Add a paragraph into the specified shape with specified text
            IParagraph paragraph = shape.TextBody.AddParagraph(text);

            //Set the vertical alignment as center
            shape.TextBody.VerticalAlignment = VerticalAlignmentType.Middle;
            //Set horizontal alignment as center
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Center;
            //Set font color as white
            paragraph.Font.Color = ColorObject.White;
        }
Example #29
0
        public void ProcessParagraphSegment(IParagraph segment, bool includeTagText)
        {
            PlainText         = new StringBuilder("");
            SegmentSections   = new List <SegmentSection>();
            Comments          = new List <Comment>();
            TagPairs          = new List <ITagPair>();
            LockedContentTags = new List <ILockedContent>();
            PlaceholderTags   = new List <IPlaceholderTag>();
            TagUnits          = new List <TagUnit>();

            IncludeTagText = includeTagText;
            VisitChildren(segment);
        }
Example #30
0
        public void ParagraphTextSetter_ThrowsException_WhenParagraphWasRemoved()
        {
            IPresentation presentation = SCPresentation.Open(Properties.Resources._020, true);
            IAutoShape    autoShape    = (IAutoShape)presentation.Slides[2].Shapes.First(sp => sp.Id == 8);
            ITextBox      textBox      = autoShape.TextBox;
            IParagraph    paragraph    = textBox.Paragraphs.First();

            textBox.Text = "new box content";

            // Act-Assert
            paragraph.Invoking(p => p.Text = "new paragraph text")
            .Should().Throw <ElementIsRemovedException>("because paragraph was being removed while changing box content.");
        }
        private void ProcessParagraph(IParagraph paragraph)
        {
            var embeddedContentVisitor = _embeddedContentVisitorFactory.CreateVisitor(ItemFactory, ItemFactory.PropertiesFactory, _textProcessor);

            foreach (var item in paragraph)
            {
                item.AcceptVisitor(embeddedContentVisitor);
            }

            var generatedParagraph = embeddedContentVisitor.GeneratedParagraph;

            CopyParagraphContents(generatedParagraph, paragraph);
        }
        public List <string> GetTagsColorCode(IParagraph paragraph, ISegment segment)
        {
            _tagPairStack = new Stack <ITagPair>();
            _colors       = new List <string>();
            _paragraph    = paragraph;
            _segment      = segment;

            AddHexColorFromParagraphContext(paragraph);

            VisitChildren(paragraph);

            return(_colors);
        }
        private void RemoveSegments(IParagraph paragraph)
        {
            var segments = from item in paragraph
                where item is ISegment
                select item as ISegment;
                   
            segments.ToList().ForEach(item =>
            {
                var sourceSegmentPosition = item.IndexInParent;

                item.RemoveFromParent();
                item.MoveAllItemsTo(paragraph, sourceSegmentPosition);
            });
           
        }
        private void ProcessParagraph(IParagraph paragraph)
        {
            var visitor = GetContentVisitor();

            foreach (var markup in paragraph)
            {
                if (markup is IStructureTag) continue;
                markup.AcceptVisitor(visitor);
            }

            var paragraphCreator = visitor as IParagraphCreator;
            if (paragraphCreator == null) return;
            var sourceParagraph = paragraphCreator.GetParagraph();

            CopyParagraph(sourceParagraph, paragraph);
        }
 public static string GetPlainText(IParagraph paragraph)
 {
     PlainTextExtractor e = new PlainTextExtractor();
     e.VisitChildren(paragraph);
     return e.PlainText;
 }
        private static void CopyParagraph(IParagraph fromParagraph, IParagraph toParagraph)
        {
            toParagraph.Clear();

            while (fromParagraph.Count > 0)
            {
                IAbstractMarkupData markupData = fromParagraph[0];
                fromParagraph.RemoveAt(0);

                toParagraph.Add(markupData);
            }
        }
 public void SetSubtitleText(string text, IParagraph p)
 {
     SubtitleText = text;
     LastParagraph = p;
 }
 /// <summary>
 /// The set subtitle text.
 /// </summary>
 /// <param name="text">
 /// The text.
 /// </param>
 /// <param name="p">
 /// The p.
 /// </param>
 public void SetSubtitleText(string text, IParagraph p)
 {
     this.SubtitleText = text;
     this.LastParagraph = p;
 }