注册本站  论坛  繁體中文

慧民电脑芯片级维修-电脑技巧
手机 | MP3 | MP4 | 显卡 | 主板 | 显示器 | 光存储 | 笔记本 | 网络设备 | 移动存储 | 数码相机
键鼠 | CPU | 音箱 | GPS | 电视 | 服务器 | 投影机 | 机箱电源 | 品牌电脑 | 办公打印 |
| 网站首页 | Cisco | Windows | Linux | Java | Dotnet | Oracle | 网页设计 | 平面设计 | 安全 | 软件应用 | 电脑维修 | 办公维修 |
您现在的位置: 电脑技巧 >> Dotnet >> C# >> Dotnet正文

C#开发智能手机游戏推箱子软件

文章来源:aspcool 作者:佚名 更新时间:2008-10-6 13:55:26 【 】 【加入收藏

  这是“使用 C# 开发智能手机软件:推箱子” 在这篇文章中,介绍 Window/ConfigDlg.cs 源程序文件。这个源程序文件包含 ConfigDlg 类,该类继承自 System.Windows.Forms.Form 类,表示推箱子的“配置”对话框。如下图所示:

下面是 Window/ConfigDlg.Designer.cs 的源程序的部分代码:

namespace Skyiv.Ben.PushBox.Window
{
partial class ConfigDlg
{
private void InitializeComponent()
{
// 注意:省略了一些代码

this.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK;
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
this.btnUp.Click += new System.EventHandler(this.btnUp_Click);
this.btnDown.Click += new System.EventHandler(this.btnDown_Click);
}

private System.Windows.Forms.ListBox lbxGroup;
private System.Windows.Forms.TextBox tbxGroup;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.Button btnUp;
private System.Windows.Forms.Button btnDown;
}
}

下面是 ConfigDlg.cs 的源程序代码:

1 using System;
2 using System.Windows.Forms;
3
4 namespace Skyiv.Ben.PushBox.Window
5 {
6 ///
7 /// “配置”对话框
8 ///
9 public partial class ConfigDlg : Form
10 {
11 public ConfigDlg(bool isTopMost)
12 {
13 InitializeComponent();
14 TopMost = isTopMost;
15 }
16
17 public string[] Groups
18 {
19 get
20 {
21 string[] groups = new string[lbxGroup.Items.Count];
22 for (int i = 0; i < lbxGroup.Items.Count; i++) groups[i] = lbxGroup.Items[i].ToString();
23 return groups;
24 }
25 set
26 {
27 if (value != null)
28 {
29 lbxGroup.BeginUpdate();
30 foreach (string group in value) lbxGroup.Items.Add(group);
31 lbxGroup.EndUpdate();
32 if (lbxGroup.Items.Count > 0) lbxGroup.SelectedIndex = 0;
33 }
34 }
35 }
36
37 private void btnAdd_Click(object sender, EventArgs e)
38 {
39 string s = tbxGroup.Text.Trim();
40 if (s.Length == 0) return;
41 int idx = lbxGroup.SelectedIndex;
42 if (idx < 0)
43 {
44 lbxGroup.Items.Add(s);
45 idx = lbxGroup.Items.Count - 1;
46 }
47 else lbxGroup.Items.Insert(idx, s);
48 lbxGroup.SelectedIndex = idx;
49 }
50
51 private void btnDelete_Click(object sender, EventArgs e)
52 {
53 int idx = lbxGroup.SelectedIndex;
54 if (idx < 0) return;
55 lbxGroup.Items.RemoveAt(idx);
56 if (lbxGroup.Items.Count <= 0) return;
57 lbxGroup.SelectedIndex = (idx < lbxGroup.Items.Count) ? idx : (idx - 1);
58 }
59
60 private void btnUp_Click(object sender, EventArgs e)
61 {
62 int idx = lbxGroup.SelectedIndex;
63 if (idx < 1) return;
64 lbxGroup.Items.Insert(idx - 1, lbxGroup.SelectedItem);
65 lbxGroup.Items.RemoveAt(idx + 1);
66 lbxGroup.SelectedIndex = idx - 1;
67 }
68
69 private void btnDown_Click(object sender, EventArgs e)
70 {
71 int idx = lbxGroup.SelectedIndex;
72 if (idx < 0    idx >= lbxGroup.Items.Count - 1) return;
73 lbxGroup.Items.Insert(idx + 2, lbxGroup.SelectedItem);
74 lbxGroup.Items.RemoveAt(idx);
75 lbxGroup.SelectedIndex = idx + 1;
76 }
77 }
78 }
这个类的代码是非常简单的,我就不多作解释了。

  • 上一篇Dotnet:

  • 下一篇Dotnet:
  • 最 新 热 门
     用VB.net2008编写屏幕抓捕程序
     用VB.net2008编写幻灯片程序
     VB.net2008创建发送与接收端程序
     在VB.NET中使用动态属性解析
     ASP.NET中图象处理过程详解
     解析VB.NET中的面向对象编程特征
     VisualC#中实现DB2数据库编程
     在VisualC#中用ListView显示数据记录
     用Dojo和Ajax创建可重用和可重新发布
     ASP.NET网络编程中经常用到的27个函数集
    最 新 推 荐
     利用C#实现超酷动态图像按钮
     C#开发智能手机游戏推箱子软件
     C# 索引器实战开发学习笔记
     编程中使用C#的BitmapData实例
     C# 制作以动画的方式显示图像
     如何构造一个C#语言的爬虫蜘蛛程序
     C#编程轻松实现对文件的操作技巧
     C#如何取硬件标志代码
     C#中将Big5繁体转换简体GB2312的代码
     C#线程池的实现
    相 关 文 章

    VisualC#中实现DB2数据库编程
    在VisualC#中用ListView显示数据记录
    利用C#实现超酷动态图像按钮
    C# 索引器实战开发学习笔记
    编程中使用C#的BitmapData实例
    C# 制作以动画的方式显示图像
    C#和Visual Basic的匿名类型区别
    Visual C#中实现DB2数据库的编程实例
    Visual C#实现DB2数据库的编程例子
    VC程序开发中定制对话框中的回车键

    | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告

     

    Copyright 2006-2008 pcjx.com All Rights Reserved
    电脑技巧 版权所有 粤ICP备06059145号 地图
    门市地址:广东省佛山市南海区黄岐黄海路133号
    本网站所有内容未经许可不得转载或做其他使用