Fix multi-day event recurrences for monthly calendar.
This commit is contained in:
@@ -330,7 +330,25 @@ namespace Wino.Calendar.ViewModels
|
||||
!(message.DisplayDate >= DayRanges.DisplayRange.StartDate && message.DisplayDate <= DayRanges.DisplayRange.EndDate));
|
||||
}
|
||||
|
||||
private void AdjustCalendarOrientation()
|
||||
{
|
||||
// Orientation only changes when we should reset.
|
||||
// Handle the FlipView orientation here.
|
||||
// We don't want to change the orientation while the item manipulation is going on.
|
||||
// That causes a glitch in the UI.
|
||||
|
||||
bool isRequestedVerticalCalendar = StatePersistanceService.CalendarDisplayType == CalendarDisplayType.Month;
|
||||
bool isLastRenderedVerticalCalendar = _currentDisplayType == CalendarDisplayType.Month;
|
||||
|
||||
if (isRequestedVerticalCalendar && !isLastRenderedVerticalCalendar)
|
||||
{
|
||||
CalendarOrientation = CalendarOrientation.Vertical;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalendarOrientation = CalendarOrientation.Horizontal;
|
||||
}
|
||||
}
|
||||
|
||||
public async void Receive(LoadCalendarMessage message)
|
||||
{
|
||||
@@ -344,23 +362,6 @@ namespace Wino.Calendar.ViewModels
|
||||
{
|
||||
Debug.WriteLine("Will reset day ranges.");
|
||||
await ClearDayRangeModelsAsync();
|
||||
|
||||
// Orientation only changes when we should reset.
|
||||
// Handle the FlipView orientation here.
|
||||
// We don't want to change the orientation while the item manipulation is going on.
|
||||
// That causes a glitch in the UI.
|
||||
|
||||
bool isRequestedVerticalCalendar = StatePersistanceService.CalendarDisplayType == CalendarDisplayType.Month;
|
||||
bool isLastRenderedVerticalCalendar = _currentDisplayType == CalendarDisplayType.Month;
|
||||
|
||||
if (isRequestedVerticalCalendar && !isLastRenderedVerticalCalendar)
|
||||
{
|
||||
CalendarOrientation = CalendarOrientation.Vertical;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalendarOrientation = CalendarOrientation.Horizontal;
|
||||
}
|
||||
}
|
||||
else if (ShouldScrollToItem(message))
|
||||
{
|
||||
@@ -370,6 +371,8 @@ namespace Wino.Calendar.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
AdjustCalendarOrientation();
|
||||
|
||||
// This will replace the whole collection because the user initiated a new render.
|
||||
await RenderDatesAsync(message.CalendarInitInitiative,
|
||||
message.DisplayDate,
|
||||
|
||||
@@ -367,9 +367,6 @@
|
||||
<RowDefinition Height="*" MinHeight="35" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Day number -->
|
||||
<TextBlock x:Name="PART_HeaderDateDayText" FontSize="17" />
|
||||
|
||||
<!-- Extras -->
|
||||
<StackPanel Grid.Column="1" HorizontalAlignment="Right" />
|
||||
|
||||
@@ -380,26 +377,14 @@
|
||||
Margin="0,6"
|
||||
Padding="0,0,16,0">
|
||||
<ItemsControl x:Name="PART_AllDayItemsControl">
|
||||
<ItemsControl.ItemTemplateSelector>
|
||||
<selectors:CustomAreaCalendarItemSelector>
|
||||
<selectors:CustomAreaCalendarItemSelector.AllDayTemplate>
|
||||
<DataTemplate x:DataType="data:CalendarItemViewModel">
|
||||
<controls:CalendarItemControl
|
||||
CalendarItem="{x:Bind}"
|
||||
DisplayingDate="{Binding DataContext, ElementName=PART_AllDayItemsControl}"
|
||||
IsCustomEventArea="True" />
|
||||
</DataTemplate>
|
||||
</selectors:CustomAreaCalendarItemSelector.AllDayTemplate>
|
||||
<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.ItemTemplate>
|
||||
<DataTemplate x:DataType="data:CalendarItemViewModel">
|
||||
<controls:CalendarItemControl
|
||||
CalendarItem="{x:Bind}"
|
||||
DisplayingDate="{Binding DataContext, ElementName=PART_AllDayItemsControl}"
|
||||
IsCustomEventArea="True" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.ItemContainerTransitions>
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition />
|
||||
|
||||
@@ -123,5 +123,37 @@ namespace Wino.Core.Domain.Entities.Calendar
|
||||
|
||||
[Ignore]
|
||||
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.
|
||||
// Change the instance StartDate and Duration.
|
||||
|
||||
ev.StartDate = occurrence.Period.StartTime.Value;
|
||||
ev.DurationInSeconds = (occurrence.Period.EndTime.Value - occurrence.Period.StartTime.Value).TotalSeconds;
|
||||
var recurrence = ev.CreateRecurrence(occurrence.Period.StartTime.Value, occurrence.Period.Duration.TotalSeconds);
|
||||
|
||||
result.Add(ev);
|
||||
result.Add(recurrence);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user