Windows Phone 7 Dev (WP7 开发其实很简单) 微软商店上架应用<<猜数字>>,适合初学者作为小练习,但是也很耗时
Windows Phone开发的书籍,正如iOS开发一样,是那么的少,苹果有斯坦福的公开课,而WP7也有她的白胡子老头的<<WP7 四天速成教程>>,在看了他的教程他所谓的四天中的不到两天之后,我写了这个简单的<<猜数字>>应用,这个程序就是在折腾着字符串,应用地址(http://windowsphone.com/s?appid=e8cc529e-1672-494a-b8a3-8c11aa531e59)
创建一个最简单程序,它就好像是HELLO WORLD一样,随意没事儿的时候,可以自己写着玩,我们拖控件,之后写事件,声明4个变量用于得到4个随机数字,
第一段代码,用于按键"1"的事件:
[csharp]
<span style="font-size:24px;">private void button1_Click(object sender, RoutedEventArgs e)
{
if(textBlockNow.Text.Length<4){
int tmp = 0;
for (int i = 0; i < textBlockNow.Text.Length; i++) {
if (textBlockNow.Text.ElementAt(i).ToString().CompareTo("1") == 0) {
tmp++;
}
} if (tmp == 0)
{
textBlockNow.Text = textBlockNow.Text + "1";
}
}
}</span>
<span style="font-size:24px;">private void button1_Click(object sender, RoutedEventArgs e)
{
if(textBlockNow.Text.Length<4){
int tmp = 0;
for (int i = 0; i < textBlockNow.Text.Length; i++) {
if (textBlockNow.Text.ElementAt(i).ToString().CompareTo("1") == 0) {
tmp++;
}
} if (tmp == 0)
{
textBlockNow.Text = textBlockNow.Text + "1";
}
}
}</span>
第二段代码,用于按键"确定"的事件,我们有8行来显示输入数据及其它的结果,如果第一行有正确的内容,那么向第二行中添加数据,以此类推,当输入正确之后,之后的行中显示"WINNER":
[csharp]
<span style="font-size:24px;">if (textBlockNow.Text.Length == 4) {
if (textBlockshow1.Text.Length == 0)
{
textBlockshow1.Text = textBlockNow.Text;
textBlockNow.Text = "";
if ((test(textBlockshow1.Text.ToString())).CompareTo("4A0B") == 0)
{
textBlockshow2.Text = "WINNER";
textBlockshow3.Text = "WINNER";
textBlockshow4.Text = "WINNER";
textBlockshow5.Text = "WINNER";
textBlockshow6.Text = "WINNER";
textBlockshow7.Text = "WINNER";
textBlockshow8.Text = "WINNER";
textBlockwin.Text = "YOU ARE WINNER!!!!!";
}
textBlockshow1.Text = textBlockshow1.Text + "......" + test(textBlockshow1.Text.ToString());
}
else if (textBlockshow2.Text.Length == 0)
{
textBlockshow2.Text = textBlockNow.Text;
&nb
补充:移动开发 , Windows Phone ,