This commit is contained in:
77
source/GZWFControls/TimePicker.cs
Normal file
77
source/GZWFControls/TimePicker.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace GZTW.WinForm.Controls
|
||||
{
|
||||
public partial class TimePicker : Form
|
||||
{
|
||||
GZDateTimePicker _gzdt = null;
|
||||
public TimePicker(GZDateTimePicker GZDateTimePickerControl)
|
||||
{
|
||||
_gzdt = GZDateTimePickerControl;
|
||||
InitializeComponent();
|
||||
this.Location = MousePosition;
|
||||
DrawButtons();
|
||||
this.Text = _gzdt.DateTime.ToShortTimeString();
|
||||
}
|
||||
|
||||
|
||||
private void DrawButtons()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
int nColumnWidth = 85;
|
||||
int nRowHeight = 29;
|
||||
int nButtonWidth = 75;
|
||||
int nButtonHeight = 23;
|
||||
int nNumberOfRows=14;
|
||||
int nNumberOfColumns=4;
|
||||
|
||||
DateTime dt=new DateTime(DateTime.Now.Year,DateTime.Now.Month, DateTime.Now.Day,8,0,0);
|
||||
|
||||
for(int row=0;row < nNumberOfRows; row ++)
|
||||
{
|
||||
for(int column=0;column < nNumberOfColumns; column++)
|
||||
{
|
||||
Button b = new Button();
|
||||
b.FlatAppearance.BorderSize = 0;
|
||||
b.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
b.Location = new System.Drawing.Point(column*nColumnWidth, row*nRowHeight);
|
||||
b.Name = "btnRow" + row.ToString() + "Column" + column.ToString(); ;
|
||||
b.Size = new System.Drawing.Size(nButtonWidth, nButtonHeight);
|
||||
b.TabIndex = 0;
|
||||
b.Text = dt.ToShortTimeString();
|
||||
b.UseVisualStyleBackColor = true;
|
||||
b.Tag = dt;
|
||||
b.Click += new System.EventHandler(this.btn_Click);
|
||||
Controls.Add(b);
|
||||
dt = dt.AddMinutes(15);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
||||
private void btn_Click(object sender, EventArgs e)
|
||||
{
|
||||
DateTime dtOld = DateTime.Today;
|
||||
|
||||
if (_gzdt.Value != null)
|
||||
dtOld = _gzdt.DateTime;
|
||||
|
||||
DateTime dt=(DateTime)((Button)sender).Tag;
|
||||
DateTime dtNew = new DateTime(dtOld.Year,dtOld.Month,dtOld.Day,dt.Hour,dt.Minute,0);
|
||||
_gzdt.Value = dtNew;
|
||||
this.Close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user