/// <summary> /// Converts a collection of <see cref="TimeSlot"/> to start end date string. /// </summary> /// <param name="value">The collection of time slots.</param> /// <param name="targetType">This parameter is not used.</param> /// <param name="parameter">This parameter is not used.</param> /// <param name="culture">This parameter is not used.</param> /// <returns> /// A <see cref="string"/> created from the first time slot's <see cref="TimeSlot.Start"/> and /// the last time slot's <see cref="TimeSlot.End"/> using "MMMd" as format string. The char '-' is /// used as a splitter between two dates. /// <remarks> /// If <paramref name="value"/> is not <see cref="IEnumerable{T}"/> of <see cref="TimeSlot"/> an empty string is returned. /// </remarks> /// </returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var enumerable = value as IEnumerable; if (enumerable != null) { IEnumerable <TimeSlot> timeSlots; try { timeSlots = enumerable.Cast <TimeSlot>().ToList(); } catch (InvalidCastException) { return(string.Empty); } var group = new TimeSlotGroup(timeSlots); DateTime start = group.Start; DateTime end = group.End.AddMilliseconds(-1); string startString = start.ToString("d ", culture); if (start.Month != end.Month) { startString += start.GetShortMonthName(culture) + " "; } string endString = end.ToString("d ", culture) + end.GetShortMonthName(culture); return(string.Concat(startString, "- ", endString)); } return(string.Empty); }
/// <summary> /// Responds to a list box selection change by raising a <see cref="System.Windows.Controls.Primitives.Selector.SelectionChanged"/> event. /// </summary> /// <param name="e">Provides data for <see cref="System.Windows.Controls.SelectionChangedEventArgs"/>.</param> protected override void OnSelectionChanged(System.Windows.Controls.SelectionChangedEventArgs e) { base.OnSelectionChanged(e); if (this.shouldUpdateSelectedTimeSlot && this.SelectedItems.Count > 0) { var selectedItems = new TimeSlotGroup(this.SelectedItems.Cast <TimeSlot>()); if (selectedItems != this.SelectedTimeSlot) { this.SelectedTimeSlot = selectedItems; } } }
private TimeRulerItem GetTimeRulerItemContainer(TimeSlotGroup group) { return(this.ItemContainerGenerator.ContainerFromItem(group) as TimeRulerItem); }