diff --git a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.Designer.cs b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.Designer.cs index c3c4f19..97cfcbd 100644 --- a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.Designer.cs +++ b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.Designer.cs @@ -1308,6 +1308,7 @@ private void InitializeComponent() this.ucCalendarNotes_Week1.DataSource = null; this.ucCalendarNotes_Week1.Location = new System.Drawing.Point(1, 1); this.ucCalendarNotes_Week1.Name = "ucCalendarNotes_Week1"; + this.ucCalendarNotes_Week1.ShowAddButton = true; this.ucCalendarNotes_Week1.ShowCloseButton = true; this.ucCalendarNotes_Week1.Size = new System.Drawing.Size(439, 344); this.ucCalendarNotes_Week1.SplitLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153))))); @@ -1316,6 +1317,7 @@ private void InitializeComponent() this.ucCalendarNotes_Week1.Visible = false; this.ucCalendarNotes_Week1.ClickNote += new HZH_Controls.Controls.UCCalendarNotes_Week.ClickNoteEvent(this.ucCalendarNotes_Week1_ClickNote); this.ucCalendarNotes_Week1.CloseClick += new System.EventHandler(this.ucCalendarNotes_Week1_CloseClick); + this.ucCalendarNotes_Week1.AddClick += this.ucCalendarNotes_Week1_AddClick; // // btnMouthNext // diff --git a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.cs b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.cs index 7c25ff2..81b4f06 100644 --- a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.cs +++ b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes.cs @@ -22,7 +22,8 @@ public partial class UCCalendarNotes : UserControl /// [Description("点击节点事件"), Category("自定义")] public event ClickNoteEvent ClickNote; - + [Description("点击添加按钮事件"), Category("自定义")] + public event UCCalendarNotes_Week.AddNoteEvent AddClick; private object dataSource; List _dataSource; @@ -324,6 +325,12 @@ private bool ucCalendarNotes_Week1_ClickNote(NoteEntity note) return default(bool); } + private void ucCalendarNotes_Week1_AddClick(DateTime beginTime) + { + if (AddClick != null) + AddClick(beginTime); + } + } [Serializable] public class NoteEntity diff --git a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.Designer.cs b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.Designer.cs index bfacd82..6d18c4c 100644 --- a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.Designer.cs +++ b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.Designer.cs @@ -42,6 +42,7 @@ private void InitializeComponent() this.panMain = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel(); this.lblClose = new System.Windows.Forms.Label(); + this.lblAdd = new System.Windows.Forms.Label(); this.panWeek.SuspendLayout(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); @@ -75,16 +76,16 @@ private void InitializeComponent() this.panWeek.Name = "panWeek"; this.panWeek.RowCount = 1; this.panWeek.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.panWeek.Size = new System.Drawing.Size(438, 51); + this.panWeek.Size = new System.Drawing.Size(394, 51); this.panWeek.TabIndex = 3; // // lblRight // this.lblRight.Dock = System.Windows.Forms.DockStyle.Fill; this.lblRight.Font = new System.Drawing.Font("宋体", 15F); - this.lblRight.Location = new System.Drawing.Point(415, 0); + this.lblRight.Location = new System.Drawing.Point(373, 0); this.lblRight.Name = "lblRight"; - this.lblRight.Size = new System.Drawing.Size(20, 51); + this.lblRight.Size = new System.Drawing.Size(18, 51); this.lblRight.TabIndex = 8; this.lblRight.Text = "▶"; this.lblRight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -95,9 +96,9 @@ private void InitializeComponent() this.lblWeek_7.Dock = System.Windows.Forms.DockStyle.Fill; this.lblWeek_7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblWeek_7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); - this.lblWeek_7.Location = new System.Drawing.Point(359, 0); + this.lblWeek_7.Location = new System.Drawing.Point(323, 0); this.lblWeek_7.Name = "lblWeek_7"; - this.lblWeek_7.Size = new System.Drawing.Size(50, 51); + this.lblWeek_7.Size = new System.Drawing.Size(44, 51); this.lblWeek_7.TabIndex = 6; this.lblWeek_7.Text = "六"; this.lblWeek_7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -108,9 +109,9 @@ private void InitializeComponent() this.lblWeek_6.Dock = System.Windows.Forms.DockStyle.Fill; this.lblWeek_6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblWeek_6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); - this.lblWeek_6.Location = new System.Drawing.Point(303, 0); + this.lblWeek_6.Location = new System.Drawing.Point(273, 0); this.lblWeek_6.Name = "lblWeek_6"; - this.lblWeek_6.Size = new System.Drawing.Size(50, 51); + this.lblWeek_6.Size = new System.Drawing.Size(44, 51); this.lblWeek_6.TabIndex = 5; this.lblWeek_6.Text = "五"; this.lblWeek_6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -121,9 +122,9 @@ private void InitializeComponent() this.lblWeek_5.Dock = System.Windows.Forms.DockStyle.Fill; this.lblWeek_5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblWeek_5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); - this.lblWeek_5.Location = new System.Drawing.Point(247, 0); + this.lblWeek_5.Location = new System.Drawing.Point(223, 0); this.lblWeek_5.Name = "lblWeek_5"; - this.lblWeek_5.Size = new System.Drawing.Size(50, 51); + this.lblWeek_5.Size = new System.Drawing.Size(44, 51); this.lblWeek_5.TabIndex = 4; this.lblWeek_5.Text = "四"; this.lblWeek_5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -134,9 +135,9 @@ private void InitializeComponent() this.lblWeek_4.Dock = System.Windows.Forms.DockStyle.Fill; this.lblWeek_4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblWeek_4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); - this.lblWeek_4.Location = new System.Drawing.Point(191, 0); + this.lblWeek_4.Location = new System.Drawing.Point(173, 0); this.lblWeek_4.Name = "lblWeek_4"; - this.lblWeek_4.Size = new System.Drawing.Size(50, 51); + this.lblWeek_4.Size = new System.Drawing.Size(44, 51); this.lblWeek_4.TabIndex = 3; this.lblWeek_4.Text = "三"; this.lblWeek_4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -147,9 +148,9 @@ private void InitializeComponent() this.lblWeek_3.Dock = System.Windows.Forms.DockStyle.Fill; this.lblWeek_3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblWeek_3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); - this.lblWeek_3.Location = new System.Drawing.Point(135, 0); + this.lblWeek_3.Location = new System.Drawing.Point(123, 0); this.lblWeek_3.Name = "lblWeek_3"; - this.lblWeek_3.Size = new System.Drawing.Size(50, 51); + this.lblWeek_3.Size = new System.Drawing.Size(44, 51); this.lblWeek_3.TabIndex = 2; this.lblWeek_3.Text = "二"; this.lblWeek_3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -160,9 +161,9 @@ private void InitializeComponent() this.lblWeek_2.Dock = System.Windows.Forms.DockStyle.Fill; this.lblWeek_2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblWeek_2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); - this.lblWeek_2.Location = new System.Drawing.Point(79, 0); + this.lblWeek_2.Location = new System.Drawing.Point(73, 0); this.lblWeek_2.Name = "lblWeek_2"; - this.lblWeek_2.Size = new System.Drawing.Size(50, 51); + this.lblWeek_2.Size = new System.Drawing.Size(44, 51); this.lblWeek_2.TabIndex = 1; this.lblWeek_2.Text = "一"; this.lblWeek_2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -175,7 +176,7 @@ private void InitializeComponent() this.lblWeek_1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); this.lblWeek_1.Location = new System.Drawing.Point(23, 0); this.lblWeek_1.Name = "lblWeek_1"; - this.lblWeek_1.Size = new System.Drawing.Size(50, 51); + this.lblWeek_1.Size = new System.Drawing.Size(44, 51); this.lblWeek_1.TabIndex = 0; this.lblWeek_1.Text = "日"; this.lblWeek_1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -209,7 +210,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.panMain.Location = new System.Drawing.Point(0, 0); this.panMain.Name = "panMain"; - this.panMain.Size = new System.Drawing.Size(465, 1220); + this.panMain.Size = new System.Drawing.Size(482, 1220); this.panMain.TabIndex = 5; this.panMain.Paint += new System.Windows.Forms.PaintEventHandler(this.panMain_Paint); this.panMain.MouseClick += new System.Windows.Forms.MouseEventHandler(this.panMain_MouseClick); @@ -217,6 +218,7 @@ private void InitializeComponent() // panel2 // this.panel2.Controls.Add(this.panWeek); + this.panel2.Controls.Add(this.lblAdd); this.panel2.Controls.Add(this.lblClose); this.panel2.Dock = System.Windows.Forms.DockStyle.Top; this.panel2.Location = new System.Drawing.Point(0, 0); @@ -237,6 +239,19 @@ private void InitializeComponent() this.lblClose.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lblClose.Click += new System.EventHandler(this.lblClose_Click); // + // lblAdd + // + this.lblAdd.Dock = System.Windows.Forms.DockStyle.Right; + this.lblAdd.Font = new System.Drawing.Font("微软雅黑", 9F); + this.lblAdd.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59))))); + this.lblAdd.Location = new System.Drawing.Point(394, 0); + this.lblAdd.Name = "lblAdd"; + this.lblAdd.Size = new System.Drawing.Size(44, 51); + this.lblAdd.TabIndex = 8; + this.lblAdd.Text = "添加\r\n日程"; + this.lblAdd.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblAdd.Click += new System.EventHandler(this.lblAdd_Click); + // // UCCalendarNotes_Week // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -269,5 +284,6 @@ private void InitializeComponent() private System.Windows.Forms.Panel panMain; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Label lblClose; + private System.Windows.Forms.Label lblAdd; } } diff --git a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.cs b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.cs index 855bab8..07c538b 100644 --- a/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.cs +++ b/HZH_Controls/HZH_Controls/Controls/DateTime/UCCalendarNotes_Week.cs @@ -18,6 +18,7 @@ public partial class UCCalendarNotes_Week : UserControl /// 节点 /// 是否刷新列表显示 public delegate bool ClickNoteEvent(NoteEntity note); + public delegate void AddNoteEvent(DateTime beginTime); /// /// 点击节点时间 /// @@ -26,6 +27,9 @@ public partial class UCCalendarNotes_Week : UserControl [Description("点击关闭按钮事件"), Category("自定义")] public event EventHandler CloseClick; + + [Description("点击添加按钮事件"), Category("自定义")] + public event AddNoteEvent AddClick; private object dataSource; List _dataSource; @@ -34,6 +38,7 @@ public partial class UCCalendarNotes_Week : UserControl /// 每个时间点的数据 /// Dictionary> m_lstHourSource = new Dictionary>(); + Dictionary m_lstAddRect = new Dictionary(); Dictionary m_lstRects = new Dictionary(); int maxSplit = 1; int splitWidth = 1; @@ -61,6 +66,8 @@ public object DataSource } [Description("是否显示关闭按钮"), Category("自定义")] public bool ShowCloseButton { get { return lblClose.Visible; } set { lblClose.Visible = value; } } + [Description("是否显示添加按钮"), Category("自定义")] + public bool ShowAddButton { get { return lblAdd.Visible; } set { lblAdd.Visible = value; } } DateTime m_dt = DateTime.Now; [Description("当前日期"), Category("自定义")] @@ -192,6 +199,9 @@ private void CheckCom() index++; } } + + Rectangle rectAdd = new Rectangle(5, 20 + i * 50, 35, 30); + m_lstAddRect[i] = rectAdd; } } @@ -248,11 +258,11 @@ private void panMain_Paint(object sender, PaintEventArgs e) for (int i = 0; i < 24; i++) { g.DrawString(i.ToString().PadLeft(2, '0') + ":00", new Font("Arial Unicode MS", 9), new SolidBrush(splitTimeForeColor), new PointF(5, 2 + i * 50)); - g.DrawLine(new Pen(new SolidBrush(splitLineColor), 1), new Point(40, 10 + i * 50), new Point(panMain.Width - 10, 10 + i * 50)); + g.DrawLine(new Pen(new SolidBrush(splitLineColor), 1), new Point(40, 10 + i * 50), new Point(panMain.Width, 10 + i * 50)); } g.DrawString("00:00", new Font("Arial Unicode MS", 9), new SolidBrush(splitTimeForeColor), new PointF(5, 2 + 24 * 50)); - g.DrawLine(new Pen(new SolidBrush(splitLineColor), 1), new Point(40, 10 + 24 * 50), new Point(panMain.Width - 10, 10 + 24 * 50)); + g.DrawLine(new Pen(new SolidBrush(splitLineColor), 1), new Point(40, 10 + 24 * 50), new Point(panMain.Width, 10 + 24 * 50)); foreach (var item in m_lstRects) { @@ -260,6 +270,11 @@ private void panMain_Paint(object sender, PaintEventArgs e) g.DrawLine(new Pen(new SolidBrush(item.Key.NoteLeftLineColor), 2), new Point(item.Value.Left + 1, item.Value.Top + 2), new Point(item.Value.Left + 1, item.Value.Bottom - 2)); g.DrawString(item.Key.Title, new Font("微软雅黑", 9), new SolidBrush(item.Key.NoteForeColor), new Rectangle(item.Value.Left + 4, item.Value.Top + 1, item.Value.Width - 4, item.Value.Height - 1)); } + + foreach (var item in m_lstAddRect) + { + g.DrawString("+", new Font("微软雅黑", 15), new SolidBrush(splitTimeForeColor), item.Value, new StringFormat() { Alignment= StringAlignment.Center, LineAlignment= StringAlignment.Center}); + } } private void lblLeft_MouseClick(object sender, MouseEventArgs e) @@ -283,6 +298,16 @@ private void panMain_MouseClick(object sender, MouseEventArgs e) if (e.Button == System.Windows.Forms.MouseButtons.Left) { + foreach (var item in m_lstAddRect) + { + if (item.Value.Contains(e.Location)) + { + if (AddClick != null) + AddClick(DateTime.Parse(CurrentTime.ToString("yyyy-MM-dd") + " " + item.Key + ":00:00")); + return; + } + } + foreach (var item in m_lstRects) { if (item.Value.Contains(e.Location)) @@ -302,7 +327,7 @@ private void panMain_MouseClick(object sender, MouseEventArgs e) } ControlHelper.FreezeControl(panel1, false); } - break; + return; } } } @@ -329,5 +354,11 @@ private void UCCalendarNotes_Week_VisibleChanged(object sender, EventArgs e) panMain.Focus(); } } + + private void lblAdd_Click(object sender, EventArgs e) + { + if (AddClick != null) + AddClick(DateTime.Parse(CurrentTime.ToString("yyyy-MM-dd"))); + } } }