Exemple #1
0
 public Paragraph parse(string message)
 {
     Paragraph p = new Paragraph();
     p.LineHeight = 1;
     DateTime today = DateTime.Now;
     p.Inlines.Add("(" + today.ToString("HH:mm:ss") + ") ");
     int lastPos = 0;
     foreach (Match match in _regexUrl.Matches(message.Replace(Environment.NewLine,"")))
     {
         if (match.Index != lastPos) {
             // parse smileys before hyperlink
             p = _smiley.insertSmileys(p, message.Substring(lastPos, match.Index - lastPos));
             lastPos = match.Index + match.Length;
             // parse hyperlink
             Hyperlink textLink = new Hyperlink(new Run(match.Value));
             textLink.NavigateUri = new Uri(match.Value);
             textLink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(_openHyperlink);
             p.Inlines.Add(textLink);
             lastPos = match.Index + match.Length;
         }
     }
     // wenn text noch nicht zu ende, noch mal nach smileys schauen
     p = _smiley.insertSmileys(p, message.Substring(lastPos));
     return p;
 }
        public void Populate(IEnumerable<ILayer> layers)
        {
            Children.Clear();
            foreach (var layer in layers)
            {
                if (string.IsNullOrEmpty(layer.Attribution.Text)) continue;
                var attribution = new StackPanel { Orientation = Orientation.Horizontal };
                var textBlock = new TextBlock();
                if (string.IsNullOrEmpty(layer.Attribution.Url))
                {
                    textBlock.Text = layer.Attribution.Text;
                }
                else
                {
                    var hyperlink = new Hyperlink();
                    hyperlink.Inlines.Add(new Run{ Text = layer.Attribution.Text});
                    hyperlink.NavigateUri = new Uri(layer.Attribution.Url);
                    textBlock.Inlines.Add(hyperlink);
                    textBlock.Padding = new Thickness(6, 2, 6, 2);
                    attribution.Children.Add(textBlock);
                }

                Children.Add(attribution);
            }
        }
 private static void OnChanged(DependencyObject o, DependencyPropertyChangedEventArgs args)
 {
     TextBlock textBl = o as TextBlock;
     var text = args.NewValue as string;
     if (textBl != null)
     {
         textBl.Inlines.Clear();
         var splits = regex.Split(text).Where(s => !s.StartsWith("/")).ToList();
         var matches = regex.Matches(text);
         for (int i = 0; i < splits.Count; i++)
         {
             var split = splits[i];
             if (i % 2 == 0)
                 textBl.Inlines.Add(new Run { Text = split });
             else
             {
                 Uri uri;
                 if (Uri.TryCreate(split, UriKind.Absolute, out uri))
                 {
                     Hyperlink link = new Hyperlink();
                     link.Click += Link_Click;
                     link.Inlines.Add(new Run { Text = split });
                     textBl.Inlines.Add(link);
                 }
             }
         }
     }
 }
        public static void Run() 
        {
            // ExStart:AddHyperlinkToShape
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Hyperlinks();

            // Load source Visio diagram
            Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
            // Get page by name
            Page page = diagram.Pages.GetPage("Page-1");
            // Get shape by ID
            Shape shape = page.Shapes.GetShape(2);

            // Initialize Hyperlink object
            Hyperlink hyperlink = new Hyperlink();
            // Set address value
            hyperlink.Address.Value = "http:// Www.google.com/";
            // Set sub address value
            hyperlink.SubAddress.Value = "Sub address here";
            // Set description value
            hyperlink.Description.Value = "Description here";
            // Set name
            hyperlink.Name = "MyHyperLink";

            // Add hyperlink to the shape
            shape.Hyperlinks.Add(hyperlink);            
            // Save diagram to local space
            diagram.Save(dataDir + "AddHyperlinkToShape_out.vsdx", SaveFileFormat.VSDX);
            // ExEnd:AddHyperlinkToShape
        }
        /// <summary>
        /// ツイート本文をパートごとに分割して加工を施します
        /// </summary>
        private void ParseText()
        {
            if (this.TwitterResponse == null || this.TextBlock == null) return;

            var tweetStatus   = this.TwitterResponse.TweetStatus.RetweetedStatus ?? this.TwitterResponse.TweetStatus;
            this.TextBlock.Inlines.Clear();
            foreach (var textPart in tweetStatus.EnumerateTextParts())
            {
                switch (textPart.Type)
                {
                    case TextPartType.Hashtag:
                        var hashtag = new Hyperlink();
                        hashtag.Inlines.Add(new Run { Text = textPart.Text });
                        this.TextBlock.Inlines.Add(hashtag);
                        break;
                    case TextPartType.Plain:
                        this.TextBlock.Inlines.Add(new Run { Text = textPart.Text });
                        break;
                    case TextPartType.Url:
                        var url = new Hyperlink { NavigateUri = new Uri(textPart.RawText) };
                        url.Inlines.Add(new Run { Text =  textPart.Text });
                        this.TextBlock.Inlines.Add(url);
                        break;
                }
            }

        }
        public virtual void RenderElement(IElement element, ITextContainer parent, RenderContextBase context)
        {
            var a = (IHtmlAnchorElement)element;

            if (a.ChildElementCount == 0)
            {
                var anchor = new Hyperlink
                {
                    Foreground = new SolidColorBrush(Colors.LightBlue)
                };
                anchor.Click += async (sender, args) =>
                {
                    var dialog = new MessageDialog(a.Href, "使用浏览器打开");
                    dialog.Commands.Add(new UICommand("确定", async cmd =>
                    {
                        var success = await Launcher.LaunchUriAsync(new Uri(a.Href, UriKind.Absolute));
                        if (success)
                        {
                            anchor.Foreground = new SolidColorBrush(Colors.Purple);
                        }
                    }));
                    dialog.Commands.Add(new UICommand("取消"));
                    await dialog.ShowAsync();
                };

                parent.Add(anchor);

                context.RenderNode(element, new SpanContainer(anchor));
            }
            else
            {
                context.RenderNode(element,parent);
            }
        }
Exemple #7
0
 internal override void VisitHyperlink(Hyperlink hyperlink)
 {
     Font styleFont = hyperlink.Document.Styles[StyleNames.Hyperlink].Font;
     if (hyperlink._font == null)
         hyperlink.Font = styleFont.Clone();
     else
         FlattenFont(hyperlink._font, styleFont);
 }
Exemple #8
0
 private void SettingHyperLink_Click(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     var vm = GotoSettings.DataContext as SettingsViewModel;
     if (vm != null)
     {
         vm.GoToSettingsCommand.Execute(null);
     }
 }
Exemple #9
0
 internal static void Analyse(HtmlNode node, InlineCollection container, ParsingStyle style)
 {
     if (node == null)
         return;
     foreach (var item in node.ChildNodes)
     {
         switch (item.Name)
         {
             //文本
             case "#text":
                 container.Add(new Run() { Text = item.InnerText });
                 continue;
             case "strong":
                 style = style | ParsingStyle.Bold;
                 break;
             //链接
             case "a":
                 var link = new Hyperlink();
                 ParseRelativeUrl(item.GetAttributeValue("href", ""), link, App.Current.NavigationService);
                 Analyse(item, link.Inlines, style);
                 container.Add(link);
                 continue;
             //图片
             case "img":
                 var image = new Image() { Source = new BitmapImage(new Uri(item.GetAttributeValue("src", ""))) };
                 var cont = new InlineUIContainer();
                 cont.Child = image;
                 container.Add(cont);
                 continue;
             //换行
             case "br":
                 container.Add(new LineBreak());
                 continue;
             //容器
             case "span":
             case "div":
             case "p":
                 break;
             case "b":
                 //TODO: 设置属性,是否要加红搜索显示结果
                 if(node.GetAttributeValue("class","") == "key_red")
                 {
                     Span p = new Span();
                     p.Foreground = new SolidColorBrush(Colors.Red);
                     Analyse(item, container, style);
                     continue;
                 }
                 else break;
             //非文本
             case "button":
                 continue;
             default:
                 continue;
         }
         Analyse(item, container, style);
     }
 }
Exemple #10
0
 /// <summary>
 /// Creates a html anchor tag for the Hyperlink object
 /// </summary>
 /// <param name="html">Extension method on HtmlHelper</param>
 /// <param name="link">The Hyperlink</param>
 /// <param name="cssSelectedClass">The CSS class name to apply if the link is selected</param>
 /// <returns>An html string</returns>
 public static string RouteLink(this HtmlHelper html, Hyperlink link, string cssSelectedClass)
 {
     Dictionary<string, object> attrs = new Dictionary<string, object>();
     if (link.IsSelected && !String.IsNullOrEmpty(cssSelectedClass))
     {
         attrs.Add("class", cssSelectedClass);
     }
     return html.RouteLink(link.Text, link.Route, attrs);
 }
Exemple #11
0
 private void ForkedFromLink_OnClick(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     var parent = (this.DataContext as RepositoryViewModel).Repository.Parent;
     App.Frame.Navigate(typeof (RepositoryPage), new RepositoryPageParameters
     {
         Name = parent.Name,
         Owner = parent.Owner.Login
     });
 }
 private void BaseRepoLink_OnClick(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     var repo = (this.DataContext as PullRequestViewModel).PR.Base.Repository;
     var repoParams = new RepositoryPage.RepositoryPageParameters
     {
         Name = repo.Name,
         Owner = repo.Owner.Login
     };
     App.Frame.Navigate(typeof(RepositoryPage), repoParams);
 }
Exemple #13
0
		private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var textBlock = d as TextBlock;
			if (textBlock == null)
				return;

			textBlock.Inlines.Clear();

			var newText = (string)e.NewValue;
			if (string.IsNullOrEmpty(newText))
				return;

			// Find all URLs using a regular expression
			int lastPos = 0;
			foreach (Match match in ReUrl.Matches(newText))
			{
				// Copy raw string from the last position up to the match
				if (match.Index != lastPos)
				{
					var rawText = newText.Substring(lastPos, match.Index - lastPos);
					textBlock.Inlines.Add(new Run(rawText));
				}

				// Create a hyperlink for the match
                var uri = match.Value.StartsWith("www.") ? string.Format("http://{0}", match.Value) : match.Value;

                // in case the regex fails
			    if (!Uri.IsWellFormedUriString(uri, UriKind.Absolute)) 
                    continue;

				var link = new Hyperlink(new Run(match.Value))
				{
					// If it starts with "www." add "http://" to make it a valid Uri
					NavigateUri = new Uri(uri),
					ToolTip = uri
				};

				link.Click += OnUrlClick;

				textBlock.Inlines.Add(link);

				// Update the last matched position
				lastPos = match.Index + match.Length;
			}

			// Finally, copy the remainder of the string
			if (lastPos < newText.Length)
				textBlock.Inlines.Add(new Run(newText.Substring(lastPos)));
		}
 private void MoreLess_Click(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     var hyperlink = (Hyperlink)sender;
     if (MoreInformationText.Visibility == Visibility.Visible)
     {
         MoreInformationText.Visibility = Visibility.Collapsed;
         MoreLessText.Text = "Show more information";
     }
     else
     {
         MoreInformationText.Visibility = Visibility.Visible;
         MoreLessText.Text = "Show less information";
     }
     rootPage.NotifyUser("", NotifyType.StatusMessage);
 }
    public static void AppendLink(this BetterRichTextbox richTextBox, string text, Uri uri)
    {
        Paragraph paragraph;

        if (richTextBox.Blocks.Count == 0 ||
            (paragraph = richTextBox.Blocks[richTextBox.Blocks.Count - 1] as Paragraph) == null)
        {
            paragraph = new Paragraph();
            richTextBox.Blocks.Add(paragraph);
        }

        var run = new Run { Text = text };
        var link = new Hyperlink { NavigateUri = uri, TargetName="_blank", Foreground = Application.Current.Resources["OrangeBrush"] as Brush };

        link.Inlines.Add(run);
        paragraph.Inlines.Add(link);
    }
        internal void FromHyperlink(Hyperlink hl)
        {
            this.SetAllNull();

            this.IsNew = false;

            if (hl.Reference != null) this.Reference = SLTool.TranslateReferenceToCellPointRange(hl.Reference.Value);

            if (hl.Id != null)
            {
                // At least I think if there's a relationship ID, it's an external link.
                this.IsExternal = true;
                this.Id = hl.Id.Value;
            }

            if (hl.Location != null) this.Location = hl.Location.Value;
            if (hl.Tooltip != null) this.ToolTip = hl.Tooltip.Value;
            if (hl.Display != null) this.Display = hl.Display.Value;
        }
        internal static void ConvertTextWithPlaceholders(TextBlock textBlock, string fullText)
        {
            textBlock.Inlines.Clear();

            if (String.IsNullOrWhiteSpace(fullText))
                return;

            string nameRegexString = @"(?<text>\[[\w\s]*\])(?<identifier>{\w*:\w*-*\w*})";
            var regex = new Regex(nameRegexString);
            int textIndex = 0;

            foreach (Match match in regex.Matches(fullText))
            {
                string identifier = match.Groups["identifier"].Value;
                int identifierStart = match.Groups["identifier"].Index;
                int identifierEnd = match.Groups["identifier"].Index + identifier.Length;

                string text = match.Groups["text"].Value;
                int text_start = match.Groups["text"].Index;
                int text_end = match.Groups["text"].Index + text.Length;

                string trimmedText = text.Trim(new char[] { '[', ']' });
                string trimmedIdentifier = identifier.Trim(new char[] { '{', '}' });

                string content = fullText.Substring(textIndex, text_start - textIndex);
                textBlock.Inlines.Add(new Run { Text = content });

                var hyperLink = new Hyperlink()
                {
                    NavigateUri = new Uri(trimmedIdentifier)
                };
                hyperLink.Inlines.Add(new Run { Text = trimmedText });
                textBlock.Inlines.Add(hyperLink);
                textIndex = identifierEnd;
            }

            string lastContent = fullText.Substring(textIndex, fullText.Length - textIndex);
            textBlock.Inlines.Add(new Run { Text = lastContent });
        }
        private void OnItemChanged(ActivityItem item)
        {
            if(item == null)
            {
                return;
            }
            MainTextBlock.Inlines.Clear();

            Hyperlink userHyperlink = new Hyperlink();
            userHyperlink.Inlines.Add(new Run { Text = item.NickName });
            userHyperlink.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x66, 0xB3, 0xFF));
            userHyperlink.UnderlineStyle = UnderlineStyle.None;
            userHyperlink.Click += HyperlinkClick;
            userHyperlink.SetValue(NameProperty, "user");
            MainTextBlock.Inlines.Add(userHyperlink);

            MainTextBlock.Inlines.Add(new Run() { Text = ConverterType(item.Type) });

            if (item.TargetLink != null)
            {
                if (item.TargetLink.Item1 == "notebook" || item.TargetLink.Item1 == "collection")
                {
                    MainTextBlock.Inlines.Add(new Run() { Text = item.Target, FontWeight = new FontWeight() { Weight = 700 } });
                }
                else
                {
                    Hyperlink targetHyperlink = new Hyperlink();
                    targetHyperlink.Inlines.Add(new Run { Text = item.Target });
                    targetHyperlink.UnderlineStyle = UnderlineStyle.None;
                    targetHyperlink.Click += HyperlinkClick;
                    targetHyperlink.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x66, 0xB3, 0xFF));
                    targetHyperlink.SetValue(NameProperty, "target");
                    MainTextBlock.Inlines.Add(targetHyperlink);
                }
            }
        }
 /// <summary>
 /// Open the Speech, Inking and Typing page under Settings -> Privacy, enabling a user to accept the 
 /// Microsoft Privacy Policy, and enable personalization.
 /// </summary>
 /// <param name="sender">Ignored</param>
 /// <param name="args">Ignored</param>
 private async void openPrivacySettings_Click(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-speechtyping"));
 }
Exemple #20
0
        /// <summary>
        /// Renders a link element
        /// </summary>
        /// <param name="element"> The parsed inline element to render. </param>
        /// <param name="context"> Persistent state. </param>
        protected override void RenderMarkdownLink(MarkdownLinkInline element, IRenderContext context)
        {
            var localContext = context as InlineRenderContext;

            if (localContext == null)
            {
                throw new RenderContextIncorrectException();
            }

            // HACK: Superscript is not allowed within a hyperlink.  But if we switch it around, so
            // that the superscript is outside the hyperlink, then it will render correctly.
            // This assumes that the entire hyperlink is to be rendered as superscript.
            if (AllTextIsSuperscript(element) == false)
            {
                // Regular ol' hyperlink.
                var link = new Hyperlink();

                // Register the link
                LinkRegister.RegisterNewHyperLink(link, element.Url);

                // Remove superscripts.
                RemoveSuperscriptRuns(element, insertCaret: true);

                // Render the children into the link inline.
                var childContext = new InlineRenderContext(link.Inlines, context)
                {
                    Parent          = link,
                    WithinHyperlink = true
                };

                if (localContext.OverrideForeground)
                {
                    link.Foreground = localContext.Foreground;
                }
                else if (LinkForeground != null)
                {
                    link.Foreground = LinkForeground;
                }

                RenderInlineChildren(element.Inlines, childContext);
                context.TrimLeadingWhitespace = childContext.TrimLeadingWhitespace;

                ToolTipService.SetToolTip(link, element.Tooltip ?? element.Url);

                // Add it to the current inlines
                localContext.InlineCollection.Add(link);
            }
            else
            {
                // THE HACK IS ON!

                // Create a fake superscript element.
                var fakeSuperscript = new SuperscriptTextInline
                {
                    Inlines = new List <MarkdownInline>
                    {
                        element
                    }
                };

                // Remove superscripts.
                RemoveSuperscriptRuns(element, insertCaret: false);

                // Now render it.
                RenderSuperscriptRun(fakeSuperscript, context);
            }
        }
Exemple #21
0
        private void FillInfoPanel()
        {
            var types = new[]
            {
                new { Category = "Characters", Type = typeof(Mob) },
                new { Category = "Characters", Type = typeof(Npc) },
                new { Category = "Characters", Type = typeof(Pet) },
                new { Category = "Characters", Type = typeof(Player) },
                new { Category = "On ground", Type = typeof(Loot) },
                new { Category = "On ground", Type = typeof(Mine) },
                new { Category = "Other", Type = typeof(HostPlayer) },
                new { Category = "Other", Type = typeof(InventoryItem) },
                new { Category = "Other", Type = typeof(Skill) },
            };

            types = types.Concat(
                typeof(PwObject).Assembly.GetTypes()
                .Where(t => t.Namespace != null && t.Namespace.EndsWith("Objects") && t.IsEnum)
                .Select(t => new { Category = "Enums", Type = t }))
                    .ToArray();

            foreach (var category in types.GroupBy(t => t.Category))
            {
                var catItem = CreateTreeViewItem(category.Key, "folder.png");
                classesTree.Items.Add(catItem);

                foreach (var type in category.Select(t => t.Type).OrderBy(t => t.Name))
                {
                    var typeItem = CreateTreeViewItem(type.Name, "class.png");
                    catItem.Items.Add(typeItem);
                    var items = new List <TreeViewItem>();
                    typeItem.Tag = items;

                    var type1 = type;
                    typeItem.MouseDoubleClick += (s, e) => InsertText(type1.Name);

                    if (type.IsEnum)
                    {
                        foreach (string enumValue in type.GetEnumNames())
                        {
                            string fullVal = string.Format("{0}.{1}", type.Name, enumValue);

                            var item = CreateTreeViewItem(enumValue, "property.png");
                            item.MouseDoubleClick += (s, e) => InsertText(fullVal);

                            items.Add(item);
                        }
                    }
                    else
                    {
                        foreach (var property in type.GetProperties().OrderBy(p => p.Name))
                        {
                            var prop = property;

                            var item = CreateTreeViewItem(string.Format("{0}  ({1})", property.Name, property.PropertyType.Name), "property.png");
                            item.ToolTip = CommonUtils.Safe(() => DocsByReflection.XMLFromMember(prop)["summary"].InnerText.Trim());

                            item.MouseDoubleClick += (s, e) => InsertText(prop.Name);

                            items.Add(item);
                        }
                    }
                }
            }

            foreach (var property in typeof(PwInterface).GetProperties().OrderBy(p => p.Name))
            {
                string insertStr = property.Name + "()";
                var    propItem  = CreateTreeViewItem(property.Name, "property.png");
                propItem.MouseDoubleClick += (s, e) => InsertText(insertStr);

                var panel = new StackPanel();
                propItem.Tag = panel;

                var linkTb = new TextBlock();
                linkTb.Inlines.Add("[");
                var link = new Hyperlink(new Run("Insert"));
                link.Click += (s, e) => InsertText(insertStr);
                linkTb.Inlines.Add(link);
                linkTb.Inlines.Add("]");
                linkTb.Inlines.Add(new LineBreak());

                panel.Children.Add(linkTb);

                try
                {
                    var    xmlDoc      = DocsByReflection.XMLFromMember(property);
                    string summaryInfo = xmlDoc["summary"].InnerText.Trim();
                    string returnInfo  = CommonUtils.Safe(() => xmlDoc["returns"].InnerText.Trim());

                    var tb = new TextBlock {
                        TextWrapping = TextWrapping.Wrap
                    };

                    tb.Inlines.Add(new Bold(new Run("Summary")));
                    tb.Inlines.Add(new LineBreak());
                    tb.Inlines.Add(summaryInfo);
                    tb.Inlines.Add(new LineBreak());

                    panel.Children.Add(tb);
                }
                catch
                {
                    panel.Children.Add(new TextBlock(new Bold(new Italic(new Run("Sorry, no info")))));
                }

                methodsTree.Items.Add(propItem);
            }

            Func <ParameterInfo, string> parameterToString = p =>
            {
                if (Attribute.IsDefined(p, typeof(ParamArrayAttribute)))
                {
                    return(string.Format("[*{0}]", p.Name));
                }

                if (p.IsOptional)
                {
                    if (p.RawDefaultValue is string)
                    {
                        return(string.Format("[{0} = \"{1}\"]", p.Name, p.RawDefaultValue));
                    }

                    return(string.Format("[{0} = {1}]", p.Name, p.RawDefaultValue ?? "None"));
                }

                return(p.Name);
            };

            foreach (var method in typeof(PwInterface).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(m => !m.IsSpecialName).OrderBy(m => m.Name))
            {
                string infoStr   = string.Format("{0}({1})", method.Name, method.GetParameters().Aggregate(parameterToString, ", "));
                string insertStr = string.Format("{0}()", method.Name);

                var methodItem = CreateTreeViewItem(infoStr, "method.png");
                methodItem.MouseDoubleClick += (s, e) => InsertText(insertStr);

                var panel = new StackPanel();
                methodItem.Tag = panel;

                var linkTb = new TextBlock();
                linkTb.Inlines.Add("[");
                var link = new Hyperlink(new Run("Insert"));
                link.Click += (s, e) => InsertText(insertStr);
                linkTb.Inlines.Add(link);
                linkTb.Inlines.Add("]");
                linkTb.Inlines.Add(new LineBreak());

                panel.Children.Add(linkTb);

                try
                {
                    var    xmlDoc      = DocsByReflection.XMLFromMember(method);
                    string summaryInfo = xmlDoc["summary"].InnerText.Trim();
                    string returnInfo  = CommonUtils.Safe(() => xmlDoc["returns"].InnerText.Trim());

                    var tb = new TextBlock {
                        TextWrapping = TextWrapping.Wrap
                    };

                    tb.Inlines.Add(new Bold(new Run("Summary")));
                    tb.Inlines.Add(new LineBreak());
                    tb.Inlines.Add(summaryInfo);
                    tb.Inlines.Add(new LineBreak());
                    tb.Inlines.Add(new LineBreak());
                    if (xmlDoc.ChildNodes.OfType <XmlElement>().Where(xel => xel.Name == "param").Any())
                    {
                        tb.Inlines.Add(new Bold(new Run("Parameters")));
                        tb.Inlines.Add(new LineBreak());
                        foreach (var param in xmlDoc.ChildNodes.OfType <XmlElement>().Where(xel => xel.Name == "param"))
                        {
                            tb.Inlines.Add(new Italic(new Run(param.GetAttribute("name") + ": ")));
                            tb.Inlines.Add(new Run(param.InnerText.Trim()));
                            tb.Inlines.Add(new LineBreak());
                        }
                        tb.Inlines.Add(new LineBreak());
                    }
                    if (!returnInfo.IsNullOrWhiteSpace())
                    {
                        tb.Inlines.Add(new Bold(new Run("Return value")));
                        tb.Inlines.Add(new LineBreak());
                        tb.Inlines.Add(returnInfo);
                        tb.Inlines.Add(new LineBreak());
                    }

                    panel.Children.Add(tb);
                }
                catch
                {
                    panel.Children.Add(new TextBlock(new Bold(new Italic(new Run("Sorry, no info")))));
                }

                methodsTree.Items.Add(methodItem);
            }
        }
Exemple #22
0
        public Preferences()
        {
            InitializeComponent();
            listview_accounts.ItemsSource = AppController.accounts;

            textblock_app_name.Text            = Spinnaker.Common.app_name;
            textblock_version_and_license.Text = "";
            textblock_version_and_license.Inlines.Add(Spinnaker.AppController.version_string);

            textblock_version_and_license.Inlines.Add(" · ");

            Hyperlink link_to_license = new Hyperlink();

            link_to_license.Click          += link_to_license_Click;
            link_to_license.TextDecorations = null;
            link_to_license.Foreground      = Brushes.White;
            link_to_license.Cursor          = Cursors.Hand;
            link_to_license.ToolTip         = "Open license text (BSD 3)";
            link_to_license.Inlines.Add("BSD 3 License");

            textblock_version_and_license.Inlines.Add(link_to_license);


            #region Tray icon init
            // from my Desktop Google Reader project

            try
            {
                m_notifyIcon      = new System.Windows.Forms.NotifyIcon();
                m_notifyIcon.Text = "Spinnaker";

                System.IO.Stream iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Spinnaker;component/Images/spinnaker_32.ico")).Stream;
                m_notifyIcon.Icon         = new System.Drawing.Icon(iconStream);
                m_notifyIcon.DoubleClick += new EventHandler(m_notifyIcon_Click);

                #region loading icons

                System.Drawing.Image preferences_icon = null;
                System.Drawing.Image quit_icon        = null;
                System.Drawing.Image write_icon       = null;

                try {
                    iconStream       = Application.GetResourceStream(new Uri("pack://application:,,,/Spinnaker;component/Images/TrayIconMenu/preferences.png")).Stream;
                    preferences_icon = System.Drawing.Image.FromStream(iconStream);

                    iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Spinnaker;component/Images/TrayIconMenu/quit.png")).Stream;
                    quit_icon  = System.Drawing.Image.FromStream(iconStream);

                    iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/Spinnaker;component/Images/TrayIconMenu/write.png")).Stream;
                    write_icon = System.Drawing.Image.FromStream(iconStream);
                }
                catch {}

                #endregion

                m_notifyMenu = new System.Windows.Forms.ContextMenuStrip();
                m_notifyMenu.Items.Add("Spinnaker");
                m_notifyMenu.Items.Add("-");
                m_notifyMenu.Items.Add(new System.Windows.Forms.ToolStripMenuItem("Open Preferences", preferences_icon, new System.EventHandler(trayContextShow)));
                System.Windows.Forms.ToolStripMenuItem menuitem_compose = new System.Windows.Forms.ToolStripMenuItem("Compose new post", write_icon, new System.EventHandler(trayContextPost));
                menuitem_compose.ToolTipText = "ctrl-shift-p";
                m_notifyMenu.Items.Add(menuitem_compose);
                m_notifyMenu.Items.Add("-");
                m_notifyMenu.Items.Add(new System.Windows.Forms.ToolStripMenuItem("Quit", quit_icon, new System.EventHandler(trayContextQuit)));

                m_notifyIcon.ContextMenuStrip = m_notifyMenu;
            }
            catch (Exception exp)
            {
                // you might have changed the binary name or the icon path - please update you m_notifyIcon code
                Console.WriteLine(exp.Message);
            }

            #endregion
        }
Exemple #23
0
        private List <Tweet2> FormatEntities(List <Tweet2> TweetList)
        {
            foreach (Tweet2 t in TweetList)
            {
                // should probably link @usernames and #hashtags somehow. also symbols.

                // if entities exist, iterate through them

                if (t.TweetEntities.Count() > 0 && t.Text != null)
                {
                    // this will be the index of the end of the previous entity and should be set in our loop
                    int i = 0;

                    // this will be our list of objects - either <run> or <hyperlink> XAML elements
                    List <object> things  = new List <object>();
                    List <Inline> inlines = new List <Inline>();

                    foreach (TweetEntity tx in t.TweetEntities)
                    {
                        int start = tx.Indices[0];
                        int end   = tx.Indices[1];
                        int len   = end - start;

                        // if the end of the last entity is NOT index of the start of this entity
                        // pull out the text into a run block

                        if (start > i)
                        {
                            string temp    = t.Tweet.Text.Substring(i, start - i);
                            Run    runtemp = new Run
                            {
                                Text = temp
                            };

                            inlines.Add(runtemp as Inline);
                        }

                        Hyperlink link = new Hyperlink();
                        link.UnderlineStyle = UnderlineStyle.None;
                        link.NavigateUri    = new Uri("http://bing.com");

                        Run run = new Run();
                        run.Text = t.Tweet.Text.Substring(start, len);

                        link.Inlines.Add(run);

                        inlines.Add(link as Inline);

                        // set i to equal the end of the entity, so we know where to start the next block of text
                        i = end;
                    }

                    if (i < t.Tweet.Text.Length)
                    {
                        // tweet ends with text, not an entity
                        string temp    = t.Tweet.Text.Substring(i, t.Tweet.Text.Length - i);
                        Run    runtemp = new Run
                        {
                            Text = temp
                        };

                        inlines.Add(runtemp as Inline);
                    }
                    t.Inlines = inlines;
                }
                else
                {
                    //tweet is just text, so we need a single inline
                    Run runtemp = new Run {
                        Text = t.Text
                    };

                    List <Inline> inlines = new List <Inline>();
                    inlines.Add(runtemp);
                    t.Inlines = inlines;
                }
            }

            return(TweetList);
        }
Exemple #24
0
        private void Hyperlink_Click(object sender, RoutedEventArgs e)
        {
            Hyperlink link = sender as Hyperlink;

            Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
        }
Exemple #25
0
 /// <summary>
 /// Constructs a new link property binding for the given hyperlink.
 /// </summary>
 /// <param name="link">The hyperlink to be bound to the property.</param>
 protected LinkPropertyBinding(Hyperlink link) : base(link)
 {
 }
 public void TextBlock_Loaded(object sender, RoutedEventArgs args)
 {
     var textBlock        = sender as TextBlock;
     var run              = new Run {Text = "クラりん可愛い"};
     var hyperlink        = new Hyperlink { NavigateUri = new Uri("https://www.google.co.jp/")};
     hyperlink.Inlines.Add(run);
     textBlock.Inlines.Add(hyperlink);
 }
Exemple #27
0
        private WorkItem toWorkItem(Ticket toImport)
        {
            var tfs_impersonated = tfsUsers.ImpersonateDefaultCreator();
            if (tfsUsers.CanAddTicket(toImport.CreatedBy))
            {
                tfs_impersonated = tfsUsers.Impersonate(toImport.CreatedBy);
            }

            var workItemStore = (WorkItemStore) tfs_impersonated.GetService(typeof (WorkItemStore));
            var workItemTypes = workItemStore.Projects[project].WorkItemTypes;

            var workItemType = workItemTypes[toImport.TicketType];
            var workItem = new WorkItem(workItemType);

            foreach (var fieldName in tfsFieldMap.Fields.EditableFields.
                Where(fieldName => string.IsNullOrEmpty(fields[fieldName].DefaultValue) == false))
            {
                assignToField(workItem, fieldName, fields[fieldName].DefaultValue);
            }

            workItem.Title = toImport.Summary;
            var description = toImport.Description;

            // TFS's limit on HTML / PlainText fields is 32k.
            if (description.Length > max_Description_length)
            {
                var attachment = string.Format("{0} (Description).txt", toImport.ID);
                description = "<p><b>Description stored as Attachment</b></p>";
                description += "<ul><li>Description exceeds 32K.A limit imposed by TFS.</li>";
                description += ("<li>See attachment \"" + attachment + "\"</li></ul>");
            }

            workItem.Description = description;
            assignToField(workItem, "Repro Steps", description);

            assignToField(workItem, "Team", assignedTeam);
            tfsUsers.AssignUser(toImport.AssignedTo, workItem);

            assignToField(workItem, "Story Points", toImport.StoryPoints);
            assignToField(workItem, "Effort", toImport.StoryPoints);
            workItem.AreaPath = (string.IsNullOrWhiteSpace(assignedAreaPath) ? project : assignedAreaPath);
            assignToField(workItem, "External Reference", toImport.ID);
            assignToField(workItem, tfsPriorityMap.PriorityField, tfsPriorityMap[toImport.Priority]);

            if (toImport.HasUrl)
            {
                try
                {
                    var hl = new Hyperlink(toImport.Url)
                    {
                        Comment = string.Format("{0} [{1}]", externalReferenceTag, toImport.ID)
                    };
                    workItem.Links.Add(hl);
                }
                catch
                {
                    /*Do nothing..*/
                }
            }

            var c = new StringBuilder();
            foreach (var comment in toImport.Comments)
            {
                var body = String.Format("<i>{0}</i></br>Created by {1} on the {2}.<br>",
                    comment.Body.Replace(Environment.NewLine, "<br>"),
                    comment.Author.DisplayName,
                    comment.CreatedOn.ToShortDateString());
                if (comment.UpdatedLater)
                {
                    body = String.Format("{0}<br>(Last updated on the {1}).<br>", body,
                        comment.Updated.ToShortDateString());
                }
                c.Append(body);
            }

            if (c.Length > 0)
            {
                c.Append("<br>");
            }
            c.Append(string.Format("<u><b>Additional {0} information</b></u><br>", externalReferenceTag));

            var rows = new List<Tuple<string, string>>
            {
                new Tuple<string, string>("Ticket",
                    string.Format("<a href=\"{0}\">{1}</a>", toImport.Url, toImport.ID + " - " + toImport.Summary)),
                new Tuple<string, string>("Created by ", toImport.CreatedBy.DisplayName),
                new Tuple<string, string>("Created on ", toImport.CreatedOn.ToString(CultureInfo.InvariantCulture))
            };
            if (toImport.TicketState == Ticket.State.Done)
            {
                rows.Add(new Tuple<string, string>("Closed on ", toImport.ClosedOn.ToString(CultureInfo.InvariantCulture)));
            }
            if (string.IsNullOrWhiteSpace(toImport.Project) == false)
            {
                rows.Add(new Tuple<string, string>("Belonged To", toImport.Project));
            }

            c.Append("<table style=\"width:100%\">");
            foreach (var row in rows)
            {
                c.Append(string.Format("<tr><td><b>{0}</b></td><td>{1}</td></tr>", row.Item1, row.Item2));
            }
            c.Append("</table>");
            workItem.History = c.ToString();

            return workItem;
        }
Exemple #28
0
        public static RichTextBox GetRichText(string richText)
        {
            var richTextBox = new RichTextBox();
            var paragraph   = new Paragraph();
            var doc         = new XmlDocument();

            doc.LoadXml("<section>" + richText + "</section>");
            if (doc.FirstChild != null)
            {
                foreach (var childNode in doc.FirstChild.ChildNodes)
                {
                    System.Diagnostics.Debug.WriteLine(childNode.InnerText);
                    var xmlText = childNode as XmlText;
                    if (xmlText != null)
                    {
                        if (!string.IsNullOrEmpty(childNode.InnerText))
                        {
                            paragraph.Inlines.Add(new Run {
                                Text = childNode.InnerText
                            });
                        }
                    }
                    var cdataNode = childNode as XmlCDataSection;
                    if (cdataNode != null)
                    {
                        var d = new XmlDocument();
                        try
                        {
                            d.LoadXml("<innerSection>" + cdataNode.InnerText + "</innerSection>");
                            if (d.FirstChild != null)
                            {
                                foreach (var c in d.FirstChild.ChildNodes)
                                {
                                    if (c.NodeName == "a")
                                    {
                                        var hyperlink = new Hyperlink {
                                            TargetName = "_blank"
                                        };
                                        foreach (var attribute in c.Attributes)
                                        {
                                            if (attribute.NodeName == "href")
                                            {
                                                var nodeInnerValue = attribute.NodeValue as string;
                                                if (!string.IsNullOrEmpty(nodeInnerValue))
                                                {
                                                    hyperlink.NavigateUri = new Uri(nodeInnerValue, UriKind.Absolute);
                                                }
                                            }
                                        }

                                        xmlText = c.FirstChild as XmlText;
                                        if (xmlText != null)
                                        {
                                            if (!string.IsNullOrEmpty(xmlText.InnerText))
                                            {
                                                hyperlink.Inlines.Add(new Run {
                                                    Text = xmlText.InnerText, Foreground = (Brush)Application.Current.Resources["TelegramBadgeAccentBrush"]
                                                });
                                                paragraph.Inlines.Add(hyperlink);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Execute.ShowDebugMessage(ex.ToString());
                        }
                    }
                }
            }

            richTextBox.Blocks.Add(paragraph);

            return(richTextBox);
        }
Exemple #29
0
 private void NavigateToTasks(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     Frame.Navigate(typeof(TasksPage));
 }
 /// <summary>
 /// Implementation for <see cref="LinkTransformer"/>.
 /// </summary>
 /// <param name="el">Formatting input XML element.</param>
 /// <returns><see cref="Span"/> with properties corresponding to <paramref name="el"/>.</returns>
 private static Span LinkTransformerImpl(XElement el)
 {
     Hyperlink link;
     switch (el.Name.LocalName.ToLowerInvariant())
     {
         case "close":
             link = new Hyperlink() { Foreground = new SolidColorBrush(Colors.Blue) };
             link.Click += (_, __) => Application.Current.Exit();
             return link;
         case "a":
             link = new Hyperlink() { Foreground = new SolidColorBrush(Colors.Blue) };
             link.Click += async (_, __) => await Launcher.LaunchUriAsync(new Uri(el.Attribute("href")?.Value));
             return link;
         default:
             return null;
     }
 }
Exemple #31
0
        private void PushFeedToDetails(SyndicationFeed feed)
        {
            Background_Episodes_Image.Opacity = 0;

            Uri getImageFromFeed = feed.ImageUri;

            try {
                var bgimage = new BitmapImage(getImageFromFeed);

                Background_Episodes_Image.Source = bgimage;
                Podcast_PosterImage.Source       = bgimage;

                SolidColorBrush blackBrush = new SolidColorBrush(Windows.UI.Colors.Black);

                PosterBorder.BorderBrush = blackBrush;
            } catch (Exception e)
            {
                Background_Episodes_Image.Source = null;
                Podcast_PosterImage.Source       = null;
                SolidColorBrush whiteBrush = new SolidColorBrush(Windows.UI.Colors.White);

                PosterBorder.BorderBrush = whiteBrush;
            }

            episodes = new ObservableCollection <Podcast_Episode>();

            int NumberOfEpisodes = feed.Items.Count;

            PodcastHeader.Text = feed.Title.Text;

            Episode_List.Items.Clear();


            for (int i = 0; i < (NumberOfEpisodes); i++)
            {
                SyndicationItem item = feed.Items[i];
                SyndicationLink link = feed.Links[0];
                //  Debug.WriteLine(item.Summary.Text);
                //  Debug.WriteLine(item.PublishedDate.ToString());

                TextBlock TextBox = new TextBlock();
                TextBox.TextWrapping = TextWrapping.Wrap;

                string thisMonth = item.PublishedDate.ToLocalTime().Month.ToString();
                string thisDay   = item.PublishedDate.ToLocalTime().Day.ToString();

                if (thisMonth.Length == 1)
                {
                    thisMonth = "0" + thisMonth;
                }
                if (thisDay.Length == 1)
                {
                    thisDay = "0" + thisDay;
                }


                TextBox.Text = item.PublishedDate.ToLocalTime().Year.ToString() + "-" +
                               thisMonth + "-" + thisDay + ": " + item.Title.Text;


                //Uri currentAddUri = new Uri(item.ItemUri.AbsoluteUri);
                // currentUris.Add(currentAddUri);



                Hyperlink hyperlink = new Hyperlink();

                Windows.Web.Syndication.SyndicationLink rssLink = item.Links.Last();
                //string rssLinkToUse = rssLink.Uri.AbsoluteUri.ToString();

                string rssLinkToUse = String.Format("{0}{1}{2}{3}", rssLink.Uri.Scheme,
                                                    "://", rssLink.Uri.Authority, rssLink.Uri.AbsolutePath);



                hyperlink.NavigateUri = new Uri(rssLinkToUse);

                TextBox.Inlines.Add(hyperlink);

                Episode_List.Items.Add(TextBox);
            }
        }
Exemple #32
0
 private void NavigateToSettings(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     Frame.Navigate(typeof(SettingsPage));
 }
 /// <summary>
 /// Open the Speech, Inking and Typing page under Settings -> Privacy, enabling a user to accept the
 /// Microsoft Privacy Policy, and enable personalization.
 /// </summary>
 /// <param name="sender">Ignored</param>
 /// <param name="args">Ignored</param>
 private async void openPrivacySettings_Click(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-speechtyping"));
 }
Exemple #34
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the  
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method 
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            this.navigationHelper.OnNavigatedTo(e);
            var list = (List<String>)e.Parameter;
            String fileName = list.ElementAt(1);
            xmlReader = XmlReader.Create(fileName, new XmlReaderSettings());

            XmlSerializer x = new XmlSerializer(typeof(ExpertSystem), "http://tempuri.org/XMLSchema.xsd");
            expertSystem = (ExpertSystem)x.Deserialize(xmlReader);

            /*  this.WebViewDescription.NavigateToString(expertSystem.description);

              this.textBlock1.Text = expertSystem.description;

              String sourceshtml = "";

              foreach (Source s in expertSystem.sources)
              {
                  sourceshtml += s.linkDescription + "</br><font color=\"blue\">" + s.link + "</font></br></br>";
              }

              this.WebViewSources.NavigateToString(sourceshtml);*/
            DescriptionTextBlock.Blocks.Clear();
            SourcesTextBlock.Blocks.Clear();

            Run r = new Run();
            r.Text = expertSystem.description;
            Paragraph p = new Paragraph();
            p.Inlines.Add(r);

            DescriptionTextBlock.Blocks.Add(p);

            foreach (var s in expertSystem.sources)
            {
                Run description = new Run();
                description.Text = s.linkDescription + "\n";

                Run linklink = new Run();
                linklink.Text = s.link + "\n";
                
                Hyperlink link = new Hyperlink();
                link.Inlines.Add(linklink);
                link.NavigateUri = new System.Uri(s.link);

                Paragraph p1 = new Paragraph();
                p1.Inlines.Add(description);
                p1.Inlines.Add(link);

                SourcesTextBlock.Blocks.Add(p1);
            }
        }
        private static IList <Inline> GetInlines(StorageFile masterFile, StorageFile outFile, UIElement anchor)
        {
            Hyperlink masterLink = new Hyperlink();

            masterLink.Click += (_1, _2) => { Windows.System.Launcher.LaunchFileAsync(masterFile); };
            masterLink.Inlines.Add(new Run()
            {
                Text = "master"
            });
            Hyperlink outLink = new Hyperlink();

            outLink.Click += (_1, _2) => { Windows.System.Launcher.LaunchFileAsync(outFile); };
            outLink.Inlines.Add(new Run()
            {
                Text = "output"
            });
            List <Inline> inlines = new List <Inline>()
            {
                new Run()
                {
                    Text = "Tree dump "
                },
                outLink,
                new Run()
                {
                    Text = " does not match "
                },
                masterLink
            };

            #region Diff support - Replace with LaunchUriAsync when we find the VSCode protocol handler Uri for diffing
            string    code_cmd = Environment.ExpandEnvironmentVariables(@"%UserProfile%\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd");
            Hyperlink diffLink = new Hyperlink();
            diffLink.Click += (_1, _2) =>
            {
                string      commandLine = $"code.cmd --diff \"{masterFile.Path}\" \"{outFile.Path}\"";
                DataPackage dataPackage = new DataPackage();
                dataPackage.SetText(commandLine);
                Clipboard.SetContent(dataPackage);
                ToolTip toolTip = new ToolTip()
                {
                    Content = "Copied to clipboard"
                };
                ToolTipService.SetToolTip(anchor, toolTip);
                toolTip.Opened += (_3, _4) =>
                {
                    var timer = Windows.System.DispatcherQueue.GetForCurrentThread().CreateTimer();
                    timer.IsRepeating = false;
                    timer.Interval    = TimeSpan.FromSeconds(1);
                    timer.Tick       += (_5, _6) =>
                    {
                        toolTip.IsOpen = false;
                        ToolTipService.SetToolTip(anchor, null);
                    };
                    timer.Start();
                };
                toolTip.IsOpen = true;
            };
            diffLink.Inlines.Add(new Run()
            {
                Text = "copy diff command to clipboard"
            });
            inlines.Add(new Run()
            {
                Text = " - "
            });
            inlines.Add(diffLink);
            #endregion
            return(inlines);
        }
Exemple #36
0
 private async void ShowCommand( Hyperlink sender, HyperlinkClickEventArgs args )
 {
     Logger.Log( ID, AppSettings.FamilyName, LogType.DEBUG );
     StringResources stx = new StringResources( "Settings" );
     await Popups.ShowDialog(
         new Dialogs.Rename(
             new CommandCopy() { Name = "CheckNetIsolation LoopbackExempt -a -n=" + AppSettings.FamilyName }
             , stx.Text( "Advanced_Server_Exempt_Command" ) , true ) );
 }
        private async void HotspotClick(Hyperlink sender, HyperlinkClickEventArgs args)
        {
            // 获取父级的 TextBlock。
            var textBlock = sender.GetAncestorsOfType<TextBlock>().First();

            // 获取点击的热点。
            var hotspot = textBlock.DataContext as Hotspot;
            if (hotspot != null)
            {
                var uri = new Uri(hotspot.Link);
                await Launcher.LaunchUriAsync(uri);

                // 获取子级的 Run。
                var runs = sender.Inlines.OfType<Run>();
                foreach (var run in runs)
                {
                    // 设置为紫色,表示已经访问过。
                    run.Foreground = new SolidColorBrush(Colors.Purple);
                }
            }
        }
 private void FeedbackButton_Click(Hyperlink sender, HyperlinkClickEventArgs args)
 {
     PageManager.NavigateTo(typeof(SettingsPage), "feedback", NavigationType.Default);
 }
        internal Hyperlink ToHyperlink()
        {
            Hyperlink hl = new Hyperlink();
            hl.Reference = SLTool.ToCellRange(this.Reference.StartRowIndex, this.Reference.StartColumnIndex, this.Reference.EndRowIndex, this.Reference.EndColumnIndex);
            if (this.Id != null && this.Id.Length > 0) hl.Id = this.Id;
            if (this.Location != null && this.Location.Length > 0) hl.Location = this.Location;
            if (this.ToolTip != null && this.ToolTip.Length > 0) hl.Tooltip = this.ToolTip;
            if (this.Display != null && this.Display.Length > 0) hl.Display = this.Display;

            return hl;
        }
Exemple #40
-1
        public override DependencyObject GetControl(HtmlFragment fragment)
        {
            var node = fragment as HtmlNode;
            if (node != null && node.Attributes.ContainsKey("href"))
            {
                Hyperlink a = new Hyperlink();

                Uri uri;

                if (Uri.TryCreate(node.Attributes["href"], UriKind.Absolute, out uri))
                {
                    try
                    {
                        a.NavigateUri = uri;
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine($"Error loading a@href '{uri?.ToString()}': {ex.Message}");
                    }
                }

                return a;
            }
            return null;
        }