简体   繁体   English

如何制作允许在Visual C#中输入整数的组件/容器?

[英]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. 我正在尝试制作一个简单的Zune“游戏”(这确实是一个应用程序,但我的Zune仅支持游戏),它吸收两个整数(时间间隔),在time1之后播放一个声音,在time1 + time2之后播放另一个声音,然后重复。我正在将Visual C#2008 Express与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. 这样做的目的是进行间歇训练,其中一个冲刺持续一定的时间,然后休息另一个持续时间,通常是30秒钟的冲刺,然后是90秒钟的休息。

In short, how do make a component that allows for the input of an integer in Visual C#? 简而言之,如何制作允许在Visual C#中输入整数的组件?

I believe the Zune SDK doesn't provide a soft input keyboard. 我相信Zune SDK不提供软输入键盘。 See this MSDN Topic: 请参阅此MSDN主题:
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 http://msdn.microsoft.com/zh-CN/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. 可以在Zune设备上运行的代码中访问与Zune上不可用的输入设备(如鼠标和键盘)相关的API。 The X and Y values in MouseState returned on Zune will always be zero. Zune上返回的MouseState中的X和Y值将始终为零。 Similarly, checking for keys pressed using Keyboard on Zune will always return keys in an unpressed state. 同样,使用Zune上的键盘检查是否有按下的键将始终以未按下状态返回键。 Also, you should not expect an exception when you access the mouse, keyboard, or other unexpected input devices on Zune. 此外,在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 :-) 您显然在这里重新创建了一些基本控件……但是,当您在Zune上创建UI框架时,这就是生命:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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