Skip to content

Commit

Permalink
修改日历备忘控件
Browse files Browse the repository at this point in the history
  • Loading branch information
kwwwvagaa committed Aug 18, 2020
1 parent 969d38a commit 8818602
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 21 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public partial class UCCalendarNotes : UserControl
/// </summary>
[Description("点击节点事件"), Category("自定义")]
public event ClickNoteEvent ClickNote;

[Description("点击添加按钮事件"), Category("自定义")]
public event UCCalendarNotes_Week.AddNoteEvent AddClick;
private object dataSource;

List<NoteEntity> _dataSource;
Expand Down Expand Up @@ -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
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public partial class UCCalendarNotes_Week : UserControl
/// <param name="note">节点</param>
/// <returns>是否刷新列表显示</returns>
public delegate bool ClickNoteEvent(NoteEntity note);
public delegate void AddNoteEvent(DateTime beginTime);
/// <summary>
/// 点击节点时间
/// </summary>
Expand All @@ -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<NoteEntity> _dataSource;
Expand All @@ -34,6 +38,7 @@ public partial class UCCalendarNotes_Week : UserControl
/// 每个时间点的数据
/// </summary>
Dictionary<int, List<NoteEntity>> m_lstHourSource = new Dictionary<int, List<NoteEntity>>();
Dictionary<int, Rectangle> m_lstAddRect = new Dictionary<int, Rectangle>();
Dictionary<NoteEntity, Rectangle> m_lstRects = new Dictionary<NoteEntity, Rectangle>();
int maxSplit = 1;
int splitWidth = 1;
Expand Down Expand Up @@ -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("自定义")]
Expand Down Expand Up @@ -192,6 +199,9 @@ private void CheckCom()
index++;
}
}

Rectangle rectAdd = new Rectangle(5, 20 + i * 50, 35, 30);
m_lstAddRect[i] = rectAdd;
}
}

Expand Down Expand Up @@ -248,18 +258,23 @@ 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)
{
g.FillPath(new SolidBrush(item.Key.NoteColor), item.Value.CreateRoundedRectanglePath(5));
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)
Expand All @@ -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))
Expand All @@ -302,7 +327,7 @@ private void panMain_MouseClick(object sender, MouseEventArgs e)
}
ControlHelper.FreezeControl(panel1, false);
}
break;
return;
}
}
}
Expand All @@ -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")));
}
}
}

0 comments on commit 8818602

Please sign in to comment.