📄 noteform.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MyNote
{
public partial class NoteForm : Form
{
//public event EventHandler RestTask;
public NoteForm(MyNotes myNotes,NoteFormStyle NFS)
{
InitializeComponent();
mNSF = NFS;
mMyNotes = myNotes;
mMyNotes.Alert += new EventHandler(this.AlertToPerson);
//timer2.Interval = 1000 * 60 * 10;
}
private MyNotes mMyNotes;
public List<MyEvent> Notes;
public void AlertToPerson(object sender, System.EventArgs e)
{
//MessageBox.Show("AlertToPerson");
//this.Show();
label1.Text = mMyNotes.mPerson.mName + ",以下是您的今天的日程安排:(" + DateTime.Now.ToShortDateString() + ")";
this.listBox1.Items.Clear();
int i;
for (i = 0; i < mMyNotes.mEvents.Length; i++)
{
if ((mMyNotes.mEvents[i].mDatetime.Date.CompareTo(DateTime.Now.Date) == 0) && (mMyNotes.mEvents[i].mState==false))
{
listBox1.Items.Add(mMyNotes.mEvents[i].mContent);
}
}
}
protected NoteFormStyle mNSF;
private void NoteForm_Load(object sender, EventArgs e)
{
timer2.Interval = 1000 * 10;
timer2.Start();
//MessageBox.Show("NoteForm_Load");
label1.Text = mMyNotes.mPerson.mName + ",以下是您的今天的日程安排:(" + DateTime.Now.ToShortDateString() + ")";
this.listBox1.Items.Clear();
int i;
for (i = 0; i < mMyNotes.mEvents.Length; i++)
{
if ((mMyNotes.mEvents[i].mDatetime.Date.CompareTo(DateTime.Now.Date) == 0) && (mMyNotes.mDoneWork[i] == false))
{
listBox1.Items.Add(mMyNotes.mEvents[i].mContent);
}
}
this.ShowInTaskbar = false;
this.Visible = false;
switch (mNSF)
{
case NoteFormStyle.Fade:
{
this.StartPosition = FormStartPosition.CenterScreen;
this.Opacity = 0;
timer1.Start();
this.WindowState = FormWindowState.Normal;
this.Visible = true;
break;
}
case NoteFormStyle.Popup:
{
this.StartPosition = FormStartPosition.Manual;
this.Top = Screen.PrimaryScreen.Bounds.Height;
this.Left = Screen.PrimaryScreen.Bounds.Width - this.Width - 2;
timer1.Start();
this.WindowState = FormWindowState.Normal;
this.Visible = true;
break;
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
switch (mNSF)
{
case NoteFormStyle.Fade:
{
if (this.Opacity < 0.98)
//MessageBox.Show("Opacity:" + this.Opacity.ToString());
this.Opacity += 0.01;
else
timer1.Stop();
break;
}
case NoteFormStyle.Popup:
{
if (this.Top >= Screen.PrimaryScreen.Bounds.Height - this.Height-23)
this.Top -= 10;
else
timer1.Stop();
break;
}
}
}
private void timer2_Tick(object sender, EventArgs e)
{
//MessageBox.Show("timer2_Tick");
mMyNotes.NewDate();
}
private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (listBox1.SelectedIndex >= 0)
{
DialogResult dr = MessageBox.Show("任务:" + (string)listBox1.Items[listBox1.SelectedIndex] + " 完成了吗?", "删除完成的任务", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
int i;
for (i = 0; i < mMyNotes.mEvents.Length; i++)
{
if ((mMyNotes.mEvents[i].mContent == (string)listBox1.Items[listBox1.SelectedIndex])
&& (mMyNotes.mDoneWork[i] == false)
&& (mMyNotes.mEvents[i].mDatetime.Date.CompareTo(DateTime.Now.Date) == 0))
{
mMyNotes.mDoneWork[i] = true;
//MessageBox.Show("mMyNotes.mDoneWork[" + i.ToString() + "]=" + mMyNotes.mDoneWork[i].ToString());
MessageBox.Show("已删除任务'" + (string)listBox1.Items[listBox1.SelectedIndex] + "'!", "删除任务确定", MessageBoxButtons.OK, MessageBoxIcon.Information);
listBox1.Items.RemoveAt(listBox1.SelectedIndex);
if (listBox1.Items.Count == 0)
{
label1.Text = mMyNotes.mPerson.mName + ",恭喜您已经完成了今天的所有任务!" + DateTime.Now.ToShortDateString();
}
break;
}
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -