Exemplo n.º 1
0
        private void BtnReady_Click(object sender, EventArgs e)
        {
            string employmentName = dataGridBusiness.CurrentCell.Value.ToString();

            if (employmentName == "Другое")
            {
                StatsManagement.WriteStats($"{employments.EmpType}!{Codes.anotherEmpCode}", currentRange);
            }
            else
            {
                employments.SetEmploymentValuesByName(employmentName);
                StatsManagement.WriteStats($"{employments.EmpType}!{employments.Code}", currentRange);
                if (employments.EmpType == "Goals")
                {
                    CheckIsGoalDone();
                }
            }

            MenuManagement.questCheck = false;  //ИСПРАВИТЬ
            UpdateMainMenuDGV();

            currentRange--;
            SetLabelValue();

            if (currentRange <= 0)
            {
                FileManagement.firstLaunch = false;
                tray.CheckNotifyNeed();
                this.Hide();
            }
        }
Exemplo n.º 2
0
 private static void CheckForEfficiency()
 {
     if (!File.Exists(Management.GetPath("Efficiency")))
     {
         using (File.Create(Management.GetPath("Efficiency"))) { }
         StatsManagement.AddNewWeekIntoEfficiency(2);
     }
 }
Exemplo n.º 3
0
 public void DataGridBusiness_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     StatsManagement.DisplayMainStats(ref lblEmployName, ref lblEmployType, ref lblDoneHours, ref lblMustSpend, DataGridBusiness.CurrentCell.ColumnIndex);
     if (DataGridBusiness.CurrentCell.ColumnIndex < 10)
     {
         lblEmploymentHour.Text = $"0{DataGridBusiness.CurrentCell.ColumnIndex.ToString()}:00";
     }
     else
     {
         lblEmploymentHour.Text = $"{DataGridBusiness.CurrentCell.ColumnIndex.ToString()}:00";
     }
     PointToBusiness(DataGridBusiness.CurrentCell.ColumnIndex);
     DataGridBusiness.ClearSelection();
 }
Exemplo n.º 4
0
        private string IsScheduleAlreadyAdded(string[] scheduleArr)
        {
            int    beginTime;
            int    endTime;
            int    dayOfWeek;
            string schedule;
            string message;
            string employment = "";

            for (int i = 0; i < 7; i++)
            {
                if (scheduleArr[i] == "H")
                {
                    continue;
                }
                beginTime = Convert.ToInt32(scheduleArr[i].Remove(scheduleArr[i].IndexOf(" ")));
                endTime   = Convert.ToInt32(scheduleArr[i].Substring(scheduleArr[i].IndexOf(" ") + 1));

                schedule = StatsManagement.IsHourInSchedule(beginTime, i);
                if (schedule == null)
                {
                    schedule = StatsManagement.IsHourInSchedule(endTime, i);
                }
                if (schedule != null)
                {
                    employment = Management.GetValueByIndex(schedule);

                    schedule = Management.GetValueByIndex(schedule, 2);      //выывод расписания
                    schedule = Management.GetValueByIndex(schedule, i, "/"); //вывод расписания для конкрентого дня недели

                    beginTime = Convert.ToInt32(schedule.Remove(schedule.IndexOf(" ")));
                    endTime   = Convert.ToInt32(schedule.Substring(schedule.IndexOf(" ") + 1));

                    dayOfWeek = i + 1;
                    dayOfWeek = dayOfWeek == 7 ? 0 : dayOfWeek;

                    message = $"Ваш {CultureInfo.CurrentCulture.DateTimeFormat.DayNames[dayOfWeek]} уже занят." +
                              $"\nВ это время вы занимаетесь \"{employment}, с {beginTime} по {endTime}.";
                    return(message);
                }
            }

            return("");
        }
Exemplo n.º 5
0
        private void TimeSpent_Load(object sender, EventArgs e)
        {
            BtnGoals_Click(null, null);

            currentRange = UserSettings.EmploymentCheckRange;

            for (int i = 1; i <= UserSettings.EmploymentCheckRange; i++)    //нахождение ближайшего часа, для которого у пользователя можно запросить деятельность
            {
                if (StatsManagement.CheckIsHourAvailable(i))
                {
                    currentRange = i;
                }
                else
                {
                    break;
                }
            }
            SetLabelValue();
        }
Exemplo n.º 6
0
        public void ScheduleBeginMessage()
        {
            string prevHrSched = StatsManagement.IsHourInSchedule(DateTime.Now.Hour - 1, CurrentDateInfo.DayOfWeek);
            string curHrSched  = StatsManagement.IsHourInSchedule(DateTime.Now.Hour, CurrentDateInfo.DayOfWeek);
            string endSchedTime;

            if (prevHrSched == null && curHrSched != null)
            {
                endSchedTime = Management.GetValueByIndex(curHrSched, 2);                                    //вывод расписания
                endSchedTime = Management.GetValueByIndex(endSchedTime, CurrentDateInfo.DayOfWeek - 1, "/"); //вывод расписания для конкретного дня недели
                endSchedTime = endSchedTime.Substring(endSchedTime.IndexOf(" ") + 1);
                endSchedTime = Convert.ToInt32(endSchedTime) >= 10 ? $"{endSchedTime}:00" : $"0{endSchedTime}:00";
                curHrSched   = Management.GetValueByIndex(curHrSched);

                trayIcon.BalloonTipIcon  = ToolTipIcon.Info;
                trayIcon.BalloonTipTitle = "Расписание";
                trayIcon.BalloonTipText  = $"{curHrSched} до {endSchedTime}";

                trayIcon.ShowBalloonTip(10000);
            }
        }
Exemplo n.º 7
0
        public static void CheckWeekRelevance()
        {
            StatsManagement stats      = new StatsManagement();
            string          commonFile = Management.GetPath("Common");
            int             fileWeekNumber;
            int             fileYear;
            int             numberOfWeeks = 0;

            string[] commonFileArr = File.ReadAllLines(commonFile);

            for (int i = 0; i < commonFileArr.Length; i++)
            {
                if (Management.GetValueByIndex(commonFileArr[i], 0) == "Week Number")
                {
                    fileYear       = Convert.ToInt32(Management.GetValueByIndex(commonFileArr[i], 2));
                    fileWeekNumber = Convert.ToInt32(Management.GetValueByIndex(commonFileArr[i], 1));

                    if (fileWeekNumber != WeekNumber || fileYear != DateTime.Now.Year)
                    {
                        if (DateTime.Now.Year - fileYear == 1 && weekNumber == 52 || DateTime.Now.Year == fileYear)
                        {
                            numberOfWeeks = weekNumber - fileWeekNumber;
                        }
                        else
                        {
                            numberOfWeeks  = (DateTime.Now.Year - fileYear - 1) * 54; //разница между годами
                            numberOfWeeks += 52 - fileWeekNumber;                     //пропущенные недели года последнего использования
                            numberOfWeeks += weekNumber;                              //недели этого года
                        }

                        StatsManagement.AddNewWeekIntoEfficiency(numberOfWeeks);
                        commonFileArr[i] = $"Week Number!{WeekNumber}!{DateTime.Now.Year}";
                        File.WriteAllLines(commonFile, commonFileArr);
                        break;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void TimerHour_Tick(object sender, EventArgs e)
        {
            const int interval60Mins = 60 * 60 * 1000;

            TimerHour.Interval = interval60Mins;
            tray.ScheduleBeginMessage();

            FileManagement.CheckAllFiles();
            CurrentDateInfo.CheckWeekRelevance();
            if (StatsManagement.CheckIsHourAvailable())
            {
                ShowQuest();
            }
            if (UserSettings.StopGames == true)
            {
                UserSettings.CloseGame();
            }
            if (DateTime.Now.Hour <= 1)
            {
                achiveNoFunAllDay.CheckCondition();
                achiveNoRestWholeDay.CheckCondition();
            }
        }
Exemplo n.º 9
0
        private void MainMenu_Load(object sender, EventArgs e)
        {
            const int miliseconds = 1000;
            const int minutes     = 60;
            int       interval;

            FileManagement.CheckAllFiles();
            CurrentDateInfo.CheckWeekRelevance();
            StatsManagement.WriteHoursFromSchedule();
            MenuManagement.AreAllFormsClosed = false;
            tray = new Tray(this.TrayIcon);

            tray.ProductiveMessage();
            _mainMenu = this;

            FillDaysOfWeek();
            DataGridDayOfWeek_CellClick(null, null);
            DataGridBusiness.CurrentCell = DataGridBusiness[DateTime.Now.Hour - 1, 0];
            DataGridBusiness_CellClick(null, null);

            DateTime dateTime1 = new DateTime();   //"будильник" на вызов формы в ближайшие "00" минут

            dateTime1 = DateTime.Now;
            dateTime1 = dateTime1.AddHours(1).AddMinutes(-dateTime1.Minute);
            interval  = dateTime1.Subtract(DateTime.Now).Minutes *minutes *miliseconds;

            TimerHour.Interval = interval == 0 ? 1 : interval;
            if (StatsManagement.CheckIsHourAvailable())
            {
                ShowQuest();
            }

            achiveNoFunAllDay.CheckCondition();
            achiveNoRestWholeDay.CheckCondition();
            SetFormDesign();
        }
Exemplo n.º 10
0
 public static void ResetProgram()
 {
     Directory.Delete(Management.GetPath(), true);
     CheckAllFiles();
     StatsManagement.WriteHoursFromSchedule();
 }