Home
Options

What is the best way to customize the dumpcontainer render ?

I've got a multiline string I want to display repeatedly (I use a DumpContainer and updatecontent to reflect changes between each "movement").
As this multiline is like an "array" (X columns, Y rows), I actually just use a dumpfixed extension method to display characters with same width.
Now, I'd like to customize the display with colors and by example colorize a character at coord X,Y like this capture

I wonder what's the best way to do it (create a class with todump(), util.rawHTML, use linqpad.controls...) ? I searched for samples but I didn't found similar things.

Comments

  • Options
    edited May 2021

    If the content is HTML, you don't need a DumpContainer - just use a Div and update its InnerHtml when you want to refresh the content:

    using LINQPad.Controls;
    
    var div = new Div().Dump();
    div.Styles["font-family"] = "consolas";
    div.HtmlElement.InnerHtml = "<pre>test <span style='background-color:yellow'>yellow</span> test </pre>";
    

    If the content is large or complex, you can make the updates more efficient by taking a more granular approach:

    var span1 = new Span("foo");
    var span2 = new Span("bar");
    var pre = new Control ("pre", span1, span2).Dump();
    // now you can update span1 or span2 by changing their InnerHtml or styles
    
  • Options

    I never used the controls in Linqpad before...I always used the Dump()...but now, I see how powerful it is :)
    Many thanks again Joe...The span with styles was the simplest I needed

    P.S. : maybe it would be nice to provide some example output using these controls

Sign In or Register to comment.