Commit 44ae48b1 kwwwvagaa
2 个父辈 6c8e33f5 2bbb01e3
......@@ -22,7 +22,8 @@ namespace HZH_Controls.Controls
/// </summary>
[Description("点击节点事件"), Category("自定义")]
public event ClickNoteEvent ClickNote;
[Description("点击添加按钮事件"), Category("自定义")]
public event UCCalendarNotes_Week.AddNoteEvent AddClick;
private object dataSource;
List<NoteEntity> _dataSource;
......@@ -324,6 +325,12 @@ namespace HZH_Controls.Controls
return default(bool);
}
private void ucCalendarNotes_Week1_AddClick(DateTime beginTime)
{
if (AddClick != null)
AddClick(beginTime);
}
}
[Serializable]
public class NoteEntity
......
......@@ -42,6 +42,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
| 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 @@
// 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 @@
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 System.Windows.Forms.Panel panMain;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label lblClose;
private System.Windows.Forms.Label lblAdd;
}
}
......@@ -18,6 +18,7 @@ namespace HZH_Controls.Controls
/// <param name="note">节点</param>
/// <returns>是否刷新列表显示</returns>
public delegate bool ClickNoteEvent(NoteEntity note);
public delegate void AddNoteEvent(DateTime beginTime);
/// <summary>
/// 点击节点时间
/// </summary>
......@@ -26,6 +27,9 @@ namespace HZH_Controls.Controls
[Description("点击关闭按钮事件"), Category("自定义")]
public event EventHandler CloseClick;
[Description("点击添加按钮事件"), Category("自定义")]
public event AddNoteEvent AddClick;
private object dataSource;
List<NoteEntity> _dataSource;
......@@ -34,6 +38,7 @@ namespace HZH_Controls.Controls
/// 每个时间点的数据
/// </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;
......@@ -61,6 +66,8 @@ namespace HZH_Controls.Controls
}
[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 @@ namespace HZH_Controls.Controls
index++;
}
}
Rectangle rectAdd = new Rectangle(5, 20 + i * 50, 35, 30);
m_lstAddRect[i] = rectAdd;
}
}
......@@ -248,11 +258,11 @@ namespace HZH_Controls.Controls
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 @@ namespace HZH_Controls.Controls
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,19 @@ namespace HZH_Controls.Controls
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"));
panMain.Invalidate();
}
return;
}
}
foreach (var item in m_lstRects)
{
if (item.Value.Contains(e.Location))
......@@ -302,7 +330,7 @@ namespace HZH_Controls.Controls
}
ControlHelper.FreezeControl(panel1, false);
}
break;
return;
}
}
}
......@@ -329,5 +357,14 @@ namespace HZH_Controls.Controls
panMain.Focus();
}
}
private void lblAdd_Click(object sender, EventArgs e)
{
if (AddClick != null)
{
AddClick(DateTime.Parse(CurrentTime.ToString("yyyy-MM-dd")));
panMain.Invalidate();
}
}
}
}
......@@ -107,7 +107,7 @@ namespace HZH_Controls.Controls
btnKeybord.Visible = value;
}
}
[Description("获取或设置一个字符,该值指示文本框中的密码。")]
public char PasswordChar
{
......@@ -119,7 +119,7 @@ namespace HZH_Controls.Controls
{
txtInput.PasswordChar = value;
}
}
}
/// <summary>
/// 获取或设置控件显示的文字的字体。
/// </summary>
......@@ -509,6 +509,10 @@ namespace HZH_Controls.Controls
{
UCKeyBorderNum key = new UCKeyBorderNum();
m_frmAnchor = new Forms.FrmAnchor(this, key);
key.EnterClick += (a, b) =>
{
m_frmAnchor.Hide();
};
m_frmAnchor.VisibleChanged += (a, b) =>
{
if (m_frmAnchor.Visible)
......
此文件的差异太大,无法显示。
......@@ -32,7 +32,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>log.ico</ApplicationIcon>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
......@@ -1021,6 +1021,7 @@
<ItemGroup>
<Content Include="log.ico" />
<None Include="Resources\rowicon.png" />
<Content Include="logo.ico" />
<Content Include="UC\UCTestLiveCharts\Cartesian\FunnelChart\Resources\fingerprint.png" />
<Content Include="UC\UCTestLiveCharts\Cartesian\FunnelChart\Resources\user.png" />
<Content Include="UC\UCTestLiveCharts\Cartesian\FunnelChart\Resources\view.png" />
......
......@@ -28,50 +28,48 @@
/// </summary>
private void InitializeComponent()
{
this.ucCalendarNotes_Week1 = new HZH_Controls.Controls.UCCalendarNotes_Week();
this.ucCalendarNotes1 = new HZH_Controls.Controls.UCCalendarNotes();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// ucCalendarNotes_Week1
//
this.ucCalendarNotes_Week1.BackColor = System.Drawing.Color.White;
this.ucCalendarNotes_Week1.CurrentTime = new System.DateTime(2020, 8, 13, 22, 14, 47, 0);
this.ucCalendarNotes_Week1.DataSource = null;
this.ucCalendarNotes_Week1.Location = new System.Drawing.Point(530, 43);
this.ucCalendarNotes_Week1.Name = "ucCalendarNotes_Week1";
this.ucCalendarNotes_Week1.ShowCloseButton = true;
this.ucCalendarNotes_Week1.Size = new System.Drawing.Size(490, 405);
this.ucCalendarNotes_Week1.SplitLineColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
this.ucCalendarNotes_Week1.SplitTimeForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(153)))), ((int)(((byte)(153)))), ((int)(((byte)(153)))));
this.ucCalendarNotes_Week1.TabIndex = 3;
//
// ucCalendarNotes1
//
this.ucCalendarNotes1.BackColor = System.Drawing.Color.White;
this.ucCalendarNotes1.CurrentTime = new System.DateTime(2020, 8, 13, 0, 0, 0, 0);
this.ucCalendarNotes1.DataSource = null;
this.ucCalendarNotes1.Location = new System.Drawing.Point(28, 43);
this.ucCalendarNotes1.Location = new System.Drawing.Point(28, 3);
this.ucCalendarNotes1.Name = "ucCalendarNotes1";
this.ucCalendarNotes1.SelectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucCalendarNotes1.Size = new System.Drawing.Size(441, 346);
this.ucCalendarNotes1.Size = new System.Drawing.Size(722, 422);
this.ucCalendarNotes1.TabIndex = 2;
this.ucCalendarNotes1.TipColor = System.Drawing.Color.Green;
this.ucCalendarNotes1.ClickNote += new HZH_Controls.Controls.UCCalendarNotes.ClickNoteEvent(this.ucCalendarNotes1_ClickNote);
this.ucCalendarNotes1.AddClick += new HZH_Controls.Controls.UCCalendarNotes_Week.AddNoteEvent(this.ucCalendarNotes1_AddClick);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(26, 428);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(287, 12);
this.label1.TabIndex = 3;
this.label1.Text = "*测试模拟一次、每天、每周、每月、每年的计划处理\r\n";
//
// UCTestCalendarNotes
//
this.Controls.Add(this.ucCalendarNotes_Week1);
this.Controls.Add(this.label1);
this.Controls.Add(this.ucCalendarNotes1);
this.Name = "UCTestCalendarNotes";
this.Size = new System.Drawing.Size(1076, 620);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private HZH_Controls.Controls.UCCalendarNotes ucCalendarNotes1;
private HZH_Controls.Controls.UCCalendarNotes_Week ucCalendarNotes_Week1;
private System.Windows.Forms.Label label1;
}
}
......@@ -12,24 +12,170 @@ namespace Test.UC
{
public partial class UCTestCalendarNotes : UserControl
{
List<NoteEntity> dataSource = new List<NoteEntity>();
public UCTestCalendarNotes()
{
InitializeComponent();
List<NoteEntity> dataSource = new List<NoteEntity>();
dataSource.Add(new NoteEntity() { Key = "1", BeginTime = DateTime.Now, Title = "aaaa", Note = "agaweas" });
dataSource.Add(new NoteEntity() { Key = "1", BeginTime = DateTime.Now, EndTime = DateTime.Now.AddHours(1), Title = "bbbb", Note = "bbbbdfasdfg" });
dataSource.Add(new NoteEntity() { Key = "1", BeginTime = DateTime.Now.AddHours(-3), EndTime = DateTime.Now.AddHours(-1), Title = "ccc", Note = "bbbbdfasdfg" });
dataSource.Add(new NoteEntity() { Key = "1", BeginTime = DateTime.Now.AddDays(-1), EndTime = DateTime.Now, Title = "ddd", Note = "bbbbdfasdfg" });
this.ucCalendarNotes1.CurrentTime = DateTime.Now;
List<TestEntity> lstDB = LoadData();
dataSource = GetShowData(lstDB);
this.ucCalendarNotes1.DataSource = dataSource;
this.ucCalendarNotes_Week1.DataSource = dataSource;
this.ucCalendarNotes_Week1.CurrentTime = DateTime.Now;
}
//这个相当于数据库数据
List<TestEntity> DBSource = new List<TestEntity>();
//从数据库读取数据
private List<TestEntity> LoadData()
{
if (DBSource.Count <= 0)
{
DBSource.Add(new TestEntity() { ID = 1, Title = "一次循环测试1", Msg = "一次循环测试1内容", LoopType = 0, BeginDateTime = DateTime.Now.AddDays(-1), EndDateTime = DateTime.Now });
DBSource.Add(new TestEntity() { ID = 2, Title = "一次循环测试2", Msg = "一次循环测试2内容", LoopType = 0, BeginDateTime = DateTime.Now, EndDateTime = DateTime.Now.AddHours(2) });
DBSource.Add(new TestEntity() { ID = 3, Title = "每天循环测试1", Msg = "一次循环测试1内容", LoopType = 1, BeginDateTime = DateTime.Now.AddDays(-5), EndDateTime = DateTime.Now, LoopBeginTime = DateTime.Parse("2000-02-02 " + "05:05:05"), LoopDuration = new TimeSpan(1, 1, 1) });
DBSource.Add(new TestEntity() { ID = 4, Title = "每天循环测试2", Msg = "一次循环测试2内容", LoopType = 1, BeginDateTime = DateTime.Now, EndDateTime = DateTime.Now.AddDays(5), LoopBeginTime = DateTime.Parse("2000-02-02 " + "10:05:05"), LoopDuration = new TimeSpan(1, 1, 1) });
DBSource.Add(new TestEntity() { ID = 5, Title = "每周循环测试1", Msg = "一次循环测试1内容", LoopType = 2, BeginDateTime = DateTime.Now.AddDays(-5), EndDateTime = DateTime.Now, LoopBeginTime = DateTime.Parse("2000-02-02 " + "05:05:05"), LoopDuration = new TimeSpan(30, 1, 1), LoopDayIndex = 1 });
DBSource.Add(new TestEntity() { ID = 6, Title = "每周循环测试2", Msg = "一次循环测试2内容", LoopType = 2, BeginDateTime = DateTime.Now, EndDateTime = DateTime.Now.AddDays(5), LoopBeginTime = DateTime.Parse("2000-02-02 " + "10:05:05"), LoopDuration = new TimeSpan(10, 1, 1), LoopDayIndex = 2 });
//每月、每年的和每周类似
}
return DBSource;
}
private List<NoteEntity> GetShowData(List<TestEntity> dbSource)
{
List<NoteEntity> lst = new List<NoteEntity>();
foreach (var item in dbSource)
{
if (item.LoopType == 0)
{
lst.Add(new NoteEntity() { Title = item.Title, Note = item.Msg, BeginTime = item.BeginDateTime, EndTime = item.EndDateTime, DataSource = item });
}
else if (item.LoopType == 1)
{
DateTime thisDt = item.BeginDateTime;
while (thisDt <= item.EndDateTime)
{
DateTime noteBeginTime = DateTime.Parse(thisDt.ToString("yyyy-MM-dd") + " " + item.LoopBeginTime.ToString("HH:mm:ss"));
DateTime noteEndTime = noteBeginTime.Add(item.LoopDuration);
if (noteBeginTime >= item.BeginDateTime && noteEndTime < item.EndDateTime)//当天的计划 是否在整个计划范围时间内
{
lst.Add(new NoteEntity() { Title = item.Title, Note = item.Msg, BeginTime = noteBeginTime, EndTime = noteEndTime, DataSource = item });
}
thisDt = thisDt.AddDays(1);
}
}
else if (item.LoopType == 2)
{
DateTime thisDt = item.BeginDateTime;
int thisWeek = (int)item.BeginDateTime.DayOfWeek;
if (thisWeek < item.LoopDayIndex)
{
thisDt = item.BeginDateTime.AddDays(item.LoopDayIndex - thisWeek);
}
else if (thisWeek > item.LoopDayIndex)
{
thisDt = item.BeginDateTime.AddDays(item.LoopDayIndex - thisWeek + 7);
}
thisDt = DateTime.Parse(thisDt.ToString("yyyy-MM-dd"));
while (thisDt <= item.EndDateTime)
{
DateTime noteBeginTime = DateTime.Parse(thisDt.ToString("yyyy-MM-dd") + " " + item.LoopBeginTime.ToString("HH:mm:ss"));
DateTime noteEndTime = noteBeginTime.Add(item.LoopDuration);
if (noteBeginTime >= item.BeginDateTime && noteEndTime < item.EndDateTime)//是否在整个计划范围时间内
{
lst.Add(new NoteEntity() { Title = item.Title, Note = item.Msg, BeginTime = noteBeginTime, EndTime = noteEndTime, DataSource = item });
}
thisDt = thisDt.AddDays(7);
}
}
else if (item.LoopType == 3)
{
DateTime thisDt = item.BeginDateTime;
while (thisDt <= item.EndDateTime)
{
DateTime noteBeginTime = DateTime.Parse(thisDt.ToString("yyyy-MM-dd") + " " + item.LoopBeginTime.ToString("HH:mm:ss"));
DateTime noteEndTime = noteBeginTime.Add(item.LoopDuration);
if (noteBeginTime >= item.BeginDateTime && noteEndTime < item.EndDateTime)//是否在整个计划范围时间内
{
lst.Add(new NoteEntity() { Title = item.Title, Note = item.Msg, BeginTime = noteBeginTime, EndTime = noteEndTime, DataSource = item });
}
thisDt = thisDt.AddMonths(1);
}
}
//月,年类似周
}
return lst;
}
private bool ucCalendarNotes1_ClickNote(NoteEntity note)
{
MessageBox.Show("点击了备忘【"+note.Title+"】,你可以在这里对备忘编辑,修改,如果要修改,请返回true,否则返回false,如果要删除,删除后重新赋值ucCalendarNotes控件DataSource属性");
return default(bool);
TestEntity entity = (TestEntity)note.DataSource;
//对entity进行修改、删除操作
entity.Title += "修改1次;";
//加载数据
List<TestEntity> lstDB = LoadData();
//获取控件绑定数据
dataSource = GetShowData(lstDB);
this.ucCalendarNotes1.DataSource = dataSource;
MessageBox.Show("修改成功");
return true;
}
private void ucCalendarNotes1_AddClick(DateTime beginTime)
{
//弹出一个新增窗体,新增数据
//这一条模拟新增
DBSource.Add(new TestEntity() { ID = 111, Title = "每周循环测试111", Msg = "一次循环测试1内容", LoopType = 2, BeginDateTime = beginTime, EndDateTime = DateTime.Now.AddDays(20), LoopBeginTime = DateTime.Parse("2000-02-02 " + "01:05:05"), LoopDuration = new TimeSpan(5, 1, 1), LoopDayIndex = (int)beginTime.DayOfWeek });
//加载数据
List<TestEntity> lstDB = LoadData();
//获取控件绑定数据
dataSource = GetShowData(lstDB);
this.ucCalendarNotes1.DataSource = dataSource;
MessageBox.Show("添加成功");
}
}
public class TestEntity
{
public int ID { get; set; }
public string Title { get; set; }
public string Msg { get; set; }
/// <summary>
/// 0:一次 1:每天 2:每周 3:每月 4:每年
/// </summary>
public int LoopType { get; set; }
/// <summary>
/// 整个计划开始时间
/// </summary>
public DateTime BeginDateTime { get; set; }
/// <summary>
/// 整个计划结束时间
/// </summary>
public DateTime EndDateTime { get; set; }
/// <summary>
/// 每次循环开始时间,取时分秒部分
/// </summary>
public DateTime LoopBeginTime { get; set; }
/// <summary>
/// 每次循环时长,每天循环,次参数无效,
/// </summary>
public TimeSpan LoopDuration { get; set; }
/// <summary>
/// 每次循环的日期索引,
/// 每天循环,次参数无效,
/// 每周:星期几索引,周日=0...周六=6
/// 每月:天索引
/// 每年:天索引
/// </summary>
public int LoopDayIndex { get; set; }
}
}
......@@ -120,20 +120,20 @@
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="ucStep3.ImgCompleted" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAACvSURBVEhL7ZLRDYMwDEQzQkfoaB2hIzBCNygbMEpHSu/IGZEIRa1x+4F40kmWY78AIp0ci5zz
VWU8kI/IC7moFYfkRtwlFCETrQ2DRvxAQjmftmXUiB9I/HIMdb8fzxG/HOHyU62K1XnLV3KD9fI2rNVr
uWukDwaHMl8xX6JsyW9a/wwsrP9ng+L9cgOLj7LfxSc3KCieTfbJDYqKryJGblBYvDOxcoPin8lP/kBK
b1p1tZEYIvwEAAAAAElFTkSuQmCC
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAAK9JREFUSEvt
ktENgzAMRDNCR+hoHaEjMEI3KBswSkdK78gZkQhFrXH7gXjSSZZjvwAinRyLnPNVZTyQj8gLuagVh+RG
3CUUIROtDYNG/EBCOZ+2ZdSIH0j8cgx1vx/PEb8c4fJTrYrVectXcoP18jas1Wu5a6QPBocyXzFfomzJ
b1r/DCys/2eD4v1yA4uPst/FJzcoKJ5N9skNioqvIkZuUFi8M7Fyg+KfyU/+QEpvWnW1kRgi/AQAAAAA
SUVORK5CYII=
</value>
</data>
<data name="ucStep1.ImgCompleted" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAACvSURBVEhL7ZLRDYMwDEQzQkfoaB2hIzBCNygbMEpHSu/IGZEIRa1x+4F40kmWY78AIp0ci5zz
VWU8kI/IC7moFYfkRtwlFCETrQ2DRvxAQjmftmXUiB9I/HIMdb8fzxG/HOHyU62K1XnLV3KD9fI2rNVr
uWukDwaHMl8xX6JsyW9a/wwsrP9ng+L9cgOLj7LfxSc3KCieTfbJDYqKryJGblBYvDOxcoPin8lP/kBK
b1p1tZEYIvwEAAAAAElFTkSuQmCC
iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGPC/xhBQAAAK9JREFUSEvt
ktENgzAMRDNCR+hoHaEjMEI3KBswSkdK78gZkQhFrXH7gXjSSZZjvwAinRyLnPNVZTyQj8gLuagVh+RG
3CUUIROtDYNG/EBCOZ+2ZdSIH0j8cgx1vx/PEb8c4fJTrYrVectXcoP18jas1Wu5a6QPBocyXzFfomzJ
b1r/DCys/2eD4v1yA4uPst/FJzcoKJ5N9skNioqvIkZuUFi8M7Fyg+KfyU/+QEpvWnW1kRgi/AQAAAAA
SUVORK5CYII=
</value>
</data>
</root>
\ No newline at end of file
此文件类型无法预览
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!