From b6ee0d025bc32469c17e56934e4981e164a424e1 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 3 Apr 2019 17:48:34 +0200 Subject: [PATCH 1/8] Update version to 0.8.0. --- build/SharedVersion.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/SharedVersion.props b/build/SharedVersion.props index b46ac16a79..7ea1dd0c65 100644 --- a/build/SharedVersion.props +++ b/build/SharedVersion.props @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Avalonia - 0.7.1 + 0.8.0 Copyright 2018 © The AvaloniaUI Project https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md https://github.com/AvaloniaUI/Avalonia/ @@ -11,4 +11,4 @@ CS1591 latest - \ No newline at end of file + From fe5d5bca1bfb616c9816891f051e80c4568894a3 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 13:43:49 +0200 Subject: [PATCH 2/8] Make TreeView.SelectionModeProperty public so it can be set from styles. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 94989254dc..0c9bedfa93 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -48,7 +48,7 @@ namespace Avalonia.Controls /// /// Defines the property. /// - protected static readonly StyledProperty SelectionModeProperty = + public static readonly StyledProperty SelectionModeProperty = AvaloniaProperty.Register( nameof(SelectionMode)); From ebe92b661975e185c739aaed1481f30520691766 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 13:56:31 +0200 Subject: [PATCH 3/8] Make sure that property is registered on a correct type. --- src/Avalonia.Controls/TreeView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 0c9bedfa93..2b1aa45dd4 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -49,7 +49,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly StyledProperty SelectionModeProperty = - AvaloniaProperty.Register( + AvaloniaProperty.Register( nameof(SelectionMode)); private static readonly IList Empty = new object[0]; From 0961cc122ae9b3c0b75f1fc2bb955f6baa9acd4b Mon Sep 17 00:00:00 2001 From: artyom Date: Mon, 8 Apr 2019 17:07:01 +0300 Subject: [PATCH 4/8] Add xmlns, move files to Avalonia.ReactiveUI namespace --- .../AppBuilderExtensions.cs | 7 ++++++- src/Avalonia.ReactiveUI/Attributes.cs | 8 ++++++++ .../AvaloniaActivationForViewFetcher.cs | 18 +++++++++++++++++- src/Avalonia.ReactiveUI/ReactiveUserControl.cs | 2 +- src/Avalonia.ReactiveUI/ReactiveWindow.cs | 2 +- src/Avalonia.ReactiveUI/RoutedViewHost.cs | 8 ++++++-- .../AvaloniaActivationForViewFetcherTest.cs | 1 + .../RoutedViewHostTest.cs | 1 + 8 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 src/Avalonia.ReactiveUI/Attributes.cs diff --git a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs index d763febdf3..f67cb7f40a 100644 --- a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs +++ b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs @@ -6,10 +6,15 @@ using Avalonia.Threading; using ReactiveUI; using Splat; -namespace Avalonia +namespace Avalonia.ReactiveUI { public static class AppBuilderExtensions { + /// + /// 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. + /// public static TAppBuilder UseReactiveUI(this TAppBuilder builder) where TAppBuilder : AppBuilderBase, new() { diff --git a/src/Avalonia.ReactiveUI/Attributes.cs b/src/Avalonia.ReactiveUI/Attributes.cs new file mode 100644 index 0000000000..e908d1de80 --- /dev/null +++ b/src/Avalonia.ReactiveUI/Attributes.cs @@ -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")] \ No newline at end of file diff --git a/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs b/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs index e1db604e95..cfa7a270be 100644 --- a/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs +++ b/src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs @@ -9,15 +9,24 @@ using Avalonia.VisualTree; using Avalonia.Controls; using ReactiveUI; -namespace Avalonia +namespace Avalonia.ReactiveUI { + /// + /// Determines when Avalonia IVisuals get activated. + /// public class AvaloniaActivationForViewFetcher : IActivationForViewFetcher { + /// + /// Returns affinity for view. + /// public int GetAffinityForView(Type view) { return typeof(IVisual).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ? 10 : 0; } + /// + /// Returns activation observable for activatable Avalonia view. + /// public IObservable GetActivationForView(IActivatable view) { if (!(view is IVisual visual)) return Observable.Return(false); @@ -25,6 +34,9 @@ namespace Avalonia return GetActivationForVisual(visual); } + /// + /// Listens to Opened and Closed events for Avalonia windows. + /// private IObservable GetActivationForWindowBase(WindowBase window) { var windowLoaded = Observable @@ -42,6 +54,10 @@ namespace Avalonia .DistinctUntilChanged(); } + /// + /// Listens to AttachedToVisualTree and DetachedFromVisualTree + /// events for Avalonia IVisuals. + /// private IObservable GetActivationForVisual(IVisual visual) { var visualLoaded = Observable diff --git a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs index 43e2ef93b6..010acc3ae0 100644 --- a/src/Avalonia.ReactiveUI/ReactiveUserControl.cs +++ b/src/Avalonia.ReactiveUI/ReactiveUserControl.cs @@ -6,7 +6,7 @@ using Avalonia.VisualTree; using Avalonia.Controls; using ReactiveUI; -namespace Avalonia +namespace Avalonia.ReactiveUI { /// /// A ReactiveUI UserControl that implements diff --git a/src/Avalonia.ReactiveUI/ReactiveWindow.cs b/src/Avalonia.ReactiveUI/ReactiveWindow.cs index bb50a37764..f0f115afbc 100644 --- a/src/Avalonia.ReactiveUI/ReactiveWindow.cs +++ b/src/Avalonia.ReactiveUI/ReactiveWindow.cs @@ -6,7 +6,7 @@ using Avalonia.VisualTree; using Avalonia.Controls; using ReactiveUI; -namespace Avalonia +namespace Avalonia.ReactiveUI { /// /// A ReactiveUI Window that implements diff --git a/src/Avalonia.ReactiveUI/RoutedViewHost.cs b/src/Avalonia.ReactiveUI/RoutedViewHost.cs index e364d5de0b..4bd86a67c0 100644 --- a/src/Avalonia.ReactiveUI/RoutedViewHost.cs +++ b/src/Avalonia.ReactiveUI/RoutedViewHost.cs @@ -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 { /// /// 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?"); diff --git a/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs index 70a5504a7d..d9f1ce47dd 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/AvaloniaActivationForViewFetcherTest.cs @@ -11,6 +11,7 @@ using DynamicData; using Xunit; using Splat; using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; namespace Avalonia { diff --git a/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs b/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs index de09a1ea89..401d169896 100644 --- a/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs +++ b/tests/Avalonia.ReactiveUI.UnitTests/RoutedViewHostTest.cs @@ -14,6 +14,7 @@ using Avalonia.Markup.Xaml; using System.ComponentModel; using System.Threading.Tasks; using System.Reactive; +using Avalonia.ReactiveUI; namespace Avalonia { From a66a2d33aa5abe93160c2286d327820b6b4e4e39 Mon Sep 17 00:00:00 2001 From: artyom Date: Mon, 8 Apr 2019 17:55:55 +0300 Subject: [PATCH 5/8] Add missing usings --- samples/BindingDemo/App.xaml.cs | 1 + samples/ControlCatalog.Desktop/Program.cs | 1 + samples/ControlCatalog.NetCore/Program.cs | 1 + samples/RenderDemo/App.xaml.cs | 1 + samples/VirtualizationDemo/Program.cs | 1 + 5 files changed, 5 insertions(+) diff --git a/samples/BindingDemo/App.xaml.cs b/samples/BindingDemo/App.xaml.cs index 01c52a2a49..f2f44cd502 100644 --- a/samples/BindingDemo/App.xaml.cs +++ b/samples/BindingDemo/App.xaml.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 diff --git a/samples/ControlCatalog.Desktop/Program.cs b/samples/ControlCatalog.Desktop/Program.cs index dd5644dd6b..b7aa34f5ba 100644 --- a/samples/ControlCatalog.Desktop/Program.cs +++ b/samples/ControlCatalog.Desktop/Program.cs @@ -4,6 +4,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Logging.Serilog; using Avalonia.Platform; +using Avalonia.ReactiveUI; using Serilog; namespace ControlCatalog diff --git a/samples/ControlCatalog.NetCore/Program.cs b/samples/ControlCatalog.NetCore/Program.cs index d13a5b5ef3..c8f3fb9921 100644 --- a/samples/ControlCatalog.NetCore/Program.cs +++ b/samples/ControlCatalog.NetCore/Program.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using Avalonia; using Avalonia.Skia; +using Avalonia.ReactiveUI; namespace ControlCatalog.NetCore { diff --git a/samples/RenderDemo/App.xaml.cs b/samples/RenderDemo/App.xaml.cs index 0f627961e6..d95018520a 100644 --- a/samples/RenderDemo/App.xaml.cs +++ b/samples/RenderDemo/App.xaml.cs @@ -4,6 +4,7 @@ using Avalonia; using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; namespace RenderDemo { diff --git a/samples/VirtualizationDemo/Program.cs b/samples/VirtualizationDemo/Program.cs index 98f1f08d6c..9d8f7c1a3d 100644 --- a/samples/VirtualizationDemo/Program.cs +++ b/samples/VirtualizationDemo/Program.cs @@ -5,6 +5,7 @@ using System; using Avalonia; using Avalonia.Controls; using Avalonia.Logging.Serilog; +using Avalonia.ReactiveUI; using Serilog; namespace VirtualizationDemo From cf1401e5f20e2a08ec6b458729822f180d4bbdac Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 8 Apr 2019 17:04:26 +0200 Subject: [PATCH 6/8] Use ListBox properties for TreeView implementation. --- src/Avalonia.Controls/ListBox.cs | 4 ++-- src/Avalonia.Controls/TreeView.cs | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/ListBox.cs b/src/Avalonia.Controls/ListBox.cs index fce568e56d..041b81155a 100644 --- a/src/Avalonia.Controls/ListBox.cs +++ b/src/Avalonia.Controls/ListBox.cs @@ -30,13 +30,13 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly new AvaloniaProperty SelectedItemsProperty = + public static readonly new DirectProperty SelectedItemsProperty = SelectingItemsControl.SelectedItemsProperty; /// /// Defines the property. /// - public static readonly new AvaloniaProperty SelectionModeProperty = + public static readonly new StyledProperty SelectionModeProperty = SelectingItemsControl.SelectionModeProperty; /// diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 2b1aa45dd4..c3fbce1d83 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -40,8 +40,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly DirectProperty SelectedItemsProperty = - AvaloniaProperty.RegisterDirect( - nameof(SelectedItems), + ListBox.SelectedItemsProperty.AddOwner( o => o.SelectedItems, (o, v) => o.SelectedItems = v); @@ -49,8 +48,7 @@ namespace Avalonia.Controls /// Defines the property. /// public static readonly StyledProperty SelectionModeProperty = - AvaloniaProperty.Register( - nameof(SelectionMode)); + ListBox.SelectionModeProperty.AddOwner(); private static readonly IList Empty = new object[0]; private object _selectedItem; From aad6bf703e19095b376d07f2e2e6b4194f11daf8 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 8 Apr 2019 20:03:33 +0100 Subject: [PATCH 7/8] bump version number and copyright year. --- build/SharedVersion.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/SharedVersion.props b/build/SharedVersion.props index 7ea1dd0c65..4f0b1f0a5b 100644 --- a/build/SharedVersion.props +++ b/build/SharedVersion.props @@ -2,8 +2,8 @@ xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> Avalonia - 0.8.0 - Copyright 2018 © The AvaloniaUI Project + 0.8.1 + Copyright 2019 © The AvaloniaUI Project https://github.com/AvaloniaUI/Avalonia/blob/master/licence.md https://github.com/AvaloniaUI/Avalonia/ https://github.com/AvaloniaUI/Avalonia/ From 129f8ca535490a6fe22f4ec5a306329b0b45309d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Tue, 9 Apr 2019 23:52:28 +0100 Subject: [PATCH 8/8] XML comment fixes. --- src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs | 2 ++ src/Avalonia.Controls/Window.cs | 3 ++- src/Avalonia.Styling/StyledElement.cs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs b/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs index 0ade1af249..b59ed166bc 100644 --- a/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs +++ b/src/Avalonia.Base/Utilities/WeakEventHandlerManager.cs @@ -19,6 +19,7 @@ namespace Avalonia.Utilities /// /// The type of the target. /// The type of the event arguments. + /// The type of the subscriber. /// The event source. /// The name of the event. /// The subscriber. @@ -40,6 +41,7 @@ namespace Avalonia.Utilities /// Unsubscribes from an event. /// /// The type of the event arguments. + /// The type of the subscriber. /// The event source. /// The name of the event. /// The subscriber. diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index f5af6774b5..c8e09b8f9c 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -291,7 +291,8 @@ namespace Avalonia.Controls /// /// The dialog result. /// - /// When the window is shown with the method, the + /// When the window is shown with the + /// or method, the /// resulting task will produce the value when the window /// is closed. /// diff --git a/src/Avalonia.Styling/StyledElement.cs b/src/Avalonia.Styling/StyledElement.cs index e52a1961ba..d314a8d44e 100644 --- a/src/Avalonia.Styling/StyledElement.cs +++ b/src/Avalonia.Styling/StyledElement.cs @@ -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;