📄 formmain.cs
字号:
//-----------------------------------------------------------------------------
// Code from _Programming the .NET Compact Framework with C#_
// and _Programming the .NET Compact Framework with VB_
// (c) Copyright 2002-2004 Paul Yao and David Durant.
// All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
/// <summary>
/// Summary description for FormMain.
/// </summary>
public class FormMain : System.Windows.Forms.Form
{
internal System.Windows.Forms.Button cmdCancel;
internal System.Windows.Forms.Button cmdAddTask;
internal System.Windows.Forms.ComboBox cboxTasks;
internal System.Windows.Forms.TextBox txtTaskActual;
internal System.Windows.Forms.TextBox txtTaskEstimated;
internal System.Windows.Forms.TextBox txtTaskName;
internal System.Windows.Forms.TextBox txtTaskStart;
internal System.Windows.Forms.TextBox txtTaskEnd;
internal System.Windows.Forms.TextBox txtTaskNo;
internal System.Windows.Forms.Label lblProjEnd;
internal System.Windows.Forms.Label lblProjName;
internal System.Windows.Forms.Button cmdNewTask;
internal System.Windows.Forms.Label lblProjStart;
private System.Windows.Forms.MainMenu mainMenu1;
public FormMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.cmdCancel = new System.Windows.Forms.Button();
this.cmdAddTask = new System.Windows.Forms.Button();
this.cboxTasks = new System.Windows.Forms.ComboBox();
this.txtTaskActual = new System.Windows.Forms.TextBox();
this.txtTaskEstimated = new System.Windows.Forms.TextBox();
this.txtTaskName = new System.Windows.Forms.TextBox();
this.txtTaskStart = new System.Windows.Forms.TextBox();
this.txtTaskEnd = new System.Windows.Forms.TextBox();
this.txtTaskNo = new System.Windows.Forms.TextBox();
this.lblProjEnd = new System.Windows.Forms.Label();
this.lblProjName = new System.Windows.Forms.Label();
this.cmdNewTask = new System.Windows.Forms.Button();
this.lblProjStart = new System.Windows.Forms.Label();
//
// cmdCancel
//
this.cmdCancel.Location = new System.Drawing.Point(164, 237);
this.cmdCancel.Text = "&Cancel";
this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
//
// cmdAddTask
//
this.cmdAddTask.Location = new System.Drawing.Point(4, 237);
this.cmdAddTask.Text = "Add &Task";
this.cmdAddTask.Click += new System.EventHandler(this.cmdAddTask_Click);
//
// cboxTasks
//
this.cboxTasks.Location = new System.Drawing.Point(12, 197);
this.cboxTasks.Size = new System.Drawing.Size(224, 22);
this.cboxTasks.SelectedIndexChanged += new System.EventHandler(this.cboxTasks_SelectedIndexChanged);
//
// txtTaskActual
//
this.txtTaskActual.Location = new System.Drawing.Point(204, 165);
this.txtTaskActual.Size = new System.Drawing.Size(32, 22);
this.txtTaskActual.Text = "";
//
// txtTaskEstimated
//
this.txtTaskEstimated.Location = new System.Drawing.Point(164, 165);
this.txtTaskEstimated.Size = new System.Drawing.Size(32, 22);
this.txtTaskEstimated.Text = "";
//
// txtTaskName
//
this.txtTaskName.Location = new System.Drawing.Point(12, 165);
this.txtTaskName.Size = new System.Drawing.Size(144, 22);
this.txtTaskName.Text = "";
//
// txtTaskStart
//
this.txtTaskStart.Location = new System.Drawing.Point(100, 133);
this.txtTaskStart.Size = new System.Drawing.Size(64, 22);
this.txtTaskStart.Text = "";
this.txtTaskStart.Validating += new System.ComponentModel.CancelEventHandler(this.txtTaskDates_Validating);
//
// txtTaskEnd
//
this.txtTaskEnd.Location = new System.Drawing.Point(172, 133);
this.txtTaskEnd.Size = new System.Drawing.Size(64, 22);
this.txtTaskEnd.Text = "";
this.txtTaskEnd.Validating += new System.ComponentModel.CancelEventHandler(this.txtTaskDates_Validating);
//
// txtTaskNo
//
this.txtTaskNo.Location = new System.Drawing.Point(12, 133);
this.txtTaskNo.Size = new System.Drawing.Size(40, 22);
this.txtTaskNo.Text = "";
//
// lblProjEnd
//
this.lblProjEnd.Location = new System.Drawing.Point(196, 13);
this.lblProjEnd.Size = new System.Drawing.Size(40, 20);
this.lblProjEnd.TextChanged += new System.EventHandler(this.lblProjEnd_TextChanged);
//
// lblProjName
//
this.lblProjName.Location = new System.Drawing.Point(20, 13);
this.lblProjName.Size = new System.Drawing.Size(120, 20);
//
// cmdNewTask
//
this.cmdNewTask.Location = new System.Drawing.Point(84, 237);
this.cmdNewTask.Text = "New &Task";
this.cmdNewTask.Click += new System.EventHandler(this.cmdNewTask_Click);
//
// lblProjStart
//
this.lblProjStart.Location = new System.Drawing.Point(148, 13);
this.lblProjStart.Size = new System.Drawing.Size(40, 20);
//
// FormMain
//
this.Controls.Add(this.cmdCancel);
this.Controls.Add(this.cmdAddTask);
this.Controls.Add(this.cboxTasks);
this.Controls.Add(this.txtTaskActual);
this.Controls.Add(this.txtTaskEstimated);
this.Controls.Add(this.txtTaskName);
this.Controls.Add(this.txtTaskStart);
this.Controls.Add(this.txtTaskEnd);
this.Controls.Add(this.txtTaskNo);
this.Controls.Add(this.lblProjEnd);
this.Controls.Add(this.lblProjName);
this.Controls.Add(this.cmdNewTask);
this.Controls.Add(this.lblProjStart);
this.Menu = this.mainMenu1;
this.Text = "Time Tracker";
this.Load += new System.EventHandler(this.FormMain_Load);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new FormMain());
}
#region Database struct Simulated
private struct Project
{
public string strProjNo;
public string strProjName;
public DateTime dateProjStart;
public DateTime dateProjEnd;
public int ctProjTasks;
public string strProjComments;
public Project( string strNo, string strName,
DateTime dateStart, DateTime dateEnd,
int ctTasks, string strComments)
{
strProjNo = strNo;
strProjName = strName;
dateProjStart = dateStart;
dateProjEnd = dateEnd;
ctProjTasks = ctTasks;
strProjComments = strComments;
}
}
private struct Task
{
private string m_strTaskIdent;
private string m_strTaskName;
public DateTime dateTaskStart;
public DateTime dateTaskEnd;
public int durTaskEstimated; // In hours;
public int durTaskActual; // In hours;
public string strTaskComments;
public string strTaskIdent
{
get
{
return m_strTaskIdent;
}
set
{
m_strTaskIdent = value;
}
}
public string strTaskName
{
get
{
return m_strTaskName;
}
set
{
m_strTaskName = value;
}
}
public Task( string strNo, string strName,
DateTime dateStart, DateTime dateEnd,
int durEstimated, int durActual,
string strComments)
{
m_strTaskIdent = strNo;
m_strTaskName = strName;
dateTaskStart = dateStart;
dateTaskEnd = dateEnd;
durTaskEstimated = durEstimated;
durTaskActual = durActual;
strTaskComments = strComments;
}
}
#endregion
private Project theProject;
private ArrayList alTasks = new ArrayList();
// A control to be created later
private TextBox txtTaskComments;
// The index number of the previous task. We will
// need to know it in case the users cancels out
// during task creation.
private int ixTaskPrev;
private void FormMain_Load(object sender, System.EventArgs e)
{
// set { the initial state of the controls.
InitControlState();
// Load and display a project.
if ( LoadProject(42) )
{
DisplayProject();
}
else
{
this.Close();
}
}
private void cmdNewTask_Click(object sender,
System.EventArgs e)
{
lblProjName.Enabled = !lblProjName.Enabled;
// Save the index number of the previous task. We will
// need to know it in case the users cancels out
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -