/// <summary> /// Initializes a new instance of the <see cref="SchedulerViewModel"/> class. /// </summary> /// <param name="scheduler">The scheduler.</param> /// <exception cref="ArgumentNullException">scheduler</exception> internal SchedulerViewModel(IScheduler scheduler) { if (scheduler == null) { throw new ArgumentNullException("scheduler"); } this.scheduler = scheduler; scheduler.ActiveViewDefinitionChanged += this.OnViewModeChanged; this.dayTimeSlotsView = new TimeSlotCollectionView(); this.dayTimeSlotsView.Scheduler = this.Scheduler as RadScheduler; this.activeViewDefinition = scheduler.ActiveViewDefinition; this.activeViewDefinition.ViewDefinitionChanged += this.OnViewDefinitionChanged; this.allDayTimeSlotsView = new TimeSlotCollectionView(); this.allDayActiveViewDefinition = new SingleMonthWeekViewDefinition(this.activeViewDefinition); this.allDayTimeSlotsView.GroupDescriptions.AddRange(this.allDayActiveViewDefinition.GroupDescriptions); scheduler.SelectedTimeSlot = new TimeSlot(DateTime.Today, TimeSpan.FromDays(1)); this.startDate = this.GetStartDateForViewDefinition( this.activeViewDefinition, scheduler.SelectedTimeSlot.Start); this.RecreateTimeSlots(); }
public void ScrollVerticalOffset(TimeSpan timeSpan) { if (this.notAllDayAppScrollViewer != null && this.timeRuler != null) { if (this.notAllDayAppScrollViewer.IsVisible) { var timeSlotsView = new TimeSlotCollectionView(); if (this.Scheduler.ViewMode == SchedulerViewMode.Week) { foreach (var item in this.TimeSlotsView.Take(this.TimeSlotsView.Count() / 7)) { timeSlotsView.Add(item); } } else if (this.Scheduler.ViewMode == SchedulerViewMode.Day) { timeSlotsView = this.TimeSlotsView; } var viewCount = timeSlotsView.Count; var timeSolt = timeSlotsView.Where(t => TimeSpan.Parse(t.Start.ToString("HH:mm")) < timeSpan); if (timeSolt.Count() > 0) { var index = timeSlotsView.IndexOf(timeSolt.Last()); var height = this.timeRuler.ActualHeight; this.notAllDayAppScrollViewer.ScrollToVerticalOffset((height / viewCount) * index); } else { this.notAllDayAppScrollViewer.ScrollToTop(); } } } }