Пример #1
0
        private LinkEventArgs CreateLinkArgs(HtmlNode node)
        {
            string link = node.GetAttributeValue("href", "none");
            var    args = new LinkEventArgs();

            if (link.Contains('#'))
            {
                var sp = link.Split('#', StringSplitOptions.RemoveEmptyEntries);
                if (sp.Length > 1)
                {
                    args.FileName = sp[0];
                }
                args.Id = sp.Last();
            }
            else if (!link.Contains("://"))
            {
                string name = link.Split('/').Last();
                args.FileName = name;
            }
            else
            {
                args.Link = link;
            }
            return(args);
        }
Пример #2
0
        private Inline CreateHyperLink(HtmlNode node, bool isSup = false)
        {
            if (string.IsNullOrEmpty(node.InnerText))
            {
                return(null);
            }
            string link = node.GetAttributeValue("href", "none");
            var    args = new LinkEventArgs();

            if (link.Contains('#'))
            {
                var sp = link.Split('#', StringSplitOptions.RemoveEmptyEntries);
                if (sp.Length > 1)
                {
                    args.FileName = sp[0];
                }
                args.Id = sp.Last();
            }
            else if (link.Contains(".html") && !link.Contains("://"))
            {
                string name = link.Split('/').Last();
                args.FileName = name;
            }
            else
            {
                args.Link = link;
            }
            var hyp = new Hyperlink();
            var run = new Run()
            {
                Text = node.InnerText
            };

            if (isSup)
            {
                run.FontSize = Style.FontSize / 1.5;
            }
            hyp.Inlines.Add(run);
            hyp.Click += (_s, _e) =>
            {
                LinkTapped?.Invoke(_s, args);
            };
            return(hyp);
        }
Пример #3
0
        private Inline CreateHyperLink(HtmlNode node, bool isSup = false)
        {
            if (string.IsNullOrEmpty(node.InnerText))
            {
                return(null);
            }
            string link = node.GetAttributeValue("href", "none");
            var    sp   = link.Split('#', StringSplitOptions.RemoveEmptyEntries);
            var    args = new LinkEventArgs();

            if (sp.Length > 1)
            {
                args.FileName = sp[0];
            }
            args.Id = sp.Last();
            if (link.IndexOf("://") == -1)
            {
                link = "jump://" + link;
            }
            var hyp = new Hyperlink();
            var run = new Run()
            {
                Text = node.InnerText
            };

            if (isSup)
            {
                run.FontSize = Style.FontSize / 1.5;
            }
            hyp.Inlines.Add(run);
            hyp.Click += async(_s, _e) =>
            {
                if (link.StartsWith("jump://") && !args.Id.Contains("html"))
                {
                    LinkTapped?.Invoke(_s, args);
                }
                else
                {
                    await Launcher.LaunchUriAsync(new Uri(link));
                }
            };
            return(hyp);
        }