Calendar rendering improvements.
This commit is contained in:
@@ -327,7 +327,18 @@ public partial class CalendarEventComposePageViewModel : CalendarBaseViewModel
|
||||
CalendarSynchronizerOperation.CreateEvent,
|
||||
ComposeResult: createdResult));
|
||||
|
||||
_navigationService.GoBack();
|
||||
NavigateBackToCalendar(createdResult.StartDate);
|
||||
}
|
||||
|
||||
private void NavigateBackToCalendar(DateTime targetDate)
|
||||
{
|
||||
_navigationService.Navigate(
|
||||
WinoPage.CalendarPage,
|
||||
new CalendarPageNavigationArgs
|
||||
{
|
||||
NavigationDate = targetDate,
|
||||
ForceReload = true
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<List<AccountContact>> SearchContactsAsync(string queryText)
|
||||
|
||||
@@ -569,33 +569,39 @@ public partial class CalendarPageViewModel : CalendarBaseViewModel,
|
||||
if (!IsPageActive(lifetimeVersion))
|
||||
return;
|
||||
|
||||
RefreshSettings();
|
||||
var currentSettings = CurrentSettings;
|
||||
if (currentSettings == null)
|
||||
{
|
||||
RefreshSettings();
|
||||
currentSettings = CurrentSettings;
|
||||
}
|
||||
|
||||
var today = _dateContextProvider.GetToday();
|
||||
var visibleRange = CalendarRangeResolver.Resolve(request, CurrentSettings, today);
|
||||
var previousRange = CalendarRangeResolver.Navigate(visibleRange, -1, CurrentSettings, today);
|
||||
var nextRange = CalendarRangeResolver.Navigate(visibleRange, 1, CurrentSettings, today);
|
||||
var visibleRange = CalendarRangeResolver.Resolve(request, currentSettings, today);
|
||||
var previousRange = CalendarRangeResolver.Navigate(visibleRange, -1, currentSettings, today);
|
||||
var nextRange = CalendarRangeResolver.Navigate(visibleRange, 1, currentSettings, today);
|
||||
var loadedDateWindow = new DateRange(
|
||||
previousRange.StartDate.ToDateTime(TimeOnly.MinValue),
|
||||
nextRange.EndDate.AddDays(1).ToDateTime(TimeOnly.MinValue));
|
||||
|
||||
var shouldReload = forceReload || !IsSameVisibleRange(CurrentVisibleRange, visibleRange) || !IsSameDateRange(LoadedDateWindow, loadedDateWindow);
|
||||
List<CalendarItemViewModel> loadedItems = null;
|
||||
|
||||
if (shouldReload)
|
||||
{
|
||||
var loadedItems = await LoadCalendarItemsAsync(loadedDateWindow, lifetimeVersion).ConfigureAwait(false);
|
||||
loadedItems = await LoadCalendarItemsAsync(loadedDateWindow, lifetimeVersion).ConfigureAwait(false);
|
||||
if (!IsPageActive(lifetimeVersion))
|
||||
return;
|
||||
|
||||
await ExecuteUIThreadIfActiveAsync(lifetimeVersion, () =>
|
||||
{
|
||||
_loadedCalendarItems = loadedItems;
|
||||
CalendarItems = loadedItems;
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await ExecuteUIThreadIfActiveAsync(lifetimeVersion, () =>
|
||||
{
|
||||
if (loadedItems != null)
|
||||
{
|
||||
_loadedCalendarItems = loadedItems;
|
||||
CalendarItems = loadedItems;
|
||||
}
|
||||
|
||||
CurrentVisibleRange = visibleRange;
|
||||
LoadedDateWindow = loadedDateWindow;
|
||||
VisibleDateRangeText = _calendarRangeTextFormatter.Format(visibleRange, _dateContextProvider);
|
||||
|
||||
@@ -228,7 +228,7 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
|
||||
// If the current event was deleted, navigate back
|
||||
if (CurrentEvent?.CalendarItem?.Id == calendarItem.Id || CurrentEvent?.CalendarItem.RecurringCalendarItemId == calendarItem.Id)
|
||||
{
|
||||
_navigationService.GoBack();
|
||||
NavigateBackToCalendar(forceReload: true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
|
||||
|
||||
await _winoRequestDelegator.ExecuteAsync(preparationRequest);
|
||||
|
||||
_navigationService.GoBack();
|
||||
NavigateBackToCalendar(forceReload: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -490,8 +490,7 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
|
||||
|
||||
await _winoRequestDelegator.ExecuteAsync(preparationRequest);
|
||||
|
||||
// Navigate back after successful deletion
|
||||
_navigationService.GoBack();
|
||||
NavigateBackToCalendar(forceReload: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -499,6 +498,19 @@ public partial class EventDetailsPageViewModel : CalendarBaseViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private void NavigateBackToCalendar(bool forceReload)
|
||||
{
|
||||
var navigationDate = CurrentEvent?.CalendarItem.LocalStartDate ?? DateTime.Now;
|
||||
|
||||
_navigationService.Navigate(
|
||||
WinoPage.CalendarPage,
|
||||
new CalendarPageNavigationArgs
|
||||
{
|
||||
NavigationDate = navigationDate,
|
||||
ForceReload = forceReload
|
||||
});
|
||||
}
|
||||
|
||||
public override async Task KeyboardShortcutHook(KeyboardShortcutTriggerDetails args)
|
||||
{
|
||||
if (args.Handled || args.Mode != WinoApplicationMode.Calendar || args.Action != KeyboardShortcutAction.Delete)
|
||||
|
||||
@@ -13,4 +13,9 @@ public class CalendarPageNavigationArgs
|
||||
/// Display the calendar view for the specified date.
|
||||
/// </summary>
|
||||
public DateTime NavigationDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Force reloading the calendar data even when the target range does not change.
|
||||
/// </summary>
|
||||
public bool ForceReload { get; set; }
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<!-- Reading Page Date/Name Group Header Background -->
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#ecf0f1</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#B2FCFCFC</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#D9ECEFF1</SolidColorBrush>
|
||||
|
||||
<local:AcrylicBrush
|
||||
x:Key="WinoApplicationBackgroundColor"
|
||||
@@ -23,6 +25,8 @@
|
||||
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#2C2C2C</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#662C2C2C</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#992C2C2C</SolidColorBrush>
|
||||
|
||||
<local:AcrylicBrush
|
||||
x:Key="WinoApplicationBackgroundColor"
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#b2dffc</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#33B2DFFC</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#66B2DFFC</SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="CalendarSeperatorBrush">#222f3e</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#b2dffc</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#33B2DFFC</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#66B2DFFC</SolidColorBrush>
|
||||
|
||||
<SolidColorBrush x:Key="CalendarSeperatorBrush">#222f3e</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#ecf0f1</SolidColorBrush>
|
||||
|
||||
<Color x:Key="MainCustomThemeColor">#D9FFFFFF</Color>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush" Color="{StaticResource MainCustomThemeColor}" Opacity="0.55" />
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush" Color="{StaticResource MainCustomThemeColor}" Opacity="0.85" />
|
||||
|
||||
<SolidColorBrush x:Key="AppBarBackgroundColor" Color="{StaticResource MainCustomThemeColor}" />
|
||||
<SolidColorBrush x:Key="NavigationViewContentBackground" Color="Transparent" />
|
||||
@@ -33,6 +35,8 @@
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#1f1f1f</SolidColorBrush>
|
||||
|
||||
<Color x:Key="MainCustomThemeColor">#E61F1F1F</Color>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush" Color="{StaticResource MainCustomThemeColor}" Opacity="0.55" />
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush" Color="{StaticResource MainCustomThemeColor}" Opacity="0.85" />
|
||||
|
||||
<!-- Reading Pane Background -->
|
||||
<SolidColorBrush x:Key="ReadingPaneBackgroundColorBrush" Color="{StaticResource MainCustomThemeColor}" />
|
||||
|
||||
@@ -13,9 +13,13 @@
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<!-- Reading Page Date/Name Group Header Background -->
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#ecf0f1</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#F7F9FA</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#DFE4EA</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#1f1f1f</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#1F1F1F</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#262626</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -12,9 +12,13 @@
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#A800D608</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#2200D608</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#4D00D608</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#59001C01</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#22001C01</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#59001C01</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -12,12 +12,16 @@
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#dcfad8</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#26DCFAD8</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#59DCFAD8</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarSeperatorBrush">#576574</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
|
||||
<!-- N/A. Light theme only. -->
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#dcfad8</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#26576574</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#59576574</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<!-- Brushes -->
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#fdcb6e</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#33FDCB6E</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#66FDCB6E</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<!-- Brushes -->
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#5413191F</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#2213191F</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#5413191F</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -13,10 +13,14 @@
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<!-- Brushes -->
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#b0c6dd</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#33B0C6DD</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#66B0C6DD</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<!-- Brushes -->
|
||||
<SolidColorBrush x:Key="MailListHeaderBackgroundColor">#b0c6dd</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarDefaultHourBackgroundBrush">#33B0C6DD</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="CalendarWorkHourBackgroundBrush">#66B0C6DD</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<x:String x:Key="ThemeName">TestTheme.xaml</x:String>
|
||||
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Name="Light">
|
||||
<!-- Background Image -->
|
||||
<x:String x:Key="ThemeBackgroundImage">ms-appx:///BackgroundImages/bg6.jpg</x:String>
|
||||
<SolidColorBrush x:Key="ShellTitleBarBackgroundColorBrush">#A3FFFFFF</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="ShellNavigationViewBackgroundColorBrush">#A3FFFFFF</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="ReadingPaneBackgroundColorBrush">#fdcb6e</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary x:Name="Dark">
|
||||
<!-- Background Image -->
|
||||
<x:String x:Key="ThemeBackgroundImage">ms-appx:///BackgroundImages/bg6.jpg</x:String>
|
||||
|
||||
<SolidColorBrush x:Key="ShellTitleBarBackgroundColorBrush">#A3000000</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="ShellNavigationViewBackgroundColorBrush">#A3000000</SolidColorBrush>
|
||||
<SolidColorBrush x:Key="ReadingPaneBackgroundColorBrush">#A3262626</SolidColorBrush>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary.ThemeDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -9,12 +9,14 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:skia="using:SkiaSharp.Views.Windows"
|
||||
xmlns:viewModels="using:Wino.Calendar.ViewModels.Data"
|
||||
|
||||
x:Name="Root"
|
||||
Loaded="ControlLoaded"
|
||||
SizeChanged="ControlSizeChanged"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
|
||||
|
||||
<DataTemplate x:Key="CalendarEventTemplate" x:DataType="viewModels:CalendarItemViewModel">
|
||||
<local:CalendarItemControl CalendarItem="{x:Bind}" />
|
||||
</DataTemplate>
|
||||
|
||||
@@ -3,12 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CommunityToolkit.WinUI;
|
||||
using Itenso.TimePeriod;
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Composition;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Hosting;
|
||||
@@ -27,6 +30,8 @@ namespace Wino.Calendar.Controls;
|
||||
|
||||
public sealed partial class CalendarPeriodControl : UserControl, INotifyPropertyChanged
|
||||
{
|
||||
private static readonly TimeSpan SizeRefreshDebounceInterval = TimeSpan.FromMilliseconds(75);
|
||||
private const double SizeChangeThreshold = 0.5d;
|
||||
private const double TimedHourColumnWidth = 64d;
|
||||
private const double TimedGridIntervalMinutes = 30d;
|
||||
private const double TimedSelectionIntervalMinutes = 30d;
|
||||
@@ -48,9 +53,12 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
private double _monthCellWidth;
|
||||
private double _monthCellHeight;
|
||||
private bool _hasPresentedState;
|
||||
private bool _refreshPending = true;
|
||||
private bool _refreshScheduled;
|
||||
private CalendarDisplayType _lastDisplayMode = CalendarDisplayType.Month;
|
||||
private DateOnly _lastDisplayDate = DateOnly.FromDateTime(DateTime.Today);
|
||||
private DayOfWeek _lastFirstDayOfWeek = DayOfWeek.Monday;
|
||||
private readonly DispatcherQueueTimer _sizeRefreshTimer;
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial VisibleDateRange? VisibleRange { get; set; }
|
||||
@@ -64,7 +72,21 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
[GeneratedDependencyProperty]
|
||||
public partial string? TimedHeaderDateFormat { get; set; }
|
||||
|
||||
public CalendarPeriodControl() => InitializeComponent();
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Brush? DefaultHourBackground { get; set; }
|
||||
|
||||
[GeneratedDependencyProperty]
|
||||
public partial Brush? WorkHourBackground { get; set; }
|
||||
|
||||
public CalendarPeriodControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_sizeRefreshTimer = DispatcherQueue.CreateTimer();
|
||||
_sizeRefreshTimer.Interval = SizeRefreshDebounceInterval;
|
||||
_sizeRefreshTimer.IsRepeating = false;
|
||||
_sizeRefreshTimer.Tick += SizeRefreshTimerTick;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
public event EventHandler<CalendarEmptySlotTappedEventArgs>? EmptySlotTapped;
|
||||
@@ -128,33 +150,51 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
|
||||
public double TimelineHeight => TimedCalendarLayoutCalculator.GetTimelineHeight(GetHourHeight());
|
||||
|
||||
partial void OnVisibleRangeChanged(VisibleDateRange? newValue) => Refresh();
|
||||
partial void OnCalendarSettingsChanged(CalendarSettings? newValue) => Refresh();
|
||||
partial void OnTimedHeaderDateFormatChanged(string? newValue) => Refresh();
|
||||
partial void OnVisibleRangeChanged(VisibleDateRange? newValue) => RequestRefresh();
|
||||
partial void OnCalendarSettingsChanged(CalendarSettings? newValue) => RequestRefresh();
|
||||
partial void OnTimedHeaderDateFormatChanged(string? newValue) => RequestRefresh();
|
||||
|
||||
partial void OnCalendarItemsChanged(IReadOnlyList<CalendarItemViewModel>? newValue)
|
||||
{
|
||||
DetachCurrentItemsSource();
|
||||
AttachItemsSource(newValue);
|
||||
Refresh();
|
||||
RequestRefresh();
|
||||
}
|
||||
|
||||
private void ControlLoaded(object sender, RoutedEventArgs e)
|
||||
private void ControlSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
AttachItemsSource(CalendarItems);
|
||||
Refresh();
|
||||
}
|
||||
if (!HasMeaningfulSizeChange(e))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private void ControlSizeChanged(object sender, SizeChangedEventArgs e) => Refresh();
|
||||
var isLiveResize = _hasPresentedState &&
|
||||
e.PreviousSize.Width > 0 &&
|
||||
e.PreviousSize.Height > 0;
|
||||
|
||||
if (isLiveResize)
|
||||
{
|
||||
_refreshPending = true;
|
||||
_sizeRefreshTimer.Stop();
|
||||
_sizeRefreshTimer.Start();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_refreshPending)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QueueRefresh();
|
||||
}
|
||||
|
||||
private IEnumerable<CalendarItemViewModel> CurrentItems => CalendarItems ?? [];
|
||||
|
||||
private void AttachItemsSource(IReadOnlyList<CalendarItemViewModel>? itemsSource)
|
||||
{
|
||||
_observableItemsSource = itemsSource as INotifyCollectionChanged;
|
||||
|
||||
if (_observableItemsSource is not null)
|
||||
if (itemsSource is INotifyCollectionChanged observableItemsSource)
|
||||
{
|
||||
_observableItemsSource = observableItemsSource;
|
||||
_observableItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
|
||||
}
|
||||
}
|
||||
@@ -183,11 +223,17 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
}
|
||||
}
|
||||
|
||||
private void ItemsSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) => Refresh();
|
||||
private void ItemsSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) => RequestRefresh();
|
||||
|
||||
private void RequestRefresh()
|
||||
{
|
||||
_refreshPending = true;
|
||||
QueueRefresh();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
if (!IsLoaded || ActualWidth <= 0 || VisibleRange is null || CalendarSettings is null)
|
||||
if (!_refreshPending || !IsLoaded || ActualWidth <= 0 || VisibleRange is null || CalendarSettings is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -206,9 +252,37 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
|
||||
RunTransition(transition);
|
||||
_hasPresentedState = true;
|
||||
_refreshPending = false;
|
||||
_lastDisplayMode = VisibleRange.DisplayType;
|
||||
_lastDisplayDate = VisibleRange.AnchorDate;
|
||||
_lastFirstDayOfWeek = CalendarSettings.FirstDayOfWeek;
|
||||
|
||||
Debug.WriteLine($"Refreshed control.");
|
||||
}
|
||||
|
||||
private static bool HasMeaningfulSizeChange(SizeChangedEventArgs e)
|
||||
=> Math.Abs(e.NewSize.Width - e.PreviousSize.Width) > SizeChangeThreshold ||
|
||||
Math.Abs(e.NewSize.Height - e.PreviousSize.Height) > SizeChangeThreshold;
|
||||
|
||||
private void QueueRefresh()
|
||||
{
|
||||
if (_refreshScheduled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_refreshScheduled = true;
|
||||
DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
_refreshScheduled = false;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
|
||||
private void SizeRefreshTimerTick(DispatcherQueueTimer sender, object args)
|
||||
{
|
||||
sender.Stop();
|
||||
QueueRefresh();
|
||||
}
|
||||
|
||||
private void RefreshTimedView()
|
||||
@@ -385,8 +459,8 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
{
|
||||
using var linePaint = CreateLinePaint();
|
||||
using var minorLinePaint = CreateMinorLinePaint();
|
||||
using var defaultFillPaint = CreateFillPaint(GetDefaultHourBackground());
|
||||
using var workFillPaint = CreateFillPaint(GetWorkHourBackground());
|
||||
using var defaultFillPaint = CreateFillPaint(DefaultHourBackground ?? new SolidColorBrush(Colors.Transparent));
|
||||
using var workFillPaint = CreateFillPaint(WorkHourBackground ?? new SolidColorBrush(Colors.Transparent));
|
||||
var canvas = e.Surface.Canvas;
|
||||
canvas.Clear(SKColors.Transparent);
|
||||
|
||||
@@ -937,26 +1011,6 @@ public sealed partial class CalendarPeriodControl : UserControl, INotifyProperty
|
||||
: SKColors.Transparent;
|
||||
}
|
||||
|
||||
private Brush GetDefaultHourBackground()
|
||||
{
|
||||
if (Application.Current.Resources.TryGetValue("LayerFillColorDefaultBrush", out var resource) && resource is Brush brush)
|
||||
{
|
||||
return brush;
|
||||
}
|
||||
|
||||
return new SolidColorBrush(Color.FromArgb(255, 28, 34, 42));
|
||||
}
|
||||
|
||||
private Brush GetWorkHourBackground()
|
||||
{
|
||||
if (Application.Current.Resources.TryGetValue("SolidBackgroundFillColorBaseBrush", out var resource) && resource is SolidColorBrush solidBrush)
|
||||
{
|
||||
return new SolidColorBrush(Color.FromArgb(64, solidBrush.Color.R, solidBrush.Color.G, solidBrush.Color.B));
|
||||
}
|
||||
|
||||
return new SolidColorBrush(Color.FromArgb(255, 34, 40, 52));
|
||||
}
|
||||
|
||||
private static double GetTimedGridIntervalHeight(double hourHeight) => hourHeight * (TimedGridIntervalMinutes / 60d);
|
||||
|
||||
private double GetTimedGridIntervalHeight() => GetTimedGridIntervalHeight(GetHourHeight());
|
||||
|
||||
@@ -14,55 +14,59 @@
|
||||
BasedOn="{StaticResource DefaultButtonStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
<Setter Property="Width" Value="44" />
|
||||
<Setter Property="Height" Value="36" />
|
||||
<Setter Property="Padding" Value="10,6" />
|
||||
<Setter Property="CornerRadius" Value="8" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Foreground" Value="{ThemeResource SystemColorControlAccentBrush}" />
|
||||
|
||||
<Setter Property="CornerRadius" Value="{ThemeResource ControlCornerRadius}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="4,0,0,0" Background="Transparent">
|
||||
<Grid Background="Transparent" ColumnSpacing="16">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="64" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid VerticalAlignment="Center" ColumnSpacing="6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Click="PreviousDateClicked" Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<Viewbox Width="12">
|
||||
<PathIcon Data="F1 M 8.72 18.599998 C 8.879999 18.733334 9.059999 18.799999 9.26 18.799999 C 9.459999 18.799999 9.633332 18.719999 9.78 18.559999 C 9.926666 18.4 10 18.219999 10 18.019999 C 10 17.82 9.92 17.653332 9.76 17.52 L 4.52 12.559999 L 17.24 12.559999 C 17.453333 12.559999 17.633331 12.486667 17.779999 12.339999 C 17.926666 12.193334 18 12.013333 18 11.799999 C 18 11.586666 17.926666 11.406667 17.779999 11.259999 C 17.633331 11.113333 17.453333 11.039999 17.24 11.039999 L 4.52 11.039999 L 9.76 6.08 C 9.973333 5.893333 10.046666 5.653332 9.98 5.359999 C 9.913333 5.066666 9.74 4.880001 9.46 4.799999 C 9.179999 4.720001 8.933332 4.786667 8.72 5 L 2.32 11.08 C 2.16 11.24 2.053333 11.426666 2 11.639999 C 1.973333 11.746666 1.973333 11.853333 2 11.959999 C 2.053333 12.173333 2.16 12.360001 2.32 12.52 Z " />
|
||||
</Viewbox>
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Click="NextDateClicked"
|
||||
Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<Viewbox Width="12">
|
||||
<PathIcon Data="F1 M 11.28 5 C 11.12 4.866667 10.94 4.806667 10.74 4.82 C 10.539999 4.833334 10.366666 4.913334 10.219999 5.059999 C 10.073333 5.206665 10 5.379999 10 5.58 C 10 5.779999 10.08 5.946667 10.24 6.08 L 15.48 11.039999 L 2.76 11.039999 C 2.546667 11.039999 2.366667 11.113333 2.22 11.259999 C 2.073333 11.406667 2 11.586666 2 11.799999 C 2 12.013333 2.073333 12.193334 2.22 12.339999 C 2.366667 12.486667 2.546667 12.559999 2.76 12.559999 L 15.48 12.559999 L 10.24 17.52 C 10.026667 17.706665 9.953333 17.946667 10.02 18.24 C 10.086666 18.533333 10.259999 18.719999 10.54 18.799999 C 10.82 18.879999 11.066667 18.813334 11.28 18.599998 L 17.68 12.52 C 17.84 12.360001 17.946667 12.173333 18 11.959999 C 18 11.853333 18 11.746666 18 11.639999 C 17.946667 11.426666 17.84 11.24 17.68 11.08 Z " />
|
||||
</Viewbox>
|
||||
</Button>
|
||||
</Grid>
|
||||
|
||||
<TextBlock
|
||||
x:Name="VisibleDateRangeTextBlock"
|
||||
Grid.Column="1"
|
||||
MaxHeight="30"
|
||||
Margin="0,4,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="18"
|
||||
IsHitTestVisible="False"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
TextAlignment="Center" />
|
||||
|
||||
<StackPanel
|
||||
<calendarControls:WinoCalendarTypeSelectorControl
|
||||
x:Name="CalendarTypeSelector"
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<StackPanel
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Spacing="4">
|
||||
<Button Click="PreviousDateClicked" Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<PathIcon Data="F1 M 8.72 18.599998 C 8.879999 18.733334 9.059999 18.799999 9.26 18.799999 C 9.459999 18.799999 9.633332 18.719999 9.78 18.559999 C 9.926666 18.4 10 18.219999 10 18.019999 C 10 17.82 9.92 17.653332 9.76 17.52 L 4.52 12.559999 L 17.24 12.559999 C 17.453333 12.559999 17.633331 12.486667 17.779999 12.339999 C 17.926666 12.193334 18 12.013333 18 11.799999 C 18 11.586666 17.926666 11.406667 17.779999 11.259999 C 17.633331 11.113333 17.453333 11.039999 17.24 11.039999 L 4.52 11.039999 L 9.76 6.08 C 9.973333 5.893333 10.046666 5.653332 9.98 5.359999 C 9.913333 5.066666 9.74 4.880001 9.46 4.799999 C 9.179999 4.720001 8.933332 4.786667 8.72 5 L 2.32 11.08 C 2.16 11.24 2.053333 11.426666 2 11.639999 C 1.973333 11.746666 1.973333 11.853333 2 11.959999 C 2.053333 12.173333 2.16 12.360001 2.32 12.52 Z " />
|
||||
</Button>
|
||||
|
||||
<Button Click="NextDateClicked" Style="{StaticResource CalendarNavigationButtonStyle}">
|
||||
<PathIcon Data="F1 M 11.28 5 C 11.12 4.866667 10.94 4.806667 10.74 4.82 C 10.539999 4.833334 10.366666 4.913334 10.219999 5.059999 C 10.073333 5.206665 10 5.379999 10 5.58 C 10 5.779999 10.08 5.946667 10.24 6.08 L 15.48 11.039999 L 2.76 11.039999 C 2.546667 11.039999 2.366667 11.113333 2.22 11.259999 C 2.073333 11.406667 2 11.586666 2 11.799999 C 2 12.013333 2.073333 12.193334 2.22 12.339999 C 2.366667 12.486667 2.546667 12.559999 2.76 12.559999 L 15.48 12.559999 L 10.24 17.52 C 10.026667 17.706665 9.953333 17.946667 10.02 18.24 C 10.086666 18.533333 10.259999 18.719999 10.54 18.799999 C 10.82 18.879999 11.066667 18.813334 11.28 18.599998 L 17.68 12.52 C 17.84 12.360001 17.946667 12.173333 18 11.959999 C 18 11.853333 18 11.746666 18 11.639999 C 17.946667 11.426666 17.84 11.24 17.68 11.08 Z " />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<calendarControls:WinoCalendarTypeSelectorControl x:Name="CalendarTypeSelector" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -487,7 +487,7 @@ public class NavigationService : NavigationServiceBase, INavigationService
|
||||
: DateOnly.FromDateTime(args.NavigationDate.Date);
|
||||
|
||||
var displayRequest = new CalendarDisplayRequest(_statePersistanceService.CalendarDisplayType, targetDate);
|
||||
return new LoadCalendarMessage(displayRequest);
|
||||
return new LoadCalendarMessage(displayRequest, args.ForceReload);
|
||||
}
|
||||
|
||||
private bool NavigateInnerShellFrame(Frame frame, Type pageType, object? parameter, NavigationTransitionType transition)
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</TitleBar.Resources>-->
|
||||
<TitleBar.Content>
|
||||
<Grid
|
||||
MinWidth="280"
|
||||
MinWidth="400"
|
||||
MaxWidth="520"
|
||||
Margin="12,0,16,0">
|
||||
<AutoSuggestBox
|
||||
|
||||
@@ -41,9 +41,11 @@
|
||||
x:Name="CalendarSurface"
|
||||
CalendarItems="{x:Bind ViewModel.CalendarItems, Mode=OneWay}"
|
||||
CalendarSettings="{x:Bind ViewModel.CurrentSettings, Mode=OneWay}"
|
||||
DefaultHourBackground="{ThemeResource CalendarDefaultHourBackgroundBrush}"
|
||||
EmptySlotTapped="CalendarSurfaceEmptySlotTapped"
|
||||
IsEnabled="{x:Bind ViewModel.IsCalendarEnabled, Mode=OneWay}"
|
||||
VisibleRange="{x:Bind ViewModel.CurrentVisibleRange, Mode=OneWay}" />
|
||||
VisibleRange="{x:Bind ViewModel.CurrentVisibleRange, Mode=OneWay}"
|
||||
WorkHourBackground="{ThemeResource CalendarWorkHourBackgroundBrush}" />
|
||||
</Border>
|
||||
|
||||
<Canvas
|
||||
|
||||
@@ -135,7 +135,6 @@
|
||||
<Page Remove="AppThemes\Garden.xaml" />
|
||||
<Page Remove="AppThemes\Nighty.xaml" />
|
||||
<Page Remove="AppThemes\Snowflake.xaml" />
|
||||
<Page Remove="AppThemes\TestTheme.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -147,7 +146,6 @@
|
||||
<Content Include="AppThemes\Garden.xaml" />
|
||||
<Content Include="AppThemes\Nighty.xaml" />
|
||||
<Content Include="AppThemes\Snowflake.xaml" />
|
||||
<Content Include="AppThemes\TestTheme.xaml" />
|
||||
<Content Include="Assets\ReleaseNotes\vnext.md" />
|
||||
<Content Include="Assets\UpdateNotes\vnext.json" />
|
||||
<Content Include="Assets\UpdateNotes\features.json" />
|
||||
|
||||
Reference in New Issue
Block a user