简体   繁体   中英

How do you make a component/container that allows for the input of an integer in Visual C#?

I'm trying to make a simple Zune "game" (it's really an app, but my Zune only supports games) that takes in two integers, which are time intervals, and plays one sound after time1 and plays another sound after time1+time2, and then repeats.I'm using Visual C# 2008 Express with XNA 3.1.

All I really need is two components/containers that allow for specification of time, and one for "play". The purpose of this is for interval training, where one sprints for a certain duration and then rests for another duration, usually 30 seconds of sprinting followed by 90 seconds of resting.

In short, how do make a component that allows for the input of an integer in Visual C#?

I believe the Zune SDK doesn't provide a soft input keyboard. See this MSDN Topic:
http://msdn.microsoft.com/en-US/library/dd282502(v=XNAGameStudio.30).aspx?appId=Dev10IDEF1&l=EN-US&k=k(MICROSOFT.XNA.FRAMEWORK.INPUT.KEYBOARD);k(TargetFrameworkMoniker-%22.NETFRAMEWORK&k=VERSION=V4.0%22);k(DevLang-CSHARP)&rd=true

APIs related to input devices not available on Zune, such as Mouse and Keyboard, can be accessed in code running on a Zune device. The X and Y values in MouseState returned on Zune will always be zero. Similarly, checking for keys pressed using Keyboard on Zune will always return keys in an unpressed state. Also, you should not expect an exception when you access the mouse, keyboard, or other unexpected input devices on Zune.

You would have to program your own display, which is relatively easy if you want simple integer input.

  1. Draw a box
  2. When the user "presses" the box, show a grid of boxes with a number drawn on each one
  3. When the user "presses" one of those boxes, draw the corresponding number in the original box

You are obviously recreating some basic controls here ... but that's life when you make a UI framework on the Zune :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM