committed by
GitHub
707 changed files with 13459 additions and 7188 deletions
@ -0,0 +1,5 @@ |
|||||
|
<ProjectConfiguration> |
||||
|
<Settings> |
||||
|
<XUnit2Enabled>False</XUnit2Enabled> |
||||
|
</Settings> |
||||
|
</ProjectConfiguration> |
||||
@ -0,0 +1,5 @@ |
|||||
|
<ProjectConfiguration> |
||||
|
<Settings> |
||||
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
||||
|
</Settings> |
||||
|
</ProjectConfiguration> |
||||
@ -1,7 +1,7 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.1-preview.108" /> |
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.3" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.1-preview.108" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.3" /> |
||||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.1-preview.108" /> |
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.3" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" /> |
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="Moq" Version="4.14.1" /> |
<PackageReference Include="Moq" Version="4.18.4" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,7 +1,7 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="SkiaSharp" Version="2.88.1" /> |
<PackageReference Include="SkiaSharp" Version="2.88.3" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" /> |
||||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1" /> |
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.3" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,39 @@ |
|||||
|
#include "common.h" |
||||
|
|
||||
|
namespace |
||||
|
{ |
||||
|
id<NSObject> s_inhibitAppSleepHandle{}; |
||||
|
} |
||||
|
|
||||
|
class PlatformBehaviorInhibition : public ComSingleObject<IAvnPlatformBehaviorInhibition, &IID_IAvnCursorFactory> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
|
||||
|
virtual void SetInhibitAppSleep(bool inhibitAppSleep, char* reason) override |
||||
|
{ |
||||
|
START_COM_CALL; |
||||
|
|
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
if (inhibitAppSleep && s_inhibitAppSleepHandle == nullptr) |
||||
|
{ |
||||
|
NSActivityOptions options = NSActivityUserInitiatedAllowingIdleSystemSleep; |
||||
|
s_inhibitAppSleepHandle = [[NSProcessInfo processInfo] beginActivityWithOptions:options reason:[NSString stringWithUTF8String: reason]]; |
||||
|
} |
||||
|
|
||||
|
if (!inhibitAppSleep) |
||||
|
{ |
||||
|
s_inhibitAppSleepHandle = nullptr; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern IAvnPlatformBehaviorInhibition* CreatePlatformBehaviorInhibition() |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
return new PlatformBehaviorInhibition(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,79 @@ |
|||||
|
<UserControl x:Class="ControlCatalog.Pages.ThemePage" |
||||
|
xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
|
xmlns:pages="clr-namespace:ControlCatalog.Pages" |
||||
|
d:DesignWidth="300" |
||||
|
mc:Ignorable="d"> |
||||
|
|
||||
|
<UserControl.Resources> |
||||
|
<ResourceDictionary> |
||||
|
<ResourceDictionary.ThemeDictionaries> |
||||
|
<ResourceDictionary x:Key="Dark"> |
||||
|
<SolidColorBrush x:Key="DemoBackground">Black</SolidColorBrush> |
||||
|
</ResourceDictionary> |
||||
|
<ResourceDictionary x:Key="Light"> |
||||
|
<SolidColorBrush x:Key="DemoBackground">White</SolidColorBrush> |
||||
|
</ResourceDictionary> |
||||
|
<ResourceDictionary x:Key="{x:Static pages:ThemePage.Pink}"> |
||||
|
<SolidColorBrush x:Key="DemoBackground">#ffe5ea</SolidColorBrush> |
||||
|
<SolidColorBrush x:Key="NormalBackgroundBrush" Color="#ffc0cb" /> |
||||
|
<SolidColorBrush x:Key="PointerOverBackgroundBrush" Color="#ffb3c0" /> |
||||
|
<SolidColorBrush x:Key="PressedBackgroundBrush" Color="#ff4d6c" /> |
||||
|
<SolidColorBrush x:Key="NormalBorderBrush" Color="#ff8096" /> |
||||
|
<SolidColorBrush x:Key="PointerOverBorderBrush" Color="#ff8096" /> |
||||
|
<SolidColorBrush x:Key="PressedBorderBrush" Color="#ff4d6c" /> |
||||
|
|
||||
|
<!-- Override colors for fluent theme --> |
||||
|
<StaticResource x:Key="ButtonBackground" ResourceKey="NormalBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ButtonBackgroundPointerOver" ResourceKey="PointerOverBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ButtonBackgroundPressed" ResourceKey="PressedBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ButtonBorderBrush" ResourceKey="NormalBorderBrush" /> |
||||
|
<StaticResource x:Key="ButtonBorderBrushPointerOver" ResourceKey="PointerOverBorderBrush" /> |
||||
|
<StaticResource x:Key="ButtonBorderBrushPressed" ResourceKey="PressedBorderBrush" /> |
||||
|
<StaticResource x:Key="TextControlBackground" ResourceKey="NormalBackgroundBrush" /> |
||||
|
<StaticResource x:Key="TextControlBackgroundPointerOver" ResourceKey="PointerOverBackgroundBrush" /> |
||||
|
<StaticResource x:Key="TextControlBackgroundFocused" ResourceKey="PointerOverBackgroundBrush" /> |
||||
|
<StaticResource x:Key="TextControlBorderBrush" ResourceKey="NormalBorderBrush" /> |
||||
|
<StaticResource x:Key="TextControlBorderBrushPointerOver" ResourceKey="PointerOverBorderBrush" /> |
||||
|
<StaticResource x:Key="TextControlBorderBrushFocused" ResourceKey="PressedBorderBrush" /> |
||||
|
<StaticResource x:Key="ComboBoxBackground" ResourceKey="NormalBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ComboBoxBackgroundPointerOver" ResourceKey="PointerOverBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ComboBoxBackgroundPressed" ResourceKey="PressedBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ComboBoxBorderBrush" ResourceKey="NormalBorderBrush" /> |
||||
|
<StaticResource x:Key="ComboBoxBorderBrushPointerOver" ResourceKey="PointerOverBorderBrush" /> |
||||
|
<StaticResource x:Key="ComboBoxBorderBrushPressed" ResourceKey="PressedBorderBrush" /> |
||||
|
<!-- Override colors for default theme --> |
||||
|
<StaticResource x:Key="ThemeControlMidBrush" ResourceKey="NormalBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ThemeControlHighBrush" ResourceKey="PressedBackgroundBrush" /> |
||||
|
<StaticResource x:Key="ThemeBorderLowBrush" ResourceKey="NormalBorderBrush" /> |
||||
|
<StaticResource x:Key="ThemeBorderMidBrush" ResourceKey="PointerOverBorderBrush" /> |
||||
|
</ResourceDictionary> |
||||
|
</ResourceDictionary.ThemeDictionaries> |
||||
|
</ResourceDictionary> |
||||
|
</UserControl.Resources> |
||||
|
|
||||
|
<ThemeVariantScope x:Name="ThemeVariantScope"> |
||||
|
<Border Background="{DynamicResource DemoBackground}" |
||||
|
VerticalAlignment="Top" |
||||
|
HorizontalAlignment="Left" |
||||
|
Padding="4" |
||||
|
CornerRadius="4"> |
||||
|
<Grid RowDefinitions="Auto, 4, Auto, 4, Auto, 4, Auto" ColumnDefinitions="150, 150"> |
||||
|
<ComboBox Grid.Column="0" Grid.Row="0" x:Name="Selector" HorizontalAlignment="Stretch"> |
||||
|
<ComboBox.ItemTemplate> |
||||
|
<DataTemplate x:DataType="x:String"> |
||||
|
<TextBlock Text="{Binding TargetNullValue=Unset}" /> |
||||
|
</DataTemplate> |
||||
|
</ComboBox.ItemTemplate> |
||||
|
</ComboBox> |
||||
|
<TextBlock Grid.Column="0" Grid.Row="2" Text="Username:" VerticalAlignment="Center" /> |
||||
|
<TextBlock Grid.Column="0" Grid.Row="4" Text="Password:" VerticalAlignment="Center" /> |
||||
|
<TextBox Grid.Column="1" Grid.Row="2" Watermark="Input here" HorizontalAlignment="Stretch" /> |
||||
|
<TextBox Grid.Column="1" Grid.Row="4" Watermark="Input here" HorizontalAlignment="Stretch" /> |
||||
|
<Button Grid.Column="1" Grid.Row="6" Content="Login" HorizontalAlignment="Stretch" /> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</ThemeVariantScope> |
||||
|
</UserControl> |
||||
@ -0,0 +1,37 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
using Avalonia.Styling; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class ThemePage : UserControl |
||||
|
{ |
||||
|
public static ThemeVariant Pink { get; } = new("Pink", ThemeVariant.Light); |
||||
|
|
||||
|
public ThemePage() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
|
||||
|
var selector = this.FindControl<ComboBox>("Selector")!; |
||||
|
var themeVariantScope = this.FindControl<ThemeVariantScope>("ThemeVariantScope")!; |
||||
|
|
||||
|
selector.Items = new[] |
||||
|
{ |
||||
|
ThemeVariant.Default, |
||||
|
ThemeVariant.Dark, |
||||
|
ThemeVariant.Light, |
||||
|
Pink |
||||
|
}; |
||||
|
selector.SelectedIndex = 0; |
||||
|
|
||||
|
selector.SelectionChanged += (_, _) => |
||||
|
{ |
||||
|
if (selector.SelectedItem is ThemeVariant theme) |
||||
|
{ |
||||
|
themeVariantScope.RequestedThemeVariant = theme; |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,8 +1,9 @@ |
|||||
<Application xmlns="https://github.com/avaloniaui" |
<Application xmlns="https://github.com/avaloniaui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
Name="Mobile Sandbox" |
Name="Mobile Sandbox" |
||||
x:Class="MobileSandbox.App"> |
x:Class="MobileSandbox.App" |
||||
|
RequestedThemeVariant="Dark"> |
||||
<Application.Styles> |
<Application.Styles> |
||||
<FluentTheme Mode="Dark" /> |
<FluentTheme /> |
||||
</Application.Styles> |
</Application.Styles> |
||||
</Application> |
</Application> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Application xmlns="https://github.com/avaloniaui"> |
<Application xmlns="https://github.com/avaloniaui"> |
||||
<Application.Styles> |
<Application.Styles> |
||||
<SimpleTheme Mode="Light" /> |
<SimpleTheme /> |
||||
</Application.Styles> |
</Application.Styles> |
||||
</Application> |
</Application> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Application xmlns="https://github.com/avaloniaui"> |
<Application xmlns="https://github.com/avaloniaui"> |
||||
<Application.Styles> |
<Application.Styles> |
||||
<SimpleTheme Mode="Light" /> |
<SimpleTheme /> |
||||
</Application.Styles> |
</Application.Styles> |
||||
</Application> |
</Application> |
||||
|
|||||
@ -0,0 +1,127 @@ |
|||||
|
using System; |
||||
|
using Android.Runtime; |
||||
|
using Android.Text; |
||||
|
using Android.Views; |
||||
|
using Android.Views.InputMethods; |
||||
|
using Avalonia.Android.Platform.SkiaPlatform; |
||||
|
using Avalonia.Controls.Presenters; |
||||
|
using Avalonia.Input; |
||||
|
using Avalonia.Input.Raw; |
||||
|
using Avalonia.Input.TextInput; |
||||
|
using Java.Lang; |
||||
|
using static System.Net.Mime.MediaTypeNames; |
||||
|
|
||||
|
namespace Avalonia.Android |
||||
|
{ |
||||
|
internal class InputEditable : SpannableStringBuilder, ITextEditable |
||||
|
{ |
||||
|
private readonly TopLevelImpl _topLevel; |
||||
|
private readonly IAndroidInputMethod _inputMethod; |
||||
|
private readonly AvaloniaInputConnection _avaloniaInputConnection; |
||||
|
private int _currentBatchLevel; |
||||
|
private string _previousText; |
||||
|
private int _previousSelectionStart; |
||||
|
private int _previousSelectionEnd; |
||||
|
|
||||
|
public event EventHandler TextChanged; |
||||
|
public event EventHandler SelectionChanged; |
||||
|
public event EventHandler CompositionChanged; |
||||
|
|
||||
|
public InputEditable(TopLevelImpl topLevel, IAndroidInputMethod inputMethod, AvaloniaInputConnection avaloniaInputConnection) |
||||
|
{ |
||||
|
_topLevel = topLevel; |
||||
|
_inputMethod = inputMethod; |
||||
|
_avaloniaInputConnection = avaloniaInputConnection; |
||||
|
} |
||||
|
|
||||
|
public InputEditable(ICharSequence text) : base(text) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public InputEditable(string text) : base(text) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public InputEditable(ICharSequence text, int start, int end) : base(text, start, end) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public InputEditable(string text, int start, int end) : base(text, start, end) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
protected InputEditable(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public int SelectionStart |
||||
|
{ |
||||
|
get => Selection.GetSelectionStart(this); set |
||||
|
{ |
||||
|
var end = SelectionEnd < 0 ? 0 : SelectionEnd; |
||||
|
_avaloniaInputConnection.SetSelection(value, end); |
||||
|
_inputMethod.IMM.UpdateSelection(_topLevel.View, value, end, value, end); |
||||
|
} |
||||
|
} |
||||
|
public int SelectionEnd |
||||
|
{ |
||||
|
get => Selection.GetSelectionEnd(this); set |
||||
|
{ |
||||
|
var start = SelectionStart < 0 ? 0 : SelectionStart; |
||||
|
_avaloniaInputConnection.SetSelection(start, value); |
||||
|
_inputMethod.IMM.UpdateSelection(_topLevel.View, start, value, start, value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public string? Text |
||||
|
{ |
||||
|
get => ToString(); set |
||||
|
{ |
||||
|
if (Text != value) |
||||
|
{ |
||||
|
Clear(); |
||||
|
Insert(0, value ?? ""); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public int CompositionStart => BaseInputConnection.GetComposingSpanStart(this); |
||||
|
|
||||
|
public int CompositionEnd => BaseInputConnection.GetComposingSpanEnd(this); |
||||
|
|
||||
|
public void BeginBatchEdit() |
||||
|
{ |
||||
|
_currentBatchLevel++; |
||||
|
|
||||
|
if (_currentBatchLevel == 1) |
||||
|
{ |
||||
|
_previousText = ToString(); |
||||
|
_previousSelectionStart = SelectionStart; |
||||
|
_previousSelectionEnd = SelectionEnd; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void EndBatchEdit() |
||||
|
{ |
||||
|
if (_currentBatchLevel == 1) |
||||
|
{ |
||||
|
if(_previousText != Text) |
||||
|
{ |
||||
|
TextChanged?.Invoke(this, EventArgs.Empty); |
||||
|
} |
||||
|
|
||||
|
if (_previousSelectionStart != SelectionStart || _previousSelectionEnd != SelectionEnd) |
||||
|
{ |
||||
|
SelectionChanged?.Invoke(this, EventArgs.Empty); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
_currentBatchLevel--; |
||||
|
} |
||||
|
|
||||
|
public void RaiseCompositionChanged() |
||||
|
{ |
||||
|
CompositionChanged?.Invoke(this, EventArgs.Empty); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,112 @@ |
|||||
|
using System; |
||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.Specialized; |
||||
|
using Avalonia.Reactive; |
||||
|
|
||||
|
namespace Avalonia.Collections |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines extension methods for working with <see cref="AvaloniaList{T}"/>s.
|
||||
|
/// </summary>
|
||||
|
public static class AvaloniaDictionaryExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Invokes an action for each item in a collection and subsequently each item added or
|
||||
|
/// removed from the collection.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TKey">The key type of the collection items.</typeparam>
|
||||
|
/// <typeparam name="TValue">The value type of the collection items.</typeparam>
|
||||
|
/// <param name="collection">The collection.</param>
|
||||
|
/// <param name="added">
|
||||
|
/// An action called initially for each item in the collection and subsequently for each
|
||||
|
/// item added to the collection. The parameters passed are the index in the collection and
|
||||
|
/// the item.
|
||||
|
/// </param>
|
||||
|
/// <param name="removed">
|
||||
|
/// An action called for each item removed from the collection. The parameters passed are
|
||||
|
/// the index in the collection and the item.
|
||||
|
/// </param>
|
||||
|
/// <param name="reset">
|
||||
|
/// An action called when the collection is reset. This will be followed by calls to
|
||||
|
/// <paramref name="added"/> for each item present in the collection after the reset.
|
||||
|
/// </param>
|
||||
|
/// <param name="weakSubscription">
|
||||
|
/// Indicates if a weak subscription should be used to track changes to the collection.
|
||||
|
/// </param>
|
||||
|
/// <returns>A disposable used to terminate the subscription.</returns>
|
||||
|
internal static IDisposable ForEachItem<TKey, TValue>( |
||||
|
this IAvaloniaReadOnlyDictionary<TKey, TValue> collection, |
||||
|
Action<TKey, TValue> added, |
||||
|
Action<TKey, TValue> removed, |
||||
|
Action reset, |
||||
|
bool weakSubscription = false) |
||||
|
where TKey : notnull |
||||
|
{ |
||||
|
void Add(IEnumerable items) |
||||
|
{ |
||||
|
foreach (KeyValuePair<TKey, TValue> pair in items) |
||||
|
{ |
||||
|
added(pair.Key, pair.Value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
void Remove(IEnumerable items) |
||||
|
{ |
||||
|
foreach (KeyValuePair<TKey, TValue> pair in items) |
||||
|
{ |
||||
|
removed(pair.Key, pair.Value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
NotifyCollectionChangedEventHandler handler = (_, e) => |
||||
|
{ |
||||
|
switch (e.Action) |
||||
|
{ |
||||
|
case NotifyCollectionChangedAction.Add: |
||||
|
Add(e.NewItems!); |
||||
|
break; |
||||
|
|
||||
|
case NotifyCollectionChangedAction.Move: |
||||
|
case NotifyCollectionChangedAction.Replace: |
||||
|
Remove(e.OldItems!); |
||||
|
int newIndex = e.NewStartingIndex; |
||||
|
if(newIndex > e.OldStartingIndex) |
||||
|
{ |
||||
|
newIndex -= e.OldItems!.Count; |
||||
|
} |
||||
|
Add(e.NewItems!); |
||||
|
break; |
||||
|
|
||||
|
case NotifyCollectionChangedAction.Remove: |
||||
|
Remove(e.OldItems!); |
||||
|
break; |
||||
|
|
||||
|
case NotifyCollectionChangedAction.Reset: |
||||
|
if (reset == null) |
||||
|
{ |
||||
|
throw new InvalidOperationException( |
||||
|
"Reset called on collection without reset handler."); |
||||
|
} |
||||
|
|
||||
|
reset(); |
||||
|
Add(collection); |
||||
|
break; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
Add(collection); |
||||
|
|
||||
|
if (weakSubscription) |
||||
|
{ |
||||
|
return collection.WeakSubscribe(handler); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
collection.CollectionChanged += handler; |
||||
|
|
||||
|
return Disposable.Create(() => collection.CollectionChanged -= handler); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Avalonia.Collections |
||||
|
{ |
||||
|
public interface IAvaloniaDictionary<TKey, TValue> |
||||
|
: IDictionary<TKey, TValue>, |
||||
|
IAvaloniaReadOnlyDictionary<TKey, TValue>, |
||||
|
IDictionary |
||||
|
where TKey : notnull |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.Specialized; |
||||
|
using System.ComponentModel; |
||||
|
|
||||
|
namespace Avalonia.Collections |
||||
|
{ |
||||
|
public interface IAvaloniaReadOnlyDictionary<TKey, TValue> |
||||
|
: IReadOnlyDictionary<TKey, TValue>, |
||||
|
INotifyCollectionChanged, |
||||
|
INotifyPropertyChanged |
||||
|
where TKey : notnull |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue