Exemple #1
0
 private void btnNextMonth_Click(object sender, RoutedEventArgs e)
 {
     if (LoadingData)
     {
         return;
     }
     StartingMonth = StartingMonth.AddMonths(1);
     DisplayDates();
 }
Exemple #2
0
        void UpdateDateMarkers(DateTime startOfMOnth)
        {
            if (CalendarItems != null)
            {
                var finalDayOfMonth = StartingMonth.AddMonths(1).AddHours(-1);

                List <DateTime> markedDates = new CalendarAssignmentSQLiteRepository().GetAssignedDates(MainWindow.CurrentCompanyId, StartingMonth, finalDayOfMonth);

                foreach (var item in CalendarItems)
                {
                    if (markedDates.Any(x => x == item.Date))
                    {
                        item.MarkedDateVisible = Visibility.Visible;
                    }
                    else
                    {
                        item.MarkedDateVisible = Visibility.Hidden;
                    }
                }
            }
        }
Exemple #3
0
        void DisplayDates()
        {
            List <CalendarDate> dates = new List <CalendarDate>();

            var startOfMonth = StartingMonth;
            var dayOfWeek    = (int)startOfMonth.DayOfWeek;

            if (dayOfWeek > 0)
            {
                startOfMonth = startOfMonth.AddDays(-dayOfWeek);
            }
            else
            {
                startOfMonth = startOfMonth.AddDays(-7);
            }

            var today = DateTime.Now.Date;


            var finalDayOfMonth = StartingMonth.AddMonths(1).AddHours(-1);

            List <DateTime> markedDates = new CalendarAssignmentSQLiteRepository().GetAssignedDates(MainWindow.CurrentCompanyId, StartingMonth, finalDayOfMonth);


            for (int i = 1; i <= 42; i++) // 6 x 7 grid
            {
                var calculated  = startOfMonth.AddDays(i);
                var visibleIcon = markedDates.Any(x => x == calculated);
                dates.Add(new CalendarDate()
                {
                    Identifier        = new Guid(),
                    Date              = calculated,
                    IsEnabled         = calculated.Date.Month == StartingMonth.Date.Month,
                    MarkedDateVisible = visibleIcon ? Visibility.Visible : Visibility.Hidden
                });
            }

            CalendarItems = new ObservableCollection <CalendarDate>(dates);

            var todaysDate = CalendarItems.FirstOrDefault(x => x.Date == today && x.IsEnabled);

            if (todaysDate != null)
            {
                todaysDate.IsSelected = true;
                TodayDate             = today;
                TomorrowDate          = today.AddDays(1);
            }
            else
            {
                TodayDate    = StartingMonth.Date;
                TomorrowDate = TodayDate.Value.AddDays(1);
            }


            Thread td = new Thread(() => {
                DisplayTodayItems();

                DisplayTomorrowItems();
            });

            td.IsBackground = true;
            td.Start();
        }