public DummyPageManagerService() { dummypages = new List <Page>(); Page page = new Page(); page.Id = 1; page.Name = "Kyler"; ParagraphItem p = new ParagraphItem(); p.PageId = page.Id; p.Id = 1; p.time = DateTime.Now; p.Title = " A Whole New World"; p.Content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut" + " labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi "; page.ParagraphItems.Add(p); dummypages.Add(page); }
public async Task <IActionResult> DeleteParagraph([Bind("PageId,Id")] ParagraphItem paragraph) { _pageManagerService.DeleteParagraph(paragraph); var items = _pageManagerService.GetPageList(); return(View("PagesManager", items)); }
public async Task <IActionResult> AddParagraph([Bind("Title,Content,PageId")] ParagraphItem paragraph) { paragraph.time = DateTime.Now; _pageManagerService.AddParagraph(paragraph); var items = _pageManagerService.GetPageList(); return(View("PagesManager", items)); }
/// <summary> /// A method that transform a paragraph string to a list of paragraph items with appropriate text format information /// </summary> /// <param name="paragraph">The text</param> /// <param name="italicStrings">A list of strings that should be written with italics</param> /// <returns></returns> private List <ParagraphItem> GetParagraphItems(String paragraph, List <String> italicStrings) { List <ParagraphItem> items = new List <ParagraphItem>(); if (paragraph == "") { return(items); } if (italicStrings.IsEmpty()) { ParagraphItem item = new ParagraphItem(paragraph, false); items.Add(item); return(items); } Int32 startPos = 0; while (startPos < paragraph.Length) { Int32 minPos = paragraph.Length; Int32 maxPos = -1; String italicItemText = ""; String normalItemText = ""; foreach (String italicString in italicStrings) { if (italicString.IsNotEmpty()) { Int32 pos = paragraph.IndexOf(italicString, startPos); if (pos > maxPos) { maxPos = pos; } if (pos < minPos && pos > -1) { minPos = pos; italicItemText = italicString; } } } normalItemText = paragraph.Substring(startPos, minPos - startPos); ParagraphItem normalItem = new ParagraphItem(normalItemText, false); items.Add(normalItem); if (italicItemText != "") { ParagraphItem italicItem = new ParagraphItem(italicItemText, true); items.Add(italicItem); } startPos = startPos + normalItemText.Length + italicItemText.Length; } return(items); }
public bool DeleteParagraph(ParagraphItem item) { ParagraphItem item1 = _context.ParagraphItems .Where(pi => pi.Id == item.Id) .FirstOrDefault(); _context.Remove(item1); _context.SaveChanges(); return(true); }
public bool AddParagraph(ParagraphItem content) { foreach (var thing in dummypages) { if (content.PageId == thing.Id) { thing.ParagraphItems.Add(content); } } return(true); }
/// <summary> /// Converts FB2 poem author element /// </summary> /// <param name="paragraphItem">item to convert</param> /// <param name="poemAuthorConverterParams"></param> /// <returns>XHTML representation</returns> public IHTMLItem Convert(ParagraphItem paragraphItem, PoemAuthorConverterParamsV2 poemAuthorConverterParams) { if (paragraphItem == null) { throw new ArgumentNullException("paragraphItem"); } var paragraphConverter = new ParagraphConverterV2(); var item = paragraphConverter.Convert(paragraphItem, new ParagraphConverterParamsV2 { ResultType = ParagraphConvTargetEnumV2.Paragraph, StartSection = false, Settings = poemAuthorConverterParams.Settings }); SetClassType(item, ElementStylesV2.PoemAuthor); return(item); }
/// <summary> /// Converts FB2 citation author element /// </summary> /// <param name="paragraphItem">item to convert</param> /// <param name="citationAuthorConverterParams"></param> /// <returns>XHTML representation</returns> public IHTMLItem Convert(ParagraphItem paragraphItem, CitationAuthorConverterParamsV2 citationAuthorConverterParams) { if (paragraphItem == null) { throw new ArgumentNullException("paragraphItem"); } var cite = new Div(HTMLElementType.XHTML11); var paragraphConverter = new ParagraphConverterV2(); cite.Add(paragraphConverter.Convert(paragraphItem, new ParagraphConverterParamsV2 { Settings = citationAuthorConverterParams.Settings, ResultType = ParagraphConvTargetEnumV2.Paragraph, StartSection = false })); SetClassType(cite, ElementStylesV2.CitationAuthor); return(cite); }
/// <summary> /// Removes empty paragraphs from the end of Word document. /// </summary> /// <param name="document">The Word document</param> private static void RemoveEmptyPage(WordDocument document) { WTextBody textBody = document.LastSection.Body; //A flag to determine any renderable item found in the Word document. bool IsRenderableItem = false; //Iterates text body items. for (int itemIndex = textBody.ChildEntities.Count - 1; itemIndex >= 0 && !IsRenderableItem; itemIndex--) { //Check item is empty paragraph and removes it. if (textBody.ChildEntities[itemIndex] is WParagraph) { WParagraph paragraph = textBody.ChildEntities[itemIndex] as WParagraph; //Iterates into paragraph for (int pIndex = paragraph.Items.Count - 1; pIndex >= 0; pIndex--) { ParagraphItem paragraphItem = paragraph.Items[pIndex]; //If page break found in end of document, then remove it to preserve contents in same page if ((paragraphItem is Break && (paragraphItem as Break).BreakType == BreakType.PageBreak)) { paragraph.Items.RemoveAt(pIndex); } //Check paragraph contains any renderable items. else if (!(paragraphItem is BookmarkStart || paragraphItem is BookmarkEnd)) { IsRenderableItem = true; //Found renderable item and break the iteration. break; } } //Remove empty paragraph and the paragraph with bookmarks only if (paragraph.Items.Count == 0 || !IsRenderableItem) { textBody.ChildEntities.RemoveAt(itemIndex); } } } }
public bool AddParagraph(ParagraphItem content) { _context.Add(content); _context.SaveChangesAsync(); return(true); }
public override object BuildDetail(EntityDTO dto) { BpmnDetailDTO detail = new BpmnDetailDTO(); EntityData data = new EntityData(); detail.Title = dto.Name; EntityDTO parent = data.GetActivityOverviewParent(dto.ID); //TODO: detail.RelatedSubprocess = parent.Name; detail.User = dto.RenderHTML(GlobalStringResource.User, RenderOption.Break); detail.ActivityNature = dto.RenderHTML(GlobalStringResource.ActivityNature, RenderOption.Break); detail.TriggerInput = dto.RenderHTML(GlobalStringResource.TriggerInput, RenderOption.Break); detail.Output = dto.RenderHTML(GlobalStringResource.Output, RenderOption.Break); detail.ActivityStepDescription = dto.RenderHTML(GlobalStringResource.ActivityStepDescription, RenderOption.Break); detail.ActivityNarrative = dto.RenderHTML(GlobalStringResource.ActivityNarrative, RenderOption.Break); List <EntityDTO> variations = data.GetActivityVariations(dto.ID); if (variations.Count > 0) { foreach (EntityDTO variation in variations) { ActivityVariationItem av = new ActivityVariationItem(); variation.ExtractProperties(); av.ActivityVariation = variation.Name; av.Description = variation.RenderHTML(GlobalStringResource.Description, RenderOption.Break); detail.ActivityVariations.Add(av); } } List <EntityDTO> mappings = data.GetSubProcessParagraphs(dto.ID); if (mappings.Count > 0) { foreach (EntityDTO map in mappings) { ParagraphItem p = new ParagraphItem(); map.ExtractProperties(); p.ParagraphName = MappingToolUrlHelper.GenerateValidParagraphLinkMarkup(map.Name); p.ParagraphRef = map.RenderHTMLAsAnchor(GlobalStringResource.ParagraphReference, RenderOption.Span, true); detail.Paragraphs.Add(p); } } List <EntityDTO> useCases = data.GetUseCases(dto.ID); if (useCases.Count > 0) { foreach (EntityDTO useCase in useCases) { UseCaseItem uc = new UseCaseItem(); useCase.ExtractProperties(); uc.UseCaseID = useCase.Name; uc.Description = useCase.RenderHTML(GlobalStringResource.Description, RenderOption.Break); detail.UseCases.Add(uc); } } List <EntityDTO> requiredData = data.GetRequiredData(dto.ID); if (requiredData.Count > 0) { requiredData.Sort((b1, b2) => string.Compare(b1.Name, b2.Name, true)); foreach (EntityDTO document in requiredData) { RequiredDataItem rq = new RequiredDataItem(); document.ExtractProperties(); rq.RequiredData = document.Name; rq.Description = document.RenderHTML(GlobalStringResource.Description, RenderOption.Break); detail.RequiredData.Add(rq); } } List <EntityDTO> sampleReferences = data.GetSampleReference(dto.ID); if (sampleReferences.Count > 0) { foreach (EntityDTO reference in sampleReferences) { SampleReferenceItem sr = new SampleReferenceItem(); reference.ExtractProperties(); sr.SampleReference = reference.Name; sr.Description = reference.RenderHTML(GlobalStringResource.Description, RenderOption.Break); sr.ReferenceLink = reference.RenderHTMLAsAnchor(GlobalStringResource.ReferenceLink, RenderOption.Span, true); detail.SampleReferences.Add(sr); } } return(detail); }
/// <summary> /// Converts FB2 Paragraph to EPUB paragraph /// </summary> /// <param name="paragraphItem">item to convert</param> /// <param name="paragraphConverterParams"></param> /// <returns></returns> public HTMLItem Convert(ParagraphItem paragraphItem, ParagraphConverterParamsV2 paragraphConverterParams) { if (paragraphItem == null) { throw new ArgumentNullException("paragraphItem"); } var paragraph = CreateBlock(paragraphConverterParams.ResultType); bool needToInsertDrop = paragraphConverterParams.Settings.CapitalDrop && paragraphConverterParams.StartSection; foreach (var item in paragraphItem.ParagraphData) { if (item is SimpleText) { var textConverter = new SimpleTextElementConverterV2(); foreach (var s in textConverter.Convert(item, new SimpleTextElementConverterParamsV2 { Settings = paragraphConverterParams.Settings, NeedToInsertDrop = needToInsertDrop })) { if (needToInsertDrop) { needToInsertDrop = false; SetClassType(paragraph, ElementStylesV2.CapitalDrop); } paragraph.Add(s); } } else if (item is InlineImageItem) { // if no image data - do not insert link if (paragraphConverterParams.Settings.Images.HasRealImages()) { var inlineItem = item as InlineImageItem; if (paragraphConverterParams.Settings.Images.IsImageIdReal(inlineItem.HRef)) { var inlineImageConverter = new InlineImageConverterV2(); paragraph.Add(inlineImageConverter.Convert(inlineItem, new InlineImageConverterParamsV2 { Settings = paragraphConverterParams.Settings })); paragraphConverterParams.Settings.Images.ImageIdUsed(inlineItem.HRef); } if (needToInsertDrop) // in case this is "drop" image - no need to create a drop { needToInsertDrop = false; } } } else if (item is InternalLinkItem) { var internalLinkConverter = new InternalLinkConverterV2(); foreach (var s in internalLinkConverter.Convert(item as InternalLinkItem, new InternalLinkConverterParamsV2 { Settings = paragraphConverterParams.Settings, NeedToInsertDrop = needToInsertDrop })) { if (needToInsertDrop) { needToInsertDrop = false; SetClassType(paragraph, ElementStylesV2.CapitalDrop); } paragraph.Add(s); } } } //SetClassType(paragraph); paragraph.GlobalAttributes.ID.Value = paragraphConverterParams.Settings.ReferencesManager.AddIdUsed(paragraphItem.ID, paragraph); return(paragraph); }
public bool DeleteParagraph(ParagraphItem item) { throw new NotImplementedException(); }