PC Review


Reply
Thread Tools Rate Thread

Creating a 'console application'

 
 
Marco Shaw
Guest
Posts: n/a
 
      29th Dec 2006
C# novice...

Can I create a console application (think the Pine email reader or even
'edit' in DOS) where I can use my up/down/side arrows to move around the
app?

I'd want something with a simple menu system as well as popup functionality.

Any hints/pointers to get me started?

Marco


 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      29th Dec 2006
Hi,

I know of nothing like that, at least for .net

why would you like something like that?



"Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message
news:%23Tp3l%(E-Mail Removed)...
> C# novice...
>
> Can I create a console application (think the Pine email reader or even
> 'edit' in DOS) where I can use my up/down/side arrows to move around the
> app?
>
> I'd want something with a simple menu system as well as popup
> functionality.
>
> Any hints/pointers to get me started?
>
> Marco
>



 
Reply With Quote
 
Tom Leylan
Guest
Posts: n/a
 
      30th Dec 2006
He Marco... The answer is "of course." :-) I hate to sound like an old dude
but frankly that's how we used to write apps. I wrote DOS apps (probably
some still in use) by writing the library code for the form, menu, buttons
and other controls first. The user could drag "windows" around the DOS
screen, control background colors, play sounds and all that good stuff.

In the extreme form the fanciest UI's were called "games." :-) Consider if
they could write DOOM without the Windows GUI you must be able to generate a
text-based menu system. As you point out, EDIT still works, if it wasn't
possible then it shouldn't work.


"Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message
news:%23Tp3l%(E-Mail Removed)...
> C# novice...
>
> Can I create a console application (think the Pine email reader or even
> 'edit' in DOS) where I can use my up/down/side arrows to move around the
> app?
>
> I'd want something with a simple menu system as well as popup
> functionality.
>
> Any hints/pointers to get me started?
>
> Marco



 
Reply With Quote
 
rossum
Guest
Posts: n/a
 
      30th Dec 2006
On Fri, 29 Dec 2006 15:29:24 -0400, "Marco Shaw"
<marcoDOTshaw_@_gmailDOTcom> wrote:

>C# novice...
>
>Can I create a console application (think the Pine email reader or even
>'edit' in DOS) where I can use my up/down/side arrows to move around the
>app?
>

Yes.

>Any hints/pointers to get me started?
>
>Marco
>

Use elements of Console for the cursor moving bit: CursorTop,
CursorLeft, KeyInfo, ConsoleKey, KeyAvailable and Read(). You may
also need System.Threading.Thread.Sleep() to wait for a key to be
pressed.

I don't know how much of a hint you want, but don't read any further
if you don't want to see a very simple demonstration.

rossum







static void Main() {
string twentyDots = new string('.', 20);

for (int i = 0; i < 10; ++i) {
Console.WriteLine(twentyDots);
} // end for
Console.WriteLine("Use arrow keys to move or X to exit.");

// Initial position of cursor
Console.CursorLeft = 9;
Console.CursorTop = 4;

// Loop to read keyboard
bool finished = false;
ConsoleKeyInfo keyInfo = new ConsoleKeyInfo();
do {
// Wait until key is pressed.
while (Console.KeyAvailable == false) {
Thread.Sleep(100);
} // end while

// 'true' stops key echo.
keyInfo = Console.ReadKey(true);
switch (keyInfo.Key) {
case ConsoleKey.DownArrow:
++Console.CursorTop;
break;
case ConsoleKey.LeftArrow:
--Console.CursorLeft;
break;
case ConsoleKey.RightArrow:
++Console.CursorLeft;
break;
case ConsoleKey.UpArrow:
--Console.CursorTop;
break;
case ConsoleKey.X:
finished = true;
break;
default:
break;
} // end switch
} while (!finished);
} // end Main()






 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Console application in C# CSharper Microsoft C# .NET 7 26th Jan 2009 10:36 PM
Console application. Console.Clear = IOException Dinsdale Microsoft VB .NET 6 14th Mar 2008 06:36 PM
How to run a console application without showing the console screen? Tee Microsoft C# .NET 2 11th Feb 2005 06:22 AM
How to run a console application without showing the console screen? Tee Microsoft VB .NET 2 11th Feb 2005 06:22 AM
How to set a fixed line in a console application liek UNIX console AA Microsoft C# .NET 1 6th Dec 2003 02:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:59 AM.