private IEnumerable <CalendarItemViewModel> FindCalendarItemViewModel(IAppointmentViewModel mdl) { if (mdl == null) { return(null); } return(DayItems.SelectMany(i => i.CalendarItems.Where(c => c.ObjectViewModel == mdl))); }
public CalendarItemViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IAppointmentViewModel obj) : base(dependencies, dataCtx, parent) { if (obj == null) throw new ArgumentNullException("obj"); this.SlotWidth = this.OverlappingWidth = 1.0; this.ObjectViewModel = obj; this.ObjectViewModel.PropertyChanged += AppointmentViewModelChanged; }
public void NewItem(DateTime dt) { var result = new NewItemCreatingEventArgs(); OnNewItemCreating(dt, result); if (result.AppointmentViewModel == null) { // Abort return; } EnsureAppointments(); var items = CreateCalendarItemViewModel(result.AppointmentViewModel); if (items != null && items.Count > 0) { _allItems.AddRange(items); RecreateItems(); SelectedItem = result.AppointmentViewModel; } }
private List <CalendarItemViewModel> CreateCalendarItemViewModel(IAppointmentViewModel a) { if (a.From <= a.Until) { List <CalendarItemViewModel> result = new List <CalendarItemViewModel>(); var from = a.From; var until = a.Until; if (from < this.From) { from = this.From; } if (until > this.To) { until = this.To; } for (var current = from; current < until; current = current.Date.AddDays(1)) { var vmdl = ViewModelFactory.CreateViewModel <CalendarItemViewModel.Factory>() .Invoke( DataContext, this, a); vmdl.From = current == a.From ? current : current.Date; vmdl.Until = current.Date == a.Until.Date ? a.Until : current.Date.AddDays(1); vmdl.IsAllDay = vmdl.From.TimeOfDay == TimeSpan.Zero && vmdl.Until.TimeOfDay == TimeSpan.Zero; result.Add(vmdl); } return(result); } else { Logging.Client.WarnFormat("Appointment item {0} has an invalid time range of {1} - {2}", a.Subject, a.From, a.Until); return(null); } }
public CalendarItemViewModel(IViewModelDependencies dependencies, IZetboxContext dataCtx, ViewModel parent, IAppointmentViewModel obj) : base(dependencies, dataCtx, parent) { if (obj == null) { throw new ArgumentNullException("obj"); } this.SlotWidth = this.OverlappingWidth = 1.0; this.ObjectViewModel = obj; this.ObjectViewModel.PropertyChanged += AppointmentViewModelChanged; }
private IEnumerable<CalendarItemViewModel> FindCalendarItemViewModel(IAppointmentViewModel mdl) { if (mdl == null) return null; return DayItems.SelectMany(i => i.CalendarItems.Where(c => c.ObjectViewModel == mdl)); }
private List<CalendarItemViewModel> CreateCalendarItemViewModel(IAppointmentViewModel a) { if (a.From <= a.Until) { List<CalendarItemViewModel> result = new List<CalendarItemViewModel>(); var from = a.From; var until = a.Until; if (from < this.From) from = this.From; if (until > this.To) until = this.To; for (var current = from; current < until; current = current.Date.AddDays(1)) { var vmdl = ViewModelFactory.CreateViewModel<CalendarItemViewModel.Factory>() .Invoke( DataContext, this, a); vmdl.From = current == a.From ? current : current.Date; vmdl.Until = current.Date == a.Until.Date ? a.Until : current.Date.AddDays(1); vmdl.IsAllDay = vmdl.From.TimeOfDay == TimeSpan.Zero && vmdl.Until.TimeOfDay == TimeSpan.Zero; result.Add(vmdl); } return result; } else { Logging.Client.WarnFormat("Appointment item {0} has an invalid time range of {1} - {2}", a.Subject, a.From, a.Until); return null; } }