public void Should_replace_link_tags()
        {
            var parser = new LinkParser("some text <<Link>>some more text<</Link>> and yet <<Link>>some more<</Link>>");
            var links = parser.Parse();
            parser.ParsedText.ShouldEqual("some text some more text and yet some more");
			links.Length.ShouldEqual(2);
        }
        public void Should_return_links()
        {
            var parser = new LinkParser("some text <<Link>>some more text<</Link>> and yet <<Link>>some more<</Link>>");
            var links = parser.Parse();
            
            links.Length.ShouldEqual(2);
			parser.ParsedText.Substring(links[0].Start, links[0].Length).ShouldEqual("some more text");
			parser.ParsedText.Substring(links[1].Start, links[1].Length).ShouldEqual("some more");
        }
Ejemplo n.º 3
0
 public void SetText(string text, string caption)
 {
     Text = caption;
     var parser = new LinkParser(text);
     var links = parser.Parse();
     linkLabel.Text = parser.ParsedText;
     linkLabel.LinkArea = new LinkArea(0, 0);
     foreach (var link in links)
         linkLabel.Links.Add(link.Start, link.Length);
     Height = linkLabel.Height + (linkLabel.Top * 2) + 28;
     Width = linkLabel.Width + (linkLabel.Left * 2) + 8;
 }
 private List<Link> getLinks()
 {
     Text = Text.Trim();
     if (Text.EndsWith(Environment.NewLine))
         Text = Text.Substring(0, Text.Length - Environment.NewLine.Length);
     var parser = new LinkParser(Text);
     var links = parser.Parse();
     Text = parser.ParsedText;
     var textForLambda = Text;
     return links
         .Where(x => containsLink(textForLambda.Substring(x.Start, x.Length)))
         .Select(x =>
         new Link(
             getBeginningOfLine(textForLambda, x.Start),
             getEndOfLine(textForLambda, x.Start + x.Length),
             getFile(textForLambda.Substring(x.Start, x.Length)),
             getLine(textForLambda.Substring(x.Start, x.Length)))).ToList();
 }
Ejemplo n.º 5
0
        private void setInfoText(string text)
        {
			try
			{
	            int previousHeight = linkLabelInfo.Height;
	            var parser = new LinkParser(text);
	            var links = parser.Parse();
				if (parser.ParsedText.Length > GDI_SIZE_LIMIT)
					linkLabelInfo.Text = parser.ParsedText.Substring(0, GDI_SIZE_LIMIT);
				else
	            	linkLabelInfo.Text = parser.ParsedText;
	            linkLabelInfo.LinkArea = new LinkArea(0, 0);
	            foreach (var link in links)
				{
					if (link.Start + link.Length <= GDI_SIZE_LIMIT)
						linkLabelInfo.Links.Add(link.Start, link.Length);
				}
	            var difference = linkLabelInfo.Height - previousHeight;
	            Height = Height + difference;
			}
			catch (Exception exception)
			{
				_bus.Publish(new ErrorMessage(exception));
			}
        }