这是“使用 C# 开发智能手机软件:推箱子”
系列文章的第十五篇。在这篇文章中,介绍 Window/OptionDlg.cs 源程序文件。这个源程序文件包含 OptionDlg
类,该类继承自 System.Windows.Forms.Form 类,表示推箱子的“选项”对话框。如下图所示:
下面是 Window/OptionDlg.Designer.cs 源程序的部分代码:
下面是 OptionDlg.cs 的源程序代码:
这个类的代码是非常简单的,我就不多作解释了。她只是一个用户界面,实际工作在 Skyiv.Ben.PushBox.Common.ConfigFile 类中完成,请参见:“使用 C# 开发智能手机软件:推箱子(九)”。
上一篇:使用 C# 开发智能手机软件:推箱子(十四)
下一篇:使用 C# 开发智能手机软件:推箱子(十六)
返回目录
下面是 Window/OptionDlg.Designer.cs 源程序的部分代码:
namespace Skyiv.Ben.PushBox.Window
{
partial class OptionDlg
{
// 这里省略了一些代码
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TrackBar tkbStepSpeed;
private System.Windows.Forms.CheckBox chkSave;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TrackBar tkbReplaySpeed;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown nudMaxLevelSize;
private System.Windows.Forms.TextBox tbxStepSpeed;
private System.Windows.Forms.TextBox tbxReplaySpeed;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
}
}
{
partial class OptionDlg
{
// 这里省略了一些代码
private System.Windows.Forms.Button btnOk;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TrackBar tkbStepSpeed;
private System.Windows.Forms.CheckBox chkSave;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TrackBar tkbReplaySpeed;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown nudMaxLevelSize;
private System.Windows.Forms.TextBox tbxStepSpeed;
private System.Windows.Forms.TextBox tbxReplaySpeed;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
}
}
下面是 OptionDlg.cs 的源程序代码:
1 using System;
2 using System.Windows.Forms;
3 using Skyiv.Ben.PushBox.Common;
4
5 namespace Skyiv.Ben.PushBox.Window
6 {
7 /// <summary>
8 /// “选项”对话框
9 /// </summary>
10 public partial class OptionDlg : Form
11 {
12 public bool IsSave { get { return chkSave.Checked; } set { chkSave.Checked = value; } }
13 public int MaxLevelSize { get { return (int)nudMaxLevelSize.Value; } set { nudMaxLevelSize.Value = value; } }
14
15 public int StepDelay
16 {
17 get
18 {
19 return Pub.MaxDelay - tkbStepSpeed.Value;
20 }
21 set
22 {
23 tkbStepSpeed.Maximum = Pub.MaxDelay;
24 tkbStepSpeed.TickFrequency = tkbStepSpeed.LargeChange = 100;
25 tkbStepSpeed.Value = Pub.MaxDelay - value;
26 }
27 }
28
29 public int ReplayDelay
30 {
31 get
32 {
33 return Pub.MaxDelay - tkbReplaySpeed.Value;
34 }
35 set
36 {
37 tkbReplaySpeed.Maximum = Pub.MaxDelay;
38 tkbReplaySpeed.TickFrequency = tkbReplaySpeed.LargeChange = 100;
39 tkbReplaySpeed.Value = Pub.MaxDelay - value;
40 }
41 }
42
43 public OptionDlg(bool isTopMost)
44 {
45 InitializeComponent();
46 TopMost = isTopMost;
47 }
48
49 private void tkbStepSpeed_ValueChanged(object sender, EventArgs e)
50 {
51 tbxStepSpeed.Text = StepDelay.ToString();
52 }
53
54 private void tkbReplaySpeed_ValueChanged(object sender, EventArgs e)
55 {
56 tbxReplaySpeed.Text = ReplayDelay.ToString();
57 }
58 }
59 }
2 using System.Windows.Forms;
3 using Skyiv.Ben.PushBox.Common;
4
5 namespace Skyiv.Ben.PushBox.Window
6 {
7 /// <summary>
8 /// “选项”对话框
9 /// </summary>
10 public partial class OptionDlg : Form
11 {
12 public bool IsSave { get { return chkSave.Checked; } set { chkSave.Checked = value; } }
13 public int MaxLevelSize { get { return (int)nudMaxLevelSize.Value; } set { nudMaxLevelSize.Value = value; } }
14
15 public int StepDelay
16 {
17 get
18 {
19 return Pub.MaxDelay - tkbStepSpeed.Value;
20 }
21 set
22 {
23 tkbStepSpeed.Maximum = Pub.MaxDelay;
24 tkbStepSpeed.TickFrequency = tkbStepSpeed.LargeChange = 100;
25 tkbStepSpeed.Value = Pub.MaxDelay - value;
26 }
27 }
28
29 public int ReplayDelay
30 {
31 get
32 {
33 return Pub.MaxDelay - tkbReplaySpeed.Value;
34 }
35 set
36 {
37 tkbReplaySpeed.Maximum = Pub.MaxDelay;
38 tkbReplaySpeed.TickFrequency = tkbReplaySpeed.LargeChange = 100;
39 tkbReplaySpeed.Value = Pub.MaxDelay - value;
40 }
41 }
42
43 public OptionDlg(bool isTopMost)
44 {
45 InitializeComponent();
46 TopMost = isTopMost;
47 }
48
49 private void tkbStepSpeed_ValueChanged(object sender, EventArgs e)
50 {
51 tbxStepSpeed.Text = StepDelay.ToString();
52 }
53
54 private void tkbReplaySpeed_ValueChanged(object sender, EventArgs e)
55 {
56 tbxReplaySpeed.Text = ReplayDelay.ToString();
57 }
58 }
59 }
这个类的代码是非常简单的,我就不多作解释了。她只是一个用户界面,实际工作在 Skyiv.Ben.PushBox.Common.ConfigFile 类中完成,请参见:“使用 C# 开发智能手机软件:推箱子(九)”。
上一篇:使用 C# 开发智能手机软件:推箱子(十四)
下一篇:使用 C# 开发智能手机软件:推箱子(十六)
返回目录