Improved calendar rendering, standartization of some templates and cleanup of old styles.

This commit is contained in:
Burak Kaan Köse
2024-12-29 22:30:00 +01:00
parent f7bfbd5080
commit d3780244cd
18 changed files with 333 additions and 481 deletions

View File

@@ -1,36 +1,87 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Wino.Core.Domain.Interfaces;
namespace Wino.Core.Domain.Collections
{
// TODO: Could be read-only collection in the MVVM package.
public class CalendarEventCollection : ObservableRangeCollection<ICalendarItem>
public class CalendarEventCollection
{
public ObservableCollection<ICalendarItem> AllDayEvents { get; } = new ObservableCollection<ICalendarItem>();
public new void Add(ICalendarItem calendarItem)
public event EventHandler<ICalendarItem> CalendarItemAdded;
public event EventHandler<ICalendarItem> CalendarItemRemoved;
public event EventHandler<List<ICalendarItem>> CalendarItemRangeAdded;
public event EventHandler<List<ICalendarItem>> CalendarItemRangeRemoved;
private ObservableRangeCollection<ICalendarItem> _internalRegularEvents = [];
private ObservableRangeCollection<ICalendarItem> _internalAllDayEvents = [];
public ReadOnlyObservableCollection<ICalendarItem> RegularEvents { get; }
public ReadOnlyObservableCollection<ICalendarItem> AllDayEvents { get; }
public CalendarEventCollection()
{
RegularEvents = new ReadOnlyObservableCollection<ICalendarItem>(_internalRegularEvents);
AllDayEvents = new ReadOnlyObservableCollection<ICalendarItem>(_internalAllDayEvents);
}
public void AddCalendarItemRange(IEnumerable<ICalendarItem> calendarItems, bool reportChange = true)
{
foreach (var calendarItem in calendarItems)
{
AddCalendarItem(calendarItem, reportChange: false);
}
CalendarItemRangeAdded?.Invoke(this, new List<ICalendarItem>(calendarItems));
}
public void RemoveCalendarItemRange(IEnumerable<ICalendarItem> calendarItems, bool reportChange = true)
{
foreach (var calendarItem in calendarItems)
{
RemoveCalendarItem(calendarItem, reportChange);
}
CalendarItemRangeRemoved?.Invoke(this, new List<ICalendarItem>(calendarItems));
}
public void AddCalendarItem(ICalendarItem calendarItem, bool reportChange = true)
{
if (calendarItem is not ICalendarItemViewModel)
throw new ArgumentException("CalendarItem must be of type ICalendarItemViewModel", nameof(calendarItem));
base.Add(calendarItem);
if (calendarItem.Period.Duration.TotalMinutes == 1440)
{
AllDayEvents.Add(calendarItem);
_internalAllDayEvents.Add(calendarItem);
}
else
{
_internalRegularEvents.Add(calendarItem);
}
if (reportChange)
{
CalendarItemAdded?.Invoke(this, calendarItem);
}
}
public new void Remove(ICalendarItem calendarItem)
public void RemoveCalendarItem(ICalendarItem calendarItem, bool reportChange = true)
{
if (calendarItem is not ICalendarItemViewModel)
throw new ArgumentException("CalendarItem must be of type ICalendarItemViewModel", nameof(calendarItem));
base.Remove(calendarItem);
if (calendarItem.Period.Duration.TotalMinutes == 1440)
{
AllDayEvents.Remove(calendarItem);
_internalAllDayEvents.Remove(calendarItem);
}
else
{
_internalRegularEvents.Remove(calendarItem);
}
if (reportChange)
{
CalendarItemRemoved?.Invoke(this, calendarItem);
}
}
}