public void VisibleDateChanging(VisibleDatesChangingEventArgs arg)
        {
            var oldValue = arg.OldValue;
            var newValue = arg.NewValue;

            if (oldValue != null)
            {
            }
            //MessageBox.Show("Visible date EventTriggered from VM");
        }
 private void Schedule_VisibleDatesChanging(object sender, VisibleDatesChangingEventArgs e)
 {
     DateTime dt = ((ObservableCollection<System.DateTime>)e.NewValue).LastOrDefault();
     String month = null;
     if (Schedule1.ScheduleType == ScheduleType.Month)
     {
         month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(CultureInfo.CurrentCulture.Calendar.GetMonth((e.NewValue as ObservableCollection<System.DateTime>)[(e.NewValue as ObservableCollection<System.DateTime>).Count / 2].Date));
         headerText.Text = month + "," + " " + (e.NewValue as ObservableCollection<System.DateTime>)[(e.NewValue as ObservableCollection<System.DateTime>).Count / 2].Year.ToString();
         headerText.Margin = new Thickness(10, 0, 0, 0);
     }
     else
         headerText.Text = String.Format("{0:MMMM, yyyy}", dt);
 }
Exemplo n.º 3
0
        private async void BanenSchema_VisibleDatesChanging(VisibleDatesChangingEventArgs e)
        {
            try
            {
                ObservableCollection <DateTime> dates = e.NewValue as ObservableCollection <DateTime>;
                DateTime _date = DateTime.Now;
                if (dates.Count > 0)
                {
                    _date = dates[0];
                }

                if (_vereniging == null)
                {
                    _vereniging = await _verenigingRepository.GetVerenigingAsync();
                }
                if (_afhang == null)
                {
                    _afhang = await _verenigingRepository.GetVerenigingSettingsAsync();
                }

                List <Baan> banen = await _baanRepository.GetBanenByDateAsync(_vereniging.Id, _vereniging.AccommodatieId, _date);

                ResourceType banenResource = new ResourceType {
                    TypeName = "Banen"
                };

                Reserveringen = new ObservableCollection <ScheduleAppointment>();

                foreach (Baan baan in banen)
                {
                    banenResource.ResourceCollection.Add(new Resource {
                        DisplayName = baan.Naam, ResourceName = baan.Naam, TypeName = "Banen"
                    });

                    /*
                     * int hours = new Random().Next(Afhang.BaanBegin.Hours, Afhang.BaanEinde.Hours);
                     * int mins = new Random().Next(Afhang.Duur_Een, Afhang.Duur_Vier);
                     * Reserveringen.Add(new ScheduleAppointment { StartTime = _date.AddHours(hours).AddMinutes(mins * -1), EndTime = _date.AddHours(hours).AddMinutes(mins), Location = "Baan 1", Status = new ScheduleAppointmentStatus { Status = ReserveringSoort.Les.ToString() }, ResourceCollection = new ObservableCollection<Resource> { new Resource() { ResourceName = baan.Naam, TypeName = "Banen" } }, Subject = "Afhangen", ReadOnly = true });
                     *
                     * hours = new Random().Next(Afhang.BaanBegin.Hours, Afhang.BaanEinde.Hours);
                     * mins = new Random().Next(Afhang.Duur_Een, Afhang.Duur_Vier);
                     * Reserveringen.Add(new ScheduleAppointment { StartTime = _date.AddHours(hours).AddMinutes(mins * -1), EndTime = _date.AddHours(hours).AddMinutes(mins), Location = "Baan 1", Status = new ScheduleAppointmentStatus { Status = ReserveringSoort.Afhangen.ToString() }, ResourceCollection = new ObservableCollection<Resource> { new Resource() { ResourceName = baan.Naam, TypeName = "Banen" } }, Subject = "Afhangen", ReadOnly = true });
                     *
                     * hours = new Random().Next(Afhang.BaanBegin.Hours, Afhang.BaanEinde.Hours);
                     * mins = new Random().Next(Afhang.Duur_Een, Afhang.Duur_Vier);
                     * Reserveringen.Add(new ScheduleAppointment { StartTime = _date.AddHours(hours).AddMinutes(mins * -1), EndTime = _date.AddHours(hours).AddMinutes(mins), Location = "Baan 1", Status = new ScheduleAppointmentStatus { Status = ReserveringSoort.Competitie.ToString() }, ResourceCollection = new ObservableCollection<Resource> { new Resource() { ResourceName = baan.Naam, TypeName = "Banen" } }, Subject = "Afhangen", ReadOnly = true });
                     */
                }

                Banen.Add(banenResource);

                ObservableCollection <Reservering> reserveringen = await _reserveringRepository.GetReserveringenByDateAsync(_date);

                foreach (Reservering reservering in reserveringen)
                {
                    reservering.Baan = banen.SingleOrDefault <Baan>(b => b.Id == reservering.BaanId);

                    if (reservering.Baan != null)
                    {
                        //reservering.BaanId
                        Reserveringen.Add(
                            new ScheduleAppointment
                        {
                            StartTime = reservering.Datum.Add(reservering.BeginTijd),
                            EndTime   = reservering.Datum.Add(reservering.EindTijd),
                            Location  = reservering.Baan.Naam,
                            Status    = new ScheduleAppointmentStatus
                            {
                                Status = reservering.Soort.ToString()
                            },
                            ResourceCollection = new ObservableCollection <Resource> {
                                new Resource()
                                {
                                    ResourceName = reservering.Baan.Naam,
                                    TypeName     = "Banen"
                                }
                            },
                            Subject  = String.IsNullOrWhiteSpace(reservering.Beschrijving) ? reservering.Soort.ToString() : reservering.Beschrijving,
                            ReadOnly = true
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                //throw;
            }
        }