Exemple #1
0
        private void rescheduleRecurrentEventsButton_Click(object sender, System.EventArgs e)
        {
            using (var db = new UnitOfWork())
            {
                db.EventsRepository.RescheduleRecursiveEvents();
            }

            Parent?.UpdateUI();
        }
Exemple #2
0
        private void deleteEventButton_Click(object sender, EventArgs e)
        {
            if (MessageCenter.Confirmation.ConfirmDeleteEvent() == DialogResult.No)
                return;

            using (var db = new UnitOfWork())
            {
                db.EventsRepository.Delete(targetEvent.Id);
            }

            observer?.UpdateUI();
            this.Close();
        }
Exemple #3
0
        static void Main()
        {
            // Clean up and reschedule necessary events at program startup
            using (var db = new UnitOfWork())
            {
                db.EventsRepository.RescheduleRecursiveEvents();
            }

            // Start the app
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new App.CalendarForm());
        }
Exemple #4
0
        private Event UpdateEvent()
        {
            using (var db = new UnitOfWork())
            {
                var ev = db.EventsRepository.Get(targetEvent.Id);

                ev.Title = titleBox.Text;
                ev.Details = descriptionBox.Text;
                ev.Date = datePicker.Value;
                ev.IsRecursive = repeatCheckBox.Checked;
                ev.IsSeen = false;

                ev.RecursionDays = int.Parse(repeatDaysBox.Text);
                ev.RecursionMonths = int.Parse(repeatMonthsBox.Text);
                ev.RecursionYears = int.Parse(repeatYearsBox.Text);

                return db.EventsRepository.Update(ev);
            }
        }
        private void EventItem_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.toolTip.ToolTipTitle = ev.Title.ToUpper();

                string message = "";
                if (ev.Details != null && ev.Details.Length > 0)
                    message += ev.Details + "\n\n";

                message += slotDate.ToString(CalendarSlot.DATE_FORMAT_LONG) + "\n\n" + Status();

                if (ev.IsRecursive)
                    message += "\n\nRepeats once every: " + ev.RecursionYears + " years, " + ev.RecursionMonths + " months and " + ev.RecursionDays + " days";

                this.toolTip.Show(message.ToUpper(), this);

                // Mark it as seen
                using (var db = new UnitOfWork())
                {
                    ev = db.EventsRepository.Get(ev.Id);

                    if (slotDate <= DateTime.Today && ev.IsSeen == this.IsSeen)
                    {
                        ev.IsSeen = this.IsSeen = true;
                        SetAppropriateImage();

                        db.EventsRepository.Update(ev);
                    }
                }
            }

            else if (e.Button == MouseButtons.Right)
            {
                new EditEventForm(ev, observer).ShowDialog();
            }
        }
        private Event CreateEvent()
        {
            var ev = new Event
            {
                Title = titleBox.Text,
                Details = descriptionBox.Text,
                IsRecursive = repeatCheckBox.Checked,
                IsSeen = false,
                Date = datePicker.Value,
            };

            if (ev.IsRecursive)
            {
                ev.RecursionDays = int.Parse(repeatDaysBox.Text);
                ev.RecursionMonths = int.Parse(repeatMonthsBox.Text);
                ev.RecursionYears = int.Parse(repeatYearsBox.Text);
            }

            using (var db = new UnitOfWork())
            {
                return db.EventsRepository.Insert(ev);
            }
        }
        private void LoadDatesOntoCalendar()
        {
            var date = navigator.Date;
            var addition = 0;

            int index = (int)date.DayOfWeek - 1;
            if (index < 0) // Sunday
                index = COLUMNS - 1;

            // Fix dates on the slots
            date = date.AddDays(-index);
            for (int i = 0; i < ROWS; i++)
            {
                for (int j = 0; j < COLUMNS; j++, addition++)
                {
                    var newDate = date.AddDays(addition);

                    slots[i * COLUMNS + j].IsToday = DateTime.Today.Equals(newDate);

                    slots[i * COLUMNS + j].Invoke((MethodInvoker)(() =>
                    {
                        slots[i * COLUMNS + j].Date = newDate;

                    }));
                }
            }

            // Load events for all the slots
            using (var db = new UnitOfWork())
            {
                var events = db.EventsRepository.GetActiveEventsAsList(slots[0].Date, slots[ROWS * COLUMNS - 1].Date);

                for (int i = 0; i < ROWS; i++)
                {
                    for (int j = 0; j < COLUMNS; j++, addition++)
                    {
                        slots[i * COLUMNS + j].Invoke((MethodInvoker)(() =>
                        {
                            slots[i * COLUMNS + j].LoadEvents(ref events);
                        }));
                    }
                }
            }
        }
Exemple #8
0
        private void RunAlarmIfNecessary()
        {
            var hasUrgentEvents = false;

            using (var db = new UnitOfWork())
            {
                hasUrgentEvents = db.EventsRepository.HasUpcomingEvents();
            }

            if (hasUrgentEvents)
            {
                StartBlinker();
                AlarmCenter.PlayAlarm();
            }
        }