Fixed the display date of the calendar items. Created test project for core library, included tests for recurring calendar events.
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
<StackPanel
|
||||
x:Name="AttributeStack"
|
||||
Grid.Column="1"
|
||||
Margin="0,4,0,0"
|
||||
Margin="0,4,4,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Orientation="Horizontal"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Itenso.TimePeriod;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Wino.Calendar.ViewModels.Data;
|
||||
using Wino.Calendar.ViewModels.Messages;
|
||||
using Wino.Core.Domain;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Wino.Calendar.Controls;
|
||||
using Wino.Core.Domain.Models.Calendar;
|
||||
|
||||
namespace Wino.Mail.WinUI.Controls.Calendar;
|
||||
|
||||
/// <summary>
|
||||
/// AOT-Safe ItemsControl for use in UniformGrid panels.
|
||||
/// </summary>
|
||||
///
|
||||
public partial class UniformItemsControl : Grid
|
||||
{
|
||||
[GeneratedDependencyProperty]
|
||||
public partial DayRangeRenderModel? RenderModel { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial List<CalendarDayModel>? ItemsSource { get; set; }
|
||||
|
||||
partial void OnRenderModelChanged(DayRangeRenderModel? newValue)
|
||||
{
|
||||
if (newValue == null || ItemsSource == null) return;
|
||||
|
||||
AdjustColumns();
|
||||
}
|
||||
|
||||
partial void OnItemsSourceChanged(List<CalendarDayModel>? newValue)
|
||||
{
|
||||
if (newValue == null || ItemsSource == null) return;
|
||||
|
||||
AdjustColumns();
|
||||
}
|
||||
|
||||
private void AdjustColumns()
|
||||
{
|
||||
if (RenderModel == null || ItemsSource == null) return;
|
||||
|
||||
Children.Clear();
|
||||
ColumnDefinitions.Clear();
|
||||
|
||||
var columns = RenderModel.TotalDays;
|
||||
|
||||
// First divide.
|
||||
for (int i = 0; i < columns; i++)
|
||||
{
|
||||
ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
|
||||
}
|
||||
|
||||
// Then add items.
|
||||
for (int i = 0; i < columns; i++)
|
||||
{
|
||||
var item = ItemsSource[i];
|
||||
|
||||
var control = new DayColumnControl()
|
||||
{
|
||||
DayModel = item
|
||||
};
|
||||
|
||||
SetColumn(control, i);
|
||||
Children.Add(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
//public partial class UniformItemsControl : ItemsControl
|
||||
//{
|
||||
// private const string ControlUniformGridName = "PART_UniformGrid";
|
||||
|
||||
// [GeneratedDependencyProperty]
|
||||
// public partial DayRangeRenderModel? RenderModel { get; set; }
|
||||
|
||||
// partial void OnRenderModelChanged(DayRangeRenderModel? newValue)
|
||||
// {
|
||||
// if (newValue == null) return;
|
||||
|
||||
// // Adjust the ItemsPanel based on the RenderModel's columns.
|
||||
// var uniGrid = WinoVisualTreeHelper.FindDescendants<UniformGrid>(this);
|
||||
|
||||
// //if (uniGrid != null)
|
||||
// //{
|
||||
// // uniGrid.Columns = newValue.TotalDays;
|
||||
// //}
|
||||
// }
|
||||
//}
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Microsoft.Graphics.Canvas.Geometry;
|
||||
using Microsoft.Graphics.Canvas.UI.Xaml;
|
||||
using Microsoft.UI.Input;
|
||||
@@ -110,6 +112,11 @@ public partial class WinoDayTimelineCanvas : Control, IDisposable
|
||||
|
||||
// When users click to cell we need to find the day, hour and minutes (first 30 minutes or second 30 minutes) that it represents on the timeline.
|
||||
|
||||
if (PositionerUIElement == null)
|
||||
{
|
||||
PositionerUIElement = this.FindParents().LastOrDefault(a => a is Grid);
|
||||
}
|
||||
|
||||
PointerPoint positionerRootPoint = e.GetCurrentPoint(PositionerUIElement);
|
||||
PointerPoint canvasPointerPoint = e.GetCurrentPoint(Canvas);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user