Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace CheckList_Reminders
- {
- public partial class Form1 : Form
- {
- ToolTip t1 = new ToolTip();
- int TogMove;
- int MValX;
- int MValY;
- bool addToolShow = false;
- string newList;
- string dateNow;
- int todayListN, TomorrowListN;
- bool timeVerifier;
- bool TDShow;
- bool TMShow;
- string[] tdTsk = new string[10];
- string[] tmTsk = new string[10];
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- string YN = yearNow();
- string dateNowL = YN + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00");
- dateNow = dateNowL;
- process();
- showTodayList();
- }
- private void Form1_MouseDown(object sender, MouseEventArgs e)
- {
- TogMove = 1;
- MValX = e.X;
- MValY = e.Y;
- }
- private void Form1_MouseUp(object sender, MouseEventArgs e)
- {
- TogMove = 0;
- }
- private void Form1_MouseMove(object sender, MouseEventArgs e)
- {
- if (TogMove == 1)
- {
- this.SetDesktopLocation(MousePosition.X - MValX, MousePosition.Y - MValY);
- }
- }
- private void timePickH_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (reminderCheck.Checked == true)
- {
- dateInput.Enabled = true;
- tTxt.Enabled = true;
- timeInput.Enabled = true;
- dateInput.Visible = true;
- tTxt.Visible = true;
- timeInput.Visible = true;
- msgInputBD.Enabled = true;
- }
- else
- {
- tTxt.Enabled = false;
- timeInput.Enabled = false;
- tTxt.Visible = false;
- timeInput.Visible = false;
- }
- }
- private void timePickM_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void addBtn_Click(object sender, EventArgs e)
- {
- addBtn.Visible = false;
- showAddtool();
- }
- void showAddtool()
- {
- if (addToolShow == false)
- {
- msgInput.Enabled = true;
- reminderCheck.Enabled = true;
- dateInput.Enabled = true;
- submitAdd.Enabled = true;
- cancleAdd.Enabled = true;
- msgInputBD.Enabled = true;
- msgInput.Visible = true;
- dateInput.Visible = true;
- reminderCheck.Visible = true;
- submitAdd.Visible = true;
- cancleAdd.Visible = true;
- msgInputBD.Visible = true;
- //addToolShow = true;
- }
- else
- {
- msgInput.Enabled = false;
- reminderCheck.Enabled = false;
- dateInput.Enabled = false;
- tTxt.Enabled = false;
- timeInput.Enabled = false;
- submitAdd.Enabled = false;
- cancleAdd.Enabled = false;
- msgInputBD.Enabled = false;
- msgInput.Visible = false;
- reminderCheck.Visible = false;
- dateInput.Visible = false;
- tTxt.Visible = false;
- timeInput.Visible = false;
- submitAdd.Visible = false;
- cancleAdd.Visible = false;
- msgInputBD.Visible = false;
- addToolShow = false;
- addBtn.Visible = true;
- addBtn.Enabled = true;
- }
- }
- private void submitAdd_Click(object sender, EventArgs e)
- {
- showAddtool();
- if (msgInput.Text == "")
- {
- MessageBox.Show("You didn't type any message in textbox", "Add format ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- if (reminderCheck.Checked == true)
- {
- timeVerifier = false;
- timeInputCheck();
- if (timeVerifier == false)
- MessageBox.Show("Incorrect remind time. Please try again.\nExample: 09:59\n\n If you do not want to remind uncheck Reminder box", "Add format ERROR!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
- else
- {
- string date_set = dateInput.Value.ToString("yyyyMMdd");
- string time_set = timeInput.Text.Substring(0, 2) + timeInput.Text.Substring(3, 2);
- newList = "UNCH" + date_set + time_set + msgInput.Text;
- save();
- addToolShow = true;
- showAddtool();
- msgInput.Clear();
- reminderCheck.Checked = false;
- timeInput.Clear();
- }
- }
- else
- {
- string date_set = dateInput.Value.ToString("yyyyMMdd");
- string time_set = "9999";
- newList = "UNCH" + date_set + time_set + msgInput.Text;
- save();
- addToolShow = true;
- showAddtool();
- msgInput.Clear();
- reminderCheck.Checked = false;
- timeInput.Clear();
- }
- }
- process();
- showTodayList();
- }
- private void cancleAdd_Click(object sender, EventArgs e)
- {
- showAddtool();
- addToolShow = true;
- }
- bool firstLine;
- void save()
- {
- System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\saveList.txt",true);
- file.WriteLine(newList);
- file.Close();
- saveMessage();
- }
- void saveMessage()
- {
- if (reminderCheck.Checked == false)
- {
- MessageBox.Show
- (newList.Substring(16) + "\n\n at "
- + newList.Substring(10, 2) + "/"
- + newList.Substring(8, 2) + "/"
- + newList.Substring(4, 4) + "\n\n ADDED!");
- }
- else
- {
- MessageBox.Show
- (newList.Substring(16) + "\n\n at "
- + newList.Substring(12, 2) + ":"
- + newList.Substring(14, 2) + " "
- + newList.Substring(10, 2) + "/"
- + newList.Substring(8, 2) + "/"
- + newList.Substring(4, 4) + "\n\n ADDED!");
- }
- }
- void process()
- {
- todayListN = 0;
- TomorrowListN = 0;
- bool firstLineTD = false;
- bool firstLineTM = false;
- string[] lines = System.IO.File.ReadAllLines(@"C:\saveList.txt");
- foreach (string line in lines)
- {
- string date = line.Substring(4,8);
- if (date == dateNow)
- {
- todayListN++;
- if (firstLineTD == false)
- {
- System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\todayList.txt");
- file.WriteLine(line);
- file.Close();
- firstLineTD = true;
- }
- else
- {
- System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\todayList.txt", true);
- file.WriteLine(line);
- file.Close();
- }
- }
- }
- string[] TM = System.IO.File.ReadAllLines(@"C:\saveList.txt");
- foreach (string line in TM)
- {
- string date = line.Substring(4, 8);
- if (date == tomorrowDate())
- {
- TomorrowListN++;
- if (firstLineTM == false)
- {
- System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\tomorrowList.txt");
- file.WriteLine(line);
- file.Close();
- firstLineTM = true;
- }
- else
- {
- System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\tomorrowList.txt", true);
- file.WriteLine(line);
- file.Close();
- }
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- process();
- }
- string yearNow()
- {
- int defaultYearNow = int.Parse(DateTime.Now.Year.ToString("0000"));
- if (defaultYearNow < 2400)
- return (defaultYearNow + 543).ToString();
- else
- return defaultYearNow.ToString();
- }
- string tomorrowDate()
- {
- string YNstring = yearNow();
- bool leapYear = false;
- int yn = int.Parse(YNstring) - 543;
- if (yn % 4 == 0)
- {
- if (yn % 100 == 0)
- {
- if (yn % 400 == 0)
- leapYear = true;
- }
- else
- {
- leapYear = true;
- }
- }
- int month = int.Parse(dateNow.Substring(4,2));
- if ((month == 1 ||
- month == 3 ||
- month == 5 ||
- month == 7 ||
- month == 8 ||
- month == 10)
- &&
- (DateTime.Now.ToString("00") == "31"))
- return yearNow() + (int.Parse(dateNow.Substring(4, 2)) + 1).ToString() + "01";
- else if ((month == 4 ||
- month == 6 ||
- month == 9 ||
- month == 11)
- && (DateTime.Now.ToString("00") == "30"))
- return yearNow() + (int.Parse(dateNow.Substring(4, 2)) + 1).ToString() + "01";
- else if (((month == 2) && (leapYear == true)) && (DateTime.Now.ToString("00") == "29"))
- return yearNow() + (int.Parse(dateNow.Substring(4, 2)) + 1).ToString() + "01";
- else if (((month == 2) && (leapYear == false)) && (DateTime.Now.ToString("00") == "28"))
- return yearNow() + (int.Parse(dateNow.Substring(4, 2)) + 1).ToString() + "01";
- else if (month == 12 && DateTime.Now.ToString("00") == "31")
- {
- string nextYear = (int.Parse(YNstring) + 1).ToString();
- return nextYear + (int.Parse(dateNow.Substring(4, 2)) + 1).ToString() + "01";
- }
- else
- return dateNow.Substring(0, 6) + (int.Parse(dateNow.Substring(6, 2)) + 1).ToString();
- }
- private void label1_Click(object sender, EventArgs e)
- {
- showTomorrowList();
- }
- void timeInputCheck()
- {
- bool HVerifier = false;
- bool MVerifier = false;
- string HCheck;
- if (timeInput.Text == "" || timeInput.Text.Length < 5)
- {
- timeVerifier = false;
- }
- else
- {
- for (int i = 0; i <= 23; i++)
- {
- if (i < 10)
- HCheck = "0" + i.ToString();
- else
- HCheck = i.ToString();
- if (HCheck == timeInput.Text.Substring(0, 2))
- {
- HVerifier = true;
- }
- }
- string MCheck;
- for (int i = 0; i <= 59; i++)
- {
- if (i < 10)
- MCheck = "0" + i.ToString();
- else
- MCheck = i.ToString();
- if (MCheck == timeInput.Text.Substring(3, 2))
- {
- MVerifier = true;
- }
- }
- if (HVerifier == true && MVerifier == true)
- {
- timeVerifier = true;
- }
- }
- }
- private void todayBar_Click(object sender, EventArgs e)
- {
- showTodayList();
- }
- private void tomorrowBar_Click(object sender, EventArgs e)
- {
- showTomorrowList();
- }
- void showTodayList()
- {
- hideTomorrowList();
- process();
- int n=0;
- string[] lines = System.IO.File.ReadAllLines(@"C:\todayList.txt");
- foreach (string line in lines)
- {
- if (line.Substring(0, 4) == "UNCH")
- {
- n++;
- if (n == 1)
- {
- tdTask01(line); tdTsk[1] = line;
- }
- if (n == 2)
- {
- tdTask02(line); tdTsk[2] = line;
- }
- if (n == 3)
- {
- tdTask03(line); tdTsk[3] = line;
- }
- if (n == 4)
- {
- tdTask04(line); tdTsk[4] = line;
- }
- if (n == 5)
- {
- tdTask05(line); tdTsk[5] = line;
- }
- if (n == 6)
- {
- tdTask06(line); tdTsk[6] = line;
- }
- if (n == 7)
- {
- tdTask07(line); tdTsk[7] = line;
- }
- if (n == 8)
- {
- tdTask08(line); tdTsk[8] = line;
- }
- if (n == 9)
- {
- tdTask09(line); tdTsk[9] = line;
- }
- if (n == 10)
- {
- tdTask10(line); tdTsk[10] = line;
- }
- if (n > 10)
- tdTaskMore();
- }
- }
- TDShow = true;
- TMShow = false;
- }
- void hideTomorrowList()
- {
- TDCheck01.Visible = false;
- TDCheck02.Visible = false;
- TDCheck03.Visible = false;
- TDCheck04.Visible = false;
- TDCheck05.Visible = false;
- TDCheck06.Visible = false;
- TDCheck07.Visible = false;
- TDCheck08.Visible = false;
- TDCheck09.Visible = false;
- TDCheck10.Visible = false;
- todayT01.Visible = false;
- todayT02.Visible = false;
- todayT03.Visible = false;
- todayT04.Visible = false;
- todayT05.Visible = false;
- todayT06.Visible = false;
- todayT07.Visible = false;
- todayT08.Visible = false;
- todayT09.Visible = false;
- todayT10.Visible = false;
- TodayMsg01.Visible = false;
- TodayMsg02.Visible = false;
- TodayMsg03.Visible = false;
- TodayMsg04.Visible = false;
- TodayMsg05.Visible = false;
- TodayMsg06.Visible = false;
- TodayMsg07.Visible = false;
- TodayMsg08.Visible = false;
- TodayMsg09.Visible = false;
- TodayMsg10.Visible = false;
- TDRemind01.Visible = false;
- TDRemind02.Visible = false;
- TDRemind03.Visible = false;
- TDRemind04.Visible = false;
- TDRemind05.Visible = false;
- TDRemind06.Visible = false;
- TDRemind07.Visible = false;
- TDRemind08.Visible = false;
- TDRemind09.Visible = false;
- TDRemind10.Visible = false;
- TomorrowMore.Visible = false;
- }
- void tdTask01(string tsk)
- {
- tomorrowBar.Location = new Point(1, 239);
- tomorrowTXT.Location = new Point(1, 245);
- TDCheck01.Enabled = true;
- TDCheck01.Visible = true;
- TodayMsg01.Enabled = true;
- TodayMsg01.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind01.Visible = true;
- TDRemind01.Enabled = true;
- TDRemind01.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT01.Enabled = true;
- todayT01.Visible = true;
- TodayMsg01.Text = tsk.Substring(16);
- }
- void tdTask02(string tsk)
- {
- tomorrowBar.Location = new Point(1, 288);
- tomorrowTXT.Location = new Point(1, 294);
- TDCheck02.Enabled = true;
- TDCheck02.Visible = true;
- TodayMsg02.Enabled = true;
- TodayMsg02.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind02.Visible = true;
- TDRemind02.Enabled = true;
- TDRemind02.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT02.Enabled = true;
- todayT02.Visible = true;
- TodayMsg02.Text = tsk.Substring(16);
- }
- void tdTask03(string tsk)
- {
- tomorrowBar.Location = new Point(1, 335);
- tomorrowTXT.Location = new Point(1, 341);
- TDCheck03.Enabled = true;
- TDCheck03.Visible = true;
- TodayMsg03.Enabled = true;
- TodayMsg03.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind03.Visible = true;
- TDRemind03.Enabled = true;
- TDRemind03.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT03.Enabled = true;
- todayT03.Visible = true;
- TodayMsg03.Text = tsk.Substring(16);
- }
- void tdTask04(string tsk)
- {
- tomorrowBar.Location = new Point(1, 381);
- tomorrowTXT.Location = new Point(1, 387);
- TDCheck04.Enabled = true;
- TDCheck04.Visible = true;
- TodayMsg04.Enabled = true;
- TodayMsg04.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind04.Visible = true;
- TDRemind04.Enabled = true;
- TDRemind04.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT04.Enabled = true;
- todayT04.Visible = true;
- TodayMsg04.Text = tsk.Substring(16);
- }
- void tdTask05(string tsk)
- {
- tomorrowBar.Location = new Point(1, 427);
- tomorrowTXT.Location = new Point(1, 433);
- TDCheck05.Enabled = true;
- TDCheck05.Visible = true;
- TodayMsg05.Enabled = true;
- TodayMsg05.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind05.Visible = true;
- TDRemind05.Enabled = true;
- TDRemind05.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT05.Enabled = true;
- todayT05.Visible = true;
- TodayMsg05.Text = tsk.Substring(16);
- }
- void tdTask06(string tsk)
- {
- tomorrowBar.Location = new Point(1, 473);
- tomorrowTXT.Location = new Point(1, 479);
- TDCheck06.Enabled = true;
- TDCheck06.Visible = true;
- TodayMsg06.Enabled = true;
- TodayMsg06.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind06.Visible = true;
- TDRemind06.Enabled = true;
- TDRemind06.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT06.Enabled = true;
- todayT06.Visible = true;
- TodayMsg06.Text = tsk.Substring(16);
- }
- void tdTask07(string tsk)
- {
- tomorrowBar.Location = new Point(1, 519);
- tomorrowTXT.Location = new Point(1, 525);
- TDCheck07.Enabled = true;
- TDCheck07.Visible = true;
- TodayMsg07.Enabled = true;
- TodayMsg07.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind07.Visible = true;
- TDRemind07.Enabled = true;
- TDRemind07.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT07.Enabled = true;
- todayT07.Visible = true;
- TodayMsg07.Text = tsk.Substring(16);
- }
- void tdTask08(string tsk)
- {
- tomorrowBar.Location = new Point(1, 565);
- tomorrowTXT.Location = new Point(1, 571);
- TDCheck08.Enabled = true;
- TDCheck08.Visible = true;
- TodayMsg08.Enabled = true;
- TodayMsg08.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind08.Visible = true;
- TDRemind08.Enabled = true;
- TDRemind08.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT08.Enabled = true;
- todayT08.Visible = true;
- TodayMsg08.Text = tsk.Substring(16);
- }
- void tdTask09(string tsk)
- {
- tomorrowBar.Location = new Point(1, 611);
- tomorrowTXT.Location = new Point(1, 617);
- TDCheck09.Enabled = true;
- TDCheck09.Visible = true;
- TodayMsg09.Enabled = true;
- TodayMsg09.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind09.Visible = true;
- TDRemind09.Enabled = true;
- TDRemind09.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT09.Enabled = true;
- todayT09.Visible = true;
- TodayMsg09.Text = tsk.Substring(16);
- }
- void tdTask10(string tsk)
- {
- tomorrowBar.Location = new Point(1, 655);
- tomorrowTXT.Location = new Point(1, 661);
- TDCheck10.Enabled = true;
- TDCheck10.Visible = true;
- TodayMsg10.Enabled = true;
- TodayMsg10.Visible = true;
- if (tsk.Substring(12, 4) != "9999")
- {
- TDRemind10.Visible = true;
- TDRemind10.Enabled = true;
- TDRemind10.Text = "at "
- + tsk.Substring(12, 2) + ":"
- + tsk.Substring(14, 2);
- }
- todayT10.Enabled = true;
- todayT10.Visible = true;
- TodayMsg10.Text = tsk.Substring(16);
- }
- void tdTaskMore()
- {
- tomorrowBar.Location = new Point(1, 689);
- tomorrowTXT.Location = new Point(1, 695);
- TodayMore.Enabled = true;
- TodayMore.Visible = true;
- }
- private void label1_Click_1(object sender, EventArgs e)
- {
- }
- void showTomorrowList()
- {
- tomorrowBar.Location = new Point(1, 198);
- tomorrowTXT.Location = new Point(1, 204);
- TDCheck01.Visible = false;
- TDCheck02.Visible = false;
- TDCheck03.Visible = false;
- TDCheck04.Visible = false;
- TDCheck05.Visible = false;
- TDCheck06.Visible = false;
- TDCheck07.Visible = false;
- TDCheck08.Visible = false;
- TDCheck09.Visible = false;
- TDCheck10.Visible = false;
- todayT01.Visible = false;
- todayT02.Visible = false;
- todayT03.Visible = false;
- todayT04.Visible = false;
- todayT05.Visible = false;
- todayT06.Visible = false;
- todayT07.Visible = false;
- todayT08.Visible = false;
- todayT09.Visible = false;
- todayT10.Visible = false;
- TodayMsg01.Visible = false;
- TodayMsg02.Visible = false;
- TodayMsg03.Visible = false;
- TodayMsg04.Visible = false;
- TodayMsg05.Visible = false;
- TodayMsg06.Visible = false;
- TodayMsg07.Visible = false;
- TodayMsg08.Visible = false;
- TodayMsg09.Visible = false;
- TodayMsg10.Visible = false;
- TDRemind01.Visible = false;
- TDRemind02.Visible = false;
- TDRemind03.Visible = false;
- TDRemind04.Visible = false;
- TDRemind05.Visible = false;
- TDRemind06.Visible = false;
- TDRemind07.Visible = false;
- TDRemind08.Visible = false;
- TDRemind09.Visible = false;
- TDRemind10.Visible = false;
- TodayMore.Visible = false;
- showTomorrowTsk();
- TDShow = false;
- TMShow = true;
- }
- void showTomorrowTsk()
- {
- try
- {
- int n = 0;
- string[] lines = System.IO.File.ReadAllLines(@"C:\tomorrowList.txt");
- foreach (string line in lines)
- {
- if (line.Substring(0, 4) == "UNCH")
- {
- n++;
- if (n == 1)
- {
- tdTask02(line); tmTsk[01] = line;
- }
- if (n == 2)
- {
- tdTask03(line); tmTsk[01] = line;
- }
- if (n == 3)
- {
- tdTask04(line); tmTsk[01] = line;
- }
- if (n == 4)
- {
- tdTask05(line); tmTsk[01] = line;
- }
- if (n == 5)
- {
- tdTask06(line); tmTsk[01] = line;
- }
- if (n == 6)
- {
- tdTask07(line); tmTsk[01] = line;
- }
- if (n == 7)
- {
- tdTask08(line); tmTsk[01] = line;
- }
- if (n == 8)
- {
- tdTask09(line); tmTsk[01] = line;
- }
- if (n == 9)
- {
- tdTask10(line); tmTsk[01] = line;
- }
- if (n > 9)
- tmTaskMore();
- }
- }
- tomorrowBar.Location = new Point(1, 198);
- tomorrowTXT.Location = new Point(1, 204);
- }
- catch
- {
- }
- }
- void tmTaskMore()
- {
- TomorrowMore.Visible = true;
- }
- private void TDCheck01_CheckedChanged(object sender, EventArgs e)
- {
- checking(tdTsk[1]);
- }
- void checking(string tsk)
- {
- MessageBox.Show("GO ON!!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement