Exemplo n.º 1
1
        private void CreateDescription(IGlymaNode node, ref Paragraph paragraph)
        {
            //paragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));

            if (node.NodeDescription.Type == "Iframe")
            {
                if (ShowDescriptionIcon)
                {
                    var descriptionIcon = new ImageInline(DescriptionIconStream, new Size(20, 15), "png");
                    paragraph.Inlines.Add(descriptionIcon);
                    paragraph.Inlines.Add(new Span("  "));
                }
                else
                {
                    paragraph.Inlines.Add(new Span("Link: ") { FontSize = 12 });
                }

                CreateLink(node.NodeDescription.Link, ref paragraph);
            }
            else
            {
                if (ShowDescriptionIcon)
                {
                    var descriptionIcon = new ImageInline(DescriptionIconStream, new Size(20, 15), "png");
                    paragraph.Inlines.Add(descriptionIcon);
                    paragraph.Inlines.Add(new Span("  "));
                }
                else
                {
                    paragraph.Inlines.Add(new Span("Description: ") { FontSize = 12 });
                }

                var htmlFormatProvider = new HtmlFormatProvider();
                var description = htmlFormatProvider.Import(node.NodeDescription.Description);
                foreach (var item in description.Sections)
                {
                    var section = item.CreateDeepCopy() as Section;
                    if (section != null)
                    {
                        foreach (var block in section.Blocks)
                        {
                            var para = block as Paragraph;
                            if (para != null)
                            {
                                foreach (Span span in para.EnumerateChildrenOfType<Span>())
                                {
                                    span.FontSize = 12;
                                }

                                foreach (var inline in para.Inlines)
                                {
                                    var theNewInLineItem = inline.CreateDeepCopy() as Inline;
                                    paragraph.Inlines.Add(theNewInLineItem);
                                }
                            }
                            else
                            {
                                CurrentBlockCollection.Add(block.CreateDeepCopy() as Block);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void AddNode(IGlymaNode node)
 {
     if (!Nodes.Contains(node))
     {
         Nodes.Add(node);
     }
 }
Exemplo n.º 3
0
 private bool IsNodeExist(IGlymaNode node)
 {
     var foundNode = Nodes.FirstOrDefault(q => q.Id == node.Id);
     if (foundNode == null)
     {
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
        private void AddSubTitle(IGlymaNode map, string bookMarkId)
        {
            var paragraph = new Paragraph();
            paragraph.StyleName = string.Format("Heading{0}", 1);
            if (ShowImage)
            {
                CreateNodeIcon(map, ref paragraph);
            }
            var text = new Span(string.IsNullOrEmpty(map.Name) ? "(No Name)" : map.Name);
            //{
            //    FontSize = 18,
            //    ForeColor = Colors.DarkSlateBlue
            //};

            var bookMarkStart = new BookmarkRangeStart(bookMarkId);
            var bookMarkEnd = new BookmarkRangeEnd();
            bookMarkEnd.PairWithStart(bookMarkStart);
            paragraph.Inlines.Add(bookMarkStart);
            paragraph.Inlines.Add(text);
            paragraph.Inlines.Add(bookMarkEnd);
            Section.Blocks.Add(paragraph);          
        }
Exemplo n.º 5
0
        private void AddNodeToDocument(IGlymaNode node, int documentListId)
        {
            var depth = node.Depth > 8 ? 8 : node.Depth;

            var paragraph = new Paragraph {ListId = documentListId, ListLevel = depth};

            int headingLevel = ((depth + 2) > 8) ? 9 : (depth + 2); //maximum of Heading level of 9
            paragraph.StyleName = string.Format("Heading{0}", headingLevel);

            if (node.Depth == 8)
            {
                paragraph.Inlines.Add(GetBulletForDepth(8));
            }

            //check if list level is more than 8, it needs to set to 8 because telerik only support maximum of 9 levels.
            if (node.Depth > 8)
            {
                var prefix = string.Empty;
                for (int i = 8; i < node.Depth; i++)
                {
                    prefix = "    " + prefix;
                }
                Span bulletSpan = GetBulletForDepth(node.Depth);
                paragraph.Inlines.Add(new Span(prefix));
                paragraph.Inlines.Add(bulletSpan);
            }

            if (ShowImage)
            {
                CreateNodeIcon(node, ref paragraph);
            }
            CreateNodeTitle(node, ref paragraph);

            Section.Blocks.Add(paragraph);

            if (ShowDescription || ShowVideo)
            {
                if (node.NodeVideo.HasVideo && ShowVideo)
                {
                    var videoParagraph = new Paragraph() { ListId = documentListId, ListLevel = depth  };
                    CreateVideo(node, ref videoParagraph);
                    Section.Blocks.Add(videoParagraph);
                }

                if (node.NodeDescription.HasDescription && ShowDescription)
                {
                    var descriptionParagraph = new Paragraph() { ListId = documentListId, ListLevel = depth };
                    CreateDescription(node, ref descriptionParagraph);
                    Section.Blocks.Add(descriptionParagraph);
                }
            }
            
            if (CurrentBlockCollection.Count > 0)
            {
                foreach (var block in CurrentBlockCollection)
                {
                    foreach (Span span in block.EnumerateChildrenOfType<Span>())
                    {
                        span.FontSize = 12;
                    }
                    Section.Blocks.Add(block);
                }
                _currentBlockCollection = null;
                Section.Blocks.Add(new Paragraph());
            }

            foreach (var child in node.ChildNodes.OrderBy(q => q.YPosition).ThenBy(q => q.XPosition))
            {
                AddNodeToDocument(child, documentListId);
            }
        }
Exemplo n.º 6
0
        private void CreateVideo(IGlymaNode node, ref Paragraph paragraph)
        {
            //paragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));

            if (ShowDescriptionIcon)
            {
                var videoIcon = new ImageInline(VideoIconStream, new Size(20, 15), "png");

                paragraph.Inlines.Add(videoIcon);
                paragraph.Inlines.Add(new Span("  "));
            }
            else
            {
                paragraph.Inlines.Add(new Span("Video:") { FontSize = 12 });
            }

            CreateLink(node.NodeVideo.Link, ref paragraph);

            if (node.NodeVideo.StartPosition.HasValue || node.NodeVideo.EndPosition.HasValue)
            {
                paragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));
                paragraph.Inlines.Add(new Span("Start Time:") { FontSize = 12 });
                if (node.NodeVideo.StartPosition.HasValue)
                {
                    paragraph.Inlines.Add(new Span(string.Format("{0:00}:{1:00}:{2:00}", node.NodeVideo.StartPosition.Value.TotalHours, node.NodeVideo.StartPosition.Value.Minutes, node.NodeVideo.StartPosition.Value.Seconds)) { FontSize = 12 });
                    paragraph.Inlines.Add(new Span("  ") { FontSize = 12 });
                }
                else
                {
                    paragraph.Inlines.Add(new Span("00:00:00") { FontSize = 12 });
                    paragraph.Inlines.Add(new Span("  ") { FontSize = 12 });
                }

                if (node.NodeVideo.EndPosition.HasValue)
                {
                    paragraph.Inlines.Add(new Span("End Time:") { FontSize = 12 });
                    paragraph.Inlines.Add(new Span(string.Format("{0:00}:{1:00}:{2:00}", node.NodeVideo.EndPosition.Value.TotalHours, node.NodeVideo.EndPosition.Value.Minutes, node.NodeVideo.EndPosition.Value.Seconds)) { FontSize = 12 });
                }
            }
        }
Exemplo n.º 7
0
        private void CreateNodeTitle(IGlymaNode node, ref Paragraph paragraph)
        {
            if (node.NodeType.Equals(MapManager.NodeTypes["CompendiumMapNode"]))
            {
                var text = new Span(string.IsNullOrEmpty(node.Name) ? "(No Name)" : node.Name)
                {
                    //ForeColor = Colors.DodgerBlue,
                    UnderlineDecoration = UnderlineTypes.Line
                };

                var hyperlinkStart = new HyperlinkRangeStart();
                var hyperlinkEnd = new HyperlinkRangeEnd();
                hyperlinkEnd.PairWithStart(hyperlinkStart);
                var hyperlinkInfo = new HyperlinkInfo
                {
                    NavigateUri = node.Id.ToLongString(),
                    Target = HyperlinkTargets.Self,
                    IsAnchor = true
                };
                hyperlinkStart.HyperlinkInfo = hyperlinkInfo;

                paragraph.Inlines.Add(hyperlinkStart);
                paragraph.Inlines.Add(text);
                paragraph.Inlines.Add(hyperlinkEnd);
            }
            else
            {
                var text = new Span(node.Name);
                paragraph.Inlines.Add(text);
            }
        }
Exemplo n.º 8
0
        private void CreateNodeIcon(IGlymaNode node, ref Paragraph paragraph)
        {
            var image = NodeIconManager.GetImage(node.NodeType.GetImageName());

            if (image != null)
            {
                paragraph.Inlines.Add(image);
                paragraph.Inlines.Add(new Span("  "));
            }
        }