Updating visibilities on calendar events on calendar activation/deactivation.

This commit is contained in:
Burak Kaan Köse
2024-12-30 01:15:31 +01:00
parent bb56815210
commit 8cc7d46d7b
5 changed files with 166 additions and 106 deletions

View File

@@ -78,6 +78,8 @@ namespace Wino.Calendar.Controls
collection.CalendarItemRangeAdded += CollectionOfEventsUpdated;
collection.CalendarItemRangeRemoved += CollectionOfEventsUpdated;
collection.CalendarItemsCleared += EventsCleared;
}
private void UnregisterEventCollectionChanged(CalendarEventCollection collection)
@@ -87,10 +89,13 @@ namespace Wino.Calendar.Controls
collection.CalendarItemRangeAdded -= CollectionOfEventsUpdated;
collection.CalendarItemRangeRemoved -= CollectionOfEventsUpdated;
collection.CalendarItemsCleared -= EventsCleared;
}
private void SingleEventUpdated(object sender, ICalendarItem calendarItem) => UpdateCollectionVisuals();
private void CollectionOfEventsUpdated(object sender, List<ICalendarItem> calendarItems) => UpdateCollectionVisuals();
private void EventsCleared(object sender, System.EventArgs e) => UpdateCollectionVisuals();
private void UpdateCollectionVisuals()
{

View File

@@ -20,7 +20,6 @@ namespace Wino.Calendar.Controls
private readonly Dictionary<Guid, CalendarItemMeasurement> _measurements = new Dictionary<Guid, CalendarItemMeasurement>();
public static readonly DependencyProperty EventItemMarginProperty = DependencyProperty.Register(nameof(EventItemMargin), typeof(Thickness), typeof(WinoCalendarPanel), new PropertyMetadata(new Thickness(0, 0, 0, 0)));
// public static readonly DependencyProperty RepresentingDateProperty = DependencyProperty.Register(nameof(RepresentingDate), typeof(DateTime), typeof(WinoCalendarControl), new PropertyMetadata(DateTime.MinValue));
public static readonly DependencyProperty HourHeightProperty = DependencyProperty.Register(nameof(HourHeight), typeof(double), typeof(WinoCalendarPanel), new PropertyMetadata(0d));
public double HourHeight
@@ -35,44 +34,6 @@ namespace Wino.Calendar.Controls
set { SetValue(EventItemMarginProperty, value); }
}
//private static void OnDayChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
//{
// if (d is WinoCalendarPanel control)
// {
// // We need to listen for new events being added or removed from the collection to reset measurements.
// if (e.OldValue is CalendarDayModel oldDayModel)
// {
// control.DetachCollection(oldDayModel.EventsCollection.RegularEvents);
// }
// if (e.NewValue is CalendarDayModel newDayModel)
// {
// control.AttachCollection(newDayModel.EventsCollection.RegularEvents);
// }
// control.ResetMeasurements();
// control.UpdateLayout();
// }
//}
//private void AttachCollection(IEnumerable<ICalendarItem> events)
//{
// if (events is INotifyCollectionChanged collection)
// {
// // var t = new Grid();
// collection.CollectionChanged += EventCollectionChanged;
// }
//}
//private void DetachCollection(IEnumerable<ICalendarItem> events)
//{
// if (events is INotifyCollectionChanged collection)
// {
// collection.CollectionChanged -= EventCollectionChanged;
// }
//}
private void ResetMeasurements() => _measurements.Clear();
// No need to handle actions. Each action requires a full measurement update.