committed by
GitHub
93 changed files with 2043 additions and 481 deletions
@ -0,0 +1,65 @@ |
|||
using System; |
|||
using System.Collections.ObjectModel; |
|||
using System.Linq; |
|||
using System.Reactive; |
|||
using Avalonia.Controls; |
|||
using ReactiveUI; |
|||
|
|||
namespace ControlCatalog.ViewModels |
|||
{ |
|||
public class ListBoxPageViewModel : ReactiveObject |
|||
{ |
|||
private int _counter; |
|||
private SelectionMode _selectionMode; |
|||
|
|||
public ListBoxPageViewModel() |
|||
{ |
|||
Items = new ObservableCollection<string>(Enumerable.Range(1, 10000).Select(i => GenerateItem())); |
|||
Selection = new SelectionModel(); |
|||
Selection.Select(1); |
|||
|
|||
AddItemCommand = ReactiveCommand.Create(() => Items.Add(GenerateItem())); |
|||
|
|||
RemoveItemCommand = ReactiveCommand.Create(() => |
|||
{ |
|||
while (Selection.SelectedItems.Count > 0) |
|||
{ |
|||
Items.Remove((string)Selection.SelectedItems.First()); |
|||
} |
|||
}); |
|||
|
|||
SelectRandomItemCommand = ReactiveCommand.Create(() => |
|||
{ |
|||
var random = new Random(); |
|||
|
|||
using (Selection.Update()) |
|||
{ |
|||
Selection.ClearSelection(); |
|||
Selection.Select(random.Next(Items.Count - 1)); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public ObservableCollection<string> Items { get; } |
|||
|
|||
public SelectionModel Selection { get; } |
|||
|
|||
public ReactiveCommand<Unit, Unit> AddItemCommand { get; } |
|||
|
|||
public ReactiveCommand<Unit, Unit> RemoveItemCommand { get; } |
|||
|
|||
public ReactiveCommand<Unit, Unit> SelectRandomItemCommand { get; } |
|||
|
|||
public SelectionMode SelectionMode |
|||
{ |
|||
get => _selectionMode; |
|||
set |
|||
{ |
|||
Selection.ClearSelection(); |
|||
this.RaiseAndSetIfChanged(ref _selectionMode, value); |
|||
} |
|||
} |
|||
|
|||
private string GenerateItem() => $"Item {_counter++.ToString()}"; |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
Compat issues with assembly Avalonia.Base: |
|||
MembersMustExist : Member 'public void Avalonia.DirectProperty<TOwner, TValue>..ctor(System.String, System.Func<TOwner, TValue>, System.Action<TOwner, TValue>, Avalonia.DirectPropertyMetadata<TValue>, System.Boolean)' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'protected void Avalonia.DirectPropertyBase<TValue>..ctor(Avalonia.AvaloniaProperty, System.Type, Avalonia.PropertyMetadata, System.Boolean)' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'protected void Avalonia.DirectPropertyBase<TValue>..ctor(System.String, System.Type, Avalonia.PropertyMetadata, System.Boolean)' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public System.Boolean Avalonia.DirectPropertyBase<TValue>.IsDataValidationEnabled.get()' does not exist in the implementation but it does exist in the contract. |
|||
Total Issues: 4 |
|||
@ -0,0 +1,7 @@ |
|||
Compat issues with assembly Avalonia.Controls: |
|||
MembersMustExist : Member 'protected void Avalonia.Controls.ComboBox.PopupClosedOverride(Avalonia.Controls.Primitives.PopupClosedEventArgs)' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.StyledProperty<System.Boolean> Avalonia.StyledProperty<System.Boolean> Avalonia.Controls.Primitives.Popup.StaysOpenProperty' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public void Avalonia.Controls.Primitives.Popup.add_Closed(System.EventHandler<Avalonia.Controls.Primitives.PopupClosedEventArgs>)' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public void Avalonia.Controls.Primitives.Popup.remove_Closed(System.EventHandler<Avalonia.Controls.Primitives.PopupClosedEventArgs>)' does not exist in the implementation but it does exist in the contract. |
|||
TypesMustExist : Type 'Avalonia.Controls.Primitives.PopupClosedEventArgs' does not exist in the implementation but it does exist in the contract. |
|||
Total Issues: 5 |
|||
@ -0,0 +1,61 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using Avalonia.Controls.Templates; |
|||
using Avalonia.Input; |
|||
using Avalonia.Rendering; |
|||
using Avalonia.Styling; |
|||
using Avalonia.VisualTree; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls.Primitives |
|||
{ |
|||
/// <summary>
|
|||
/// A layer that is used to dismiss a <see cref="Popup"/> when the user clicks outside.
|
|||
/// </summary>
|
|||
public class LightDismissOverlayLayer : Border, ICustomHitTest |
|||
{ |
|||
public IInputElement? InputPassThroughElement { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Returns the light dismiss overlay for a specified visual.
|
|||
/// </summary>
|
|||
/// <param name="visual">The visual.</param>
|
|||
/// <returns>The light dismiss overlay, or null if none found.</returns>
|
|||
public static LightDismissOverlayLayer? GetLightDismissOverlayLayer(IVisual visual) |
|||
{ |
|||
visual = visual ?? throw new ArgumentNullException(nameof(visual)); |
|||
|
|||
VisualLayerManager? manager; |
|||
|
|||
if (visual is TopLevel topLevel) |
|||
{ |
|||
manager = topLevel.GetTemplateChildren() |
|||
.OfType<VisualLayerManager>() |
|||
.FirstOrDefault(); |
|||
} |
|||
else |
|||
{ |
|||
manager = visual.FindAncestorOfType<VisualLayerManager>(); |
|||
} |
|||
|
|||
return manager?.LightDismissOverlayLayer; |
|||
} |
|||
|
|||
public bool HitTest(Point point) |
|||
{ |
|||
if (InputPassThroughElement is object) |
|||
{ |
|||
var p = point.Transform(this.TransformToVisual(VisualRoot)!.Value); |
|||
var hit = VisualRoot.GetVisualAt(p, x => x != this); |
|||
|
|||
if (hit is object) |
|||
{ |
|||
return !InputPassThroughElement.IsVisualAncestorOf(hit); |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Interactivity; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls.Primitives |
|||
{ |
|||
/// <summary>
|
|||
/// Holds data for the <see cref="Popup.Closed"/> event.
|
|||
/// </summary>
|
|||
public class PopupClosedEventArgs : EventArgs |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="PopupClosedEventArgs"/> class.
|
|||
/// </summary>
|
|||
/// <param name="closeEvent"></param>
|
|||
public PopupClosedEventArgs(EventArgs? closeEvent) |
|||
{ |
|||
CloseEvent = closeEvent; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the event that closed the popup, if any.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// If <see cref="Popup.StaysOpen"/> is false, then this property will hold details of the
|
|||
/// interaction that caused the popup to close if the close was caused by e.g. a pointer press
|
|||
/// outside the popup. It can be used to mark the event as handled if the event should not
|
|||
/// be propagated.
|
|||
/// </remarks>
|
|||
public EventArgs? CloseEvent { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,334 @@ |
|||
<!-- |
|||
// (c) Copyright Microsoft Corporation. |
|||
// This source is subject to the Microsoft Public License (Ms-PL). |
|||
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. |
|||
// All other rights reserved. |
|||
--> |
|||
|
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:sys="clr-namespace:System;assembly=netstandard"> |
|||
<Styles.Resources> |
|||
<Thickness x:Key="DatePickerTopHeaderMargin">0,0,0,4</Thickness> |
|||
<x:Double x:Key="DatePickerFlyoutPresenterHighlightHeight">40</x:Double> |
|||
<x:Double x:Key="DatePickerFlyoutPresenterItemHeight">40</x:Double> |
|||
<x:Double x:Key="DatePickerFlyoutPresenterAcceptDismissHostGridHeight">41</x:Double> |
|||
<x:Double x:Key="DatePickerThemeMinWidth">296</x:Double> |
|||
<x:Double x:Key="DatePickerThemeMaxWidth">456</x:Double> |
|||
<Thickness x:Key="DatePickerFlyoutPresenterItemPadding">0,3,0,6</Thickness> |
|||
<Thickness x:Key="DatePickerFlyoutPresenterMonthPadding">9,3,0,6</Thickness> |
|||
<Thickness x:Key="DatePickerHostPadding">0,3,0,6</Thickness> |
|||
<Thickness x:Key="DatePickerHostMonthPadding">9,3,0,6</Thickness> |
|||
<x:Double x:Key="DatePickerSpacerThemeWidth">1</x:Double> |
|||
</Styles.Resources> |
|||
|
|||
<!-- Styles for the items displayed in the selectors --> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem"> |
|||
<Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterItemPadding}"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center" /> |
|||
</Style> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem:selected"> |
|||
<Setter Property="IsHitTestVisible" Value="False"/> |
|||
</Style> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem:selected /template/ Rectangle#PressedBackground"> |
|||
<Setter Property="Fill" Value="Transparent"/> |
|||
</Style> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem:selected /template/ ContentPresenter"> |
|||
<Setter Property="Background" Value="Transparent" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem.MonthItem"> |
|||
<Setter Property="Padding" Value="{DynamicResource DatePickerFlyoutPresenterMonthPadding}"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|||
</Style> |
|||
|
|||
|
|||
<!-- This is used for both the accept/dismiss & repeatbuttons in the presenter--> |
|||
<Style Selector=":is(Button).DateTimeFlyoutButtonStyle"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlTransparentBrush}" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}"> |
|||
<ContentPresenter x:Name="ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{DynamicResource ThemeControlTransparentBrush}" |
|||
BorderThickness="{DynamicResource DateTimeFlyoutButtonBorderThickness}" |
|||
Content="{TemplateBinding Content}" |
|||
TextBlock.Foreground="{DynamicResource ThemeForegroundBrush}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector=":is(Button).DateTimeFlyoutButtonStyle:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightLowBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlTransparentBrush}"/> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector=":is(Button).DateTimeFlyoutButtonStyle:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightMidBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlTransparentBrush}"/> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
|
|||
|
|||
<Style Selector="RepeatButton.UpButton"> |
|||
<Setter Property="VerticalAlignment" Value="Top"/> |
|||
<Setter Property="Height" Value="22" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightLowBrush}" /> |
|||
<Setter Property="Content"> |
|||
<Template> |
|||
<Viewbox Height="10" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center"> |
|||
<Path Stroke="{Binding $parent[RepeatButton].Foreground}" StrokeThickness="1" Data="M 0,9 L 9,0 L 18,9"/> |
|||
</Viewbox> |
|||
</Template> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="RepeatButton.DownButton"> |
|||
<Setter Property="VerticalAlignment" Value="Bottom"/> |
|||
<Setter Property="Height" Value="22" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighlightLowBrush}" /> |
|||
<Setter Property="Content"> |
|||
<Template> |
|||
<Viewbox Height="10" Width="10" HorizontalAlignment="Center" VerticalAlignment="Center"> |
|||
<Path Stroke="{Binding $parent[RepeatButton].Foreground}" StrokeThickness="1" Data="M 0,0 L 9,9 L 18,0"/> |
|||
</Viewbox> |
|||
</Template> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DatePicker"> |
|||
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighlightMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}" RowDefinitions="Auto,*"> |
|||
<ContentPresenter Name="HeaderContentPresenter" Grid.Row="0" |
|||
Content="{TemplateBinding Header}" |
|||
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|||
Margin="{DynamicResource DatePickerTopHeaderMargin}" |
|||
MaxWidth="{DynamicResource DatePickerThemeMaxWidth}" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Top"/> |
|||
|
|||
<Button Name="FlyoutButton" Grid.Row="1" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
IsEnabled="{TemplateBinding IsEnabled}" |
|||
MinWidth="{DynamicResource DatePickerThemeMinWidth}" |
|||
MaxWidth="{DynamicResource DatePickerThemeMaxWidth}" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
HorizontalContentAlignment="Stretch" |
|||
VerticalContentAlignment="Stretch" |
|||
TemplatedControl.IsTemplateFocusTarget="True"> |
|||
<Button.Template> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="ContentPresenter" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Content="{TemplateBinding Content}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalContentAlignment="Stretch" |
|||
VerticalContentAlignment="Stretch"/> |
|||
</ControlTemplate> |
|||
</Button.Template> |
|||
<Grid Name="ButtonContentGrid" ColumnDefinitions="78*,Auto,132*,Auto,78*"> |
|||
<TextBlock Name="DayText" Text="day" HorizontalAlignment="Center" |
|||
Padding="{DynamicResource DatePickerHostPadding}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
FontSize="{TemplateBinding FontSize}"/> |
|||
<TextBlock Name="MonthText" Text="month" TextAlignment="Left" |
|||
Padding="{DynamicResource DatePickerHostMonthPadding}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
FontSize="{TemplateBinding FontSize}"/> |
|||
<TextBlock Name="YearText" Text="year" HorizontalAlignment="Center" |
|||
Padding="{DynamicResource DatePickerHostPadding}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
FontSize="{TemplateBinding FontSize}"/> |
|||
<Rectangle x:Name="FirstSpacer" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="1" |
|||
Grid.Column="1" /> |
|||
<Rectangle x:Name="SecondSpacer" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="1" |
|||
Grid.Column="3" /> |
|||
</Grid> |
|||
</Button> |
|||
|
|||
<Popup Name="Popup" WindowManagerAddShadowHint="False" |
|||
StaysOpen="False" PlacementTarget="{TemplateBinding}" |
|||
PlacementMode="Bottom"> |
|||
<DatePickerPresenter Name="PickerPresenter" /> |
|||
</Popup> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="DatePicker /template/ ContentPresenter#HeaderContentPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
<Style Selector="DatePicker:disabled /template/ Rectangle"> |
|||
<!--<Setter Property="Fill" Value="{DynamicResource DatePickerSpacerFillDisabled}"/>--> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DatePicker /template/ Button#FlyoutButton:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
<!--<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundPointerOver}"/>--> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="DatePicker /template/ Button#FlyoutButton:pressed /template/ ContentPresenter"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlLowBrush}"/> |
|||
<Setter Property="Background"> |
|||
<SolidColorBrush Color="{DynamicResource ThemeControlMidHighColor}" Opacity="0.6" /> |
|||
</Setter> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="DatePicker /template/ Button#FlyoutButton:disabled /template/ ContentPresenter"> |
|||
<!--<Setter Property="BorderBrush" Value="{DynamicResource DatePickerButtonBorderBrushDisabled}"/> |
|||
<Setter Property="Background" Value="{DynamicResource DatePickerButtonBackgroundDisabled}"/> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource DatePickerButtonForegroundDisabled}"/>--> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
|||
</Style> |
|||
|
|||
<!-- Changes foreground for watermark text when SelectedDate is null--> |
|||
<Style Selector="DatePicker:hasnodate /template/ Button#FlyoutButton TextBlock"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/> |
|||
</Style> |
|||
|
|||
<!--WinUI: DatePickerFlyoutPresenter--> |
|||
<Style Selector="DatePickerPresenter"> |
|||
<Setter Property="Width" Value="296" /> |
|||
<Setter Property="MinWidth" Value="296" /> |
|||
<Setter Property="MaxHeight" Value="398" /> |
|||
<Setter Property="FontWeight" Value="Normal" /> |
|||
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource DateTimeFlyoutBorderThickness}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="Background" Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Padding="{DynamicResource DateTimeFlyoutBorderPadding}" |
|||
MaxHeight="398"> |
|||
<Grid Name="ContentRoot" RowDefinitions="*,Auto"> |
|||
<Grid Name="PickerContainer"> |
|||
<!--Column Definitions set in code, ignore here--> |
|||
<Panel Name="MonthHost"> |
|||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" |
|||
VerticalScrollBarVisibility="Hidden"> |
|||
<DateTimePickerPanel Name="MonthSelector" |
|||
PanelType="Month" |
|||
ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}" |
|||
ShouldLoop="True" /> |
|||
</ScrollViewer> |
|||
<RepeatButton Name="MonthUpButton" |
|||
Classes="DateTimeFlyoutButtonStyle UpButton"/> |
|||
<RepeatButton Name="MonthDownButton" |
|||
Classes="DateTimeFlyoutButtonStyle DownButton"/> |
|||
</Panel> |
|||
<Panel Name="DayHost"> |
|||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" |
|||
VerticalScrollBarVisibility="Hidden"> |
|||
<DateTimePickerPanel Name="DaySelector" |
|||
PanelType="Day" |
|||
ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}" |
|||
ShouldLoop="True" /> |
|||
</ScrollViewer> |
|||
<RepeatButton Name="DayUpButton" |
|||
Classes="DateTimeFlyoutButtonStyle UpButton"/> |
|||
<RepeatButton Name="DayDownButton" |
|||
Classes="DateTimeFlyoutButtonStyle DownButton"/> |
|||
</Panel> |
|||
<Panel Name="YearHost"> |
|||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" |
|||
VerticalScrollBarVisibility="Hidden"> |
|||
<DateTimePickerPanel Name="YearSelector" |
|||
PanelType="Year" |
|||
ItemHeight="{DynamicResource DatePickerFlyoutPresenterItemHeight}" |
|||
ShouldLoop="False" /> |
|||
</ScrollViewer> |
|||
<RepeatButton Name="YearUpButton" |
|||
Classes="DateTimeFlyoutButtonStyle UpButton"/> |
|||
<RepeatButton Name="YearDownButton" |
|||
Classes="DateTimeFlyoutButtonStyle DownButton"/> |
|||
</Panel> |
|||
<Rectangle Name="HighlightRect" IsHitTestVisible="False" ZIndex="-1" |
|||
Fill="{DynamicResource DatePickerFlyoutPresenterHighlightFill}" |
|||
Grid.Column="0" Grid.ColumnSpan="5" VerticalAlignment="Center" |
|||
Height="{DynamicResource DatePickerFlyoutPresenterHighlightHeight}" /> |
|||
<Rectangle Name="FirstSpacer" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="{DynamicResource DatePickerSpacerThemeWidth}" |
|||
Grid.Column="1" /> |
|||
<Rectangle Name="SecondSpacer" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="{DynamicResource DatePickerSpacerThemeWidth}" |
|||
Grid.Column="3" /> |
|||
</Grid> |
|||
<Grid Grid.Row="1" Height="{DynamicResource DatePickerFlyoutPresenterAcceptDismissHostGridHeight}" |
|||
Name="AcceptDismissGrid" ColumnDefinitions="*,*"> |
|||
<Rectangle Height="{DynamicResource DatePickerSpacerThemeWidth}" VerticalAlignment="Top" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
Grid.ColumnSpan="2"/> |
|||
<Button Name="AcceptButton" Grid.Column="0" Classes="DateTimeFlyoutButtonStyle" |
|||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<Path Stroke="{Binding $parent[Button].Foreground}" StrokeLineCap="Round" |
|||
StrokeThickness="0.75" Data="M0.5,8.5 5,13.5 15.5,3" /> |
|||
</Button> |
|||
<Button Name="DismissButton" Grid.Column="1" Classes="DateTimeFlyoutButtonStyle" |
|||
FontSize="16" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<Path Stroke="{Binding $parent[Button].Foreground}" StrokeLineCap="Round" |
|||
StrokeThickness="0.75" Data="M2,2 14,14 M2,14 14 2" /> |
|||
</Button> |
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DatePickerPresenter /template/ Panel RepeatButton"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DatePickerPresenter /template/ Panel:pointerover RepeatButton"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
@ -0,0 +1,219 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
|
|||
<Styles.Resources> |
|||
<x:Double x:Key="SplitViewOpenPaneThemeLength">320</x:Double> |
|||
<x:Double x:Key="SplitViewCompactPaneThemeLength">48</x:Double> |
|||
|
|||
<!-- Not used here (directly) since they're strings, but preserving for reference |
|||
<x:String x:Key="SplitViewPaneAnimationOpenDuration">00:00:00.2</x:String> |
|||
<x:String x:Key="SplitViewPaneAnimationOpenPreDuration">00:00:00.19999</x:String> |
|||
<x:String x:Key="SplitViewPaneAnimationCloseDuration">00:00:00.1</x:String>--> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="SplitView"> |
|||
<Setter Property="OpenPaneLength" Value="{DynamicResource SplitViewOpenPaneThemeLength}" /> |
|||
<Setter Property="CompactPaneLength" Value="{DynamicResource SplitViewCompactPaneThemeLength}" /> |
|||
<Setter Property="PaneBackground" Value="{DynamicResource ThemeControlHighlightLowBrush}" /> |
|||
</Style> |
|||
|
|||
<!-- Left --> |
|||
<Style Selector="SplitView:left"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid Name="Container" Background="{TemplateBinding Background}"> |
|||
<Grid.ColumnDefinitions> |
|||
<!-- why is this throwing a binding error? --> |
|||
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneColumnGridLength}"/> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<Panel Name="PART_PaneRoot" Background="{TemplateBinding PaneBackground}" |
|||
ClipToBounds="True" |
|||
HorizontalAlignment="Left" |
|||
ZIndex="100"> |
|||
<Border Child="{TemplateBinding Pane}"/> |
|||
<Rectangle Name="HCPaneBorder" Fill="{DynamicResource SystemControlForegroundTransparentBrush}" Width="1" HorizontalAlignment="Right" /> |
|||
</Panel> |
|||
|
|||
<Panel Name="ContentRoot"> |
|||
<Border Child="{TemplateBinding Content}" /> |
|||
<Rectangle Name="LightDismissLayer"/> |
|||
</Panel> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Overlay --> |
|||
<Style Selector="SplitView:overlay:left /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
<!-- ColumnSpan should be 2 --> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
</Style> |
|||
<Style Selector="SplitView:overlay:left /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="2"/> |
|||
</Style> |
|||
|
|||
<!-- CompactInline --> |
|||
<Style Selector="SplitView:compactinline:left /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:compactinline:left /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
</Style> |
|||
|
|||
<!-- CompactOverlay --> |
|||
<Style Selector="SplitView:compactoverlay:left /template/ Panel#PART_PaneRoot"> |
|||
<!-- ColumnSpan should be 2 --> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:compactoverlay:left /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
</Style> |
|||
|
|||
<!-- Inline --> |
|||
<Style Selector="SplitView:inline:left /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:inline:left /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
</Style> |
|||
|
|||
<!-- Right --> |
|||
<Style Selector="SplitView:right"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid Name="Container" Background="{TemplateBinding Background}"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*"/> |
|||
<ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.PaneColumnGridLength}"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<Panel Name="PART_PaneRoot" Background="{TemplateBinding PaneBackground}" |
|||
ClipToBounds="True" |
|||
HorizontalAlignment="Right" |
|||
ZIndex="100"> |
|||
<Border Child="{TemplateBinding Pane}"/> |
|||
<Rectangle Name="HCPaneBorder" |
|||
Fill="{DynamicResource SystemControlForegroundTransparentBrush}" |
|||
Width="1" HorizontalAlignment="Left" /> |
|||
</Panel> |
|||
|
|||
<Panel Name="ContentRoot"> |
|||
<Border Child="{TemplateBinding Content}" /> |
|||
<Rectangle Name="LightDismissLayer"/> |
|||
</Panel> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Overlay --> |
|||
<Style Selector="SplitView:overlay:right /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
<Setter Property="Grid.ColumnSpan" Value="2"/> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
</Style> |
|||
<Style Selector="SplitView:overlay:right /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="2"/> |
|||
</Style> |
|||
|
|||
<!-- CompactInline --> |
|||
<Style Selector="SplitView:compactinline:right /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:compactinline:right /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
</Style> |
|||
|
|||
<!-- CompactOverlay --> |
|||
<Style Selector="SplitView:compactoverlay:right /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Grid.ColumnSpan" Value="2"/> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:compactoverlay:right /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
</Style> |
|||
|
|||
<!-- Inline --> |
|||
<Style Selector="SplitView:inline:right /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
<Setter Property="Grid.Column" Value="1"/> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:inline:right /template/ Panel#ContentRoot"> |
|||
<Setter Property="Grid.Column" Value="0"/> |
|||
<Setter Property="Grid.ColumnSpan" Value="1"/> |
|||
</Style> |
|||
|
|||
<!-- Open/Close Pane animation --> |
|||
<Style Selector="SplitView:open /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Width" Duration="00:00:00.2" Easing="0.1,0.9,0.2,1.0" /> |
|||
</Transitions> |
|||
</Setter> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=OpenPaneLength}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:open /template/ Rectangle#LightDismissLayer"> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="00:00:00.2" Easing="0.1,0.9,0.2,1.0" /> |
|||
</Transitions> |
|||
</Setter> |
|||
<Setter Property="Opacity" Value="1.0"/> |
|||
</Style> |
|||
|
|||
<Style Selector="SplitView:closed /template/ Panel#PART_PaneRoot"> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Width" Duration="00:00:00.1" Easing="0.1,0.9,0.2,1.0" /> |
|||
</Transitions> |
|||
</Setter> |
|||
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ClosedPaneWidth}" /> |
|||
</Style> |
|||
<Style Selector="SplitView:closed /template/ Rectangle#LightDismissLayer"> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="00:00:00.2" Easing="0.1,0.9,0.2,1.0" /> |
|||
</Transitions> |
|||
</Setter> |
|||
<Setter Property="Opacity" Value="0.0"/> |
|||
</Style> |
|||
|
|||
<Style Selector="SplitView /template/ Rectangle#LightDismissLayer"> |
|||
<Setter Property="IsVisible" Value="False"/> |
|||
<Setter Property="Fill" Value="Transparent" /> |
|||
</Style> |
|||
<Style Selector="SplitView:lightdismiss /template/ Rectangle#LightDismissLayer"> |
|||
<Setter Property="Fill" Value="{DynamicResource SplitViewLightDismissOverlayBackground}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="SplitView:overlay:open /template/ Rectangle#LightDismissLayer"> |
|||
<Setter Property="IsVisible" Value="True"/> |
|||
</Style> |
|||
<Style Selector="SplitView:compactoverlay:open /template/ Rectangle#LightDismissLayer"> |
|||
<Setter Property="IsVisible" Value="True"/> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
@ -0,0 +1,283 @@ |
|||
<!-- |
|||
// (c) Copyright Microsoft Corporation. |
|||
// This source is subject to the Microsoft Public License (Ms-PL). |
|||
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. |
|||
// All other rights reserved. |
|||
--> |
|||
|
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:sys="clr-namespace:System;assembly=netstandard"> |
|||
<Styles.Resources> |
|||
<x:Double x:Key="TimePickerFlyoutPresenterItemHeight">40</x:Double> |
|||
<x:Double x:Key="TimePickerSpacerThemeWidth">1</x:Double> |
|||
<Thickness x:Key="TimePickerBorderThemeThickness">1</Thickness> |
|||
<Thickness x:Key="TimePickerTopHeaderMargin">0,0,0,4</Thickness> |
|||
<x:Double x:Key="TimePickerFlyoutPresenterHighlightHeight">40</x:Double> |
|||
<x:Double x:Key="TimePickerFlyoutPresenterAcceptDismissHostGridHeight">41</x:Double> |
|||
<x:Double x:Key="TimePickerThemeMinWidth">242</x:Double> |
|||
<x:Double x:Key="TimePickerThemeMaxWidth">456</x:Double> |
|||
<Thickness x:Key="TimePickerFlyoutPresenterItemPadding">0,3,0,6</Thickness> |
|||
<Thickness x:Key="TimePickerHostPadding">0,3,0,6</Thickness> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="ListBoxItem.DateTimePickerItem.HourItem"> |
|||
<Setter Property="Padding" Value="{DynamicResource TimePickerFlyoutPresenterItemPadding}" /> |
|||
</Style> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem.MinuteItem"> |
|||
<Setter Property="Padding" Value="{DynamicResource TimePickerFlyoutPresenterItemPadding}" /> |
|||
</Style> |
|||
<Style Selector="ListBoxItem.DateTimePickerItem.TimePeriodItem"> |
|||
<Setter Property="Padding" Value="{DynamicResource TimePickerFlyoutPresenterItemPadding}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePicker"> |
|||
<Setter Property="FontSize" Value="{DynamicResource FontSizeNormal}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighlightMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource TimePickerBorderThemeThickness}"/> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}" RowDefinitions="Auto,*"> |
|||
<ContentPresenter x:Name="HeaderContentPresenter" |
|||
Grid.Row="0" |
|||
Content="{TemplateBinding Header}" |
|||
ContentTemplate="{TemplateBinding HeaderTemplate}" |
|||
Margin="{DynamicResource TimePickerTopHeaderMargin}" |
|||
MaxWidth="{DynamicResource TimePickerThemeMaxWidth}" |
|||
TextBlock.Foreground="{DynamicResource TimePickerHeaderForeground}" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Top" /> |
|||
|
|||
<Button x:Name="FlyoutButton" |
|||
Grid.Row="1" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
IsEnabled="{TemplateBinding IsEnabled}" |
|||
MinWidth="{DynamicResource TimePickerThemeMinWidth}" |
|||
MaxWidth="{DynamicResource TimePickerThemeMaxWidth}" |
|||
HorizontalAlignment="Stretch" |
|||
HorizontalContentAlignment="Stretch" |
|||
VerticalAlignment="Top" |
|||
VerticalContentAlignment="Stretch"> |
|||
<Button.Template> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="ContentPresenter" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Content="{TemplateBinding Content}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalContentAlignment="Stretch" |
|||
VerticalContentAlignment="Stretch" /> |
|||
</ControlTemplate> |
|||
</Button.Template> |
|||
|
|||
<Grid Name="FlyoutButtonContentGrid"> |
|||
<!--Ignore col defs here, set in code--> |
|||
<Border x:Name="FirstPickerHost" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<TextBlock x:Name="HourTextBlock" |
|||
HorizontalAlignment="Center" |
|||
Padding="{DynamicResource TimePickerHostPadding}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
FontSize="{TemplateBinding FontSize}" /> |
|||
</Border> |
|||
|
|||
<Rectangle Name="FirstColumnDivider" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="{DynamicResource TimePickerSpacerThemeWidth}" |
|||
Grid.Column="1" /> |
|||
|
|||
<Border x:Name="SecondPickerHost" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<TextBlock x:Name="MinuteTextBlock" |
|||
HorizontalAlignment="Center" |
|||
Padding="{DynamicResource TimePickerHostPadding}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
FontSize="{TemplateBinding FontSize}"/> |
|||
</Border> |
|||
|
|||
<Rectangle Name="SecondColumnDivider" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="{DynamicResource TimePickerSpacerThemeWidth}" |
|||
Grid.Column="3" /> |
|||
|
|||
<Border x:Name="ThirdPickerHost" Grid.Column="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<TextBlock x:Name="PeriodTextBlock" |
|||
HorizontalAlignment="Center" |
|||
Padding="{DynamicResource TimePickerHostPadding}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
FontSize="{TemplateBinding FontSize}" /> |
|||
</Border> |
|||
</Grid> |
|||
</Button> |
|||
|
|||
<Popup Name="Popup" WindowManagerAddShadowHint="False" |
|||
StaysOpen="False" PlacementTarget="{TemplateBinding}" |
|||
PlacementMode="Bottom"> |
|||
<TimePickerPresenter Name="PickerPresenter" /> |
|||
</Popup> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePicker:disabled /template/ ContentPresenter#HeaderContentPresenter"> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
<Style Selector="TimePicker:disabled /template/ Rectangle"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePicker /template/ Button#FlyoutButton:pointerover /template/ ContentPresenter"> |
|||
<!--<Setter Property="Background" Value="{DynamicResource TimePickerButtonBackgroundPointerOver}"/>--> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePicker /template/ Button:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Background"> |
|||
<SolidColorBrush Color="{DynamicResource ThemeControlMidHighColor}" Opacity="0.6" /> |
|||
</Setter> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlLowBrush}"/> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePicker /template/ Button:disabled /template/ ContentPresenter"> |
|||
<!--<Setter Property="Background" Value="{DynamicResource TimePickerButtonBackgroundDisabled}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource TimePickerButtonBorderBrushDisabled}"/> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource TimePickerButtonForegroundDisabled}"/>--> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePicker:hasnotime /template/ Button#FlyoutButton TextBlock"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundLowBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePickerPresenter"> |
|||
<Setter Property="Width" Value="242" /> |
|||
<Setter Property="MinWidth" Value="242" /> |
|||
<Setter Property="MaxHeight" Value="398" /> |
|||
<Setter Property="FontWeight" Value="Normal" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource DateTimeFlyoutBorderThickness}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="Background" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Padding="{DynamicResource DateTimeFlyoutBorderPadding}" |
|||
MaxHeight="398"> |
|||
<Grid Name="ContentPanel" RowDefinitions="*,Auto"> |
|||
<Grid Name="PickerContainer"> |
|||
<!--Ignore col defs here, set in code--> |
|||
<Panel Name="HourHost" Grid.Column="0"> |
|||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" |
|||
VerticalScrollBarVisibility="Hidden"> |
|||
<DateTimePickerPanel Name="HourSelector" |
|||
PanelType="Hour" |
|||
ShouldLoop="True" |
|||
ItemHeight="{DynamicResource TimePickerFlyoutPresenterItemHeight}"/> |
|||
</ScrollViewer> |
|||
<RepeatButton Name="HourUpButton" |
|||
Classes="DateTimeFlyoutButtonStyle UpButton"/> |
|||
<RepeatButton Name="HourDownButton" |
|||
Classes="DateTimeFlyoutButtonStyle DownButton"/> |
|||
|
|||
</Panel> |
|||
|
|||
<Panel Name="MinuteHost" Grid.Column="2"> |
|||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" |
|||
VerticalScrollBarVisibility="Hidden"> |
|||
<DateTimePickerPanel Name="MinuteSelector" |
|||
PanelType="Minute" |
|||
ShouldLoop="True" |
|||
ItemHeight="{DynamicResource TimePickerFlyoutPresenterItemHeight}"/> |
|||
</ScrollViewer> |
|||
<RepeatButton Name="MinuteUpButton" |
|||
Classes="DateTimeFlyoutButtonStyle UpButton"/> |
|||
<RepeatButton Name="MinuteDownButton" |
|||
Classes="DateTimeFlyoutButtonStyle DownButton"/> |
|||
|
|||
</Panel> |
|||
|
|||
<Panel Name="PeriodHost" Grid.Column="4"> |
|||
<ScrollViewer HorizontalScrollBarVisibility="Disabled" |
|||
VerticalScrollBarVisibility="Hidden"> |
|||
<DateTimePickerPanel Name="PeriodSelector" |
|||
PanelType="TimePeriod" |
|||
ShouldLoop="False" |
|||
ItemHeight="{DynamicResource TimePickerFlyoutPresenterItemHeight}"/> |
|||
</ScrollViewer> |
|||
<RepeatButton Name="PeriodUpButton" |
|||
Classes="DateTimeFlyoutButtonStyle UpButton"/> |
|||
<RepeatButton Name="PeriodDownButton" |
|||
Classes="DateTimeFlyoutButtonStyle DownButton"/> |
|||
|
|||
</Panel> |
|||
|
|||
<Rectangle x:Name="HighlightRect" ZIndex="-1" |
|||
Fill="{DynamicResource TimePickerFlyoutPresenterHighlightFill}" |
|||
Grid.Column="0" |
|||
Grid.ColumnSpan="5" |
|||
VerticalAlignment="Center" |
|||
Height="{DynamicResource TimePickerFlyoutPresenterHighlightHeight}" /> |
|||
|
|||
<Rectangle Name="FirstSpacer" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="{DynamicResource TimePickerSpacerThemeWidth}" |
|||
Grid.Column="1" /> |
|||
|
|||
<Rectangle Name="SecondSpacer" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
HorizontalAlignment="Center" |
|||
Width="{DynamicResource TimePickerSpacerThemeWidth}" |
|||
Grid.Column="3" /> |
|||
</Grid> |
|||
|
|||
<Grid Grid.Row="1" Height="{DynamicResource TimePickerFlyoutPresenterAcceptDismissHostGridHeight}" |
|||
Name="AcceptDismissHostGrid" ColumnDefinitions="*,*"> |
|||
<Rectangle Height="{DynamicResource TimePickerSpacerThemeWidth}" |
|||
VerticalAlignment="Top" |
|||
Fill="{DynamicResource ThemeControlMidHighBrush}" |
|||
Grid.ColumnSpan="2" /> |
|||
<Button Name="AcceptButton" Grid.Column="0" Classes="DateTimeFlyoutButtonStyle" |
|||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<Path Stroke="{Binding $parent[Button].Foreground}" StrokeLineCap="Round" |
|||
StrokeThickness="0.75" Data="M0.5,8.5 5,13.5 15.5,3" /> |
|||
</Button> |
|||
<Button Name="DismissButton" Grid.Column="1" Classes="DateTimeFlyoutButtonStyle" |
|||
FontSize="16" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
|||
<Path Stroke="{Binding $parent[Button].Foreground}" StrokeLineCap="Round" |
|||
StrokeThickness="0.75" Data="M2,2 14,14 M2,14 14 2" /> |
|||
</Button> |
|||
</Grid> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePickerPresenter /template/ Panel RepeatButton"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TimePickerPresenter /template/ Panel:pointerover RepeatButton"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
@ -0,0 +1,72 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.Threading; |
|||
|
|||
namespace Avalonia.Rendering |
|||
{ |
|||
public class SleepLoopRenderTimer : IRenderTimer |
|||
{ |
|||
private Action<TimeSpan> _tick; |
|||
private int _count; |
|||
private readonly object _lock = new object(); |
|||
private bool _running; |
|||
private readonly Stopwatch _st = Stopwatch.StartNew(); |
|||
private readonly TimeSpan _timeBetweenTicks; |
|||
|
|||
public SleepLoopRenderTimer(int fps) |
|||
{ |
|||
_timeBetweenTicks = TimeSpan.FromSeconds(1d / fps); |
|||
} |
|||
|
|||
public event Action<TimeSpan> Tick |
|||
{ |
|||
add |
|||
{ |
|||
lock (_lock) |
|||
{ |
|||
_tick += value; |
|||
_count++; |
|||
if (_running) |
|||
return; |
|||
_running = true; |
|||
new Thread(LoopProc) { IsBackground = true }.Start(); |
|||
} |
|||
|
|||
} |
|||
remove |
|||
{ |
|||
lock (_lock) |
|||
{ |
|||
_tick -= value; |
|||
_count--; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void LoopProc() |
|||
{ |
|||
var now = _st.Elapsed; |
|||
var lastTick = now; |
|||
|
|||
while (true) |
|||
{ |
|||
var timeTillNextTick = lastTick + _timeBetweenTicks - now; |
|||
if (timeTillNextTick.TotalMilliseconds > 1) Thread.Sleep(timeTillNextTick); |
|||
|
|||
lock (_lock) |
|||
{ |
|||
if (_count == 0) |
|||
{ |
|||
_running = false; |
|||
return; |
|||
} |
|||
} |
|||
|
|||
_tick?.Invoke(now); |
|||
now = _st.Elapsed; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,126 @@ |
|||
using System.Linq; |
|||
using Avalonia.Controls.Presenters; |
|||
using Avalonia.Controls.Templates; |
|||
using Avalonia.Input; |
|||
using Avalonia.Styling; |
|||
using Avalonia.UnitTests; |
|||
using Avalonia.VisualTree; |
|||
using Xunit; |
|||
|
|||
namespace Avalonia.Controls.UnitTests |
|||
{ |
|||
public class ListBoxTests_Multiple |
|||
{ |
|||
[Fact] |
|||
public void Focusing_Item_With_Shift_And_Arrow_Key_Should_Add_To_Selection() |
|||
{ |
|||
var target = new ListBox |
|||
{ |
|||
Template = new FuncControlTemplate(CreateListBoxTemplate), |
|||
Items = new[] { "Foo", "Bar", "Baz " }, |
|||
SelectionMode = SelectionMode.Multiple |
|||
}; |
|||
|
|||
ApplyTemplate(target); |
|||
|
|||
target.SelectedItem = "Foo"; |
|||
|
|||
target.Presenter.Panel.Children[1].RaiseEvent(new GotFocusEventArgs |
|||
{ |
|||
RoutedEvent = InputElement.GotFocusEvent, |
|||
NavigationMethod = NavigationMethod.Directional, |
|||
KeyModifiers = KeyModifiers.Shift |
|||
}); |
|||
|
|||
Assert.Equal(new[] { "Foo", "Bar" }, target.SelectedItems); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Focusing_Item_With_Ctrl_And_Arrow_Key_Should_Add_To_Selection() |
|||
{ |
|||
var target = new ListBox |
|||
{ |
|||
Template = new FuncControlTemplate(CreateListBoxTemplate), |
|||
Items = new[] { "Foo", "Bar", "Baz " }, |
|||
SelectionMode = SelectionMode.Multiple |
|||
}; |
|||
|
|||
ApplyTemplate(target); |
|||
|
|||
target.SelectedItem = "Foo"; |
|||
|
|||
target.Presenter.Panel.Children[1].RaiseEvent(new GotFocusEventArgs |
|||
{ |
|||
RoutedEvent = InputElement.GotFocusEvent, |
|||
NavigationMethod = NavigationMethod.Directional, |
|||
KeyModifiers = KeyModifiers.Control |
|||
}); |
|||
|
|||
Assert.Equal(new[] { "Foo", "Bar" }, target.SelectedItems); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Focusing_Selected_Item_With_Ctrl_And_Arrow_Key_Should_Remove_From_Selection() |
|||
{ |
|||
var target = new ListBox |
|||
{ |
|||
Template = new FuncControlTemplate(CreateListBoxTemplate), |
|||
Items = new[] { "Foo", "Bar", "Baz " }, |
|||
SelectionMode = SelectionMode.Multiple |
|||
}; |
|||
|
|||
ApplyTemplate(target); |
|||
|
|||
target.SelectedItems.Add("Foo"); |
|||
target.SelectedItems.Add("Bar"); |
|||
|
|||
target.Presenter.Panel.Children[0].RaiseEvent(new GotFocusEventArgs |
|||
{ |
|||
RoutedEvent = InputElement.GotFocusEvent, |
|||
NavigationMethod = NavigationMethod.Directional, |
|||
KeyModifiers = KeyModifiers.Control |
|||
}); |
|||
|
|||
Assert.Equal(new[] { "Bar" }, target.SelectedItems); |
|||
} |
|||
|
|||
private Control CreateListBoxTemplate(ITemplatedControl parent, INameScope scope) |
|||
{ |
|||
return new ScrollViewer |
|||
{ |
|||
Template = new FuncControlTemplate(CreateScrollViewerTemplate), |
|||
Content = new ItemsPresenter |
|||
{ |
|||
Name = "PART_ItemsPresenter", |
|||
[~ItemsPresenter.ItemsProperty] = parent.GetObservable(ItemsControl.ItemsProperty).ToBinding(), |
|||
}.RegisterInNameScope(scope) |
|||
}; |
|||
} |
|||
|
|||
private Control CreateScrollViewerTemplate(ITemplatedControl parent, INameScope scope) |
|||
{ |
|||
return new ScrollContentPresenter |
|||
{ |
|||
Name = "PART_ContentPresenter", |
|||
[~ContentPresenter.ContentProperty] = |
|||
parent.GetObservable(ContentControl.ContentProperty).ToBinding(), |
|||
}.RegisterInNameScope(scope); |
|||
} |
|||
|
|||
private void ApplyTemplate(ListBox target) |
|||
{ |
|||
// Apply the template to the ListBox itself.
|
|||
target.ApplyTemplate(); |
|||
|
|||
// Then to its inner ScrollViewer.
|
|||
var scrollViewer = (ScrollViewer)target.GetVisualChildren().Single(); |
|||
scrollViewer.ApplyTemplate(); |
|||
|
|||
// Then make the ScrollViewer create its child.
|
|||
((ContentPresenter)scrollViewer.Presenter).UpdateChild(); |
|||
|
|||
// Now the ItemsPresenter should be reigstered, so apply its template.
|
|||
target.Presenter.ApplyTemplate(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue