예제 #1
0
        private async void BindData(int index)
        {
            var calendar = new Calendar();
            calendar.AddMonths(index);

            CurrentMonth = calendar.MonthAsString();
            CurrentYear = calendar.YearAsString();

            // Save month.
            GlobalData.SelectedMonthIndex = calendar.Month;

            var fDayOfThisMonth = new DateTime(calendar.Year, calendar.Month, calendar.FirstDayInThisMonth);
            var fbuffer = CalcBuffer(fDayOfThisMonth);

            // Save this value to draw grid of month later
            GlobalData.NumberOfRows = NumberOfRowsForMonth(calendar, fDayOfThisMonth);

            var lDayOfThisMonth = new DateTime(calendar.Year, calendar.Month, calendar.LastDayInThisMonth);
            var lbuffer = CalcBuffer(lDayOfThisMonth, true);

            calendar.AddMonths(-1);

            var temp = new List<DayItemModel>();
            // Add pre buffer
            for (var i = 1; i <= fbuffer; i++)
            {
                var dim = new DayItemModel
                    {
                        Today = new DateTime(calendar.Year, calendar.Month, calendar.LastDayInThisMonth - (fbuffer - i)),
                    };
                dim.TaskList = await TaskRepository.Instance.GetTaskListFor(dim.Today);
                temp.Add(dim);
            }

            calendar.AddMonths(1);
            // Add month
            for (var i = 0; i < lDayOfThisMonth.Day; i++)
            {
                var dim = new DayItemModel
                    {
                        Today = new DateTime(calendar.Year, calendar.Month, calendar.FirstDayInThisMonth + i)
                    };
                dim.TaskList = await TaskRepository.Instance.GetTaskListFor(dim.Today);

                temp.Add(dim);
            }

            calendar.AddMonths(1);
            // Add post buffer
            for (var i = 0; i < lbuffer; i++)
            {
                var dim = new DayItemModel
                    {
                        Today = new DateTime(calendar.Year, calendar.Month, calendar.FirstDayInThisMonth + i)
                    };
                dim.TaskList = await TaskRepository.Instance.GetTaskListFor(dim.Today);

                temp.Add(dim);
            }

            SingleMonth = temp;
        }
예제 #2
0
 private async void BindWeather(DayItemModel itemModel)
 {
     try
     {
         itemModel.WeatherModel = await WeatherRepository.Instance.GetWeather(itemModel.Today) ??
                                  new DayWeatherModel
                                      {
                                          AverageTempuratureC = null,
                                          AverageTempuratureF = null,
                                          WeatherType = WeatherType.notavailable
                                      };
     }
     catch
     {
     }
 }