diff --git a/.gitmodules b/.gitmodules index 6e9b10efa4..98b6d076c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "src/Avalonia.ReactiveUI/src"] - path = src/Avalonia.ReactiveUI/src - url = https://github.com/reactiveui/ReactiveUI.git [submodule "src/Avalonia.HtmlRenderer/external"] path = src/Avalonia.HtmlRenderer/external url = https://github.com/AvaloniaUI/HTML-Renderer.git diff --git a/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject b/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject new file mode 100644 index 0000000000..6800b4a3fe --- /dev/null +++ b/.ncrunch/Avalonia.LinuxFramebuffer.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject b/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject new file mode 100644 index 0000000000..6800b4a3fe --- /dev/null +++ b/.ncrunch/Avalonia.Visuals.UnitTests.net461.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject b/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject new file mode 100644 index 0000000000..6800b4a3fe --- /dev/null +++ b/.ncrunch/Avalonia.Win32.Interop.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/Avalonia.sln b/Avalonia.sln index afaee6a907..7fdc0bc932 100644 --- a/Avalonia.sln +++ b/Avalonia.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26228.4 +VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Base", "src\Avalonia.Base\Avalonia.Base.csproj", "{B09B78D8-9B26-48B0-9149-D64A2F120F3F}" EndProject @@ -169,6 +169,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Props", "Props", "{F3AC8BC1 build\Microsoft.Reactive.Testing.props = build\Microsoft.Reactive.Testing.props build\Moq.props = build\Moq.props build\NetCore.props = build\NetCore.props + build\ReactiveUI.props = build\ReactiveUI.props build\Rx.props = build\Rx.props build\Serilog.props = build\Serilog.props build\Serilog.Sinks.Trace.props = build\Serilog.Sinks.Trace.props diff --git a/build.cake b/build.cake index c56089ab55..6c2e554df4 100644 --- a/build.cake +++ b/build.cake @@ -193,7 +193,7 @@ Task("Run-Net-Core-Unit-Tests") Task("Run-Unit-Tests") .IsDependentOn("Run-Net-Core-Unit-Tests") .IsDependentOn("Build") - .IsDependentOn("Run-Leak-Tests") + //.IsDependentOn("Run-Leak-Tests") .WithCriteria(() => !parameters.SkipTests) .Does(() => { diff --git a/build/ReactiveUI.props b/build/ReactiveUI.props new file mode 100644 index 0000000000..4473447647 --- /dev/null +++ b/build/ReactiveUI.props @@ -0,0 +1,5 @@ + + + + + diff --git a/build/Rx.props b/build/Rx.props index 5d74a6b214..e88ab1ec37 100644 --- a/build/Rx.props +++ b/build/Rx.props @@ -1,11 +1,10 @@  - - - - - - - + + + + + + diff --git a/build/SharpDX.props b/build/SharpDX.props index 0eb910e71e..69aa817a01 100644 --- a/build/SharpDX.props +++ b/build/SharpDX.props @@ -1,9 +1,9 @@  - - - - - + + + + + diff --git a/docs/tutorial/from-wpf.md b/docs/tutorial/from-wpf.md index 2db40cfd86..0eb6e80327 100644 --- a/docs/tutorial/from-wpf.md +++ b/docs/tutorial/from-wpf.md @@ -161,7 +161,7 @@ the same way that event class listeners are added](../spec/working-with-properti ## RenderTransforms and RenderTransformOrigin -RenderTransformOrigins are different in WPF and Avalonia: If you apply a `RenderTransform`, keep in mind that our default value for the RenderTransformOrigin is `RelativePoint.Middle`. In WPF the default value is `RelativePoint.TopLeft` (0, 0). In controls like Viewbox (currently being developed) the same code will lead to a different rendering behavior: +RenderTransformOrigins are different in WPF and Avalonia: If you apply a `RenderTransform`, keep in mind that our default value for the RenderTransformOrigin is `RelativePoint.Center`. In WPF the default value is `RelativePoint.TopLeft` (0, 0). In controls like Viewbox (currently being developed) the same code will lead to a different rendering behavior: In WPF: ![WPF](https://files.gitter.im/AvaloniaUI/Avalonia/cDrM/image.png) diff --git a/packages.cake b/packages.cake index 1f37461da7..78052e8a5e 100644 --- a/packages.cake +++ b/packages.cake @@ -111,6 +111,7 @@ public class Packages var SplatVersion = packageVersions["Splat"].FirstOrDefault().Item1; var SpracheVersion = packageVersions["Sprache"].FirstOrDefault().Item1; var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1; + var ReactiveUIVersion = packageVersions["reactiveui"].FirstOrDefault().Item1; var SystemValueTupleVersion = packageVersions["System.ValueTuple"].FirstOrDefault().Item1; SkiaSharpVersion = packageVersions["SkiaSharp"].FirstOrDefault().Item1; SkiaSharpLinuxVersion = packageVersions["Avalonia.Skia.Linux.Natives"].FirstOrDefault().Item1; @@ -124,6 +125,7 @@ public class Packages context.Information("Package: Splat, version: {0}", SplatVersion); context.Information("Package: Sprache, version: {0}", SpracheVersion); context.Information("Package: System.Reactive, version: {0}", SystemReactiveVersion); + context.Information("Package: reactiveui, version: {0}", ReactiveUIVersion); context.Information("Package: System.ValueTuple, version: {0}", SystemValueTupleVersion); context.Information("Package: SkiaSharp, version: {0}", SkiaSharpVersion); context.Information("Package: Avalonia.Skia.Linux.Natives, version: {0}", SkiaSharpLinuxVersion); @@ -176,7 +178,6 @@ public class Packages new [] { "./src/", "Avalonia.Visuals", ".xml" }, new [] { "./src/", "Avalonia.Styling", ".dll" }, new [] { "./src/", "Avalonia.Styling", ".xml" }, - new [] { "./src/", "Avalonia.ReactiveUI", ".dll" }, new [] { "./src/", "Avalonia.Themes.Default", ".dll" }, new [] { "./src/", "Avalonia.Themes.Default", ".xml" }, new [] { "./src/Markup/", "Avalonia.Markup", ".dll" }, @@ -273,7 +274,24 @@ public class Packages }, BasePath = context.Directory("./src/Avalonia.HtmlRenderer/bin/" + parameters.DirSuffix + "/netstandard1.3"), OutputDirectory = parameters.NugetRoot - } + }, + /////////////////////////////////////////////////////////////////////////////// + // Avalonia.ReactiveUI + /////////////////////////////////////////////////////////////////////////////// + new NuGetPackSettings() + { + Id = "Avalonia.ReactiveUI", + Dependencies = new DependencyBuilder(this) + { + new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, + }.Deps(new string[] {null}, "reactiveui"), + Files = new [] + { + new NuSpecContent { Source = "Avalonia.ReactiveUI.dll", Target = "lib/netstandard1.3" } + }, + BasePath = context.Directory("./src/Avalonia.ReactiveUI/bin/" + parameters.DirSuffix + "/netstandard1.3"), + OutputDirectory = parameters.NugetRoot + }, }; var nuspecNuGetSettingsMobile = new [] @@ -406,9 +424,9 @@ public class Packages }, Files = new [] { - new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/net45" } + new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/netstandard1.3" } }, - BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix), + BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix + "/netstandard1.3"), OutputDirectory = parameters.NugetRoot }, /////////////////////////////////////////////////////////////////////////////// diff --git a/samples/BindingTest/App.config b/samples/BindingTest/App.config index d9f870f27b..373b3a13f8 100644 --- a/samples/BindingTest/App.config +++ b/samples/BindingTest/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/BindingTest/App.xaml.cs b/samples/BindingTest/App.xaml.cs index 7bcaf837a8..42e5716541 100644 --- a/samples/BindingTest/App.xaml.cs +++ b/samples/BindingTest/App.xaml.cs @@ -20,6 +20,7 @@ namespace BindingTest AppBuilder.Configure() .UsePlatformDetect() + .UseReactiveUI() .Start(); } diff --git a/samples/BindingTest/BindingTest.csproj b/samples/BindingTest/BindingTest.csproj index eab656eb33..b4dd17194b 100644 --- a/samples/BindingTest/BindingTest.csproj +++ b/samples/BindingTest/BindingTest.csproj @@ -45,7 +45,6 @@ - @@ -163,4 +162,5 @@ + \ No newline at end of file diff --git a/samples/BindingTest/ViewModels/MainWindowViewModel.cs b/samples/BindingTest/ViewModels/MainWindowViewModel.cs index d8ea280abf..1116810ccb 100644 --- a/samples/BindingTest/ViewModels/MainWindowViewModel.cs +++ b/samples/BindingTest/ViewModels/MainWindowViewModel.cs @@ -28,15 +28,13 @@ namespace BindingTest.ViewModels SelectedItems = new ObservableCollection(); - ShuffleItems = ReactiveCommand.Create(); - ShuffleItems.Subscribe(_ => + ShuffleItems = ReactiveCommand.Create(() => { var r = new Random(); Items.Move(r.Next(Items.Count), 1); }); - StringValueCommand = ReactiveCommand.Create(); - StringValueCommand.Subscribe(param => + StringValueCommand = ReactiveCommand.Create(param => { BooleanFlag = !BooleanFlag; StringValue = param.ToString(); @@ -58,7 +56,7 @@ namespace BindingTest.ViewModels public ObservableCollection Items { get; } public ObservableCollection SelectedItems { get; } - public ReactiveCommand ShuffleItems { get; } + public ReactiveCommand ShuffleItems { get; } public string BooleanString { @@ -91,7 +89,7 @@ namespace BindingTest.ViewModels } public IObservable CurrentTimeObservable { get; } - public ReactiveCommand StringValueCommand { get; } + public ReactiveCommand StringValueCommand { get; } public DataAnnotationsErrorViewModel DataAnnotationsValidation { get; } = new DataAnnotationsErrorViewModel(); public ExceptionErrorViewModel ExceptionDataValidation { get; } = new ExceptionErrorViewModel(); diff --git a/samples/ControlCatalog.Desktop/App.config b/samples/ControlCatalog.Desktop/App.config index 10a06d8258..68403e421f 100644 --- a/samples/ControlCatalog.Desktop/App.config +++ b/samples/ControlCatalog.Desktop/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/ControlCatalog/MainWindow.xaml.cs b/samples/ControlCatalog/MainWindow.xaml.cs index c7c61e2b4e..413794dfa2 100644 --- a/samples/ControlCatalog/MainWindow.xaml.cs +++ b/samples/ControlCatalog/MainWindow.xaml.cs @@ -10,6 +10,7 @@ namespace ControlCatalog { this.InitializeComponent(); this.AttachDevTools(); + Renderer.DrawDirtyRects = Renderer.DrawFps = true; } private void InitializeComponent() diff --git a/samples/RenderTest/App.config b/samples/RenderTest/App.config index 10a06d8258..68403e421f 100644 --- a/samples/RenderTest/App.config +++ b/samples/RenderTest/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/RenderTest/Program.cs b/samples/RenderTest/Program.cs index 7a23e09dd4..514771097f 100644 --- a/samples/RenderTest/Program.cs +++ b/samples/RenderTest/Program.cs @@ -18,6 +18,7 @@ namespace RenderTest // again. AppBuilder.Configure() .UsePlatformDetect() + .UseReactiveUI() .Start(); } diff --git a/samples/RenderTest/RenderTest.csproj b/samples/RenderTest/RenderTest.csproj index 95f1479b6b..3b4602a740 100644 --- a/samples/RenderTest/RenderTest.csproj +++ b/samples/RenderTest/RenderTest.csproj @@ -183,4 +183,5 @@ + \ No newline at end of file diff --git a/samples/RenderTest/ViewModels/MainWindowViewModel.cs b/samples/RenderTest/ViewModels/MainWindowViewModel.cs index bd68752f66..b2fa2e8b7a 100644 --- a/samples/RenderTest/ViewModels/MainWindowViewModel.cs +++ b/samples/RenderTest/ViewModels/MainWindowViewModel.cs @@ -10,10 +10,8 @@ namespace RenderTest.ViewModels public MainWindowViewModel() { - ToggleDrawDirtyRects = ReactiveCommand.Create(); - ToggleDrawDirtyRects.Subscribe(_ => DrawDirtyRects = !DrawDirtyRects); - ToggleDrawFps = ReactiveCommand.Create(); - ToggleDrawFps.Subscribe(_ => DrawFps = !DrawFps); + ToggleDrawDirtyRects = ReactiveCommand.Create(() => DrawDirtyRects = !DrawDirtyRects); + ToggleDrawFps = ReactiveCommand.Create(() => DrawFps = !DrawFps); } public bool DrawDirtyRects @@ -28,7 +26,7 @@ namespace RenderTest.ViewModels set { this.RaiseAndSetIfChanged(ref drawFps, value); } } - public ReactiveCommand ToggleDrawDirtyRects { get; } - public ReactiveCommand ToggleDrawFps { get; } + public ReactiveCommand ToggleDrawDirtyRects { get; } + public ReactiveCommand ToggleDrawFps { get; } } } diff --git a/samples/VirtualizationTest/App.config b/samples/VirtualizationTest/App.config index 10a06d8258..68403e421f 100644 --- a/samples/VirtualizationTest/App.config +++ b/samples/VirtualizationTest/App.config @@ -1,21 +1,21 @@ - + - + - - + + - - + + - - + + diff --git a/samples/VirtualizationTest/Program.cs b/samples/VirtualizationTest/Program.cs index d5649f6a06..e9156d803f 100644 --- a/samples/VirtualizationTest/Program.cs +++ b/samples/VirtualizationTest/Program.cs @@ -17,6 +17,7 @@ namespace VirtualizationTest AppBuilder.Configure() .UsePlatformDetect() + .UseReactiveUI() .Start(); } diff --git a/samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs b/samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs index 86869eb46a..a0e1570a36 100644 --- a/samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs +++ b/samples/VirtualizationTest/ViewModels/MainWindowViewModel.cs @@ -23,20 +23,15 @@ namespace VirtualizationTest.ViewModels public MainWindowViewModel() { this.WhenAnyValue(x => x.ItemCount).Subscribe(ResizeItems); - RecreateCommand = ReactiveCommand.Create(); - RecreateCommand.Subscribe(_ => Recreate()); + RecreateCommand = ReactiveCommand.Create(() => Recreate()); - AddItemCommand = ReactiveCommand.Create(); - AddItemCommand.Subscribe(_ => AddItem()); + AddItemCommand = ReactiveCommand.Create(() => AddItem()); - RemoveItemCommand = ReactiveCommand.Create(); - RemoveItemCommand.Subscribe(_ => Remove()); + RemoveItemCommand = ReactiveCommand.Create(() => Remove()); - SelectFirstCommand = ReactiveCommand.Create(); - SelectFirstCommand.Subscribe(_ => SelectItem(0)); + SelectFirstCommand = ReactiveCommand.Create(() => SelectItem(0)); - SelectLastCommand = ReactiveCommand.Create(); - SelectLastCommand.Subscribe(_ => SelectItem(Items.Count - 1)); + SelectLastCommand = ReactiveCommand.Create(() => SelectItem(Items.Count - 1)); } public string NewItemString @@ -78,11 +73,11 @@ namespace VirtualizationTest.ViewModels public IEnumerable VirtualizationModes => Enum.GetValues(typeof(ItemVirtualizationMode)).Cast(); - public ReactiveCommand AddItemCommand { get; private set; } - public ReactiveCommand RecreateCommand { get; private set; } - public ReactiveCommand RemoveItemCommand { get; private set; } - public ReactiveCommand SelectFirstCommand { get; private set; } - public ReactiveCommand SelectLastCommand { get; private set; } + public ReactiveCommand AddItemCommand { get; private set; } + public ReactiveCommand RecreateCommand { get; private set; } + public ReactiveCommand RemoveItemCommand { get; private set; } + public ReactiveCommand SelectFirstCommand { get; private set; } + public ReactiveCommand SelectLastCommand { get; private set; } private void ResizeItems(int count) { diff --git a/samples/VirtualizationTest/VirtualizationTest.csproj b/samples/VirtualizationTest/VirtualizationTest.csproj index 327e659966..9d31a6cb86 100644 --- a/samples/VirtualizationTest/VirtualizationTest.csproj +++ b/samples/VirtualizationTest/VirtualizationTest.csproj @@ -158,4 +158,5 @@ + \ No newline at end of file diff --git a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj index 55384d787c..da230d34c6 100644 --- a/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj +++ b/samples/interop/Direct3DInteropSample/Direct3DInteropSample.csproj @@ -4,8 +4,8 @@ net461 - - + + %(Filename) diff --git a/samples/interop/Direct3DInteropSample/Program.cs b/samples/interop/Direct3DInteropSample/Program.cs index 7fb650a7a8..d5de5ccb4e 100644 --- a/samples/interop/Direct3DInteropSample/Program.cs +++ b/samples/interop/Direct3DInteropSample/Program.cs @@ -11,7 +11,7 @@ namespace Direct3DInteropSample { static void Main(string[] args) { - AppBuilder.Configure().UseWin32().UseDirect2D1().Start(); + AppBuilder.Configure().UseWin32(deferredRendering: false).UseDirect2D1().Start(); } } } diff --git a/src/Android/Avalonia.Android/AndroidPlatform.cs b/src/Android/Avalonia.Android/AndroidPlatform.cs index e9b4ad0a6d..7134e7d1b4 100644 --- a/src/Android/Avalonia.Android/AndroidPlatform.cs +++ b/src/Android/Avalonia.Android/AndroidPlatform.cs @@ -52,13 +52,11 @@ namespace Avalonia.Android .Bind().ToTransient() .Bind().ToSingleton() .Bind().ToConstant(Instance) - .Bind().ToConstant(ImmediateRenderer.Factory) .Bind().ToConstant(new AndroidThreadingInterface()) .Bind().ToTransient() .Bind().ToConstant(Instance) .Bind().ToSingleton() .Bind().ToConstant(new DefaultRenderLoop(60)) - .Bind().ToConstant(new AssetLoader(app.GetType().Assembly)); SkiaPlatform.Initialize(); diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index 0c62eb9060..6c8db17c71 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -13,6 +13,7 @@ using System.Reactive.Disposables; using Avalonia.Android.Platform.Input; using Avalonia.Controls; using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Rendering; namespace Avalonia.Android.Platform.SkiaPlatform { @@ -85,7 +86,12 @@ namespace Avalonia.Android.Platform.SkiaPlatform public IPlatformHandle Handle => _view; public IEnumerable Surfaces => new object[] {this}; - + + public IRenderer CreateRenderer(IRenderRoot root) + { + return new ImmediateRenderer(root); + } + public virtual void Hide() { _view.Visibility = ViewStates.Invisible; diff --git a/src/Avalonia.Base/Collections/AvaloniaList.cs b/src/Avalonia.Base/Collections/AvaloniaList.cs index ace898b55f..a3c3015a38 100644 --- a/src/Avalonia.Base/Collections/AvaloniaList.cs +++ b/src/Avalonia.Base/Collections/AvaloniaList.cs @@ -220,7 +220,7 @@ namespace Avalonia.Collections /// /// Removes all items from the collection. /// - public void Clear() + public virtual void Clear() { if (this.Count > 0) { diff --git a/src/Avalonia.Base/Utilities/WeakObservable.cs b/src/Avalonia.Base/Utilities/WeakObservable.cs index c261cc0520..b1fe78c206 100644 --- a/src/Avalonia.Base/Utilities/WeakObservable.cs +++ b/src/Avalonia.Base/Utilities/WeakObservable.cs @@ -16,12 +16,13 @@ namespace Avalonia.Utilities /// Converts a .NET event conforming to the standard .NET event pattern into an observable /// sequence, subscribing weakly. /// + /// The type of target. /// The type of the event args. /// Object instance that exposes the event to convert. /// Name of the event to convert. /// - public static IObservable> FromEventPattern( - object target, + public static IObservable> FromEventPattern( + TTarget target, string eventName) where TEventArgs : EventArgs { diff --git a/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs b/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs index 356be2ba31..f1e8fa6f9b 100644 --- a/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs +++ b/src/Avalonia.Base/Utilities/WeakSubscriptionManager.cs @@ -17,22 +17,23 @@ namespace Avalonia.Utilities /// /// Subscribes to an event on an object using a weak subscription. /// - /// The type of the event arguments. + /// The type of the target. + /// The type of the event arguments. /// The event source. /// The name of the event. /// The subscriber. - public static void Subscribe(object target, string eventName, IWeakSubscriber subscriber) - where T : EventArgs + public static void Subscribe(TTarget target, string eventName, IWeakSubscriber subscriber) + where TEventArgs : EventArgs { - var dic = SubscriptionTypeStorage.Subscribers.GetOrCreateValue(target); - Subscription sub; + var dic = SubscriptionTypeStorage.Subscribers.GetOrCreateValue(target); + Subscription sub; if (!dic.TryGetValue(eventName, out sub)) { - dic[eventName] = sub = new Subscription(dic, target, eventName); + dic[eventName] = sub = new Subscription(dic, typeof(TTarget), target, eventName); } - sub.Add(new WeakReference>(subscriber)); + sub.Add(new WeakReference>(subscriber)); } /// @@ -84,19 +85,18 @@ namespace Avalonia.Utilities private WeakReference>[] _data = new WeakReference>[16]; private int _count = 0; - public Subscription(SubscriptionDic sdic, object target, string eventName) + public Subscription(SubscriptionDic sdic, Type targetType, object target, string eventName) { _sdic = sdic; _target = target; _eventName = eventName; - var t = target.GetType(); Dictionary evDic; - if (!Accessors.TryGetValue(t, out evDic)) - Accessors[t] = evDic = new Dictionary(); + if (!Accessors.TryGetValue(targetType, out evDic)) + Accessors[targetType] = evDic = new Dictionary(); if (!evDic.TryGetValue(eventName, out _info)) { - var ev = t.GetRuntimeEvents().FirstOrDefault(x => x.Name == eventName); + var ev = targetType.GetRuntimeEvents().FirstOrDefault(x => x.Name == eventName); if (ev == null) { diff --git a/src/Avalonia.Controls/Classes.cs b/src/Avalonia.Controls/Classes.cs index 02fd6e63bf..c897e86697 100644 --- a/src/Avalonia.Controls/Classes.cs +++ b/src/Avalonia.Controls/Classes.cs @@ -86,6 +86,20 @@ namespace Avalonia.Controls base.AddRange(c); } + /// + /// Remvoes all non-pseudoclasses from the collection. + /// + public override void Clear() + { + for (var i = Count - 1; i >= 0; --i) + { + if (!this[i].StartsWith(":")) + { + RemoveAt(i); + } + } + } + /// /// Inserts a style class into the collection. /// diff --git a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs index ba3ecb99c5..60e25d2be6 100644 --- a/src/Avalonia.Controls/Platform/ITopLevelImpl.cs +++ b/src/Avalonia.Controls/Platform/ITopLevelImpl.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using Avalonia.Input; using Avalonia.Input.Raw; +using Avalonia.Rendering; using JetBrains.Annotations; namespace Avalonia.Platform @@ -60,6 +61,12 @@ namespace Avalonia.Platform /// Action ScalingChanged { get; set; } + /// + /// Creates a new renderer for the toplevel. + /// + /// The toplevel. + IRenderer CreateRenderer(IRenderRoot root); + /// /// Invalidates a rect on the toplevel. /// diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index a0a8f6b27e..f8db0e2a5b 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -90,8 +90,7 @@ namespace Avalonia.Controls _renderInterface = TryGetService(dependencyResolver); var renderLoop = TryGetService(dependencyResolver); - var rendererFactory = TryGetService(dependencyResolver); - Renderer = rendererFactory?.CreateRenderer(this, renderLoop); + Renderer = impl.CreateRenderer(this); impl.SetInputRoot(this); @@ -181,6 +180,9 @@ namespace Avalonia.Controls /// double ILayoutRoot.LayoutScaling => PlatformImpl?.Scaling ?? 1; + /// + double IRenderRoot.RenderScaling => PlatformImpl?.Scaling ?? 1; + IStyleHost IStyleHost.StylingParent { get { return AvaloniaLocator.Current.GetService(); } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 3802f2b6ea..46c625cc4c 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -225,8 +225,14 @@ namespace Avalonia.Controls /// public override void Hide() { + if (!IsVisible) + { + return; + } + using (BeginAutoSizing()) { + Renderer?.Stop(); PlatformImpl?.Hide(); } @@ -252,6 +258,7 @@ namespace Avalonia.Controls using (BeginAutoSizing()) { PlatformImpl?.Show(); + Renderer?.Start(); } } @@ -297,6 +304,8 @@ namespace Avalonia.Controls var modal = PlatformImpl?.ShowDialog(); var result = new TaskCompletionSource(); + Renderer?.Start(); + Observable.FromEventPattern( x => this.Closed += x, x => this.Closed -= x) diff --git a/src/Avalonia.Controls/WindowBase.cs b/src/Avalonia.Controls/WindowBase.cs index fbdf64b14a..bcc09936ba 100644 --- a/src/Avalonia.Controls/WindowBase.cs +++ b/src/Avalonia.Controls/WindowBase.cs @@ -117,6 +117,7 @@ namespace Avalonia.Controls try { + Renderer?.Stop(); PlatformImpl?.Hide(); IsVisible = false; } @@ -145,6 +146,7 @@ namespace Avalonia.Controls } PlatformImpl?.Show(); + Renderer?.Start(); } finally { diff --git a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs new file mode 100644 index 0000000000..e081763e99 --- /dev/null +++ b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs @@ -0,0 +1,24 @@ +// 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 Avalonia.Controls; +using Avalonia.Threading; +using ReactiveUI; +using System; +using System.Reactive.Concurrency; +using System.Threading; + +namespace Avalonia +{ + public static class AppBuilderExtensions + { + public static TAppBuilder UseReactiveUI(this TAppBuilder builder) + where TAppBuilder : AppBuilderBase, new() + { + return builder.AfterSetup(_ => + { + RxApp.MainThreadScheduler = AvaloniaScheduler.Instance; + }); + } + } +} diff --git a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj index 2d66b62eab..6d547d9eb0 100644 --- a/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj +++ b/src/Avalonia.ReactiveUI/Avalonia.ReactiveUI.csproj @@ -1,80 +1,10 @@  netstandard1.3 - False false - - true - full - false - bin\Debug\ - TRACE;DEBUG;MONO PORTABLE;NETSTANDARD1_1 - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;MONO PORTABLE;RELEASE;NETSTANDARD1_1 - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -87,5 +17,6 @@ + \ No newline at end of file diff --git a/src/Avalonia.ReactiveUI/Properties/AssemblyInfo.cs b/src/Avalonia.ReactiveUI/Properties/AssemblyInfo.cs index 358c6224fb..c9ead6f6e6 100644 --- a/src/Avalonia.ReactiveUI/Properties/AssemblyInfo.cs +++ b/src/Avalonia.ReactiveUI/Properties/AssemblyInfo.cs @@ -1,33 +1,6 @@ // 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.Resources; using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. [assembly: AssemblyTitle("Avalonia.ReactiveUI")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Avalonia.ReactiveUI")] -[assembly: AssemblyCopyright("Copyright \u00A9 2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("en")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Avalonia.ReactiveUI/Registrations.cs b/src/Avalonia.ReactiveUI/Registrations.cs deleted file mode 100644 index 066aa46dc1..0000000000 --- a/src/Avalonia.ReactiveUI/Registrations.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.Concurrency; -using System.Threading; - - -namespace ReactiveUI -{ - /// - /// Ignore me. This class is a secret handshake between RxUI and RxUI.Xaml - /// in order to register certain classes on startup that would be difficult - /// to register otherwise. - /// - public class PlatformRegistrations : IWantsToRegisterStuff - { - public void Register(Action, Type> registerFunction) - { - RxApp.MainThreadScheduler = new SynchronizationContextScheduler(SynchronizationContext.Current); - } - } -} diff --git a/src/Avalonia.ReactiveUI/Shims.cs b/src/Avalonia.ReactiveUI/Shims.cs deleted file mode 100644 index 2729a68d6f..0000000000 --- a/src/Avalonia.ReactiveUI/Shims.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace System.Runtime.Serialization -{ - class IgnoreDataMemberAttribute : Attribute - { - } - - class DataMemberAttribute : Attribute - { - } - class OnDeserializedAttribute : Attribute - { - } - - class DataContractAttribute : Attribute - { - } - - class StreamingContext { } -} - -namespace System.Diagnostics.Contracts -{ - static class Contract - { - public static void Requires(bool condition) - { - - } - } -} diff --git a/src/Avalonia.ReactiveUI/src b/src/Avalonia.ReactiveUI/src deleted file mode 160000 index 3f725c808b..0000000000 --- a/src/Avalonia.ReactiveUI/src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3f725c808b1d4c8457f0d3204e0a071aa462cd75 diff --git a/src/Avalonia.Themes.Default/CheckBox.xaml b/src/Avalonia.Themes.Default/CheckBox.xaml index e88e93eac6..2fc19b2679 100644 --- a/src/Avalonia.Themes.Default/CheckBox.xaml +++ b/src/Avalonia.Themes.Default/CheckBox.xaml @@ -1,10 +1,11 @@