committed by
GitHub
341 changed files with 16360 additions and 8593 deletions
@ -1,7 +1,9 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<configuration> |
|||
<packageSources> |
|||
<clear /> |
|||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> |
|||
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" /> |
|||
</packageSources> |
|||
</configuration> |
|||
|
|||
@ -0,0 +1,12 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<ApiContractPackageVersion>0.10.0-preview3</ApiContractPackageVersion> |
|||
<NugetPackageName Condition="'$(PackageId)' != ''">$(PackageId)</NugetPackageName> |
|||
<NugetPackageName Condition="'$(PackageId)' == ''">Avalonia</NugetPackageName> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<PackageDownload Include="$(NugetPackageName)" Version="[$(ApiContractPackageVersion)]" /> |
|||
<PackageReference Include="Microsoft.DotNet.ApiCompat" Version="5.0.0-beta.20372.2" PrivateAssets="All" /> |
|||
<ResolvedMatchingContract Include="$(NuGetPackageRoot)\$(NugetPackageName.ToLower())\$(ApiContractPackageVersion)\lib\$(TargetFramework)\$(AssemblyName).dll" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,5 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="ReactiveUI" Version="10.3.6" /> |
|||
<PackageReference Include="ReactiveUI" Version="11.5.17" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="2.80.0" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.80.0" /> |
|||
<PackageReference Include="SkiaSharp" Version="2.80.2-preview.33" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.80.2-preview.33" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -0,0 +1,66 @@ |
|||
using System; |
|||
using System.Collections.ObjectModel; |
|||
using System.Linq; |
|||
using System.Reactive; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Selection; |
|||
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<string>(); |
|||
Selection.Select(1); |
|||
|
|||
AddItemCommand = ReactiveCommand.Create(() => Items.Add(GenerateItem())); |
|||
|
|||
RemoveItemCommand = ReactiveCommand.Create(() => |
|||
{ |
|||
while (Selection.Count > 0) |
|||
{ |
|||
Items.Remove(Selection.SelectedItems.First()); |
|||
} |
|||
}); |
|||
|
|||
SelectRandomItemCommand = ReactiveCommand.Create(() => |
|||
{ |
|||
var random = new Random(); |
|||
|
|||
using (Selection.BatchUpdate()) |
|||
{ |
|||
Selection.Clear(); |
|||
Selection.Select(random.Next(Items.Count - 1)); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public ObservableCollection<string> Items { get; } |
|||
|
|||
public SelectionModel<string> 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.Clear(); |
|||
this.RaiseAndSetIfChanged(ref _selectionMode, value); |
|||
} |
|||
} |
|||
|
|||
private string GenerateItem() => $"Item {_counter++.ToString()}"; |
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
using System.Diagnostics; |
|||
using System.Runtime.InteropServices; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.LogicalTree; |
|||
using Avalonia.Media; |
|||
using Avalonia.Media.Imaging; |
|||
using Avalonia.Media.Immutable; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace RenderDemo.Pages |
|||
{ |
|||
public class WriteableBitmapPage : Control |
|||
{ |
|||
private WriteableBitmap _unpremulBitmap; |
|||
private WriteableBitmap _premulBitmap; |
|||
private readonly Stopwatch _st = Stopwatch.StartNew(); |
|||
|
|||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) |
|||
{ |
|||
_unpremulBitmap = new WriteableBitmap(new PixelSize(256, 256), new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Unpremul); |
|||
_premulBitmap = new WriteableBitmap(new PixelSize(256, 256), new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Premul); |
|||
|
|||
base.OnAttachedToLogicalTree(e); |
|||
} |
|||
|
|||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnDetachedFromLogicalTree(e); |
|||
|
|||
_unpremulBitmap?.Dispose(); |
|||
_unpremulBitmap = null; |
|||
|
|||
_premulBitmap?.Dispose(); |
|||
_unpremulBitmap = null; |
|||
} |
|||
|
|||
public override void Render(DrawingContext context) |
|||
{ |
|||
void FillPixels(WriteableBitmap bitmap, byte fillAlpha, bool premul) |
|||
{ |
|||
using (var fb = bitmap.Lock()) |
|||
{ |
|||
var data = new int[fb.Size.Width * fb.Size.Height]; |
|||
|
|||
for (int y = 0; y < fb.Size.Height; y++) |
|||
{ |
|||
for (int x = 0; x < fb.Size.Width; x++) |
|||
{ |
|||
var color = new Color(fillAlpha, 0, 255, 0); |
|||
|
|||
if (premul) |
|||
{ |
|||
byte r = (byte) (color.R * color.A / 255); |
|||
byte g = (byte) (color.G * color.A / 255); |
|||
byte b = (byte) (color.B * color.A / 255); |
|||
|
|||
color = new Color(fillAlpha, r, g, b); |
|||
} |
|||
|
|||
data[y * fb.Size.Width + x] = (int) color.ToUint32(); |
|||
} |
|||
} |
|||
|
|||
Marshal.Copy(data, 0, fb.Address, fb.Size.Width * fb.Size.Height); |
|||
} |
|||
} |
|||
|
|||
base.Render(context); |
|||
|
|||
byte alpha = (byte)((_st.ElapsedMilliseconds / 10) % 256); |
|||
|
|||
FillPixels(_unpremulBitmap, alpha, false); |
|||
FillPixels(_premulBitmap, alpha, true); |
|||
|
|||
context.FillRectangle(Brushes.Red, new Rect(0, 0, 256 * 3, 256)); |
|||
|
|||
context.DrawImage(_unpremulBitmap, |
|||
new Rect(0, 0, 256, 256), |
|||
new Rect(0, 0, 256, 256)); |
|||
|
|||
context.DrawImage(_premulBitmap, |
|||
new Rect(0, 0, 256, 256), |
|||
new Rect(256, 0, 256, 256)); |
|||
|
|||
context.FillRectangle(new ImmutableSolidColorBrush(Colors.Lime, alpha / 255d), new Rect(512, 0, 256, 256)); |
|||
|
|||
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,10 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="..\..\build\ApiDiff.props" /> |
|||
</Project> |
|||
|
|||
@ -1,41 +0,0 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using System.Reflection; |
|||
using System.Windows.Input; |
|||
using Avalonia.Utilities; |
|||
|
|||
namespace Avalonia.Data.Converters |
|||
{ |
|||
class AlwaysEnabledDelegateCommand : ICommand |
|||
{ |
|||
private readonly Delegate action; |
|||
|
|||
private ParameterInfo parameterInfo; |
|||
|
|||
public AlwaysEnabledDelegateCommand(Delegate action) |
|||
{ |
|||
this.action = action; |
|||
var parameters = action.Method.GetParameters(); |
|||
parameterInfo = parameters.Length == 0 ? null : parameters[0]; |
|||
} |
|||
|
|||
#pragma warning disable 0067
|
|||
public event EventHandler CanExecuteChanged; |
|||
#pragma warning restore 0067
|
|||
|
|||
public bool CanExecute(object parameter) => true; |
|||
|
|||
public void Execute(object parameter) |
|||
{ |
|||
if (parameterInfo == null) |
|||
{ |
|||
action.DynamicInvoke(); |
|||
} |
|||
else |
|||
{ |
|||
TypeUtilities.TryConvert(parameterInfo.ParameterType, parameter, CultureInfo.CurrentCulture, out object convertedParameter); |
|||
action.DynamicInvoke(convertedParameter); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,230 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Linq.Expressions; |
|||
using System.Reflection; |
|||
using System.Windows.Input; |
|||
using Avalonia.Utilities; |
|||
|
|||
namespace Avalonia.Data.Converters |
|||
{ |
|||
class MethodToCommandConverter : ICommand |
|||
{ |
|||
readonly static Func<object, bool> AlwaysEnabled = (_) => true; |
|||
readonly static MethodInfo tryConvert = typeof(TypeUtilities) |
|||
.GetMethod(nameof(TypeUtilities.TryConvert), BindingFlags.Public | BindingFlags.Static); |
|||
readonly static PropertyInfo currentCulture = typeof(CultureInfo) |
|||
.GetProperty(nameof(CultureInfo.CurrentCulture), BindingFlags.Public | BindingFlags.Static); |
|||
readonly Func<object, bool> canExecute; |
|||
readonly Action<object> execute; |
|||
readonly WeakPropertyChangedProxy weakPropertyChanged; |
|||
readonly PropertyChangedEventHandler propertyChangedEventHandler; |
|||
readonly string[] dependencyProperties; |
|||
|
|||
public MethodToCommandConverter(Delegate action) |
|||
{ |
|||
var target = action.Target; |
|||
var canExecuteMethodName = "Can" + action.Method.Name; |
|||
var parameters = action.Method.GetParameters(); |
|||
var parameterInfo = parameters.Length == 0 ? null : parameters[0].ParameterType; |
|||
|
|||
if (parameterInfo == null) |
|||
{ |
|||
execute = CreateExecute(target, action.Method); |
|||
} |
|||
else |
|||
{ |
|||
execute = CreateExecute(target, action.Method, parameterInfo); |
|||
} |
|||
|
|||
var canExecuteMethod = action.Method.DeclaringType.GetRuntimeMethods() |
|||
.FirstOrDefault(m => m.Name == canExecuteMethodName |
|||
&& m.GetParameters().Length == 1 |
|||
&& m.GetParameters()[0].ParameterType == typeof(object)); |
|||
if (canExecuteMethod == null) |
|||
{ |
|||
canExecute = AlwaysEnabled; |
|||
} |
|||
else |
|||
{ |
|||
canExecute = CreateCanExecute(target, canExecuteMethod); |
|||
dependencyProperties = canExecuteMethod |
|||
.GetCustomAttributes(typeof(Metadata.DependsOnAttribute), true) |
|||
.OfType<Metadata.DependsOnAttribute>() |
|||
.Select(x => x.Name) |
|||
.ToArray(); |
|||
if (dependencyProperties.Any() |
|||
&& target is INotifyPropertyChanged inpc) |
|||
{ |
|||
propertyChangedEventHandler = OnPropertyChanged; |
|||
weakPropertyChanged = new WeakPropertyChangedProxy(inpc, propertyChangedEventHandler); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void OnPropertyChanged(object sender,PropertyChangedEventArgs args) |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(args.PropertyName) |
|||
|| dependencyProperties?.Contains(args.PropertyName) == true) |
|||
{ |
|||
Threading.Dispatcher.UIThread.Post(() => CanExecuteChanged?.Invoke(this, EventArgs.Empty) |
|||
, Threading.DispatcherPriority.Input); |
|||
} |
|||
} |
|||
|
|||
#pragma warning disable 0067
|
|||
public event EventHandler CanExecuteChanged; |
|||
#pragma warning restore 0067
|
|||
|
|||
public bool CanExecute(object parameter) => canExecute(parameter); |
|||
|
|||
public void Execute(object parameter) => execute(parameter); |
|||
|
|||
|
|||
static Action<object> CreateExecute(object target |
|||
, System.Reflection.MethodInfo method) |
|||
{ |
|||
|
|||
var parameter = Expression.Parameter(typeof(object), "parameter"); |
|||
|
|||
var instance = Expression.Convert |
|||
( |
|||
Expression.Constant(target), |
|||
method.DeclaringType |
|||
); |
|||
|
|||
|
|||
var call = Expression.Call |
|||
( |
|||
instance, |
|||
method |
|||
); |
|||
|
|||
|
|||
return Expression |
|||
.Lambda<Action<object>>(call, parameter) |
|||
.Compile(); |
|||
} |
|||
|
|||
static Action<object> CreateExecute(object target |
|||
, System.Reflection.MethodInfo method |
|||
, Type parameterType) |
|||
{ |
|||
|
|||
var parameter = Expression.Parameter(typeof(object), "parameter"); |
|||
|
|||
var instance = Expression.Convert |
|||
( |
|||
Expression.Constant(target), |
|||
method.DeclaringType |
|||
); |
|||
|
|||
Expression body; |
|||
|
|||
if (parameterType == typeof(object)) |
|||
{ |
|||
body = Expression.Call(instance, |
|||
method, |
|||
parameter |
|||
); |
|||
} |
|||
else |
|||
{ |
|||
var arg0 = Expression.Variable(typeof(object), "argX"); |
|||
var convertCall = Expression.Call(tryConvert, |
|||
Expression.Constant(parameterType), |
|||
parameter, |
|||
Expression.Property(null, currentCulture), |
|||
arg0 |
|||
); |
|||
|
|||
var call = Expression.Call(instance, |
|||
method, |
|||
Expression.Convert(arg0, parameterType) |
|||
); |
|||
body = Expression.Block(new[] { arg0 }, |
|||
convertCall, |
|||
call |
|||
); |
|||
|
|||
} |
|||
Action<object> action = null; |
|||
try |
|||
{ |
|||
action = Expression |
|||
.Lambda<Action<object>>(body, parameter) |
|||
.Compile(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
return action; |
|||
} |
|||
|
|||
static Func<object, bool> CreateCanExecute(object target |
|||
, System.Reflection.MethodInfo method) |
|||
{ |
|||
var parameter = Expression.Parameter(typeof(object), "parameter"); |
|||
var instance = Expression.Convert |
|||
( |
|||
Expression.Constant(target), |
|||
method.DeclaringType |
|||
); |
|||
var call = Expression.Call |
|||
( |
|||
instance, |
|||
method, |
|||
parameter |
|||
); |
|||
return Expression |
|||
.Lambda<Func<object, bool>>(call, parameter) |
|||
.Compile(); |
|||
} |
|||
|
|||
|
|||
internal class WeakPropertyChangedProxy |
|||
{ |
|||
readonly WeakReference<PropertyChangedEventHandler> _listener = new WeakReference<PropertyChangedEventHandler>(null); |
|||
readonly PropertyChangedEventHandler _handler; |
|||
internal WeakReference<INotifyPropertyChanged> Source { get; } = new WeakReference<INotifyPropertyChanged>(null); |
|||
|
|||
public WeakPropertyChangedProxy() |
|||
{ |
|||
_handler = new PropertyChangedEventHandler(OnPropertyChanged); |
|||
} |
|||
|
|||
public WeakPropertyChangedProxy(INotifyPropertyChanged source, PropertyChangedEventHandler listener) : this() |
|||
{ |
|||
SubscribeTo(source, listener); |
|||
} |
|||
|
|||
public void SubscribeTo(INotifyPropertyChanged source, PropertyChangedEventHandler listener) |
|||
{ |
|||
source.PropertyChanged += _handler; |
|||
|
|||
Source.SetTarget(source); |
|||
_listener.SetTarget(listener); |
|||
} |
|||
|
|||
public void Unsubscribe() |
|||
{ |
|||
if (Source.TryGetTarget(out INotifyPropertyChanged source) && source != null) |
|||
source.PropertyChanged -= _handler; |
|||
|
|||
Source.SetTarget(null); |
|||
_listener.SetTarget(null); |
|||
} |
|||
|
|||
void OnPropertyChanged(object sender, PropertyChangedEventArgs e) |
|||
{ |
|||
if (_listener.TryGetTarget(out var handler) && handler != null) |
|||
handler(sender, e); |
|||
else |
|||
Unsubscribe(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,645 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Styles.Resources> |
|||
<Thickness x:Key="DataGridTextColumnCellTextBlockMargin">12,0,12,0</Thickness> |
|||
|
|||
<x:Double x:Key="ListAccentLowOpacity">0.6</x:Double> |
|||
<x:Double x:Key="ListAccentMediumOpacity">0.8</x:Double> |
|||
|
|||
<StreamGeometry x:Key="DataGridSortIconAscendingPath">M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z</StreamGeometry> |
|||
<StreamGeometry x:Key="DataGridSortIconDescendingPath">M1965 947l-941 -941l-941 941l90 90l787 -787v1798h128v-1798l787 787z</StreamGeometry> |
|||
<StreamGeometry x:Key="DataGridRowGroupHeaderIconClosedPath">M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z</StreamGeometry> |
|||
<StreamGeometry x:Key="DataGridRowGroupHeaderIconOpenedPath">M1939 1581l90 -90l-1005 -1005l-1005 1005l90 90l915 -915z</StreamGeometry> |
|||
|
|||
<SolidColorBrush x:Key="DataGridGridLinesBrush" |
|||
Color="{StaticResource SystemBaseMediumLowColor}" |
|||
Opacity="0.4" /> |
|||
<SolidColorBrush x:Key="DataGridDropLocationIndicatorBackground" |
|||
Color="#3F4346" /> |
|||
<SolidColorBrush x:Key="DataGridDisabledVisualElementBackground" |
|||
Color="#8CFFFFFF" /> |
|||
<SolidColorBrush x:Key="DataGridFillerGridLinesBrush" |
|||
Color="Transparent" /> |
|||
<SolidColorBrush x:Key="DataGridCurrencyVisualPrimaryBrush" |
|||
Color="Transparent" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderBackgroundColor" |
|||
ResourceKey="SystemAltHighColor" /> |
|||
<SolidColorBrush x:Key="DataGridColumnHeaderBackgroundBrush" |
|||
Color="{StaticResource DataGridColumnHeaderBackgroundColor}" /> |
|||
<StaticResource x:Key="DataGridScrollBarsSeparatorBackground" |
|||
ResourceKey="SystemChromeLowColor" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderForegroundBrush" |
|||
ResourceKey="SystemControlForegroundBaseMediumBrush" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderHoveredBackgroundColor" |
|||
ResourceKey="SystemListLowColor" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderPressedBackgroundColor" |
|||
ResourceKey="SystemListMediumColor" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderDraggedBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundChromeMediumLowBrush" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderPointerOverBrush" |
|||
ResourceKey="SystemControlHighlightListLowBrush" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderPressedBrush" |
|||
ResourceKey="SystemControlHighlightListMediumBrush" /> |
|||
<StaticResource x:Key="DataGridDetailsPresenterBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundChromeMediumLowBrush" /> |
|||
<StaticResource x:Key="DataGridFillerColumnGridLinesBrush" |
|||
ResourceKey="DataGridFillerGridLinesBrush" /> |
|||
<StaticResource x:Key="DataGridRowSelectedBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedBackgroundOpacity" |
|||
ResourceKey="ListAccentLowOpacity" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredBackgroundOpacity" |
|||
ResourceKey="ListAccentMediumOpacity" /> |
|||
<StaticResource x:Key="DataGridRowSelectedUnfocusedBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedUnfocusedBackgroundOpacity" |
|||
ResourceKey="ListAccentLowOpacity" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredUnfocusedBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredUnfocusedBackgroundOpacity" |
|||
ResourceKey="ListAccentMediumOpacity" /> |
|||
<StaticResource x:Key="DataGridRowHeaderForegroundBrush" |
|||
ResourceKey="SystemControlForegroundBaseMediumBrush" /> |
|||
<StaticResource x:Key="DataGridRowHeaderBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundAltHighBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundChromeMediumBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderHoveredBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundListLowBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderPressedBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundListMediumBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderForegroundBrush" |
|||
ResourceKey="SystemControlForegroundBaseHighBrush" /> |
|||
<StaticResource x:Key="DataGridRowInvalidBrush" |
|||
ResourceKey="SystemErrorTextColor" /> |
|||
<StaticResource x:Key="DataGridCellBackgroundBrush" |
|||
ResourceKey="SystemControlTransparentBrush" /> |
|||
<StaticResource x:Key="DataGridCellFocusVisualPrimaryBrush" |
|||
ResourceKey="SystemControlFocusVisualPrimaryBrush" /> |
|||
<StaticResource x:Key="DataGridCellFocusVisualSecondaryBrush" |
|||
ResourceKey="SystemControlFocusVisualSecondaryBrush" /> |
|||
<StaticResource x:Key="DataGridCellInvalidBrush" |
|||
ResourceKey="SystemErrorTextColor" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="DataGridCell"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridCellBackgroundBrush}" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="FontSize" Value="15" /> |
|||
<Setter Property="MinHeight" Value="32" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid x:Name="PART_CellRoot" |
|||
ColumnDefinitions="*,Auto" |
|||
Background="{TemplateBinding Background}"> |
|||
|
|||
<Rectangle x:Name="CurrencyVisual" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCurrencyVisualPrimaryBrush}" |
|||
StrokeThickness="1" /> |
|||
<Grid x:Name="FocusVisual" |
|||
IsHitTestVisible="False"> |
|||
<Rectangle HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}" |
|||
StrokeThickness="2" /> |
|||
<Rectangle Margin="2" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}" |
|||
StrokeThickness="1" /> |
|||
</Grid> |
|||
|
|||
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Margin="{TemplateBinding Padding}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
|
|||
<Rectangle x:Name="InvalidVisualElement" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellInvalidBrush}" |
|||
StrokeThickness="1" /> |
|||
|
|||
<Rectangle Name="PART_RightGridLine" |
|||
Grid.Column="1" |
|||
VerticalAlignment="Stretch" |
|||
Width="1" |
|||
Fill="{DynamicResource DataGridFillerColumnGridLinesBrush}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridCell /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell:current /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
<Style Selector="DataGrid:focus DataGridCell:current /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell:invalid /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader"> |
|||
<Setter Property="Foreground" Value="{DynamicResource DataGridColumnHeaderForegroundBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderBackgroundBrush}" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="SeparatorBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="Padding" Value="12,0,0,0" /> |
|||
<Setter Property="FontSize" Value="12" /> |
|||
<Setter Property="MinHeight" Value="32" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid Name="PART_ColumnHeaderRoot" |
|||
ColumnDefinitions="*,Auto" |
|||
Background="{TemplateBinding Background}"> |
|||
|
|||
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Margin="{TemplateBinding Padding}"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition MinWidth="32" |
|||
Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter Content="{TemplateBinding Content}" /> |
|||
|
|||
<Path Name="SortIcon" |
|||
Grid.Column="1" |
|||
Fill="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Stretch="Uniform" |
|||
Height="12" /> |
|||
</Grid> |
|||
|
|||
<Rectangle Name="VerticalSeparator" |
|||
Grid.Column="1" |
|||
Width="1" |
|||
VerticalAlignment="Stretch" |
|||
Fill="{TemplateBinding SeparatorBrush}" |
|||
IsVisible="{TemplateBinding AreSeparatorsVisible}" /> |
|||
|
|||
<Grid x:Name="FocusVisual" |
|||
IsHitTestVisible="False"> |
|||
<Rectangle x:Name="FocusVisualPrimary" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}" |
|||
StrokeThickness="2" /> |
|||
<Rectangle x:Name="FocusVisualSecondary" |
|||
Margin="2" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}" |
|||
StrokeThickness="1" /> |
|||
</Grid> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridColumnHeader:focus-visible /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:pointerover /template/ Grid#PART_ColumnHeaderRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderHoveredBackgroundColor}" /> |
|||
</Style> |
|||
<Style Selector="DataGridColumnHeader:pressed /template/ Grid#PART_ColumnHeaderRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderPressedBackgroundColor}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:dragIndicator"> |
|||
<Setter Property="Opacity" Value="0.5" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader /template/ Path#SortIcon"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:sortascending /template/ Path#SortIcon"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
<Setter Property="Data" Value="{StaticResource DataGridSortIconAscendingPath}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:sortdescending /template/ Path#SortIcon"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
<Setter Property="Data" Value="{StaticResource DataGridSortIconDescendingPath}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRow"> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<DataGridFrozenGrid Name="PART_Root" |
|||
RowDefinitions="*,Auto,Auto" |
|||
ColumnDefinitions="Auto,*"> |
|||
|
|||
<Rectangle Name="BackgroundRectangle" |
|||
Grid.RowSpan="2" |
|||
Grid.ColumnSpan="2" /> |
|||
<Rectangle x:Name="InvalidVisualElement" |
|||
Grid.ColumnSpan="2" |
|||
Fill="{DynamicResource DataGridRowInvalidBrush}" /> |
|||
|
|||
<DataGridRowHeader Name="PART_RowHeader" |
|||
Grid.RowSpan="3" |
|||
DataGridFrozenGrid.IsFrozen="True" /> |
|||
<DataGridCellsPresenter Name="PART_CellsPresenter" |
|||
Grid.Column="1" |
|||
DataGridFrozenGrid.IsFrozen="True" /> |
|||
<DataGridDetailsPresenter Name="PART_DetailsPresenter" |
|||
Grid.Row="1" |
|||
Grid.Column="1" |
|||
Background="{DynamicResource DataGridDetailsPresenterBackgroundBrush}" /> |
|||
<Rectangle Name="PART_BottomGridLine" |
|||
Grid.Row="2" |
|||
Grid.Column="1" |
|||
HorizontalAlignment="Stretch" |
|||
Height="1" /> |
|||
|
|||
</DataGridFrozenGrid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRow /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:invalid /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0.4" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:invalid /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRow /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemControlTransparentBrush}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemListLowColor}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected:pointerover /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected:pointerover:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowHeader"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowHeaderBackgroundBrush}" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="SeparatorBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="AreSeparatorsVisible" Value="False" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid x:Name="PART_Root" |
|||
RowDefinitions="*,*,Auto" |
|||
ColumnDefinitions="Auto,*"> |
|||
<Border Grid.RowSpan="3" |
|||
Grid.ColumnSpan="2" |
|||
BorderBrush="{TemplateBinding SeparatorBrush}" |
|||
BorderThickness="0,0,1,0"> |
|||
<Grid Background="{TemplateBinding Background}"> |
|||
<Rectangle x:Name="RowInvalidVisualElement" |
|||
Fill="{DynamicResource DataGridRowInvalidBrush}" |
|||
Stretch="Fill" /> |
|||
<Rectangle x:Name="BackgroundRectangle" |
|||
Stretch="Fill" /> |
|||
</Grid> |
|||
</Border> |
|||
<Rectangle x:Name="HorizontalSeparator" |
|||
Grid.Row="2" |
|||
Grid.ColumnSpan="2" |
|||
Height="1" |
|||
Margin="1,0,1,0" |
|||
HorizontalAlignment="Stretch" |
|||
Fill="{TemplateBinding SeparatorBrush}" |
|||
IsVisible="{TemplateBinding AreSeparatorsVisible}" /> |
|||
|
|||
<ContentPresenter Grid.RowSpan="2" |
|||
Grid.Column="1" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Content="{TemplateBinding Content}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowHeader /template/ Rectangle#RowInvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:invalid /template/ Rectangle#RowInvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0.4" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:invalid /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowHeader /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemControlTransparentBrush}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover DataGridRowHeader /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemListLowColor}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:selected /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover DataGridRowHeader:selected /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:selected:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover DataGridRowHeader:selected:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader"> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource DataGridRowGroupHeaderForegroundBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderBackgroundBrush}" /> |
|||
<Setter Property="FontSize" Value="15" /> |
|||
<Setter Property="MinHeight" Value="32" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<DataGridFrozenGrid Name="PART_Root" |
|||
MinHeight="{TemplateBinding MinHeight}" |
|||
ColumnDefinitions="Auto,Auto,Auto,Auto,*" |
|||
RowDefinitions="*,Auto"> |
|||
|
|||
<Rectangle Name="IndentSpacer" |
|||
Grid.Column="1" /> |
|||
<ToggleButton Name="ExpanderButton" |
|||
Grid.Column="2" |
|||
Width="12" |
|||
Height="12" |
|||
Margin="12,0,0,0" |
|||
Background="{TemplateBinding Background}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Focusable="False" /> |
|||
|
|||
<StackPanel Grid.Column="3" |
|||
Orientation="Horizontal" |
|||
VerticalAlignment="Center" |
|||
Margin="12,0,0,0"> |
|||
<TextBlock Name="PropertyNameElement" |
|||
Margin="4,0,0,0" |
|||
IsVisible="{TemplateBinding IsPropertyNameVisible}" |
|||
Foreground="{TemplateBinding Foreground}" /> |
|||
<TextBlock Margin="4,0,0,0" |
|||
Text="{Binding Key}" |
|||
Foreground="{TemplateBinding Foreground}" /> |
|||
<TextBlock Name="ItemCountElement" |
|||
Margin="4,0,0,0" |
|||
IsVisible="{TemplateBinding IsItemCountVisible}" |
|||
Foreground="{TemplateBinding Foreground}" /> |
|||
</StackPanel> |
|||
|
|||
<Rectangle x:Name="CurrencyVisual" |
|||
Grid.ColumnSpan="5" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCurrencyVisualPrimaryBrush}" |
|||
StrokeThickness="1" /> |
|||
<Grid x:Name="FocusVisual" |
|||
Grid.ColumnSpan="5" |
|||
IsHitTestVisible="False"> |
|||
<Rectangle HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}" |
|||
StrokeThickness="2" /> |
|||
<Rectangle Margin="2" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}" |
|||
StrokeThickness="1" /> |
|||
</Grid> |
|||
|
|||
<DataGridRowHeader Name="PART_RowHeader" |
|||
Grid.RowSpan="2" |
|||
DataGridFrozenGrid.IsFrozen="True" /> |
|||
|
|||
<Rectangle x:Name="PART_BottomGridLine" |
|||
Grid.Row="1" |
|||
Grid.ColumnSpan="5" |
|||
Height="1" /> |
|||
</DataGridFrozenGrid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Grid.Column="0" |
|||
Width="12" |
|||
Height="12" |
|||
Background="Transparent" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"> |
|||
<Path Fill="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center" |
|||
Stretch="Uniform" /> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton /template/ Path"> |
|||
<Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconOpenedPath}" /> |
|||
<Setter Property="Stretch" Value="Uniform" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton:checked /template/ Path"> |
|||
<Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconClosedPath}" /> |
|||
<Setter Property="Stretch" Value="UniformToFill" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ DataGridFrozenGrid#PART_Root"> |
|||
<Setter Property="Background" Value="{Binding $parent[DataGridRowGroupHeader].Background}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader:pointerover /template/ DataGridFrozenGrid#PART_Root"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderHoveredBackgroundBrush}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader:pressed /template/ DataGridFrozenGrid#PART_Root"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderPressedBackgroundBrush}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader:current /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
<Style Selector="DataGrid:focus DataGridRowGroupHeader:current /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGrid"> |
|||
<Setter Property="RowBackground" Value="Transparent" /> |
|||
<Setter Property="AlternatingRowBackground" Value="Transparent" /> |
|||
<Setter Property="HeadersVisibility" Value="Column" /> |
|||
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" /> |
|||
<Setter Property="VerticalScrollBarVisibility" Value="Auto" /> |
|||
<Setter Property="SelectionMode" Value="Extended" /> |
|||
<Setter Property="GridLinesVisibility" Value="None" /> |
|||
<Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="DropLocationIndicatorTemplate"> |
|||
<Template> |
|||
<Rectangle Fill="{DynamicResource DataGridDropLocationIndicatorBackground}" |
|||
Width="2" /> |
|||
</Template> |
|||
</Setter> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Grid RowDefinitions="Auto,*,Auto,Auto" |
|||
ColumnDefinitions="Auto,*,Auto"> |
|||
<Grid.Resources> |
|||
<ControlTemplate x:Key="TopLeftHeaderTemplate" |
|||
TargetType="DataGridColumnHeader"> |
|||
<Grid x:Name="TopLeftHeaderRoot" |
|||
RowDefinitions="*,*,Auto"> |
|||
<Border Grid.RowSpan="2" |
|||
BorderThickness="0,0,1,0" |
|||
BorderBrush="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Rectangle Grid.RowSpan="2" |
|||
VerticalAlignment="Bottom" |
|||
StrokeThickness="1" |
|||
Height="1" |
|||
Fill="{DynamicResource DataGridGridLinesBrush}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
<ControlTemplate x:Key="TopRightHeaderTemplate" |
|||
TargetType="DataGridColumnHeader"> |
|||
<Grid x:Name="RootElement" /> |
|||
</ControlTemplate> |
|||
</Grid.Resources> |
|||
|
|||
<DataGridColumnHeader Name="PART_TopLeftCornerHeader" |
|||
Template="{StaticResource TopLeftHeaderTemplate}" /> |
|||
<DataGridColumnHeadersPresenter Name="PART_ColumnHeadersPresenter" |
|||
Grid.Column="1" |
|||
Grid.ColumnSpan="2" /> |
|||
<!--<DataGridColumnHeader Name="PART_TopRightCornerHeader" |
|||
Grid.Column="2" |
|||
Template="{StaticResource TopRightHeaderTemplate}" />--> |
|||
<!--<Rectangle Name="PART_ColumnHeadersAndRowsSeparator" |
|||
Grid.ColumnSpan="3" |
|||
VerticalAlignment="Bottom" |
|||
StrokeThickness="1" |
|||
Height="1" |
|||
Fill="{DynamicResource DataGridGridLinesBrush}" />--> |
|||
<Border Name="PART_ColumnHeadersAndRowsSeparator" |
|||
Grid.ColumnSpan="3" |
|||
Height="2" |
|||
VerticalAlignment="Bottom" |
|||
BorderThickness="0,0,0,1" |
|||
BorderBrush="{DynamicResource DataGridGridLinesBrush}" /> |
|||
|
|||
<DataGridRowsPresenter Name="PART_RowsPresenter" |
|||
Grid.Row="1" |
|||
Grid.RowSpan="2" |
|||
Grid.ColumnSpan="3" /> |
|||
<Rectangle Name="PART_BottomRightCorner" |
|||
Fill="{DynamicResource DataGridScrollBarsSeparatorBackground}" |
|||
Grid.Column="2" |
|||
Grid.Row="2" /> |
|||
<!--<Rectangle Name="BottomLeftCorner" |
|||
Fill="{DynamicResource DataGridScrollBarsSeparatorBackground}" |
|||
Grid.Row="2" |
|||
Grid.ColumnSpan="2" />--> |
|||
<ScrollBar Name="PART_VerticalScrollbar" |
|||
Orientation="Vertical" |
|||
Grid.Column="2" |
|||
Grid.Row="1" |
|||
Width="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
<Grid Grid.Column="1" |
|||
Grid.Row="2" |
|||
ColumnDefinitions="Auto,*"> |
|||
<Rectangle Name="PART_FrozenColumnScrollBarSpacer" /> |
|||
<ScrollBar Name="PART_HorizontalScrollbar" |
|||
Grid.Column="1" |
|||
Orientation="Horizontal" |
|||
Height="{DynamicResource ScrollBarSize}" /> |
|||
</Grid> |
|||
<Border x:Name="PART_DisabledVisualElement" |
|||
Grid.ColumnSpan="3" |
|||
Grid.RowSpan="4" |
|||
IsHitTestVisible="False" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
CornerRadius="2" |
|||
Background="{DynamicResource DataGridDisabledVisualElementBackground}" |
|||
IsVisible="{Binding !$parent[DataGrid].IsEnabled}" /> |
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,18 @@ |
|||
Compat issues with assembly Avalonia.Controls: |
|||
TypesMustExist : Type 'Avalonia.Controls.IndexPath' does not exist in the implementation but it does exist in the contract. |
|||
TypesMustExist : Type 'Avalonia.Controls.ISelectedItemInfo' does not exist in the implementation but it does exist in the contract. |
|||
TypesMustExist : Type 'Avalonia.Controls.ISelectionModel' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.DirectProperty<Avalonia.Controls.Primitives.SelectingItemsControl, Avalonia.Controls.ISelectionModel> Avalonia.DirectProperty<Avalonia.Controls.Primitives.SelectingItemsControl, Avalonia.Controls.ISelectionModel> Avalonia.Controls.ListBox.SelectionProperty' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.Controls.ISelectionModel Avalonia.Controls.ListBox.Selection.get()' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public void Avalonia.Controls.ListBox.Selection.set(Avalonia.Controls.ISelectionModel)' does not exist in the implementation but it does exist in the contract. |
|||
TypesMustExist : Type 'Avalonia.Controls.SelectionModel' does not exist in the implementation but it does exist in the contract. |
|||
TypesMustExist : Type 'Avalonia.Controls.SelectionModelChildrenRequestedEventArgs' does not exist in the implementation but it does exist in the contract. |
|||
TypesMustExist : Type 'Avalonia.Controls.SelectionModelSelectionChangedEventArgs' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.DirectProperty<Avalonia.Controls.TreeView, Avalonia.Controls.ISelectionModel> Avalonia.DirectProperty<Avalonia.Controls.TreeView, Avalonia.Controls.ISelectionModel> Avalonia.Controls.TreeView.SelectionProperty' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.Interactivity.RoutedEvent<Avalonia.Controls.SelectionChangedEventArgs> Avalonia.Interactivity.RoutedEvent<Avalonia.Controls.SelectionChangedEventArgs> Avalonia.Controls.TreeView.SelectionChangedEvent' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.Controls.ISelectionModel Avalonia.Controls.TreeView.Selection.get()' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public void Avalonia.Controls.TreeView.Selection.set(Avalonia.Controls.ISelectionModel)' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public Avalonia.DirectProperty<Avalonia.Controls.Primitives.SelectingItemsControl, Avalonia.Controls.ISelectionModel> Avalonia.DirectProperty<Avalonia.Controls.Primitives.SelectingItemsControl, Avalonia.Controls.ISelectionModel> Avalonia.Controls.Primitives.SelectingItemsControl.SelectionProperty' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'protected Avalonia.Controls.ISelectionModel Avalonia.Controls.Primitives.SelectingItemsControl.Selection.get()' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'protected void Avalonia.Controls.Primitives.SelectingItemsControl.Selection.set(Avalonia.Controls.ISelectionModel)' does not exist in the implementation but it does exist in the contract. |
|||
Total Issues: 16 |
|||
@ -1,249 +0,0 @@ |
|||
// This source file is adapted from the WinUI project.
|
|||
// (https://github.com/microsoft/microsoft-ui-xaml)
|
|||
//
|
|||
// Licensed to The Avalonia Project under MIT License, courtesy of The .NET Foundation.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Holds the selected items for a control.
|
|||
/// </summary>
|
|||
public interface ISelectionModel : INotifyPropertyChanged |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the anchor index.
|
|||
/// </summary>
|
|||
IndexPath AnchorIndex { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or set the index of the first selected item.
|
|||
/// </summary>
|
|||
IndexPath SelectedIndex { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or set the indexes of the selected items.
|
|||
/// </summary>
|
|||
IReadOnlyList<IndexPath> SelectedIndices { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the first selected item.
|
|||
/// </summary>
|
|||
object SelectedItem { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the selected items.
|
|||
/// </summary>
|
|||
IReadOnlyList<object> SelectedItems { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether the model represents a single or multiple selection.
|
|||
/// </summary>
|
|||
bool SingleSelect { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether to always keep an item selected where possible.
|
|||
/// </summary>
|
|||
bool AutoSelect { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the collection that contains the items that can be selected.
|
|||
/// </summary>
|
|||
object Source { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Raised when the children of a selection are required.
|
|||
/// </summary>
|
|||
event EventHandler<SelectionModelChildrenRequestedEventArgs> ChildrenRequested; |
|||
|
|||
/// <summary>
|
|||
/// Raised when the selection has changed.
|
|||
/// </summary>
|
|||
event EventHandler<SelectionModelSelectionChangedEventArgs> SelectionChanged; |
|||
|
|||
/// <summary>
|
|||
/// Clears the selection.
|
|||
/// </summary>
|
|||
void ClearSelection(); |
|||
|
|||
/// <summary>
|
|||
/// Deselects an item.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item.</param>
|
|||
void Deselect(int index); |
|||
|
|||
/// <summary>
|
|||
/// Deselects an item.
|
|||
/// </summary>
|
|||
/// <param name="groupIndex">The index of the item group.</param>
|
|||
/// <param name="itemIndex">The index of the item in the group.</param>
|
|||
void Deselect(int groupIndex, int itemIndex); |
|||
|
|||
/// <summary>
|
|||
/// Deselects an item.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item.</param>
|
|||
void DeselectAt(IndexPath index); |
|||
|
|||
/// <summary>
|
|||
/// Deselects a range of items.
|
|||
/// </summary>
|
|||
/// <param name="start">The start index of the range.</param>
|
|||
/// <param name="end">The end index of the range.</param>
|
|||
void DeselectRange(IndexPath start, IndexPath end); |
|||
|
|||
/// <summary>
|
|||
/// Deselects a range of items, starting at <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="index">The end index of the range.</param>
|
|||
void DeselectRangeFromAnchor(int index); |
|||
|
|||
/// <summary>
|
|||
/// Deselects a range of items, starting at <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="endGroupIndex">
|
|||
/// The index of the item group that represents the end of the selection.
|
|||
/// </param>
|
|||
/// <param name="endItemIndex">
|
|||
/// The index of the item in the group that represents the end of the selection.
|
|||
/// </param>
|
|||
void DeselectRangeFromAnchor(int endGroupIndex, int endItemIndex); |
|||
|
|||
/// <summary>
|
|||
/// Deselects a range of items, starting at <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="index">The end index of the range.</param>
|
|||
void DeselectRangeFromAnchorTo(IndexPath index); |
|||
|
|||
/// <summary>
|
|||
/// Disposes the object and clears the selection.
|
|||
/// </summary>
|
|||
void Dispose(); |
|||
|
|||
/// <summary>
|
|||
/// Checks whether an item is selected.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item</param>
|
|||
bool IsSelected(int index); |
|||
|
|||
/// <summary>
|
|||
/// Checks whether an item is selected.
|
|||
/// </summary>
|
|||
/// <param name="groupIndex">The index of the item group.</param>
|
|||
/// <param name="itemIndex">The index of the item in the group.</param>
|
|||
bool IsSelected(int groupIndex, int itemIndex); |
|||
|
|||
/// <summary>
|
|||
/// Checks whether an item is selected.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item</param>
|
|||
public bool IsSelectedAt(IndexPath index); |
|||
|
|||
/// <summary>
|
|||
/// Checks whether an item or its descendents are selected.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item</param>
|
|||
/// <returns>
|
|||
/// True if the item and all its descendents are selected, false if the item and all its
|
|||
/// descendents are deselected, or null if a combination of selected and deselected.
|
|||
/// </returns>
|
|||
bool? IsSelectedWithPartial(int index); |
|||
|
|||
/// <summary>
|
|||
/// Checks whether an item or its descendents are selected.
|
|||
/// </summary>
|
|||
/// <param name="groupIndex">The index of the item group.</param>
|
|||
/// <param name="itemIndex">The index of the item in the group.</param>
|
|||
/// <returns>
|
|||
/// True if the item and all its descendents are selected, false if the item and all its
|
|||
/// descendents are deselected, or null if a combination of selected and deselected.
|
|||
/// </returns>
|
|||
bool? IsSelectedWithPartial(int groupIndex, int itemIndex); |
|||
|
|||
/// <summary>
|
|||
/// Checks whether an item or its descendents are selected.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item</param>
|
|||
/// <returns>
|
|||
/// True if the item and all its descendents are selected, false if the item and all its
|
|||
/// descendents are deselected, or null if a combination of selected and deselected.
|
|||
/// </returns>
|
|||
bool? IsSelectedWithPartialAt(IndexPath index); |
|||
|
|||
/// <summary>
|
|||
/// Selects an item.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item</param>
|
|||
void Select(int index); |
|||
|
|||
/// <summary>
|
|||
/// Selects an item.
|
|||
/// </summary>
|
|||
/// <param name="groupIndex">The index of the item group.</param>
|
|||
/// <param name="itemIndex">The index of the item in the group.</param>
|
|||
void Select(int groupIndex, int itemIndex); |
|||
|
|||
/// <summary>
|
|||
/// Selects an item.
|
|||
/// </summary>
|
|||
/// <param name="index">The index of the item</param>
|
|||
void SelectAt(IndexPath index); |
|||
|
|||
/// <summary>
|
|||
/// Selects all items.
|
|||
/// </summary>
|
|||
void SelectAll(); |
|||
|
|||
/// <summary>
|
|||
/// Selects a range of items.
|
|||
/// </summary>
|
|||
/// <param name="start">The start index of the range.</param>
|
|||
/// <param name="end">The end index of the range.</param>
|
|||
void SelectRange(IndexPath start, IndexPath end); |
|||
|
|||
/// <summary>
|
|||
/// Selects a range of items, starting at <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="index">The end index of the range.</param>
|
|||
void SelectRangeFromAnchor(int index); |
|||
|
|||
/// <summary>
|
|||
/// Selects a range of items, starting at <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="endGroupIndex">
|
|||
/// The index of the item group that represents the end of the selection.
|
|||
/// </param>
|
|||
/// <param name="endItemIndex">
|
|||
/// The index of the item in the group that represents the end of the selection.
|
|||
/// </param>
|
|||
void SelectRangeFromAnchor(int endGroupIndex, int endItemIndex); |
|||
|
|||
/// <summary>
|
|||
/// Selects a range of items, starting at <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="index">The end index of the range.</param>
|
|||
void SelectRangeFromAnchorTo(IndexPath index); |
|||
|
|||
/// <summary>
|
|||
/// Sets the <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="index">The anchor index.</param>
|
|||
void SetAnchorIndex(int index); |
|||
|
|||
/// <summary>
|
|||
/// Sets the <see cref="AnchorIndex"/>.
|
|||
/// </summary>
|
|||
/// <param name="groupIndex">The index of the item group.</param>
|
|||
/// <param name="index">The index of the item in the group.</param>
|
|||
void SetAnchorIndex(int groupIndex, int index); |
|||
|
|||
/// <summary>
|
|||
/// Begins a batch update of the selection.
|
|||
/// </summary>
|
|||
/// <returns>An <see cref="IDisposable"/> that finishes the batch update.</returns>
|
|||
IDisposable Update(); |
|||
} |
|||
} |
|||
@ -1,200 +0,0 @@ |
|||
// This source file is adapted from the WinUI project.
|
|||
// (https://github.com/microsoft/microsoft-ui-xaml)
|
|||
//
|
|||
// Licensed to The Avalonia Project under MIT License, courtesy of The .NET Foundation.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public readonly struct IndexPath : IComparable<IndexPath>, IEquatable<IndexPath> |
|||
{ |
|||
public static readonly IndexPath Unselected = default; |
|||
|
|||
private readonly int _index; |
|||
private readonly int[]? _path; |
|||
|
|||
public IndexPath(int index) |
|||
{ |
|||
_index = index + 1; |
|||
_path = null; |
|||
} |
|||
|
|||
public IndexPath(int groupIndex, int itemIndex) |
|||
{ |
|||
_index = 0; |
|||
_path = new[] { groupIndex, itemIndex }; |
|||
} |
|||
|
|||
public IndexPath(IEnumerable<int>? indices) |
|||
{ |
|||
if (indices != null) |
|||
{ |
|||
_index = 0; |
|||
_path = indices.ToArray(); |
|||
} |
|||
else |
|||
{ |
|||
_index = 0; |
|||
_path = null; |
|||
} |
|||
} |
|||
|
|||
private IndexPath(int[] basePath, int index) |
|||
{ |
|||
basePath = basePath ?? throw new ArgumentNullException(nameof(basePath)); |
|||
|
|||
_index = 0; |
|||
_path = new int[basePath.Length + 1]; |
|||
Array.Copy(basePath, _path, basePath.Length); |
|||
_path[basePath.Length] = index; |
|||
} |
|||
|
|||
public int GetSize() => _path?.Length ?? (_index == 0 ? 0 : 1); |
|||
|
|||
public int GetAt(int index) |
|||
{ |
|||
if (index >= GetSize()) |
|||
{ |
|||
throw new IndexOutOfRangeException(); |
|||
} |
|||
|
|||
return _path?[index] ?? (_index - 1); |
|||
} |
|||
|
|||
public int CompareTo(IndexPath other) |
|||
{ |
|||
var rhsPath = other; |
|||
int compareResult = 0; |
|||
int lhsCount = GetSize(); |
|||
int rhsCount = rhsPath.GetSize(); |
|||
|
|||
if (lhsCount == 0 || rhsCount == 0) |
|||
{ |
|||
// one of the paths are empty, compare based on size
|
|||
compareResult = (lhsCount - rhsCount); |
|||
} |
|||
else |
|||
{ |
|||
// both paths are non-empty, but can be of different size
|
|||
for (int i = 0; i < Math.Min(lhsCount, rhsCount); i++) |
|||
{ |
|||
if (GetAt(i) < rhsPath.GetAt(i)) |
|||
{ |
|||
compareResult = -1; |
|||
break; |
|||
} |
|||
else if (GetAt(i) > rhsPath.GetAt(i)) |
|||
{ |
|||
compareResult = 1; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
// if both match upto min(lhsCount, rhsCount), compare based on size
|
|||
compareResult = compareResult == 0 ? (lhsCount - rhsCount) : compareResult; |
|||
} |
|||
|
|||
if (compareResult != 0) |
|||
{ |
|||
compareResult = compareResult > 0 ? 1 : -1; |
|||
} |
|||
|
|||
return compareResult; |
|||
} |
|||
|
|||
public IndexPath CloneWithChildIndex(int childIndex) |
|||
{ |
|||
if (_path != null) |
|||
{ |
|||
return new IndexPath(_path, childIndex); |
|||
} |
|||
else if (_index != 0) |
|||
{ |
|||
return new IndexPath(_index - 1, childIndex); |
|||
} |
|||
else |
|||
{ |
|||
return new IndexPath(childIndex); |
|||
} |
|||
} |
|||
|
|||
public bool IsAncestorOf(in IndexPath other) |
|||
{ |
|||
if (other.GetSize() <= GetSize()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
var size = GetSize(); |
|||
|
|||
for (int i = 0; i < size; i++) |
|||
{ |
|||
if (GetAt(i) != other.GetAt(i)) |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
public override string ToString() |
|||
{ |
|||
if (_path != null) |
|||
{ |
|||
return "R" + string.Join(".", _path); |
|||
} |
|||
else if (_index != 0) |
|||
{ |
|||
return "R" + (_index - 1); |
|||
} |
|||
else |
|||
{ |
|||
return "R"; |
|||
} |
|||
} |
|||
|
|||
public static IndexPath CreateFrom(int index) => new IndexPath(index); |
|||
|
|||
public static IndexPath CreateFrom(int groupIndex, int itemIndex) => new IndexPath(groupIndex, itemIndex); |
|||
|
|||
public static IndexPath CreateFromIndices(IList<int> indices) => new IndexPath(indices); |
|||
|
|||
public override bool Equals(object obj) => obj is IndexPath other && Equals(other); |
|||
|
|||
public bool Equals(IndexPath other) => CompareTo(other) == 0; |
|||
|
|||
public override int GetHashCode() |
|||
{ |
|||
var hashCode = -504981047; |
|||
|
|||
if (_path != null) |
|||
{ |
|||
foreach (var i in _path) |
|||
{ |
|||
hashCode = hashCode * -1521134295 + i.GetHashCode(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
hashCode = hashCode * -1521134295 + _index.GetHashCode(); |
|||
} |
|||
|
|||
return hashCode; |
|||
} |
|||
|
|||
public static bool operator <(IndexPath x, IndexPath y) { return x.CompareTo(y) < 0; } |
|||
public static bool operator >(IndexPath x, IndexPath y) { return x.CompareTo(y) > 0; } |
|||
public static bool operator <=(IndexPath x, IndexPath y) { return x.CompareTo(y) <= 0; } |
|||
public static bool operator >=(IndexPath x, IndexPath y) { return x.CompareTo(y) >= 0; } |
|||
public static bool operator ==(IndexPath x, IndexPath y) { return x.CompareTo(y) == 0; } |
|||
public static bool operator !=(IndexPath x, IndexPath y) { return x.CompareTo(y) != 0; } |
|||
public static bool operator ==(IndexPath? x, IndexPath? y) { return (x ?? default).CompareTo(y ?? default) == 0; } |
|||
public static bool operator !=(IndexPath? x, IndexPath? y) { return (x ?? default).CompareTo(y ?? default) != 0; } |
|||
} |
|||
} |
|||
@ -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; } |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue