Jump to content
  • entries
    222
  • comments
    606
  • views
    591086

Text mode graphics and help file indexing

Sign in to follow this  
benryves

1044 views

In light of the TMDC, I thought I'd package up the .NET class for easy text-mode graphics I'd been throwing together.


Click for big


Once initialised, all you need are two things; the Graphics object it provides to handle your drawing, and the Refresh() method to update the console with whatever it is you've been composing.

It relies on a fairly large palette (128KB) which is hugely wasted in the current version - it maps every 16-bit colour value (R5G6B5) to an attribute/character pair. For the purpose of not looking extremely ugly, the palette provided only uses a few basic characters, not the full range, hence that 128KB could be reduced somewhat.

If you want to provide your own palette, it's just a sequence of two byte pairs (character then attribute) for each of the 16-bit colour values.

You'll need to compile with the unsafe flag set.

Download VC? project (with a quick-and-dirty sample program - an oldschool flame that spins around, some curves and some alpha-blended text). ClearType does make the text look a bit odd.

// Set window to 80x50
TextSharp TS = new TextSharp(80, 50);

// Set window title text
TS.Title = "TextSharp Demo";

// Set up some pleasant antialiasing/filtering
TS.Graphics.SmoothingMode = SmoothingMode.HighQuality;
TS.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

// Now use the Graphics object like any other
TS.Graphics.Clear(Color.White);
TS.Graphics.DrawLine(Pens.Black, 0, 0, 80, 50);

// Update console window
TS.Refresh();


The document browser progresses (slowly) - it now exports and imports to/from a single file (the .docpack) and has a nifty search-as-you-type index.



Why is it that all you need to do to solve all your .NET WinForms woes is to make the control invisible then visible again? When clearing/adding large numbers of nodes to a TreeView control, you get a dancing scrollbar that pauses the app for a second or so - make the control invisible then visible again and it's instant. (This is using Clear and AddRange - it's not as if I'm adding them one-by-one).
Sign in to follow this  


3 Comments


Recommended Comments

Are you calling BeginUpdate() before you start modifying the contents and EndUpdate() after? I thought that was supposed to stop it continuously redrawing itself.

Never used the Treeview control so I might be completely wrong though....

Share this comment


Link to comment
Hmm, I didn't check that (and it would seem sensible). Having only looked up the ListBox before (“Maintains performance while items are added to the ListBox one at a time by preventing the control from drawing until the EndUpdate method is called.”) I'd assumed that adding in ranges wouldn't have the problem. It sounds like that's the fix, though. Thanks for pointing that out. [grin]

Share this comment


Link to comment
Hmm, I didn't check that (and it would seem sensible). Having only looked up the ListBox before (“Maintains performance while items are added to the ListBox one at a time by preventing the control from drawing until the EndUpdate method is called.”) I'd assumed that adding in ranges wouldn't have the problem. It sounds like that's the fix, though. Thanks for pointing that out. [grin]

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!