Browse Source
Merge branch 'master' into fix-treeview-selectionmode
pull/2436/head
Dariusz Komosiński
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with
51 additions and
7 deletions
-
samples/BindingDemo/App.xaml.cs
-
samples/ControlCatalog.Desktop/Program.cs
-
samples/ControlCatalog.NetCore/Program.cs
-
samples/RenderDemo/App.xaml.cs
-
samples/VirtualizationDemo/Program.cs
-
src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs
-
src/Avalonia.Controls/Window.cs
-
src/Avalonia.ReactiveUI/AppBuilderExtensions.cs
-
src/Avalonia.ReactiveUI/Attributes.cs
-
src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs
-
src/Avalonia.ReactiveUI/ReactiveUserControl.cs
-
src/Avalonia.ReactiveUI/ReactiveWindow.cs
-
src/Avalonia.ReactiveUI/RoutedViewHost.cs
-
src/Avalonia.Styling/StyledElement.cs
-
tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs
-
tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs
|
|
|
@ -3,6 +3,7 @@ using Avalonia; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Logging.Serilog; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
using Serilog; |
|
|
|
|
|
|
|
namespace BindingDemo |
|
|
|
|
|
|
|
@ -4,6 +4,7 @@ using Avalonia; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Logging.Serilog; |
|
|
|
using Avalonia.Platform; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
using Serilog; |
|
|
|
|
|
|
|
namespace ControlCatalog |
|
|
|
|
|
|
|
@ -4,6 +4,7 @@ using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using Avalonia; |
|
|
|
using Avalonia.Skia; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
|
|
|
|
namespace ControlCatalog.NetCore |
|
|
|
{ |
|
|
|
|
|
|
|
@ -4,6 +4,7 @@ |
|
|
|
using Avalonia; |
|
|
|
using Avalonia.Logging.Serilog; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
|
|
|
|
namespace RenderDemo |
|
|
|
{ |
|
|
|
|
|
|
|
@ -5,6 +5,7 @@ using System; |
|
|
|
using Avalonia; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Logging.Serilog; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
using Serilog; |
|
|
|
|
|
|
|
namespace VirtualizationDemo |
|
|
|
|
|
|
|
@ -19,6 +19,7 @@ namespace Avalonia.Utilities |
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TTarget">The type of the target.</typeparam>
|
|
|
|
/// <typeparam name="TEventArgs">The type of the event arguments.</typeparam>
|
|
|
|
/// <typeparam name="TSubscriber">The type of the subscriber.</typeparam>
|
|
|
|
/// <param name="target">The event source.</param>
|
|
|
|
/// <param name="eventName">The name of the event.</param>
|
|
|
|
/// <param name="subscriber">The subscriber.</param>
|
|
|
|
@ -40,6 +41,7 @@ namespace Avalonia.Utilities |
|
|
|
/// Unsubscribes from an event.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TEventArgs">The type of the event arguments.</typeparam>
|
|
|
|
/// <typeparam name="TSubscriber">The type of the subscriber.</typeparam>
|
|
|
|
/// <param name="target">The event source.</param>
|
|
|
|
/// <param name="eventName">The name of the event.</param>
|
|
|
|
/// <param name="subscriber">The subscriber.</param>
|
|
|
|
|
|
|
|
@ -291,7 +291,8 @@ namespace Avalonia.Controls |
|
|
|
/// </summary>
|
|
|
|
/// <param name="dialogResult">The dialog result.</param>
|
|
|
|
/// <remarks>
|
|
|
|
/// When the window is shown with the <see cref="ShowDialog{TResult}"/> method, the
|
|
|
|
/// When the window is shown with the <see cref="ShowDialog{TResult}(IWindowImpl)"/>
|
|
|
|
/// or <see cref="ShowDialog{TResult}(Window)"/> method, the
|
|
|
|
/// resulting task will produce the <see cref="_dialogResult"/> value when the window
|
|
|
|
/// is closed.
|
|
|
|
/// </remarks>
|
|
|
|
|
|
|
|
@ -6,10 +6,15 @@ using Avalonia.Threading; |
|
|
|
using ReactiveUI; |
|
|
|
using Splat; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
namespace Avalonia.ReactiveUI |
|
|
|
{ |
|
|
|
public static class AppBuilderExtensions |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Initializes ReactiveUI framework to use with Avalonia. Registers Avalonia
|
|
|
|
/// scheduler and Avalonia activation for view fetcher. Always remember to
|
|
|
|
/// call this method if you are using ReactiveUI in your application.
|
|
|
|
/// </summary>
|
|
|
|
public static TAppBuilder UseReactiveUI<TAppBuilder>(this TAppBuilder builder) |
|
|
|
where TAppBuilder : AppBuilderBase<TAppBuilder>, new() |
|
|
|
{ |
|
|
|
|
|
|
|
@ -0,0 +1,8 @@ |
|
|
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
using System.Reflection; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using Avalonia.Metadata; |
|
|
|
|
|
|
|
[assembly: XmlnsDefinition("http://reactiveui.net", "Avalonia.ReactiveUI")] |
|
|
|
@ -9,15 +9,24 @@ using Avalonia.VisualTree; |
|
|
|
using Avalonia.Controls; |
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
namespace Avalonia.ReactiveUI |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Determines when Avalonia IVisuals get activated.
|
|
|
|
/// </summary>
|
|
|
|
public class AvaloniaActivationForViewFetcher : IActivationForViewFetcher |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// Returns affinity for view.
|
|
|
|
/// </summary>
|
|
|
|
public int GetAffinityForView(Type view) |
|
|
|
{ |
|
|
|
return typeof(IVisual).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ? 10 : 0; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns activation observable for activatable Avalonia view.
|
|
|
|
/// </summary>
|
|
|
|
public IObservable<bool> GetActivationForView(IActivatable view) |
|
|
|
{ |
|
|
|
if (!(view is IVisual visual)) return Observable.Return(false); |
|
|
|
@ -25,6 +34,9 @@ namespace Avalonia |
|
|
|
return GetActivationForVisual(visual); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Listens to Opened and Closed events for Avalonia windows.
|
|
|
|
/// </summary>
|
|
|
|
private IObservable<bool> GetActivationForWindowBase(WindowBase window) |
|
|
|
{ |
|
|
|
var windowLoaded = Observable |
|
|
|
@ -42,6 +54,10 @@ namespace Avalonia |
|
|
|
.DistinctUntilChanged(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Listens to AttachedToVisualTree and DetachedFromVisualTree
|
|
|
|
/// events for Avalonia IVisuals.
|
|
|
|
/// </summary>
|
|
|
|
private IObservable<bool> GetActivationForVisual(IVisual visual) |
|
|
|
{ |
|
|
|
var visualLoaded = Observable |
|
|
|
|
|
|
|
@ -6,7 +6,7 @@ using Avalonia.VisualTree; |
|
|
|
using Avalonia.Controls; |
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
namespace Avalonia.ReactiveUI |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// A ReactiveUI UserControl that implements <see cref="IViewFor{TViewModel}"/>
|
|
|
|
|
|
|
|
@ -6,7 +6,7 @@ using Avalonia.VisualTree; |
|
|
|
using Avalonia.Controls; |
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
namespace Avalonia.ReactiveUI |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// A ReactiveUI Window that implements <see cref="IViewFor{TViewModel}"/>
|
|
|
|
|
|
|
|
@ -1,13 +1,17 @@ |
|
|
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Reactive.Disposables; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using Avalonia.Animation; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Styling; |
|
|
|
using Avalonia; |
|
|
|
using ReactiveUI; |
|
|
|
using Splat; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
namespace Avalonia.ReactiveUI |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// This control hosts the View associated with ReactiveUI RoutingState,
|
|
|
|
@ -157,7 +161,7 @@ namespace Avalonia |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var viewLocator = ViewLocator ?? ReactiveUI.ViewLocator.Current; |
|
|
|
var viewLocator = ViewLocator ?? global::ReactiveUI.ViewLocator.Current; |
|
|
|
var view = viewLocator.ResolveView(viewModel); |
|
|
|
if (view == null) throw new Exception($"Couldn't find view for '{viewModel}'. Is it registered?"); |
|
|
|
|
|
|
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Specialized; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Linq; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using System.Reactive.Subjects; |
|
|
|
|
|
|
|
@ -11,6 +11,7 @@ using DynamicData; |
|
|
|
using Xunit; |
|
|
|
using Splat; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
{ |
|
|
|
|
|
|
|
@ -14,6 +14,7 @@ using Avalonia.Markup.Xaml; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Reactive; |
|
|
|
using Avalonia.ReactiveUI; |
|
|
|
|
|
|
|
namespace Avalonia |
|
|
|
{ |
|
|
|
|