Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2004, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default Console events...?!

I posted this topic regarding the same problem. Now I am trying to do it in C#, but cannot get much further!

The thing is that I would like to have a console dialog, in which the dialog continues after only one key press, and not after a whole string has been entered and the 'Enter' key has been pressed. Is this possible and how?

Thanks

Jacob.
__________________
Danish audio books for download at http://www.lytenbog.dk (Danske lydbøger til download).
 
Old February 16th, 2004, 10:41 AM
Authorized User
 
Join Date: Nov 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to KABay
Default

Not to split hairs but here you speak of a 'console dialog'. But in [u]your</u> other posting your code sample was:

Code:
String s;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true)
{
    showDialog(); 
    s = br.readLine();
    switch(s.charAt(0))
    {
        case '1':


A console dialog, to me, says you have created a console app but your Java code says you are creating a dialog window yourself. Assuming the latter have you considered replacing your Readline() approach, which requires an Enter with a method within your dialog that monitors the keyboard for the press of a key and exits the dialog when the appropriate ones are pressed:

Code:
protected override void OnKeyDown(KeyEventArgs keyg) {
   switch(keyg.KeyData) {
      case Keys.1:
         //...   processing - send event/keycode to parent window & exit?
   }
}
 
Old February 16th, 2004, 06:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, sorry... I may have been unclear on this. I am not doing a windowed dialog in Java. I didn't show the showDialog method since it is irrelevant for the problem; I thought. The showDialog only shows some lines of text output on the standard out stream!
Code:
    public static void showDialog()
    {
        System.out.println("Choose one of the following options...\n");
 
        System.out.println("1. Make new user");
        ...
        System.out.println("7. Identify user");
        System.out.println("9. Exit");

        System.out.println();
        System.out.print("Enter option number: ");
    }
}
I will tell you the full story! The thing is that I am currently working on a small project where I am trying to identify users from the way they press the keyboard. For this I am using a program called xlisten, and which runs on Linux. I pipe the output from xlisten into my Java program so I can analyze the xlisten output! Part of the Java program require the user to enter som data from which typing patterns are retrieved, and this is why I use a console dialog etc.

By the way... The reason for my C# question was that I am primerily a Windows user, so I am mostly developing on this platform, and some C# help might have helped me!

Thanks anyway.

Jacob.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Console sektor Visual Basic 2008 Essentials 0 July 10th, 2008 12:43 AM
Console application but no Console gamotter C# 2 August 22nd, 2007 11:41 PM
Console App Notify Icon Events invid C# 2005 0 January 21st, 2006 03:53 PM
console menu Xanoo C++ Programming 0 April 14th, 2004 07:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.