Handling of basic all-day events for calendar.
This commit is contained in:
@@ -261,7 +261,7 @@ namespace Wino.Calendar.ViewModels
|
||||
// Wait for the animation to finish.
|
||||
// Otherwise it somehow shutters a little, which is annoying.
|
||||
|
||||
if (!removeCurrent) await Task.Delay(500);
|
||||
if (!removeCurrent) await Task.Delay(350);
|
||||
|
||||
// Insert each render model in reverse order.
|
||||
for (int i = renderModels.Count - 1; i >= 0; i--)
|
||||
|
||||
54
Wino.Calendar/Controls/AllDayItemsControl.xaml
Normal file
54
Wino.Calendar/Controls/AllDayItemsControl.xaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<UserControl
|
||||
x:Class="Wino.Calendar.Controls.AllDayItemsControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Wino.Calendar.Controls"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:domain="using:Wino.Core.Domain"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="400"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<ScrollViewer x:Name="PART_AllDayItemsListScrollHost">
|
||||
<ItemsControl
|
||||
x:Name="PART_AllDayItemsList"
|
||||
ItemTemplate="{x:Bind AllDayEventTemplate}"
|
||||
ItemsSource="{x:Bind AllDayEvents, Mode=OneWay}" />
|
||||
</ScrollViewer>
|
||||
<Button
|
||||
x:Name="AllDayItemsSummaryButton"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Visibility="Collapsed">
|
||||
<Button.Flyout>
|
||||
<Flyout Placement="Bottom">
|
||||
<ScrollViewer>
|
||||
<ItemsControl ItemTemplate="{x:Bind AllDayEventTemplate}" ItemsSource="{x:Bind AllDayEvents, Mode=OneWay}" />
|
||||
</ScrollViewer>
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
</Button>
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="ViewStates">
|
||||
<VisualState x:Name="FullView" />
|
||||
<VisualState x:Name="SummaryView">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="PART_AllDayItemsListScrollHost.Visibility" Value="Collapsed" />
|
||||
<Setter Target="PART_AllDayItemsList.Visibility" Value="Collapsed" />
|
||||
<Setter Target="AllDayItemsSummaryButton.Visibility" Value="Visible" />
|
||||
<Setter Target="AllDayItemsSummaryButton.Content">
|
||||
<Setter.Value>
|
||||
<TextBlock>
|
||||
<Run Text="{x:Bind AllDayEvents.Count, Mode=OneWay, TargetNullValue='0'}" /> <Run Text="{x:Bind domain:Translator.CalendarAllDayEventSummary}" />
|
||||
</TextBlock>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
90
Wino.Calendar/Controls/AllDayItemsControl.xaml.cs
Normal file
90
Wino.Calendar/Controls/AllDayItemsControl.xaml.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
|
||||
|
||||
namespace Wino.Calendar.Controls
|
||||
{
|
||||
public sealed partial class AllDayItemsControl : UserControl
|
||||
{
|
||||
private const string STATE_SummaryView = "SummaryView";
|
||||
private const string STATE_FullView = "FullView";
|
||||
|
||||
#region Dependency Properties
|
||||
|
||||
public static readonly DependencyProperty AllDayEventsProperty = DependencyProperty.Register(nameof(AllDayEvents), typeof(ObservableCollection<ICalendarItem>), typeof(AllDayItemsControl), new PropertyMetadata(null, new PropertyChangedCallback(OnAllDayEventsChanged)));
|
||||
public static readonly DependencyProperty AllDayEventTemplateProperty = DependencyProperty.Register(nameof(AllDayEventTemplate), typeof(DataTemplate), typeof(AllDayItemsControl), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate AllDayEventTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(AllDayEventTemplateProperty); }
|
||||
set { SetValue(AllDayEventTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public ObservableCollection<ICalendarItem> AllDayEvents
|
||||
{
|
||||
get { return (ObservableCollection<ICalendarItem>)GetValue(AllDayEventsProperty); }
|
||||
set { SetValue(AllDayEventsProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public AllDayItemsControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private static void OnAllDayEventsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is AllDayItemsControl control)
|
||||
{
|
||||
if (e.OldValue != null && e.OldValue is ObservableCollection<ICalendarItem> oldCollection)
|
||||
{
|
||||
control.UnregisterEventCollectionChanged(oldCollection);
|
||||
}
|
||||
|
||||
if (e.NewValue != null && e.NewValue is ObservableCollection<ICalendarItem> newCollection)
|
||||
{
|
||||
control.RegisterEventCollectionChanged(newCollection);
|
||||
}
|
||||
|
||||
control.UpdateCollectionVisuals();
|
||||
}
|
||||
}
|
||||
|
||||
private void RegisterEventCollectionChanged(ObservableCollection<ICalendarItem> collection)
|
||||
{
|
||||
collection.CollectionChanged += EventsCollectionUpdated;
|
||||
}
|
||||
|
||||
private void UnregisterEventCollectionChanged(ObservableCollection<ICalendarItem> collection)
|
||||
{
|
||||
collection.CollectionChanged -= EventsCollectionUpdated;
|
||||
}
|
||||
|
||||
private void EventsCollectionUpdated(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
UpdateCollectionVisuals();
|
||||
}
|
||||
|
||||
private void UpdateCollectionVisuals()
|
||||
{
|
||||
if (AllDayEvents == null) return;
|
||||
|
||||
if (AllDayEvents.Count > 1)
|
||||
{
|
||||
// Summarize
|
||||
|
||||
VisualStateManager.GoToState(this, STATE_SummaryView, false);
|
||||
|
||||
// AllDayItemsSummaryButton.Content = $"{AllDayEvents.Count} {Translator.CalendarAllDayEventSummary}";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Full view.
|
||||
VisualStateManager.GoToState(this, STATE_FullView, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,19 +66,17 @@
|
||||
<StackPanel Grid.Column="1" HorizontalAlignment="Right" />
|
||||
|
||||
<!-- All-Day Events -->
|
||||
<ScrollViewer
|
||||
<controls:AllDayItemsControl
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
VerticalScrollBarVisibility="Hidden">
|
||||
<ItemsControl ItemsSource="{Binding EventsCollection.AllDayEvents, Mode=OneWay}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<!-- All-Day Event template -->
|
||||
<DataTemplate x:DataType="interfaces:ICalendarItem">
|
||||
<TextBlock Text="{x:Bind Title}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
AllDayEvents="{Binding EventsCollection.AllDayEvents}">
|
||||
<controls:AllDayItemsControl.AllDayEventTemplate>
|
||||
<!-- All-Day Event template -->
|
||||
<DataTemplate x:DataType="interfaces:ICalendarItem">
|
||||
<TextBlock Text="{x:Bind Title}" />
|
||||
</DataTemplate>
|
||||
</controls:AllDayItemsControl.AllDayEventTemplate>
|
||||
</controls:AllDayItemsControl>
|
||||
</Grid>
|
||||
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
</Compile>
|
||||
<Compile Include="Args\TimelineCellSelectedArgs.cs" />
|
||||
<Compile Include="Args\TimelineCellUnselectedArgs.cs" />
|
||||
<Compile Include="Controls\AllDayItemsControl.xaml.cs">
|
||||
<DependentUpon>AllDayItemsControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\CalendarDayItemsControl.cs" />
|
||||
<Compile Include="Controls\CalendarItemControl.cs" />
|
||||
<Compile Include="Controls\CustomCalendarFlipView.cs" />
|
||||
@@ -248,6 +251,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="Controls\AllDayItemsControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
"DialogMessage_EnableStartupLaunchMessage": "Let Wino Mail automatically launch minimized on Windows startup to not miss any notifications.\n\nDo you want to enable startup launch?",
|
||||
"DialogMessage_EnableStartupLaunchDeniedMessage": "You can enable startup launch from Settings -> App Preferences.",
|
||||
"Dialog_DontAskAgain": "Don't ask again",
|
||||
"CalendarAllDayEventSummary": "all-day events",
|
||||
"CreateAccountAliasDialog_Title": "Create Account Alias",
|
||||
"CreateAccountAliasDialog_Description": "Make sure your outgoing server allows sending mails from this alias.",
|
||||
"CreateAccountAliasDialog_AliasAddress": "Address",
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
<!-- Override AppBarToggleButton's checked background color. -->
|
||||
<StaticResource x:Key="AppBarToggleButtonBackgroundChecked" ResourceKey="SystemAccentColor" />
|
||||
<StaticResource x:Key="AppBarToggleButtonBackgroundCheckedPointerOver" ResourceKey="SystemAccentColor" />
|
||||
<StaticResource x:Key="AppBarToggleButtonBackgroundCheckedPressed" ResourceKey="SystemAccentColor" />
|
||||
|
||||
<Thickness x:Key="ImapSetupDialogSubPagePadding">24,24,24,24</Thickness>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>12.0</LangVersion>
|
||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user