//////////////// public UIWebUrl(UITheme theme, string label, string url, bool hoverUrl = true, float scale = 0.85f, bool large = false) : base() { this.Theme = theme; this.IsVisited = false; this.Url = url; this.WillDrawOwnHoverUrl = hoverUrl; this.Scale = scale; this.Large = large; this.TextElem = new UIText(label, scale, large); this.TextElem.TextColor = theme.UrlColor; this.Append(this.TextElem); this.LineElem = UIWebUrl.GetLineElement(label, scale, large); this.LineElem.TextColor = theme.UrlColor; this.Append(this.LineElem); CalculatedStyle labelSize = this.TextElem.GetDimensions(); this.Width.Set(labelSize.Width, 0f); this.Height.Set(labelSize.Height, 0f); UIText textElem = this.TextElem; UIText lineElem = this.LineElem; this.OnMouseOver += delegate(UIMouseEvent evt, UIElement fromElem) { if (textElem.TextColor != theme.UrlVisitColor) { textElem.TextColor = theme.UrlLitColor; textElem.TextColor = theme.UrlLitColor; } }; this.OnMouseOut += delegate(UIMouseEvent evt, UIElement fromElem) { if (textElem.TextColor != theme.UrlVisitColor) { textElem.TextColor = theme.UrlColor; textElem.TextColor = theme.UrlColor; } }; this.OnClick += delegate(UIMouseEvent evt, UIElement fromElem) { try { SystemHelpers.OpenUrl(this.Url); //System.Diagnostics.Process.Start( this.Url ); this.IsVisited = true; textElem.TextColor = theme.UrlVisitColor; lineElem.TextColor = theme.UrlVisitColor; } catch (Exception e) { Main.NewText(e.Message); } }; }
//////////////// public void SetText(string text) { this.TextElem.SetText(text, this.Scale, this.Large); this.RemoveChild(this.LineElem); this.LineElem.Remove(); this.LineElem = UIWebUrl.GetLineElement(text, this.Scale, this.Large); this.Append(this.LineElem); this.Recalculate(); }