示例#1
0
        private void HandleView()
        {
            Int32 eventsNum = _DataStorage.GetPlanRemindersNum();

            if (eventsNum == 0)
            {
                _WindowView.SendTextToConsole("You have no events to view");
            }
            else
            {
                _WindowView.SendTextToConsole("Existing events found:");
                DateTime tDateTime = DateTime.Now;
                for (Int32 i = 0; i < eventsNum; i++)
                {
                    PlanReminderObj reminderObj = _DataStorage.GetPlanReminder(i);
                    _WindowView.SendTextToConsoleAtSameLine((i + 1).ToString());
                    _WindowView.PasteSpaceToConsole();
                    reminderObj.ViewInfo();
                    if (reminderObj._DateTime.CompareTo(tDateTime) < 0)
                    {
                        _WindowView.SendTextToConsoleAtSameLine(" - outdated\n");
                    }
                    else
                    {
                        _WindowView.SendTextToConsoleAtSameLine("\n");
                    }
                }
            }
        }
示例#2
0
        private void ParseFileToList()
        {
            int state = _DataStorageFile.OpenFile();

            if (state.Equals(-1))
            {
                return; // file empty or not exists
            }
            else
            {
                string tStr;
                while ((tStr = _DataStorageFile.GetTheNextStringFromFile()) != null)
                {
                    PlanReminderObj planReminderObj = new PlanReminderObj();
                    try {
                        DateTime tDate = DateTime.Parse(tStr);
                        planReminderObj._DateTime = tDate;
                        tStr = _DataStorageFile.GetTheNextStringFromFile();
                        planReminderObj._Text = tStr;
                        SetPlanReminder(planReminderObj);
                    }
                    catch {
                        return; // something wrong with data in file
                    }
                }
            }
        }
示例#3
0
        private Int32 HandleEditTakeNum()
        {
            Int32  eventsNum  = _DataStorage.GetPlanRemindersNum();
            String tString    = _ParseInput.GetInputString();
            Int32  fromString = 0;

            try {
                fromString = (Int32.Parse(tString) - 1);
                if (fromString > eventsNum)
                {
                    _WindowView.SendTextToConsole("Sorry, you have less stored " +
                                                  "events than you've been entered. Try again.");
                }
                else
                {
                    _ComRespReminderObj = _DataStorage.GetPlanReminder(fromString);
                    _WindowView.SendTextToConsole("Enter new date and time of the event:");
                    _WindowView.SendTextToConsole(_ComRespReminderObj._DateTime.ToString());
                }
            }
            catch {
                _ParseInput.ResetCmd();
                _WindowView.SendTextToConsole("Sorry, can't recognize the number.");
            }
            return(fromString);
        }
示例#4
0
 public void SetPlanReminderAt(PlanReminderObj planObj, Int32 num)
 {
     _ToDoList[num] = planObj;
     try {
         _ToDoList.Sort(CompareDates);
     }
     catch {
         return;
     }
 }
示例#5
0
 public void SetPlanReminder(PlanReminderObj planObj)
 {
     _ToDoList.Add(planObj);
     try {
         _ToDoList.Sort(CompareDates);
     }
     catch {
         return;
     }
 }
示例#6
0
 private static int CompareDates(PlanReminderObj first, PlanReminderObj second)
 {
     return(first._DateTime.CompareTo(second._DateTime));
 }
示例#7
0
 private void HandleNew()
 {
     _WindowView.NewViewDateTime();
     _ComRespReminderObj = new PlanReminderObj();
 }