Console application to screensaver...


A

Adman

Hi all... I have a pretty weird question.

I have a console mode application that uses ANSI (or vt100) escape
sequences to do some animation type stuff. You know, change colors,
draw text graphics, and I'd like to modify that into fullscreen
screensaver.

Any ideas where to begin?

I'm familiar with both screensaver programming, and Windows Forms
programming, and console application programming, but not sure how to
do console-like stuff in a windows form...

Adam
 
Ad

Advertisements

A

Adman

I think you'll have to write your own console.  Which, for the specific 
purpose, probably isn't really all that hard.  It's not like you need to  
implement a CLI or deal with process management.  You just need to write a  
basic dumb terminal that can interpret the escape codes of interest (i.e. 
characters in the specific on-screen positions, keeping track of cursor  
position, background/foreground color, etc.), and then render that to the 
screen with the usual methods (in this case, you'll probably wind up using  
the Graphics.DrawString() or TextRenderer.DrawText() methods, of course).

You'll have to port the original console application code, just enough to 
hook it to your console emulator object inside your screen saver.  But  
that shouldn't be too hard, and depending on how you do it, might involve 
just wrapping all of the original code in a class where the functions it  
calls to output the data are simply defined in that class, with the output  
redirected as desired (i.e. to whatever API you put in your console  
emulator object).

Pete

Thanks Pete... that's pretty much exactly what I've done.

One other question: I'm having a hard time coming up with a font that
will display old-school ASCII graphics (with the extended box drawing
type characters). My program is working, but the characters aren't
printing out properly.

I fixed this in my console application by doing this:

Console.OutputEncoding = Encoding.GetEncoding(28591);

Any ideas?

Thanks again!
Adman
 
A

Adman

Sounds like a hack.

For GUI, you'll obviously need a specific font to use, as the encoding is 
irrelevant (.NET strings are all UTF-16).  You can look at the fonts as 
easily as I can, but the two most obvious choices I looked at -- Courier  
New, and Lucida Console -- both have the old-style DOS characters.

The trick will be making sure you're using the right character value.  I  
don't know off the top of my head if you can use the old ASCII codes, or  
will have to use the actual character point in UTF-16.  But that shouldn't  
be hard to figure out, and it'll work once you do.  :)

Pete

Got it. Neither Courier New or Lucida Console had what I needed,
which is basically this stuff:

http://www.ascii.ws/images/extended-ascii.gif

....but I'll keep looking around. I'm not really familiar with fonts,
encoding, and code pages, so I've got some playing to do.

Thanks for your help!
Adam
 
Ad

Advertisements

A

Adman

Just to followup, this is basically what I did, and everything is
working perfectly. Thanks again for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top