Fix multi-day event recurrences for monthly calendar.
This commit is contained in:
@@ -330,21 +330,8 @@ namespace Wino.Calendar.ViewModels
|
|||||||
!(message.DisplayDate >= DayRanges.DisplayRange.StartDate && message.DisplayDate <= DayRanges.DisplayRange.EndDate));
|
!(message.DisplayDate >= DayRanges.DisplayRange.StartDate && message.DisplayDate <= DayRanges.DisplayRange.EndDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AdjustCalendarOrientation()
|
||||||
|
|
||||||
public async void Receive(LoadCalendarMessage message)
|
|
||||||
{
|
{
|
||||||
await _calendarLoadingSemaphore.WaitAsync();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await ExecuteUIThread(() => IsCalendarEnabled = false);
|
|
||||||
|
|
||||||
if (ShouldResetDayRanges(message))
|
|
||||||
{
|
|
||||||
Debug.WriteLine("Will reset day ranges.");
|
|
||||||
await ClearDayRangeModelsAsync();
|
|
||||||
|
|
||||||
// Orientation only changes when we should reset.
|
// Orientation only changes when we should reset.
|
||||||
// Handle the FlipView orientation here.
|
// Handle the FlipView orientation here.
|
||||||
// We don't want to change the orientation while the item manipulation is going on.
|
// We don't want to change the orientation while the item manipulation is going on.
|
||||||
@@ -362,6 +349,20 @@ namespace Wino.Calendar.ViewModels
|
|||||||
CalendarOrientation = CalendarOrientation.Horizontal;
|
CalendarOrientation = CalendarOrientation.Horizontal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async void Receive(LoadCalendarMessage message)
|
||||||
|
{
|
||||||
|
await _calendarLoadingSemaphore.WaitAsync();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ExecuteUIThread(() => IsCalendarEnabled = false);
|
||||||
|
|
||||||
|
if (ShouldResetDayRanges(message))
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Will reset day ranges.");
|
||||||
|
await ClearDayRangeModelsAsync();
|
||||||
|
}
|
||||||
else if (ShouldScrollToItem(message))
|
else if (ShouldScrollToItem(message))
|
||||||
{
|
{
|
||||||
// Scroll to the selected date.
|
// Scroll to the selected date.
|
||||||
@@ -370,6 +371,8 @@ namespace Wino.Calendar.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AdjustCalendarOrientation();
|
||||||
|
|
||||||
// This will replace the whole collection because the user initiated a new render.
|
// This will replace the whole collection because the user initiated a new render.
|
||||||
await RenderDatesAsync(message.CalendarInitInitiative,
|
await RenderDatesAsync(message.CalendarInitInitiative,
|
||||||
message.DisplayDate,
|
message.DisplayDate,
|
||||||
|
|||||||
@@ -367,9 +367,6 @@
|
|||||||
<RowDefinition Height="*" MinHeight="35" />
|
<RowDefinition Height="*" MinHeight="35" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Day number -->
|
|
||||||
<TextBlock x:Name="PART_HeaderDateDayText" FontSize="17" />
|
|
||||||
|
|
||||||
<!-- Extras -->
|
<!-- Extras -->
|
||||||
<StackPanel Grid.Column="1" HorizontalAlignment="Right" />
|
<StackPanel Grid.Column="1" HorizontalAlignment="Right" />
|
||||||
|
|
||||||
@@ -380,26 +377,14 @@
|
|||||||
Margin="0,6"
|
Margin="0,6"
|
||||||
Padding="0,0,16,0">
|
Padding="0,0,16,0">
|
||||||
<ItemsControl x:Name="PART_AllDayItemsControl">
|
<ItemsControl x:Name="PART_AllDayItemsControl">
|
||||||
<ItemsControl.ItemTemplateSelector>
|
<ItemsControl.ItemTemplate>
|
||||||
<selectors:CustomAreaCalendarItemSelector>
|
|
||||||
<selectors:CustomAreaCalendarItemSelector.AllDayTemplate>
|
|
||||||
<DataTemplate x:DataType="data:CalendarItemViewModel">
|
<DataTemplate x:DataType="data:CalendarItemViewModel">
|
||||||
<controls:CalendarItemControl
|
<controls:CalendarItemControl
|
||||||
CalendarItem="{x:Bind}"
|
CalendarItem="{x:Bind}"
|
||||||
DisplayingDate="{Binding DataContext, ElementName=PART_AllDayItemsControl}"
|
DisplayingDate="{Binding DataContext, ElementName=PART_AllDayItemsControl}"
|
||||||
IsCustomEventArea="True" />
|
IsCustomEventArea="True" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</selectors:CustomAreaCalendarItemSelector.AllDayTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
<selectors:CustomAreaCalendarItemSelector.MultiDayTemplate>
|
|
||||||
<DataTemplate x:DataType="data:CalendarItemViewModel">
|
|
||||||
<controls:CalendarItemControl
|
|
||||||
CalendarItem="{x:Bind}"
|
|
||||||
DisplayingDate="{Binding DataContext, ElementName=PART_AllDayItemsControl}"
|
|
||||||
IsCustomEventArea="True" />
|
|
||||||
</DataTemplate>
|
|
||||||
</selectors:CustomAreaCalendarItemSelector.MultiDayTemplate>
|
|
||||||
</selectors:CustomAreaCalendarItemSelector>
|
|
||||||
</ItemsControl.ItemTemplateSelector>
|
|
||||||
<ItemsControl.ItemContainerTransitions>
|
<ItemsControl.ItemContainerTransitions>
|
||||||
<TransitionCollection>
|
<TransitionCollection>
|
||||||
<AddDeleteThemeTransition />
|
<AddDeleteThemeTransition />
|
||||||
|
|||||||
@@ -123,5 +123,37 @@ namespace Wino.Core.Domain.Entities.Calendar
|
|||||||
|
|
||||||
[Ignore]
|
[Ignore]
|
||||||
public IAccountCalendar AssignedCalendar { get; set; }
|
public IAccountCalendar AssignedCalendar { get; set; }
|
||||||
|
|
||||||
|
public CalendarItem CreateRecurrence(DateTime startDate, double durationInSeconds)
|
||||||
|
{
|
||||||
|
// Create a copy with the new start date and duration
|
||||||
|
|
||||||
|
return new CalendarItem
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Title = Title,
|
||||||
|
Description = Description,
|
||||||
|
Location = Location,
|
||||||
|
StartDate = startDate,
|
||||||
|
DurationInSeconds = durationInSeconds,
|
||||||
|
Recurrence = Recurrence,
|
||||||
|
OrganizerDisplayName = OrganizerDisplayName,
|
||||||
|
OrganizerEmail = OrganizerEmail,
|
||||||
|
RecurringCalendarItemId = Id,
|
||||||
|
AssignedCalendar = AssignedCalendar,
|
||||||
|
CalendarId = CalendarId,
|
||||||
|
CreatedAt = CreatedAt,
|
||||||
|
UpdatedAt = UpdatedAt,
|
||||||
|
Visibility = Visibility,
|
||||||
|
Status = Status,
|
||||||
|
CustomEventColorHex = CustomEventColorHex,
|
||||||
|
HtmlLink = HtmlLink,
|
||||||
|
StartDateOffset = StartDateOffset,
|
||||||
|
EndDateOffset = EndDateOffset,
|
||||||
|
RemoteEventId = RemoteEventId,
|
||||||
|
IsHidden = IsHidden,
|
||||||
|
IsLocked = IsLocked,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,10 +158,9 @@ namespace Wino.Services
|
|||||||
// There is no exception for the period.
|
// There is no exception for the period.
|
||||||
// Change the instance StartDate and Duration.
|
// Change the instance StartDate and Duration.
|
||||||
|
|
||||||
ev.StartDate = occurrence.Period.StartTime.Value;
|
var recurrence = ev.CreateRecurrence(occurrence.Period.StartTime.Value, occurrence.Period.Duration.TotalSeconds);
|
||||||
ev.DurationInSeconds = (occurrence.Period.EndTime.Value - occurrence.Period.StartTime.Value).TotalSeconds;
|
|
||||||
|
|
||||||
result.Add(ev);
|
result.Add(recurrence);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user