From 1f8400a6ff2da8f627285f2fdccd03803dedb19c Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Mon, 25 Jun 2018 17:09:53 +0800 Subject: [PATCH 01/80] Fix ghosting artifacts on both Renderers #1687 --- src/Avalonia.Visuals/Rendering/DeferredRenderer.cs | 2 ++ src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index a14923b410..ed557b8b74 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -337,6 +337,8 @@ namespace Avalonia.Rendering private void RenderComposite(Scene scene, IDrawingContextImpl context) { + context.Clear(Colors.Transparent); + var clientRect = new Rect(scene.Size); foreach (var layer in scene.Layers) diff --git a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs index 2118b66de2..93bb36c3cd 100644 --- a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs @@ -224,6 +224,9 @@ namespace Avalonia.Rendering var clipToBounds = visual.ClipToBounds; var bounds = new Rect(visual.Bounds.Size); + if (visual == _root) + context.PlatformImpl.Clear(Colors.Transparent); + if (visual.IsVisible && opacity > 0) { var m = Matrix.CreateTranslation(visual.Bounds.Position); From db50c65340da5ec073389d45dbad87d1f518b4c9 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 27 Jun 2018 08:08:47 +0800 Subject: [PATCH 02/80] Move ImmediateRenderer clearing code to Paint(). --- src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs index 93bb36c3cd..a9e251865b 100644 --- a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs @@ -54,6 +54,9 @@ namespace Avalonia.Rendering { using (var context = new DrawingContext(_renderTarget.CreateDrawingContext(this))) { + + context.PlatformImpl.Clear(Colors.Transparent); + using (context.PushTransformContainer()) { Render(context, _root, _root.Bounds); @@ -224,9 +227,6 @@ namespace Avalonia.Rendering var clipToBounds = visual.ClipToBounds; var bounds = new Rect(visual.Bounds.Size); - if (visual == _root) - context.PlatformImpl.Clear(Colors.Transparent); - if (visual.IsVisible && opacity > 0) { var m = Matrix.CreateTranslation(visual.Bounds.Position); From f92339b251458f1cf7e417097618c33dbc7d74c7 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 27 Jun 2018 13:48:59 +0800 Subject: [PATCH 03/80] Fix nit --- src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs index a9e251865b..24638ad150 100644 --- a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs @@ -54,7 +54,6 @@ namespace Avalonia.Rendering { using (var context = new DrawingContext(_renderTarget.CreateDrawingContext(this))) { - context.PlatformImpl.Clear(Colors.Transparent); using (context.PushTransformContainer()) From bf104a1e902e478be7c6afb250b69695e1beb167 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 19 Jul 2018 01:00:15 +0800 Subject: [PATCH 04/80] Set AlphaMode to Premultiplied in SwapChainRenderTarget.cs --- src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs index 0a23c63498..ea52081393 100644 --- a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs @@ -119,7 +119,7 @@ namespace Avalonia.Direct2D1 new BitmapProperties1( new PixelFormat { - AlphaMode = AlphaMode.Ignore, + AlphaMode = AlphaMode.Premultiplied, Format = Format.B8G8R8A8_UNorm }, _savedDpi.Width, From 0624d300376d2140b069a53a9808ff59933a44c5 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 01:24:17 +0800 Subject: [PATCH 05/80] Make ASM more Genericized. --- src/Avalonia.Animation/AnimatorStateMachine`1.cs | 12 ++++++------ src/Avalonia.Animation/Animator`1.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 1a51b897c0..414f07190a 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -7,10 +7,10 @@ namespace Avalonia.Animation /// /// Provides statefulness for an iteration of a keyframe animation. /// - internal class AnimatorStateMachine : IObservable, IDisposable + internal class AnimatorStateMachine : IObservable, IDisposable { - object _lastInterpValue; - object _firstKFValue; + T _lastInterpValue; + T _firstKFValue; private ulong _delayTotalFrameCount; private ulong _durationTotalFrameCount; @@ -34,7 +34,7 @@ namespace Avalonia.Animation private Animatable _targetControl; private T _neutralValue; internal bool _unsubscribe = false; - private IObserver _targetObserver; + private IObserver _targetObserver; [Flags] private enum KeyFramesStates @@ -100,7 +100,7 @@ namespace Avalonia.Animation { if (!_gotFirstKFValue) { - _firstKFValue = _parent.First().Value; + _firstKFValue = (T)_parent.First().Value; _gotFirstKFValue = true; } @@ -253,7 +253,7 @@ namespace Avalonia.Animation } } - public IDisposable Subscribe(IObserver observer) + public IDisposable Subscribe(IObserver observer) { _targetObserver = observer; return this; diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index a1eef87e1e..37764b34e8 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -106,7 +106,7 @@ namespace Avalonia.Animation .TakeWhile(_ => !stateMachine._unsubscribe) .Subscribe(p => stateMachine.Step(p, DoInterpolation)); - return control.Bind(Property, stateMachine, BindingPriority.Animation); + return control.Bind((AvaloniaProperty)Property, stateMachine, BindingPriority.Animation); } /// From 87934f2bfda67acb52dd363e910e4864db543c31 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 01:30:43 +0800 Subject: [PATCH 06/80] Remove underscores on ASM fields. --- .../AnimatorStateMachine`1.cs | 218 +++++++++--------- src/Avalonia.Animation/Animator`1.cs | 2 +- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 414f07190a..923cdd07b3 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -9,32 +9,32 @@ namespace Avalonia.Animation /// internal class AnimatorStateMachine : IObservable, IDisposable { - T _lastInterpValue; - T _firstKFValue; - - private ulong _delayTotalFrameCount; - private ulong _durationTotalFrameCount; - private ulong _delayFrameCount; - private ulong _durationFrameCount; - private ulong _repeatCount; - private ulong _currentIteration; - - private bool _isLooping; - private bool _isRepeating; - private bool _isReversed; - private bool _checkLoopAndRepeat; - private bool _gotFirstKFValue; - - private FillMode _fillMode; - private PlaybackDirection _animationDirection; - private KeyFramesStates _currentState; - private KeyFramesStates _savedState; - private Animator _parent; - private Animation _targetAnimation; - private Animatable _targetControl; - private T _neutralValue; - internal bool _unsubscribe = false; - private IObserver _targetObserver; + T lastInterpValue; + T firstKFValue; + + private ulong delayTotalFrameCount; + private ulong durationTotalFrameCount; + private ulong delayFrameCount; + private ulong durationFrameCount; + private ulong repeatCount; + private ulong currentIteration; + + private bool isLooping; + private bool isRepeating; + private bool isReversed; + private bool checkLoopAndRepeat; + private bool gotFirstKFValue; + + private FillMode fillMode; + private PlaybackDirection animationDirection; + private KeyFramesStates currentState; + private KeyFramesStates savedState; + private Animator parent; + private Animation targetAnimation; + private Animatable targetControl; + private T neutralValue; + internal bool unsubscribe = false; + private IObserver targetObserver; [Flags] private enum KeyFramesStates @@ -53,197 +53,197 @@ namespace Avalonia.Animation public void Initialize(Animation animation, Animatable control, Animator animator) { - _parent = animator; - _targetAnimation = animation; - _targetControl = control; - _neutralValue = (T)_targetControl.GetValue(_parent.Property); + parent = animator; + targetAnimation = animation; + targetControl = control; + neutralValue = (T)targetControl.GetValue(parent.Property); - _delayTotalFrameCount = (ulong)(animation.Delay.Ticks / Timing.FrameTick.Ticks); - _durationTotalFrameCount = (ulong)(animation.Duration.Ticks / Timing.FrameTick.Ticks); + delayTotalFrameCount = (ulong)(animation.Delay.Ticks / Timing.FrameTick.Ticks); + durationTotalFrameCount = (ulong)(animation.Duration.Ticks / Timing.FrameTick.Ticks); switch (animation.RepeatCount.RepeatType) { case RepeatType.Loop: - _isLooping = true; - _checkLoopAndRepeat = true; + isLooping = true; + checkLoopAndRepeat = true; break; case RepeatType.Repeat: - _isRepeating = true; - _checkLoopAndRepeat = true; - _repeatCount = animation.RepeatCount.Value; + isRepeating = true; + checkLoopAndRepeat = true; + repeatCount = animation.RepeatCount.Value; break; } - _isReversed = (animation.PlaybackDirection & PlaybackDirection.Reverse) != 0; - _animationDirection = _targetAnimation.PlaybackDirection; - _fillMode = _targetAnimation.FillMode; + isReversed = (animation.PlaybackDirection & PlaybackDirection.Reverse) != 0; + animationDirection = targetAnimation.PlaybackDirection; + fillMode = targetAnimation.FillMode; - if (_durationTotalFrameCount > 0) - _currentState = KeyFramesStates.DoDelay; + if (durationTotalFrameCount > 0) + currentState = KeyFramesStates.DoDelay; else - _currentState = KeyFramesStates.DoRun; + currentState = KeyFramesStates.DoRun; } - public void Step(PlayState _playState, Func Interpolator) + public void Step(PlayState playState, Func Interpolator) { try { - InternalStep(_playState, Interpolator); + InternalStep(playState, Interpolator); } catch (Exception e) { - _targetObserver?.OnError(e); + targetObserver?.OnError(e); } } - private void InternalStep(PlayState _playState, Func Interpolator) + private void InternalStep(PlayState playState, Func Interpolator) { - if (!_gotFirstKFValue) + if (!gotFirstKFValue) { - _firstKFValue = (T)_parent.First().Value; - _gotFirstKFValue = true; + firstKFValue = (T)parent.First().Value; + gotFirstKFValue = true; } - if (_currentState == KeyFramesStates.Disposed) + if (currentState == KeyFramesStates.Disposed) throw new InvalidProgramException("This KeyFrames Animation is already disposed."); - if (_playState == PlayState.Stop) - _currentState = KeyFramesStates.Stop; + if (playState == PlayState.Stop) + currentState = KeyFramesStates.Stop; - // Save state and pause the machine - if (_playState == PlayState.Pause && _currentState != KeyFramesStates.Pause) - { - _savedState = _currentState; - _currentState = KeyFramesStates.Pause; - } + // // Save state and pause the machine + // if (playState == PlayState.Pause && currentState != KeyFramesStates.Pause) + // { + // savedState = currentState; + // currentState = KeyFramesStates.Pause; + // } - // Resume the previous state - if (_playState != PlayState.Pause && _currentState == KeyFramesStates.Pause) - _currentState = _savedState; + // // Resume the previous state + // if (playState != PlayState.Pause && currentState == KeyFramesStates.Pause) + // currentState = savedState; - double _tempDuration = 0d, _easedTime; + double tempDuration = 0d, easedTime; bool handled = false; while (!handled) { - switch (_currentState) + switch (currentState) { case KeyFramesStates.DoDelay: - if (_fillMode == FillMode.Backward - || _fillMode == FillMode.Both) + if (fillMode == FillMode.Backward + || fillMode == FillMode.Both) { - if (_currentIteration == 0) + if (currentIteration == 0) { - _targetObserver.OnNext(_firstKFValue); + targetObserver.OnNext(firstKFValue); } else { - _targetObserver.OnNext(_lastInterpValue); + targetObserver.OnNext(lastInterpValue); } } - if (_delayFrameCount > _delayTotalFrameCount) + if (delayFrameCount > delayTotalFrameCount) { - _currentState = KeyFramesStates.DoRun; + currentState = KeyFramesStates.DoRun; } else { handled = true; - _delayFrameCount++; + delayFrameCount++; } break; case KeyFramesStates.DoRun: - if (_isReversed) - _currentState = KeyFramesStates.RunBackwards; + if (isReversed) + currentState = KeyFramesStates.RunBackwards; else - _currentState = KeyFramesStates.RunForwards; + currentState = KeyFramesStates.RunForwards; break; case KeyFramesStates.RunForwards: - if (_durationFrameCount > _durationTotalFrameCount) + if (durationFrameCount > durationTotalFrameCount) { - _currentState = KeyFramesStates.RunComplete; + currentState = KeyFramesStates.RunComplete; } else { - _tempDuration = (double)_durationFrameCount / _durationTotalFrameCount; - _currentState = KeyFramesStates.RunApplyValue; + tempDuration = (double)durationFrameCount / durationTotalFrameCount; + currentState = KeyFramesStates.RunApplyValue; } break; case KeyFramesStates.RunBackwards: - if (_durationFrameCount > _durationTotalFrameCount) + if (durationFrameCount > durationTotalFrameCount) { - _currentState = KeyFramesStates.RunComplete; + currentState = KeyFramesStates.RunComplete; } else { - _tempDuration = (double)(_durationTotalFrameCount - _durationFrameCount) / _durationTotalFrameCount; - _currentState = KeyFramesStates.RunApplyValue; + tempDuration = (double)(durationTotalFrameCount - durationFrameCount) / durationTotalFrameCount; + currentState = KeyFramesStates.RunApplyValue; } break; case KeyFramesStates.RunApplyValue: - _easedTime = _targetAnimation.Easing.Ease(_tempDuration); + easedTime = targetAnimation.Easing.Ease(tempDuration); - _durationFrameCount++; - _lastInterpValue = Interpolator(_easedTime, _neutralValue); - _targetObserver.OnNext(_lastInterpValue); - _currentState = KeyFramesStates.DoRun; + durationFrameCount++; + lastInterpValue = Interpolator(easedTime, neutralValue); + targetObserver.OnNext(lastInterpValue); + currentState = KeyFramesStates.DoRun; handled = true; break; case KeyFramesStates.RunComplete: - if (_checkLoopAndRepeat) + if (checkLoopAndRepeat) { - _delayFrameCount = 0; - _durationFrameCount = 0; + delayFrameCount = 0; + durationFrameCount = 0; - if (_isLooping) + if (isLooping) { - _currentState = KeyFramesStates.DoRun; + currentState = KeyFramesStates.DoRun; } - else if (_isRepeating) + else if (isRepeating) { - if (_currentIteration >= _repeatCount) + if (currentIteration >= repeatCount) { - _currentState = KeyFramesStates.Stop; + currentState = KeyFramesStates.Stop; } else { - _currentState = KeyFramesStates.DoRun; + currentState = KeyFramesStates.DoRun; } - _currentIteration++; + currentIteration++; } - if (_animationDirection == PlaybackDirection.Alternate - || _animationDirection == PlaybackDirection.AlternateReverse) - _isReversed = !_isReversed; + if (animationDirection == PlaybackDirection.Alternate + || animationDirection == PlaybackDirection.AlternateReverse) + isReversed = !isReversed; break; } - _currentState = KeyFramesStates.Stop; + currentState = KeyFramesStates.Stop; break; case KeyFramesStates.Stop: - if (_fillMode == FillMode.Forward - || _fillMode == FillMode.Both) + if (fillMode == FillMode.Forward + || fillMode == FillMode.Both) { - _targetControl.SetValue(_parent.Property, _lastInterpValue, BindingPriority.LocalValue); + targetControl.SetValue(parent.Property, lastInterpValue, BindingPriority.LocalValue); } - _targetObserver.OnCompleted(); + targetObserver.OnCompleted(); handled = true; break; default: @@ -255,14 +255,14 @@ namespace Avalonia.Animation public IDisposable Subscribe(IObserver observer) { - _targetObserver = observer; + targetObserver = observer; return this; } public void Dispose() { - _unsubscribe = true; - _currentState = KeyFramesStates.Disposed; + unsubscribe = true; + currentState = KeyFramesStates.Disposed; } } } diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 37764b34e8..654ee327f8 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -103,7 +103,7 @@ namespace Avalonia.Animation stateMachine.Initialize(animation, control, this); Timing.AnimationStateTimer - .TakeWhile(_ => !stateMachine._unsubscribe) + .TakeWhile(_ => !stateMachine.unsubscribe) .Subscribe(p => stateMachine.Step(p, DoInterpolation)); return control.Bind((AvaloniaProperty)Property, stateMachine, BindingPriority.Animation); From 127d060f6611045628ea0afa5eeae78f7d33a207 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 01:47:45 +0800 Subject: [PATCH 07/80] Add new properties for Animations. --- src/Avalonia.Animation/Animation.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 4e777b36ed..eaf6b280bc 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -75,6 +75,16 @@ namespace Avalonia.Animation /// public Easing Easing { get; set; } = new LinearEasing(); + /// + /// Sets the speed multiple for this animation. + /// + public double SpeedRatio { get; set; } = 1d; + + /// + /// Sets the behavior for having a delay between repeats for this animation. + /// + public bool DelayBetweenRepeats { get; set; } + public Animation() { this.CollectionChanged += delegate { _isChildrenChanged = true; }; From b3ebfa574865a5aee54594e6dd48ca38e11e0713 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 02:03:14 +0800 Subject: [PATCH 08/80] Add the global frame count to AnimationStateTimer. --- src/Avalonia.Animation/Timing.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index 10d65cca7f..3eddc0ac26 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -16,6 +16,7 @@ namespace Avalonia.Animation public static class Timing { static ulong _transitionsFrameCount; + static long _tickStartTimeStamp; static PlayState _globalState = PlayState.Run; /// @@ -33,12 +34,16 @@ namespace Avalonia.Animation /// static Timing() { + + _tickStartTimeStamp = Stopwatch.GetTimestamp(); + var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); AnimationStateTimer = globalTimer .Select(_ => { - return _globalState; + return (_globalState, (Stopwatch.GetTimestamp() - _tickStartTimeStamp) + / (Stopwatch.Frequency / FramesPerSecond)); }) .Publish() .RefCount(); @@ -76,7 +81,7 @@ namespace Avalonia.Animation /// defined in . /// The parameter passed to a subsciber is the current playstate of the animation. /// - internal static IObservable AnimationStateTimer + internal static IObservable<(PlayState, long)> AnimationStateTimer { get; } From 5365fd0a41220d840acb7d6d2511f3f3fda8478b Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 02:04:38 +0800 Subject: [PATCH 09/80] Add the new animation algorithm. --- src/Avalonia.Animation/Animatable.cs | 4 +- .../AnimatorStateMachine`1.cs | 284 +++++++----------- src/Avalonia.Animation/Animator`1.cs | 2 +- 3 files changed, 113 insertions(+), 177 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index a27d996301..85317af1a8 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -29,7 +29,7 @@ namespace Avalonia.Animation { if (this._playState == PlayState.Pause) { - return PlayState.Pause; + return (PlayState.Pause, p.Item2); } else return p; }) @@ -41,7 +41,7 @@ namespace Avalonia.Animation /// The specific animations timer for this control. /// /// - public IObservable AnimatableTimer; + public IObservable<(PlayState, long)> AnimatableTimer; /// /// Defines the property. diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 923cdd07b3..6854645cc2 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Avalonia.Animation.Utils; using Avalonia.Data; namespace Avalonia.Animation @@ -12,91 +13,97 @@ namespace Avalonia.Animation T lastInterpValue; T firstKFValue; - private ulong delayTotalFrameCount; - private ulong durationTotalFrameCount; - private ulong delayFrameCount; - private ulong durationFrameCount; - private ulong repeatCount; - private ulong currentIteration; + private long delayFC; + private long durationFC; + private long repeatCount; + private long currentIteration; + private long firstFrameCount; private bool isLooping; private bool isRepeating; - private bool isReversed; - private bool checkLoopAndRepeat; private bool gotFirstKFValue; + private bool gotFirstFrameCount; + private bool delayBetweenIterations; private FillMode fillMode; private PlaybackDirection animationDirection; - private KeyFramesStates currentState; - private KeyFramesStates savedState; private Animator parent; - private Animation targetAnimation; private Animatable targetControl; private T neutralValue; - internal bool unsubscribe = false; - private IObserver targetObserver; + private double speedRatio; + internal bool unsubscribe; + private bool isDisposed; - [Flags] - private enum KeyFramesStates - { - Initialize, - DoDelay, - DoRun, - RunForwards, - RunBackwards, - RunApplyValue, - RunComplete, - Pause, - Stop, - Disposed - } + private Easings.Easing EaseFunc; + private IObserver targetObserver; public void Initialize(Animation animation, Animatable control, Animator animator) { + + if (animation.SpeedRatio <= 0 || DoubleUtils.AboutEqual(animation.SpeedRatio, 0)) + throw new InvalidOperationException("Speed ratio cannot be negative or zero."); + + if (animation.Duration.TotalSeconds <= 0 || DoubleUtils.AboutEqual(animation.Duration.TotalSeconds, 0)) + throw new InvalidOperationException("Animation duration cannot be negative or zero."); + parent = animator; - targetAnimation = animation; + EaseFunc = animation.Easing; targetControl = control; neutralValue = (T)targetControl.GetValue(parent.Property); - delayTotalFrameCount = (ulong)(animation.Delay.Ticks / Timing.FrameTick.Ticks); - durationTotalFrameCount = (ulong)(animation.Duration.Ticks / Timing.FrameTick.Ticks); + speedRatio = animation.SpeedRatio; + delayFC = (long)((animation.Delay.Ticks / Timing.FrameTick.Ticks) * speedRatio); + durationFC = (long)((animation.Duration.Ticks / Timing.FrameTick.Ticks) * speedRatio); switch (animation.RepeatCount.RepeatType) { + case RepeatType.None: + repeatCount = 1; + break; case RepeatType.Loop: isLooping = true; - checkLoopAndRepeat = true; break; case RepeatType.Repeat: isRepeating = true; - checkLoopAndRepeat = true; - repeatCount = animation.RepeatCount.Value; + repeatCount = (long)animation.RepeatCount.Value; break; } - isReversed = (animation.PlaybackDirection & PlaybackDirection.Reverse) != 0; - animationDirection = targetAnimation.PlaybackDirection; - fillMode = targetAnimation.FillMode; + animationDirection = animation.PlaybackDirection; + fillMode = animation.FillMode; - if (durationTotalFrameCount > 0) - currentState = KeyFramesStates.DoDelay; - else - currentState = KeyFramesStates.DoRun; } - public void Step(PlayState playState, Func Interpolator) + public void Step(PlayState playState, long frameTick, Func Interpolator) { try { - InternalStep(playState, Interpolator); + InternalStep(playState, frameTick, Interpolator); } catch (Exception e) { targetObserver?.OnError(e); } } + + private void DoComplete() + { + if (fillMode == FillMode.Forward || fillMode == FillMode.Both) + targetControl.SetValue(parent.Property, lastInterpValue, BindingPriority.LocalValue); + + targetObserver.OnCompleted(); + } - private void InternalStep(PlayState playState, Func Interpolator) + private void DoDelay() + { + if (fillMode == FillMode.Backward || fillMode == FillMode.Both) + if (currentIteration == 0) + targetObserver.OnNext(firstKFValue); + else + targetObserver.OnNext(lastInterpValue); + } + + private void InternalStep(PlayState playState, long frameTick, Func Interpolator) { if (!gotFirstKFValue) { @@ -104,13 +111,19 @@ namespace Avalonia.Animation gotFirstKFValue = true; } - if (currentState == KeyFramesStates.Disposed) + if (!gotFirstFrameCount) + { + firstFrameCount = frameTick; + gotFirstFrameCount = true; + } + + if (isDisposed) throw new InvalidProgramException("This KeyFrames Animation is already disposed."); if (playState == PlayState.Stop) - currentState = KeyFramesStates.Stop; + DoComplete(); - // // Save state and pause the machine + // Save state and pause the machine // if (playState == PlayState.Pause && currentState != KeyFramesStates.Pause) // { // savedState = currentState; @@ -121,135 +134,58 @@ namespace Avalonia.Animation // if (playState != PlayState.Pause && currentState == KeyFramesStates.Pause) // currentState = savedState; - double tempDuration = 0d, easedTime; + // get the time with the initial fc as point of origin. + var t = (frameTick - firstFrameCount); - bool handled = false; + // check if t is within the zeroth iteration + if (t <= (delayFC + durationFC)) + { + currentIteration = 0; + t = t % (delayFC + durationFC); + } + else + { + var totalDur = (double)((delayBetweenIterations ? delayFC : 0) + durationFC + 1); + currentIteration = (long)Math.Floor((double)t / totalDur); + t = t % (long)totalDur; + } + + // check if it's over the repeat count + if (currentIteration > ((long)repeatCount - 1) && !isLooping) + { + DoComplete(); + } + + // check if the current iteration should be reversed or not. + bool isCurIterReverse = animationDirection == PlaybackDirection.Normal ? false : + animationDirection == PlaybackDirection.Alternate ? (currentIteration % 2 == 0) ? false : true : + animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : + animationDirection == PlaybackDirection.Reverse ? true : false; - while (!handled) + long x1 = delayFC; + long x2 = x1 + durationFC; + + if (delayFC > 0 & t >= 0 & t <= x1) + { + if (currentIteration == 0 && delayBetweenIterations) + DoDelay(); + + } + else if (t >= x1 & t <= x2) + { + var interpVal = t / (double)durationFC; + + if (isCurIterReverse) + interpVal = 1 - interpVal; + + var easedTime = EaseFunc.Ease(interpVal); + + lastInterpValue = Interpolator(easedTime, neutralValue); + targetObserver.OnNext(lastInterpValue); + } + else if (t > x2 & (currentIteration + 1 > repeatCount & !isLooping)) { - switch (currentState) - { - case KeyFramesStates.DoDelay: - - if (fillMode == FillMode.Backward - || fillMode == FillMode.Both) - { - if (currentIteration == 0) - { - targetObserver.OnNext(firstKFValue); - } - else - { - targetObserver.OnNext(lastInterpValue); - } - } - - if (delayFrameCount > delayTotalFrameCount) - { - currentState = KeyFramesStates.DoRun; - } - else - { - handled = true; - delayFrameCount++; - } - break; - - case KeyFramesStates.DoRun: - - if (isReversed) - currentState = KeyFramesStates.RunBackwards; - else - currentState = KeyFramesStates.RunForwards; - - break; - - case KeyFramesStates.RunForwards: - - if (durationFrameCount > durationTotalFrameCount) - { - currentState = KeyFramesStates.RunComplete; - } - else - { - tempDuration = (double)durationFrameCount / durationTotalFrameCount; - currentState = KeyFramesStates.RunApplyValue; - - } - break; - - case KeyFramesStates.RunBackwards: - - if (durationFrameCount > durationTotalFrameCount) - { - currentState = KeyFramesStates.RunComplete; - } - else - { - tempDuration = (double)(durationTotalFrameCount - durationFrameCount) / durationTotalFrameCount; - currentState = KeyFramesStates.RunApplyValue; - } - break; - - case KeyFramesStates.RunApplyValue: - - easedTime = targetAnimation.Easing.Ease(tempDuration); - - durationFrameCount++; - lastInterpValue = Interpolator(easedTime, neutralValue); - targetObserver.OnNext(lastInterpValue); - currentState = KeyFramesStates.DoRun; - handled = true; - break; - - case KeyFramesStates.RunComplete: - - if (checkLoopAndRepeat) - { - delayFrameCount = 0; - durationFrameCount = 0; - - if (isLooping) - { - currentState = KeyFramesStates.DoRun; - } - else if (isRepeating) - { - if (currentIteration >= repeatCount) - { - currentState = KeyFramesStates.Stop; - } - else - { - currentState = KeyFramesStates.DoRun; - } - currentIteration++; - } - - if (animationDirection == PlaybackDirection.Alternate - || animationDirection == PlaybackDirection.AlternateReverse) - isReversed = !isReversed; - - break; - } - - currentState = KeyFramesStates.Stop; - break; - - case KeyFramesStates.Stop: - - if (fillMode == FillMode.Forward - || fillMode == FillMode.Both) - { - targetControl.SetValue(parent.Property, lastInterpValue, BindingPriority.LocalValue); - } - targetObserver.OnCompleted(); - handled = true; - break; - default: - handled = true; - break; - } + DoComplete(); } } @@ -262,7 +198,7 @@ namespace Avalonia.Animation public void Dispose() { unsubscribe = true; - currentState = KeyFramesStates.Disposed; + isDisposed = true; } } -} +} \ No newline at end of file diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 654ee327f8..cdf15c4c2f 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -104,7 +104,7 @@ namespace Avalonia.Animation Timing.AnimationStateTimer .TakeWhile(_ => !stateMachine.unsubscribe) - .Subscribe(p => stateMachine.Step(p, DoInterpolation)); + .Subscribe(p => stateMachine.Step(p.Item1, p.Item2, DoInterpolation)); return control.Bind((AvaloniaProperty)Property, stateMachine, BindingPriority.Animation); } From 0b248e6bb27509584eebf2b69899282882314d1d Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 2 Aug 2018 02:18:55 +0800 Subject: [PATCH 10/80] Optimize & remove excess numeric castings. --- .../AnimatorStateMachine`1.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 6854645cc2..21a9fe7a50 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -13,10 +13,10 @@ namespace Avalonia.Animation T lastInterpValue; T firstKFValue; - private long delayFC; - private long durationFC; + private double delayFC; + private double durationFC; private long repeatCount; - private long currentIteration; + private double currentIteration; private long firstFrameCount; private bool isLooping; @@ -52,8 +52,9 @@ namespace Avalonia.Animation neutralValue = (T)targetControl.GetValue(parent.Property); speedRatio = animation.SpeedRatio; - delayFC = (long)((animation.Delay.Ticks / Timing.FrameTick.Ticks) * speedRatio); - durationFC = (long)((animation.Duration.Ticks / Timing.FrameTick.Ticks) * speedRatio); + delayFC = ((animation.Delay.Ticks / Timing.FrameTick.Ticks) * speedRatio); + durationFC = ((animation.Duration.Ticks / Timing.FrameTick.Ticks) * speedRatio); + delayBetweenIterations = animation.DelayBetweenRepeats; switch (animation.RepeatCount.RepeatType) { @@ -85,7 +86,7 @@ namespace Avalonia.Animation targetObserver?.OnError(e); } } - + private void DoComplete() { if (fillMode == FillMode.Forward || fillMode == FillMode.Both) @@ -135,7 +136,7 @@ namespace Avalonia.Animation // currentState = savedState; // get the time with the initial fc as point of origin. - var t = (frameTick - firstFrameCount); + double t = (frameTick - firstFrameCount); // check if t is within the zeroth iteration if (t <= (delayFC + durationFC)) @@ -146,12 +147,12 @@ namespace Avalonia.Animation else { var totalDur = (double)((delayBetweenIterations ? delayFC : 0) + durationFC + 1); - currentIteration = (long)Math.Floor((double)t / totalDur); - t = t % (long)totalDur; + currentIteration = Math.Floor(t / totalDur); + t = t % totalDur; } // check if it's over the repeat count - if (currentIteration > ((long)repeatCount - 1) && !isLooping) + if (currentIteration > (repeatCount - 1) && !isLooping) { DoComplete(); } @@ -162,8 +163,8 @@ namespace Avalonia.Animation animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : animationDirection == PlaybackDirection.Reverse ? true : false; - long x1 = delayFC; - long x2 = x1 + durationFC; + double x1 = delayFC; + double x2 = x1 + durationFC; if (delayFC > 0 & t >= 0 & t <= x1) { @@ -173,7 +174,7 @@ namespace Avalonia.Animation } else if (t >= x1 & t <= x2) { - var interpVal = t / (double)durationFC; + var interpVal = t / durationFC; if (isCurIterReverse) interpVal = 1 - interpVal; From cfabbe9b65b9514c5bf3a4a27701f2af37d32e2b Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 3 Aug 2018 12:46:07 +0800 Subject: [PATCH 11/80] More optimizations. --- .../AnimatorStateMachine`1.cs | 12 +++++------ src/Avalonia.Animation/Timing.cs | 21 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 21a9fe7a50..8bfdf8b04a 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -163,16 +163,16 @@ namespace Avalonia.Animation animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : animationDirection == PlaybackDirection.Reverse ? true : false; - double x1 = delayFC; - double x2 = x1 + durationFC; + double delayEndpoint = delayFC; + double iterationEndpoint = delayEndpoint + durationFC; - if (delayFC > 0 & t >= 0 & t <= x1) + if (delayFC > 0 & t >= 0 & t <= delayEndpoint) { - if (currentIteration == 0 && delayBetweenIterations) + if (currentIteration == 0 || delayBetweenIterations) DoDelay(); } - else if (t >= x1 & t <= x2) + else if (t >= delayEndpoint & t <= iterationEndpoint) { var interpVal = t / durationFC; @@ -184,7 +184,7 @@ namespace Avalonia.Animation lastInterpValue = Interpolator(easedTime, neutralValue); targetObserver.OnNext(lastInterpValue); } - else if (t > x2 & (currentIteration + 1 > repeatCount & !isLooping)) + else if (t > iterationEndpoint & (currentIteration + 1 > repeatCount & !isLooping)) { DoComplete(); } diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index 3eddc0ac26..fb61e15f05 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -15,15 +15,17 @@ namespace Avalonia.Animation /// public static class Timing { - static ulong _transitionsFrameCount; static long _tickStartTimeStamp; static PlayState _globalState = PlayState.Run; + static long TicksPerFrame = Stopwatch.Frequency / FramesPerSecond; + /// /// The number of frames per second. /// public const int FramesPerSecond = 60; + /// /// The time span of each frame. /// @@ -39,17 +41,18 @@ namespace Avalonia.Animation var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); + AnimationStateTimer = globalTimer .Select(_ => { return (_globalState, (Stopwatch.GetTimestamp() - _tickStartTimeStamp) - / (Stopwatch.Frequency / FramesPerSecond)); + / TicksPerFrame); }) .Publish() .RefCount(); TransitionsTimer = globalTimer - .Select(p => _transitionsFrameCount++) + .Select(p => p) .Publish() .RefCount(); } @@ -95,7 +98,7 @@ namespace Avalonia.Animation /// The parameter passed to a subsciber is the number of frames since the animation system was /// initialized. /// - public static IObservable TransitionsTimer + public static IObservable TransitionsTimer { get; } @@ -113,16 +116,14 @@ namespace Avalonia.Animation /// public static IObservable GetTransitionsTimer(Animatable control, TimeSpan duration, TimeSpan delay = default(TimeSpan)) { - var startTime = _transitionsFrameCount; - var _duration = (ulong)(duration.Ticks / FrameTick.Ticks); - var endTime = startTime + _duration; + var _duration = (duration.Ticks / FrameTick.Ticks); + var endTime = _duration; return TransitionsTimer .TakeWhile(x => x < endTime) - .Select(x => (double)(x - startTime) / _duration) + .Select(x => (double)x / _duration) .StartWith(0.0) .Concat(Observable.Return(1.0)); } - } -} +} \ No newline at end of file From 1757604dab071f6d09b4e1b63a1eddad1c708f72 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 3 Aug 2018 12:47:01 +0800 Subject: [PATCH 12/80] Fix onComplete assignment. --- src/Avalonia.Animation/AnimatorStateMachine`1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 32acafcfc7..18ad76c51e 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -73,7 +73,7 @@ namespace Avalonia.Animation animationDirection = animation.PlaybackDirection; fillMode = animation.FillMode; - onComplete = onComplete; + this.onComplete = onComplete; } public void Step(PlayState playState, long frameTick, Func Interpolator) From b020bddb20bae6f4ca299cff7858ee9d60af7e95 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 3 Aug 2018 12:47:01 +0800 Subject: [PATCH 13/80] Fix onComplete assignment. --- src/Avalonia.Animation/Animation.cs | 7 +------ src/Avalonia.Animation/AnimatorStateMachine`1.cs | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 46179aa3f4..344b63d15c 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -85,12 +85,7 @@ namespace Avalonia.Animation /// Sets the behavior for having a delay between repeats for this animation. /// public bool DelayBetweenRepeats { get; set; } - - public Animation() - { - this.CollectionChanged += delegate { _isChildrenChanged = true; }; - } - + private (IList Animators, IList subscriptions) InterpretKeyframes(Animatable control) { var handlerList = new List<(Type type, AvaloniaProperty property)>(); diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 32acafcfc7..18ad76c51e 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -73,7 +73,7 @@ namespace Avalonia.Animation animationDirection = animation.PlaybackDirection; fillMode = animation.FillMode; - onComplete = onComplete; + this.onComplete = onComplete; } public void Step(PlayState playState, long frameTick, Func Interpolator) From 1b37397e69b97a1f9a7274a8ceb5644129475ae0 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 3 Aug 2018 17:38:41 +0800 Subject: [PATCH 14/80] Fix bug on PageTransitions by adding 1 to the zeroth iteration frame count modulo. --- src/Avalonia.Animation/AnimatorStateMachine`1.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 18ad76c51e..38ccce6cb5 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -145,7 +145,7 @@ namespace Avalonia.Animation if (t <= (delayFC + durationFC)) { currentIteration = 0; - t = t % (delayFC + durationFC); + t = t % (delayFC + durationFC + 1); } else { From bfefeb9e9c63830e3cd17311be7f3c5ef7b6bb7c Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Fri, 3 Aug 2018 17:39:19 +0800 Subject: [PATCH 15/80] Make Transitions Bind strongly typed. --- src/Avalonia.Animation/Transition`1.cs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/Avalonia.Animation/Transition`1.cs b/src/Avalonia.Animation/Transition`1.cs index 5db3082deb..c097b930a5 100644 --- a/src/Avalonia.Animation/Transition`1.cs +++ b/src/Avalonia.Animation/Transition`1.cs @@ -24,17 +24,7 @@ namespace Avalonia.Animation /// /// Gets the easing class to be used. /// - public Easing Easing - { - get - { - return _easing ?? (_easing = new LinearEasing()); - } - set - { - _easing = value; - } - } + public Easing Easing { get; set; } = new LinearEasing(); /// public AvaloniaProperty Property @@ -61,8 +51,8 @@ namespace Avalonia.Animation /// public virtual IDisposable Apply(Animatable control, object oldValue, object newValue) { - var transition = DoTransition(Timing.GetTransitionsTimer(control, Duration, TimeSpan.Zero), (T)oldValue, (T)newValue).Select(p => (object)p); - return control.Bind(Property, transition, Data.BindingPriority.Animation); + var transition = DoTransition(Timing.GetTransitionsTimer(control, Duration, TimeSpan.Zero), (T)oldValue, (T)newValue); + return control.Bind((AvaloniaProperty)Property, transition, Data.BindingPriority.Animation); } } } \ No newline at end of file From 714606b2ad8bd0d8adb3acc4d30701a8f195d2f7 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Sun, 12 Aug 2018 01:26:03 +0800 Subject: [PATCH 16/80] Add PlayState support. Redoing the main algorithm yet again. --- .../ViewModels/AnimationsPageViewModel.cs | 10 +- src/Avalonia.Animation/Animatable.cs | 21 +---- src/Avalonia.Animation/Animation.cs | 87 ++++++++++-------- .../AnimatorStateMachine`1.cs | 92 ++++++++++--------- src/Avalonia.Animation/Animator`1.cs | 21 ++--- src/Avalonia.Animation/Timing.cs | 59 +++--------- 6 files changed, 127 insertions(+), 163 deletions(-) diff --git a/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs b/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs index 626a3e7c77..c76d4db513 100644 --- a/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs +++ b/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs @@ -10,21 +10,21 @@ namespace RenderDemo.ViewModels public AnimationsPageViewModel() { - ToggleGlobalPlayState = ReactiveCommand.Create(()=>TogglePlayState()); + ToggleGlobalPlayState = ReactiveCommand.Create(() => TogglePlayState()); } void TogglePlayState() { - switch (Timing.GetGlobalPlayState()) + switch (Timing.GlobalPlayState) { case PlayState.Run: PlayStateText = "Resume all animations"; - Timing.SetGlobalPlayState(PlayState.Pause); + Timing.GlobalPlayState = PlayState.Pause; break; case PlayState.Pause: PlayStateText = "Pause all animations"; - Timing.SetGlobalPlayState(PlayState.Run); + Timing.GlobalPlayState = PlayState.Run; break; } } @@ -36,5 +36,5 @@ namespace RenderDemo.ViewModels } public ReactiveCommand ToggleGlobalPlayState { get; } - } + } } diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 85317af1a8..303e01aed8 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -23,25 +23,8 @@ namespace Avalonia.Animation /// public Animatable() { - Transitions = new Transitions(); - AnimatableTimer = Timing.AnimationStateTimer - .Select(p => - { - if (this._playState == PlayState.Pause) - { - return (PlayState.Pause, p.Item2); - } - else return p; - }) - .Publish() - .RefCount(); - } - - /// - /// The specific animations timer for this control. - /// - /// - public IObservable<(PlayState, long)> AnimatableTimer; + Transitions = new Transitions(); + } /// /// Defines the property. diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 344b63d15c..da2fc75c0b 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -21,70 +21,81 @@ namespace Avalonia.Animation /// public class Animation : AvaloniaList, IAnimation { - private readonly static List<(Func Condition, Type Animator)> Animators = new List<(Func, Type)> - { - ( prop => typeof(double).IsAssignableFrom(prop.PropertyType), typeof(DoubleAnimator) ) - }; - - public static void RegisterAnimator(Func condition) - where TAnimator : IAnimator - { - Animators.Insert(0, (condition, typeof(TAnimator))); - } - - private static Type GetAnimatorType(AvaloniaProperty property) - { - foreach (var (condition, type) in Animators) - { - if (condition(property)) - { - return type; - } - } - return null; - } public AvaloniaList _animators { get; set; } = new AvaloniaList(); /// - /// Run time of this animation. + /// Gets or sets the active time of this animation. /// public TimeSpan Duration { get; set; } /// - /// Delay time for this animation. - /// - public TimeSpan Delay { get; set; } - - /// - /// The repeat count for this animation. + /// Gets or sets the repeat count for this animation. /// public RepeatCount RepeatCount { get; set; } /// - /// The playback direction for this animation. + /// Gets or sets the playback direction for this animation. /// public PlaybackDirection PlaybackDirection { get; set; } /// - /// The value fill mode for this animation. + /// Gets or sets the value fill mode for this animation. /// public FillMode FillMode { get; set; } /// - /// Easing function to be used. + /// Gets or sets the easing function to be used for this animation. /// public Easing Easing { get; set; } = new LinearEasing(); - + /// - /// Sets the speed multiple for this animation. + /// Gets or sets the speed multiple for this animation. /// public double SpeedRatio { get; set; } = 1d; - /// - /// Sets the behavior for having a delay between repeats for this animation. - /// - public bool DelayBetweenRepeats { get; set; } + /// + /// Gets or sets the delay time for this animation. + /// + /// + /// Describes a delay to be added before the animation starts, and optionally between + /// repeats of the animation if is set. + /// + public TimeSpan Delay { get; set; } + + /// + /// Gets or sets a value indicating whether will be applied between + /// iterations of the animation. + /// + /// + /// If this property is not set, then will only be applied to the first + /// iteration of the animation. + /// + public bool DelayBetweenIterations { get; set; } + + + private readonly static List<(Func Condition, Type Animator)> Animators = new List<(Func, Type)> + { + ( prop => typeof(double).IsAssignableFrom(prop.PropertyType), typeof(DoubleAnimator) ) + }; + + public static void RegisterAnimator(Func condition) + where TAnimator : IAnimator + { + Animators.Insert(0, (condition, typeof(TAnimator))); + } + + private static Type GetAnimatorType(AvaloniaProperty property) + { + foreach (var (condition, type) in Animators) + { + if (condition(property)) + { + return type; + } + } + return null; + } private (IList Animators, IList subscriptions) InterpretKeyframes(Animatable control) { diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 38ccce6cb5..47bfa1c321 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -9,7 +9,7 @@ namespace Avalonia.Animation /// Provides statefulness for an iteration of a keyframe animation. /// internal class AnimatorStateMachine : IObservable, IDisposable - { + { T lastInterpValue; T firstKFValue; @@ -34,6 +34,11 @@ namespace Avalonia.Animation internal bool unsubscribe; private bool isDisposed; + private long? internalClock; + + private long? previousClock = null; + private long currentDiscreteTime; + private Easings.Easing EaseFunc; private IObserver targetObserver; private readonly Action onComplete; @@ -55,7 +60,7 @@ namespace Avalonia.Animation speedRatio = animation.SpeedRatio; delayFC = ((animation.Delay.Ticks / Timing.FrameTick.Ticks) * speedRatio); durationFC = ((animation.Duration.Ticks / Timing.FrameTick.Ticks) * speedRatio); - delayBetweenIterations = animation.DelayBetweenRepeats; + delayBetweenIterations = animation.DelayBetweenIterations; switch (animation.RepeatCount.RepeatType) { @@ -72,15 +77,15 @@ namespace Avalonia.Animation } animationDirection = animation.PlaybackDirection; - fillMode = animation.FillMode; + fillMode = animation.FillMode; this.onComplete = onComplete; } - public void Step(PlayState playState, long frameTick, Func Interpolator) + public void Step(long frameTick, Func Interpolator) { try { - InternalStep(playState, frameTick, Interpolator); + InternalStep(frameTick, Interpolator); } catch (Exception e) { @@ -107,8 +112,31 @@ namespace Avalonia.Animation targetObserver.OnNext(lastInterpValue); } - private void InternalStep(PlayState playState, long frameTick, Func Interpolator) + private void InternalStep(long time, Func Interpolator) { + if (Timing.GlobalPlayState == PlayState.Stop || targetControl.PlayState == PlayState.Stop) + DoComplete(); + + if (!previousClock.HasValue) + { + previousClock = time; + internalClock = 0; + } + else + { + if (Timing.GlobalPlayState == PlayState.Pause || targetControl.PlayState == PlayState.Pause) + { + previousClock = time; + return; + } + var delta = time - previousClock; + internalClock += delta; + previousClock = time; + } + + // currentDiscreteTime = internalClock.Value; + currentDiscreteTime++; + if (!gotFirstKFValue) { firstKFValue = (T)parent.First().Value; @@ -117,42 +145,23 @@ namespace Avalonia.Animation if (!gotFirstFrameCount) { - firstFrameCount = frameTick; + firstFrameCount = currentDiscreteTime; gotFirstFrameCount = true; } if (isDisposed) throw new InvalidProgramException("This KeyFrames Animation is already disposed."); - if (playState == PlayState.Stop) - DoComplete(); - - // Save state and pause the machine - // if (playState == PlayState.Pause && currentState != KeyFramesStates.Pause) - // { - // savedState = currentState; - // currentState = KeyFramesStates.Pause; - // } - - // // Resume the previous state - // if (playState != PlayState.Pause && currentState == KeyFramesStates.Pause) - // currentState = savedState; - // get the time with the initial fc as point of origin. - double t = (frameTick - firstFrameCount); + double t = (currentDiscreteTime - firstFrameCount); // check if t is within the zeroth iteration - if (t <= (delayFC + durationFC)) - { - currentIteration = 0; - t = t % (delayFC + durationFC + 1); - } - else - { - var totalDur = (double)((delayBetweenIterations ? delayFC : 0) + durationFC + 1); - currentIteration = Math.Floor(t / totalDur); - t = t % totalDur; - } + + double delayEndpoint = delayFC; + double iterationEndpoint = delayEndpoint + durationFC; + + currentIteration = Math.Floor(t / iterationEndpoint); + t = t % iterationEndpoint; // check if it's over the repeat count if (currentIteration > (repeatCount - 1) && !isLooping) @@ -166,19 +175,17 @@ namespace Avalonia.Animation animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : animationDirection == PlaybackDirection.Reverse ? true : false; - double delayEndpoint = delayFC; - double iterationEndpoint = delayEndpoint + durationFC; - if (delayFC > 0 & t >= 0 & t <= delayEndpoint) + if (delayFC > 0 & t <= delayEndpoint) { - if (currentIteration == 0 || delayBetweenIterations) + if (currentIteration == 0) DoDelay(); - } - else if (t >= delayEndpoint & t <= iterationEndpoint) + else if (t > delayEndpoint & t < iterationEndpoint) { - var interpVal = t / durationFC; - + double k = t - delayFC; + var interpVal = k / (double)durationFC; + if (isCurIterReverse) interpVal = 1 - interpVal; @@ -187,7 +194,7 @@ namespace Avalonia.Animation lastInterpValue = Interpolator(easedTime, neutralValue); targetObserver.OnNext(lastInterpValue); } - else if (t > iterationEndpoint & (currentIteration + 1 > repeatCount & !isLooping)) + else if (t > iterationEndpoint && !isLooping) { DoComplete(); } @@ -198,7 +205,6 @@ namespace Avalonia.Animation targetObserver = observer; return this; } - public void Dispose() { unsubscribe = true; diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 607ccee947..a8b5ce7a27 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -21,7 +21,7 @@ namespace Avalonia.Animation /// private readonly SortedList _convertedKeyframes = new SortedList(); - private bool _isVerfifiedAndConverted; + private bool isVerfifiedAndConverted; /// /// Gets or sets the target property for the keyframe. @@ -31,18 +31,17 @@ namespace Avalonia.Animation public Animator() { // Invalidate keyframes when changed. - this.CollectionChanged += delegate { _isVerfifiedAndConverted = false; }; + this.CollectionChanged += delegate { isVerfifiedAndConverted = false; }; } /// - public virtual IDisposable Apply(Animation animation, Animatable control, IObservable obsMatch, Action onComplete) + public virtual IDisposable Apply(Animation animation, Animatable control, IObservable Match, Action onComplete) { - if (!_isVerfifiedAndConverted) + if (!isVerfifiedAndConverted) VerifyConvertKeyFrames(); - return obsMatch - // Ignore triggers when global timers are paused. - .Where(p => p && Timing.GetGlobalPlayState() != PlayState.Pause) + return Match + .Where(p => p) .Subscribe(_ => { var timerObs = RunKeyFrames(animation, control, onComplete); @@ -101,9 +100,9 @@ namespace Avalonia.Animation { var stateMachine = new AnimatorStateMachine(animation, control, this, onComplete); - Timing.AnimationStateTimer + Timing.AnimationsTimer .TakeWhile(_ => !stateMachine.unsubscribe) - .Subscribe(p => stateMachine.Step(p.Item1, p.Item2, DoInterpolation)); + .Subscribe(p => stateMachine.Step(p, DoInterpolation)); return control.Bind((AvaloniaProperty)Property, stateMachine, BindingPriority.Animation); } @@ -124,7 +123,7 @@ namespace Avalonia.Animation } AddNeutralKeyFramesIfNeeded(); - _isVerfifiedAndConverted = true; + isVerfifiedAndConverted = true; } @@ -133,7 +132,7 @@ namespace Avalonia.Animation bool hasStartKey, hasEndKey; hasStartKey = hasEndKey = false; - // Make start and end keyframe mandatory. + // Check if there's start and end keyframes. foreach (var converted in _convertedKeyframes.Keys) { if (DoubleUtils.AboutEqual(converted, 0.0)) diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index fb61e15f05..c6def06b15 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -16,16 +16,18 @@ namespace Avalonia.Animation public static class Timing { static long _tickStartTimeStamp; - static PlayState _globalState = PlayState.Run; static long TicksPerFrame = Stopwatch.Frequency / FramesPerSecond; + /// + /// Gets or sets the animation play state for all animations + /// + public static PlayState GlobalPlayState { get; set; } = PlayState.Run; /// /// The number of frames per second. /// public const int FramesPerSecond = 60; - /// /// The time span of each frame. /// @@ -36,45 +38,20 @@ namespace Avalonia.Animation /// static Timing() { - _tickStartTimeStamp = Stopwatch.GetTimestamp(); var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); - - AnimationStateTimer = globalTimer + AnimationsTimer = globalTimer .Select(_ => { - return (_globalState, (Stopwatch.GetTimestamp() - _tickStartTimeStamp) - / TicksPerFrame); + return (Stopwatch.GetTimestamp() - _tickStartTimeStamp) + / TicksPerFrame * 2; }) .Publish() .RefCount(); - - TransitionsTimer = globalTimer - .Select(p => p) - .Publish() - .RefCount(); - } - - - /// - /// Sets the animation play state for all animations - /// - public static void SetGlobalPlayState(PlayState playState) - { - Dispatcher.UIThread.VerifyAccess(); - _globalState = playState; } - /// - /// Gets the animation play state for all animations - /// - public static PlayState GetGlobalPlayState() - { - Dispatcher.UIThread.VerifyAccess(); - return _globalState; - } /// /// Gets the animation timer. @@ -84,21 +61,7 @@ namespace Avalonia.Animation /// defined in . /// The parameter passed to a subsciber is the current playstate of the animation. /// - internal static IObservable<(PlayState, long)> AnimationStateTimer - { - get; - } - - /// - /// Gets the transitions timer. - /// - /// - /// The transitions timer increments usually 60 times per second as - /// defined in . - /// The parameter passed to a subsciber is the number of frames since the animation system was - /// initialized. - /// - public static IObservable TransitionsTimer + internal static IObservable AnimationsTimer { get; } @@ -116,10 +79,12 @@ namespace Avalonia.Animation /// public static IObservable GetTransitionsTimer(Animatable control, TimeSpan duration, TimeSpan delay = default(TimeSpan)) { + // TODO: Fix this mess. var _duration = (duration.Ticks / FrameTick.Ticks); - var endTime = _duration; + long? endTime = ((Stopwatch.GetTimestamp() - _tickStartTimeStamp) + / TicksPerFrame) + _duration; - return TransitionsTimer + return AnimationsTimer .TakeWhile(x => x < endTime) .Select(x => (double)x / _duration) .StartWith(0.0) From dc4c7cf4ca66e3b59580fc09e51cb40f57130e29 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Sun, 12 Aug 2018 13:32:55 +0800 Subject: [PATCH 17/80] Make the algorithm use TimeSpans directly instead of converting to quantized framecounts to avoid/reduce quantization errors in interpolation. --- .../AnimatorStateMachine`1.cs | 81 +++++++++---------- src/Avalonia.Animation/Timing.cs | 30 +++---- 2 files changed, 50 insertions(+), 61 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index 47bfa1c321..e5a6864899 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -13,11 +13,8 @@ namespace Avalonia.Animation T lastInterpValue; T firstKFValue; - private double delayFC; - private double durationFC; private long repeatCount; private double currentIteration; - private long firstFrameCount; private bool isLooping; private bool isRepeating; @@ -34,10 +31,11 @@ namespace Avalonia.Animation internal bool unsubscribe; private bool isDisposed; - private long? internalClock; - - private long? previousClock = null; - private long currentDiscreteTime; + private TimeSpan delayFC; + private TimeSpan durationFC; + private TimeSpan firstFrameCount; + private TimeSpan internalClock; + private TimeSpan? previousClock; private Easings.Easing EaseFunc; private IObserver targetObserver; @@ -58,8 +56,10 @@ namespace Avalonia.Animation neutralValue = (T)targetControl.GetValue(parent.Property); speedRatio = animation.SpeedRatio; - delayFC = ((animation.Delay.Ticks / Timing.FrameTick.Ticks) * speedRatio); - durationFC = ((animation.Duration.Ticks / Timing.FrameTick.Ticks) * speedRatio); + + delayFC = animation.Delay; + durationFC = animation.Duration; + delayBetweenIterations = animation.DelayBetweenIterations; switch (animation.RepeatCount.RepeatType) @@ -81,7 +81,7 @@ namespace Avalonia.Animation this.onComplete = onComplete; } - public void Step(long frameTick, Func Interpolator) + public void Step(TimeSpan frameTick, Func Interpolator) { try { @@ -112,31 +112,28 @@ namespace Avalonia.Animation targetObserver.OnNext(lastInterpValue); } - private void InternalStep(long time, Func Interpolator) + private void DoPlayStatesAndTime(TimeSpan systemTime) { if (Timing.GlobalPlayState == PlayState.Stop || targetControl.PlayState == PlayState.Stop) DoComplete(); if (!previousClock.HasValue) { - previousClock = time; - internalClock = 0; + previousClock = systemTime; + internalClock = TimeSpan.Zero; } else { if (Timing.GlobalPlayState == PlayState.Pause || targetControl.PlayState == PlayState.Pause) { - previousClock = time; + previousClock = systemTime; return; } - var delta = time - previousClock; - internalClock += delta; - previousClock = time; + var delta = systemTime - previousClock; + internalClock += delta.Value; + previousClock = systemTime; } - // currentDiscreteTime = internalClock.Value; - currentDiscreteTime++; - if (!gotFirstKFValue) { firstKFValue = (T)parent.First().Value; @@ -145,47 +142,47 @@ namespace Avalonia.Animation if (!gotFirstFrameCount) { - firstFrameCount = currentDiscreteTime; + firstFrameCount = internalClock; gotFirstFrameCount = true; } + } + + private void InternalStep(TimeSpan systemTime, Func Interpolator) + { + DoPlayStatesAndTime(systemTime); if (isDisposed) throw new InvalidProgramException("This KeyFrames Animation is already disposed."); - // get the time with the initial fc as point of origin. - double t = (currentDiscreteTime - firstFrameCount); - - // check if t is within the zeroth iteration + var t = internalClock - firstFrameCount; - double delayEndpoint = delayFC; - double iterationEndpoint = delayEndpoint + durationFC; + var delayEndpoint = delayFC; + var iterationEndpoint = delayEndpoint + durationFC; - currentIteration = Math.Floor(t / iterationEndpoint); - t = t % iterationEndpoint; + currentIteration = (int)Math.Floor((double)t.Ticks / iterationEndpoint.Ticks); + t = TimeSpan.FromTicks(t.Ticks % iterationEndpoint.Ticks); - // check if it's over the repeat count if (currentIteration > (repeatCount - 1) && !isLooping) - { DoComplete(); - } - // check if the current iteration should be reversed or not. + if (t > iterationEndpoint & !isLooping) + DoComplete(); + bool isCurIterReverse = animationDirection == PlaybackDirection.Normal ? false : animationDirection == PlaybackDirection.Alternate ? (currentIteration % 2 == 0) ? false : true : animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : animationDirection == PlaybackDirection.Reverse ? true : false; - - if (delayFC > 0 & t <= delayEndpoint) + if (delayFC > TimeSpan.Zero & t < delayEndpoint) { if (currentIteration == 0) DoDelay(); } - else if (t > delayEndpoint & t < iterationEndpoint) + else if (t >= delayEndpoint & t <= iterationEndpoint) { - double k = t - delayFC; - var interpVal = k / (double)durationFC; - + var k = t - delayFC; + var interpVal = (double)k.Ticks / durationFC.Ticks; + if (isCurIterReverse) interpVal = 1 - interpVal; @@ -194,10 +191,7 @@ namespace Avalonia.Animation lastInterpValue = Interpolator(easedTime, neutralValue); targetObserver.OnNext(lastInterpValue); } - else if (t > iterationEndpoint && !isLooping) - { - DoComplete(); - } + } public IDisposable Subscribe(IObserver observer) @@ -205,6 +199,7 @@ namespace Avalonia.Animation targetObserver = observer; return this; } + public void Dispose() { unsubscribe = true; diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index c6def06b15..575cedc620 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -15,9 +15,6 @@ namespace Avalonia.Animation /// public static class Timing { - static long _tickStartTimeStamp; - static long TicksPerFrame = Stopwatch.Frequency / FramesPerSecond; - /// /// Gets or sets the animation play state for all animations /// @@ -37,22 +34,18 @@ namespace Avalonia.Animation /// Initializes static members of the class. /// static Timing() - { - _tickStartTimeStamp = Stopwatch.GetTimestamp(); - + { var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); AnimationsTimer = globalTimer .Select(_ => { - return (Stopwatch.GetTimestamp() - _tickStartTimeStamp) - / TicksPerFrame * 2; + return TimeSpan.FromMilliseconds(Environment.TickCount); }) .Publish() .RefCount(); } - /// /// Gets the animation timer. /// @@ -61,7 +54,7 @@ namespace Avalonia.Animation /// defined in . /// The parameter passed to a subsciber is the current playstate of the animation. /// - internal static IObservable AnimationsTimer + internal static IObservable AnimationsTimer { get; } @@ -80,15 +73,16 @@ namespace Avalonia.Animation public static IObservable GetTransitionsTimer(Animatable control, TimeSpan duration, TimeSpan delay = default(TimeSpan)) { // TODO: Fix this mess. - var _duration = (duration.Ticks / FrameTick.Ticks); - long? endTime = ((Stopwatch.GetTimestamp() - _tickStartTimeStamp) - / TicksPerFrame) + _duration; + // var _duration = (duration.Ticks / FrameTick.Ticks); + // long? endTime = ((Stopwatch.GetTimestamp() - _tickStartTimeStamp) + // / TicksPerFrame) + _duration; - return AnimationsTimer - .TakeWhile(x => x < endTime) - .Select(x => (double)x / _duration) - .StartWith(0.0) - .Concat(Observable.Return(1.0)); + // return AnimationsTimer + // .TakeWhile(x => x < endTime) + // .Select(x => (double)x / _duration) + // .StartWith(0.0) + // .Concat(Observable.Return(1.0)); + return Observable.Empty(); } } } \ No newline at end of file From b6e6b7db48c8c279b74d8b0b8a20d1dc1316970d Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 14 Aug 2018 15:38:55 +0800 Subject: [PATCH 18/80] Fix Delay and Iteration Delay behaviors. AnimatorStateMachine is functionally complete. --- .../AnimatorStateMachine`1.cs | 104 +++++++++++------- 1 file changed, 65 insertions(+), 39 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimatorStateMachine`1.cs index e5a6864899..0a785ab496 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimatorStateMachine`1.cs @@ -6,7 +6,7 @@ using Avalonia.Data; namespace Avalonia.Animation { /// - /// Provides statefulness for an iteration of a keyframe animation. + /// Provides statefulness for keyframe animations. /// internal class AnimatorStateMachine : IObservable, IDisposable { @@ -17,10 +17,9 @@ namespace Avalonia.Animation private double currentIteration; private bool isLooping; - private bool isRepeating; private bool gotFirstKFValue; private bool gotFirstFrameCount; - private bool delayBetweenIterations; + private bool iterationDelay; private FillMode fillMode; private PlaybackDirection animationDirection; @@ -31,36 +30,34 @@ namespace Avalonia.Animation internal bool unsubscribe; private bool isDisposed; - private TimeSpan delayFC; - private TimeSpan durationFC; + private TimeSpan delay; + private TimeSpan duration; private TimeSpan firstFrameCount; private TimeSpan internalClock; private TimeSpan? previousClock; - private Easings.Easing EaseFunc; + private Easings.Easing easeFunc; private IObserver targetObserver; - private readonly Action onComplete; + private readonly Action onCompleteAction; - public AnimatorStateMachine(Animation animation, Animatable control, Animator animator, Action onComplete) + public AnimatorStateMachine(Animation animation, Animatable control, Animator animator, Action OnComplete) { - if (animation.SpeedRatio <= 0 || DoubleUtils.AboutEqual(animation.SpeedRatio, 0)) throw new InvalidOperationException("Speed ratio cannot be negative or zero."); if (animation.Duration.TotalSeconds <= 0 || DoubleUtils.AboutEqual(animation.Duration.TotalSeconds, 0)) - throw new InvalidOperationException("Animation duration cannot be negative or zero."); - + throw new InvalidOperationException("Duration cannot be negative or zero."); + parent = animator; - EaseFunc = animation.Easing; + easeFunc = animation.Easing; targetControl = control; neutralValue = (T)targetControl.GetValue(parent.Property); speedRatio = animation.SpeedRatio; - delayFC = animation.Delay; - durationFC = animation.Duration; - - delayBetweenIterations = animation.DelayBetweenIterations; + delay = animation.Delay; + duration = animation.Duration; + iterationDelay = animation.DelayBetweenIterations; switch (animation.RepeatCount.RepeatType) { @@ -71,14 +68,13 @@ namespace Avalonia.Animation isLooping = true; break; case RepeatType.Repeat: - isRepeating = true; repeatCount = (long)animation.RepeatCount.Value; break; } animationDirection = animation.PlaybackDirection; fillMode = animation.FillMode; - this.onComplete = onComplete; + onCompleteAction = OnComplete; } public void Step(TimeSpan frameTick, Func Interpolator) @@ -99,7 +95,7 @@ namespace Avalonia.Animation targetControl.SetValue(parent.Property, lastInterpValue, BindingPriority.LocalValue); targetObserver.OnCompleted(); - onComplete?.Invoke(); + onCompleteAction?.Invoke(); Dispose(); } @@ -154,44 +150,74 @@ namespace Avalonia.Animation if (isDisposed) throw new InvalidProgramException("This KeyFrames Animation is already disposed."); - var t = internalClock - firstFrameCount; + var time = internalClock - firstFrameCount; + var delayEndpoint = delay; + var iterationEndpoint = delayEndpoint + duration; - var delayEndpoint = delayFC; - var iterationEndpoint = delayEndpoint + durationFC; + //determine if time is currently in the first iteration. + if (time >= TimeSpan.Zero & time <= iterationEndpoint) + { + currentIteration = 1; + } + else if (time > iterationEndpoint) + { + //Subtract first iteration to properly get the subsequent iteration time + time -= iterationEndpoint; - currentIteration = (int)Math.Floor((double)t.Ticks / iterationEndpoint.Ticks); - t = TimeSpan.FromTicks(t.Ticks % iterationEndpoint.Ticks); + if (!iterationDelay & delayEndpoint > TimeSpan.Zero) + { + delayEndpoint = TimeSpan.Zero; + iterationEndpoint = duration; + } - if (currentIteration > (repeatCount - 1) && !isLooping) - DoComplete(); + //Calculate the current iteration number + currentIteration = (int)Math.Floor((double)time.Ticks / iterationEndpoint.Ticks) + 2; + } + else + { + previousClock = systemTime; + return; + } - if (t > iterationEndpoint & !isLooping) - DoComplete(); - + time = TimeSpan.FromTicks(time.Ticks % iterationEndpoint.Ticks); + + if (!isLooping) + { + if (currentIteration > repeatCount) + DoComplete(); + + if (time > iterationEndpoint) + DoComplete(); + } + + // Determine if the current iteration should have its normalized time inverted. bool isCurIterReverse = animationDirection == PlaybackDirection.Normal ? false : animationDirection == PlaybackDirection.Alternate ? (currentIteration % 2 == 0) ? false : true : animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : animationDirection == PlaybackDirection.Reverse ? true : false; - if (delayFC > TimeSpan.Zero & t < delayEndpoint) + if (delayEndpoint > TimeSpan.Zero & time < delayEndpoint) { - if (currentIteration == 0) - DoDelay(); + DoDelay(); } - else if (t >= delayEndpoint & t <= iterationEndpoint) + else { - var k = t - delayFC; - var interpVal = (double)k.Ticks / durationFC.Ticks; + // Offset the delay time + time -= delayEndpoint; + iterationEndpoint -= delayEndpoint; + + // Normalize time + var interpVal = (double)time.Ticks / iterationEndpoint.Ticks; if (isCurIterReverse) interpVal = 1 - interpVal; - var easedTime = EaseFunc.Ease(interpVal); - + // Ease and interpolate + var easedTime = easeFunc.Ease(interpVal); lastInterpValue = Interpolator(easedTime, neutralValue); + targetObserver.OnNext(lastInterpValue); } - } public IDisposable Subscribe(IObserver observer) @@ -199,7 +225,7 @@ namespace Avalonia.Animation targetObserver = observer; return this; } - + public void Dispose() { unsubscribe = true; From 5d49c5f969be55d34408010aed3d1d54a69ed1fc Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 14 Aug 2018 23:27:02 +0800 Subject: [PATCH 19/80] Rename AnimatorStateMachine to AnimationsEngine to properly reflect the functions of the new algorithm. --- .../{AnimatorStateMachine`1.cs => AnimationsEngine`1.cs} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename src/Avalonia.Animation/{AnimatorStateMachine`1.cs => AnimationsEngine`1.cs} (96%) diff --git a/src/Avalonia.Animation/AnimatorStateMachine`1.cs b/src/Avalonia.Animation/AnimationsEngine`1.cs similarity index 96% rename from src/Avalonia.Animation/AnimatorStateMachine`1.cs rename to src/Avalonia.Animation/AnimationsEngine`1.cs index 0a785ab496..169f0a7ae0 100644 --- a/src/Avalonia.Animation/AnimatorStateMachine`1.cs +++ b/src/Avalonia.Animation/AnimationsEngine`1.cs @@ -6,9 +6,10 @@ using Avalonia.Data; namespace Avalonia.Animation { /// - /// Provides statefulness for keyframe animations. + /// Handles interpolatoin and time-related functions + /// for keyframe animations. /// - internal class AnimatorStateMachine : IObservable, IDisposable + internal class AnimationsEngine : IObservable, IDisposable { T lastInterpValue; T firstKFValue; @@ -40,7 +41,7 @@ namespace Avalonia.Animation private IObserver targetObserver; private readonly Action onCompleteAction; - public AnimatorStateMachine(Animation animation, Animatable control, Animator animator, Action OnComplete) + public AnimationsEngine(Animation animation, Animatable control, Animator animator, Action OnComplete) { if (animation.SpeedRatio <= 0 || DoubleUtils.AboutEqual(animation.SpeedRatio, 0)) throw new InvalidOperationException("Speed ratio cannot be negative or zero."); From 3d7516cc0c1f82fc7d703f4c3d9add31dc9a0242 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 14 Aug 2018 23:54:48 +0800 Subject: [PATCH 20/80] Implement a new timing engine for Transitions. Transtions are fixed now.Move out some stuff from Timing.cs. --- .../ViewModels/AnimationsPageViewModel.cs | 6 +- src/Avalonia.Animation/Animation.cs | 5 +- src/Avalonia.Animation/AnimationsEngine`1.cs | 4 +- src/Avalonia.Animation/Animator`1.cs | 2 +- src/Avalonia.Animation/Timing.cs | 38 +----------- src/Avalonia.Animation/Transition`1.cs | 5 +- src/Avalonia.Animation/TransitionsEngine.cs | 58 +++++++++++++++++++ 7 files changed, 75 insertions(+), 43 deletions(-) create mode 100644 src/Avalonia.Animation/TransitionsEngine.cs diff --git a/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs b/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs index c76d4db513..f724baf3c6 100644 --- a/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs +++ b/samples/RenderDemo/ViewModels/AnimationsPageViewModel.cs @@ -15,16 +15,16 @@ namespace RenderDemo.ViewModels void TogglePlayState() { - switch (Timing.GlobalPlayState) + switch (Animation.GlobalPlayState) { case PlayState.Run: PlayStateText = "Resume all animations"; - Timing.GlobalPlayState = PlayState.Pause; + Animation.GlobalPlayState = PlayState.Pause; break; case PlayState.Pause: PlayStateText = "Pause all animations"; - Timing.GlobalPlayState = PlayState.Run; + Animation.GlobalPlayState = PlayState.Run; break; } } diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index da2fc75c0b..204cc9d04d 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -21,6 +21,10 @@ namespace Avalonia.Animation /// public class Animation : AvaloniaList, IAnimation { + /// + /// Gets or sets the animation play state for all animations + /// + public static PlayState GlobalPlayState { get; set; } = PlayState.Run; public AvaloniaList _animators { get; set; } = new AvaloniaList(); @@ -73,7 +77,6 @@ namespace Avalonia.Animation /// public bool DelayBetweenIterations { get; set; } - private readonly static List<(Func Condition, Type Animator)> Animators = new List<(Func, Type)> { ( prop => typeof(double).IsAssignableFrom(prop.PropertyType), typeof(DoubleAnimator) ) diff --git a/src/Avalonia.Animation/AnimationsEngine`1.cs b/src/Avalonia.Animation/AnimationsEngine`1.cs index 169f0a7ae0..cccb3098c0 100644 --- a/src/Avalonia.Animation/AnimationsEngine`1.cs +++ b/src/Avalonia.Animation/AnimationsEngine`1.cs @@ -111,7 +111,7 @@ namespace Avalonia.Animation private void DoPlayStatesAndTime(TimeSpan systemTime) { - if (Timing.GlobalPlayState == PlayState.Stop || targetControl.PlayState == PlayState.Stop) + if (Animation.GlobalPlayState == PlayState.Stop || targetControl.PlayState == PlayState.Stop) DoComplete(); if (!previousClock.HasValue) @@ -121,7 +121,7 @@ namespace Avalonia.Animation } else { - if (Timing.GlobalPlayState == PlayState.Pause || targetControl.PlayState == PlayState.Pause) + if (Animation.GlobalPlayState == PlayState.Pause || targetControl.PlayState == PlayState.Pause) { previousClock = systemTime; return; diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index a8b5ce7a27..8079ac69b5 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -98,7 +98,7 @@ namespace Avalonia.Animation /// private IDisposable RunKeyFrames(Animation animation, Animatable control, Action onComplete) { - var stateMachine = new AnimatorStateMachine(animation, control, this, onComplete); + var stateMachine = new AnimationsEngine(animation, control, this, onComplete); Timing.AnimationsTimer .TakeWhile(_ => !stateMachine.unsubscribe) diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index 575cedc620..b8282c05d0 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -15,11 +15,6 @@ namespace Avalonia.Animation /// public static class Timing { - /// - /// Gets or sets the animation play state for all animations - /// - public static PlayState GlobalPlayState { get; set; } = PlayState.Run; - /// /// The number of frames per second. /// @@ -38,14 +33,13 @@ namespace Avalonia.Animation var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); AnimationsTimer = globalTimer - .Select(_ => - { - return TimeSpan.FromMilliseconds(Environment.TickCount); - }) + .Select(_ => GetTickCount()) .Publish() .RefCount(); } + internal static TimeSpan GetTickCount() => TimeSpan.FromMilliseconds(Environment.TickCount); + /// /// Gets the animation timer. /// @@ -58,31 +52,5 @@ namespace Avalonia.Animation { get; } - - /// - /// Gets a timer that fires every frame for the specified duration with delay. - /// - /// - /// An observable that notifies the subscriber of the progress along the transition. - /// - /// - /// The parameter passed to the subscriber is the progress along the transition, with - /// 0 being the start and 1 being the end. The observable is guaranteed to fire 0 - /// immediately on subscribe and 1 at the end of the duration. - /// - public static IObservable GetTransitionsTimer(Animatable control, TimeSpan duration, TimeSpan delay = default(TimeSpan)) - { - // TODO: Fix this mess. - // var _duration = (duration.Ticks / FrameTick.Ticks); - // long? endTime = ((Stopwatch.GetTimestamp() - _tickStartTimeStamp) - // / TicksPerFrame) + _duration; - - // return AnimationsTimer - // .TakeWhile(x => x < endTime) - // .Select(x => (double)x / _duration) - // .StartWith(0.0) - // .Concat(Observable.Return(1.0)); - return Observable.Empty(); - } } } \ No newline at end of file diff --git a/src/Avalonia.Animation/Transition`1.cs b/src/Avalonia.Animation/Transition`1.cs index c097b930a5..346c328809 100644 --- a/src/Avalonia.Animation/Transition`1.cs +++ b/src/Avalonia.Animation/Transition`1.cs @@ -5,6 +5,7 @@ using Avalonia.Metadata; using System; using System.Reactive.Linq; using Avalonia.Animation.Easings; +using Avalonia.Animation.Utils; namespace Avalonia.Animation { @@ -51,8 +52,10 @@ namespace Avalonia.Animation /// public virtual IDisposable Apply(Animatable control, object oldValue, object newValue) { - var transition = DoTransition(Timing.GetTransitionsTimer(control, Duration, TimeSpan.Zero), (T)oldValue, (T)newValue); + var transition = DoTransition(new TransitionsEngine(Duration), (T)oldValue, (T)newValue); return control.Bind((AvaloniaProperty)Property, transition, Data.BindingPriority.Animation); } + + } } \ No newline at end of file diff --git a/src/Avalonia.Animation/TransitionsEngine.cs b/src/Avalonia.Animation/TransitionsEngine.cs new file mode 100644 index 0000000000..4d52b2bd48 --- /dev/null +++ b/src/Avalonia.Animation/TransitionsEngine.cs @@ -0,0 +1,58 @@ +// 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.Metadata; +using System; +using System.Reactive.Linq; +using Avalonia.Animation.Easings; +using Avalonia.Animation.Utils; + +namespace Avalonia.Animation +{ + public class TransitionsEngine : IObservable, IDisposable + { + private IObserver observer; + private IDisposable timerSubscription; + private readonly TimeSpan startTime; + private readonly TimeSpan duration; + + public TransitionsEngine(TimeSpan Duration) + { + startTime = Timing.GetTickCount(); + duration = Duration; + + timerSubscription = Timing + .AnimationsTimer + .Subscribe(t => TimerTick(t)); + } + + private void TimerTick(TimeSpan t) + { + var interpVal = (double)(t.Ticks - startTime.Ticks) / duration.Ticks; + + if (interpVal > 1d + || interpVal < 0d) + { + this.Dispose(); + return; + } + + observer?.OnNext(interpVal); + } + + public void Dispose() + { + timerSubscription?.Dispose(); + observer?.OnCompleted(); + } + + public IDisposable Subscribe(IObserver Observer) + { + if (Observer is null) + throw new InvalidProgramException("Can only set the subscription once."); + + observer = Observer; + return this; + } + } +} \ No newline at end of file From 799b498afcfb416fa5d2535bd282c48d19d4b0d9 Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Sat, 25 Aug 2018 16:29:37 +0100 Subject: [PATCH 21/80] Cleaning up Themes. Renamed ErrorBrushLight to ErrorLightBrush. ListBoxItem - Removed hardcoded Colors/Brushes, added additional sytling. Removed ListBoxItem Style Selector from AutoCompleteBox (inherrited). CalendarButton - Removed hardcoded Colors/Brushes. DropDownItem - Removed hardcoded Colors/Brushes, added additional sytling. ScrollBar - Removed hardcoded Colors/Brushes. Added ListBox to ControlCatalog. Slider bug fix (hopefully). --- samples/ControlCatalog/ControlCatalog.csproj | 9 +++ samples/ControlCatalog/MainView.xaml | 3 +- samples/ControlCatalog/Pages/ListBoxPage.xaml | 13 ++++ .../ControlCatalog/Pages/ListBoxPage.xaml.cs | 25 ++++++++ .../Pages/NumericUpDownPage.xaml | 4 +- src/Avalonia.Controls/Slider.cs | 8 +-- .../Accents/BaseLight.xaml | 60 +++++++++++++------ .../AutoCompleteBox.xaml | 6 +- .../CalendarButton.xaml | 5 +- .../DataValidationErrors.xaml | 4 +- src/Avalonia.Themes.Default/DropDownItem.xaml | 22 +++++-- src/Avalonia.Themes.Default/ListBoxItem.xaml | 23 ++++++- src/Avalonia.Themes.Default/ScrollBar.xaml | 10 ++-- 13 files changed, 145 insertions(+), 47 deletions(-) create mode 100644 samples/ControlCatalog/Pages/ListBoxPage.xaml create mode 100644 samples/ControlCatalog/Pages/ListBoxPage.xaml.cs diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index dea9b35e24..52f91b1295 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -33,6 +33,15 @@ + + + + MSBuild:Compile + + + MSBuild:Compile + + \ No newline at end of file diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index 87cb5e9c5c..ec3bf799b4 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -20,8 +20,9 @@ + - + diff --git a/samples/ControlCatalog/Pages/ListBoxPage.xaml b/samples/ControlCatalog/Pages/ListBoxPage.xaml new file mode 100644 index 0000000000..3dd8be91c2 --- /dev/null +++ b/samples/ControlCatalog/Pages/ListBoxPage.xaml @@ -0,0 +1,13 @@ + + + ListBox + Hosts a collection of ListBoxItem. + + + + + + diff --git a/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs b/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs new file mode 100644 index 0000000000..dbe6c74800 --- /dev/null +++ b/samples/ControlCatalog/Pages/ListBoxPage.xaml.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ControlCatalog.Pages +{ + public class ListBoxPage : UserControl + { + public ListBoxPage() + { + this.InitializeComponent(); + DataContext = Enumerable.Range(1, 10).Select(i => $"Item {i}" ) + .ToArray(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + } +} diff --git a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml index 305bcd177c..2bb6214b58 100644 --- a/samples/ControlCatalog/Pages/NumericUpDownPage.xaml +++ b/samples/ControlCatalog/Pages/NumericUpDownPage.xaml @@ -14,7 +14,7 @@ AllowSpin: - + ClipValueToMinMax: @@ -77,4 +77,4 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index 31113812d1..32b0a1f259 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -171,11 +171,7 @@ namespace Avalonia.Controls /// Value that want to snap to closest Tick. private void MoveToNextTick(double value) { - double next = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); - if (next != value) - { - Value = next; - } + Value = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); } /// @@ -194,4 +190,4 @@ namespace Avalonia.Controls return value; } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml index 4c85e172ff..afac69c9b3 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml @@ -2,23 +2,49 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"> - #FFFFFFFF - #FFAAAAAA - #FF888888 - #FF333333 - #FFFFFFFF - #FFAAAAAA - #FF888888 - #FF000000 - #FF808080 + + #CC119EDA + #99119EDA + #66119EDA + #33119EDA + + #FFFFFFFF + #FFAAAAAA + #FF888888 + #FF333333 + #FFFFFFFF + #FFAAAAAA + #FF888888 + #FFF0F0F0 + #FFD0D0D0 + #FF808080 + #FF000000 + #FF808080 + + #FF086F9E + #FFFF0000 + #10FF0000 - #FF086F9E - #CC119EDA - #99119EDA - #66119EDA - #33119EDA - Red - #10ff0000 + + + + + + + + + + + + + + + + + + + + 2 0.5 @@ -27,4 +53,4 @@ 12 16 - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/AutoCompleteBox.xaml b/src/Avalonia.Themes.Default/AutoCompleteBox.xaml index 6a9af487cb..11d8a344d9 100644 --- a/src/Avalonia.Themes.Default/AutoCompleteBox.xaml +++ b/src/Avalonia.Themes.Default/AutoCompleteBox.xaml @@ -36,8 +36,4 @@ - - - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/CalendarButton.xaml b/src/Avalonia.Themes.Default/CalendarButton.xaml index 84969c135f..b70740e0c8 100644 --- a/src/Avalonia.Themes.Default/CalendarButton.xaml +++ b/src/Avalonia.Themes.Default/CalendarButton.xaml @@ -7,6 +7,7 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/DataValidationErrors.xaml b/src/Avalonia.Themes.Default/DataValidationErrors.xaml index f7f28d90d0..be45dfd1b9 100644 --- a/src/Avalonia.Themes.Default/DataValidationErrors.xaml +++ b/src/Avalonia.Themes.Default/DataValidationErrors.xaml @@ -24,7 +24,7 @@ Background="#00FFFFFF"> @@ -35,4 +35,4 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/DropDownItem.xaml b/src/Avalonia.Themes.Default/DropDownItem.xaml index 257030d8af..f52608c0a8 100644 --- a/src/Avalonia.Themes.Default/DropDownItem.xaml +++ b/src/Avalonia.Themes.Default/DropDownItem.xaml @@ -18,10 +18,24 @@ + + + - + + + + - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/ListBoxItem.xaml b/src/Avalonia.Themes.Default/ListBoxItem.xaml index fc2600c1a9..19a6e3d4ec 100644 --- a/src/Avalonia.Themes.Default/ListBoxItem.xaml +++ b/src/Avalonia.Themes.Default/ListBoxItem.xaml @@ -1,6 +1,9 @@ + + + + + + + + - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/ScrollBar.xaml b/src/Avalonia.Themes.Default/ScrollBar.xaml index b24c863be9..ef57474eaf 100644 --- a/src/Avalonia.Themes.Default/ScrollBar.xaml +++ b/src/Avalonia.Themes.Default/ScrollBar.xaml @@ -10,7 +10,7 @@ Grid.Column="0"> + Fill="{DynamicResource ThemeForegroundLightBrush}" /> + Fill="{DynamicResource ThemeForegroundLightBrush}" /> @@ -61,7 +61,7 @@ Grid.Column="0"> + Fill="{DynamicResource ThemeForegroundLightBrush}" /> + Fill="{DynamicResource ThemeForegroundLightBrush}" /> @@ -124,4 +124,4 @@ - \ No newline at end of file + From f7e31e58c09d6c3efb281f96b8a7b70e12cbf618 Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Sat, 25 Aug 2018 16:32:53 +0100 Subject: [PATCH 22/80] Removed junk. --- samples/ControlCatalog/ControlCatalog.csproj | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/samples/ControlCatalog/ControlCatalog.csproj b/samples/ControlCatalog/ControlCatalog.csproj index 52f91b1295..61f2443eb7 100644 --- a/samples/ControlCatalog/ControlCatalog.csproj +++ b/samples/ControlCatalog/ControlCatalog.csproj @@ -33,15 +33,6 @@ - - - - MSBuild:Compile - - - MSBuild:Compile - - - \ No newline at end of file + From e9cde299bb282db2ea99a7c6e14d9b43f83b2a35 Mon Sep 17 00:00:00 2001 From: Jeffrey Ye Date: Sat, 25 Aug 2018 15:34:52 -0700 Subject: [PATCH 23/80] #1802 add SelectedItemChanged event to TreeView --- .../SelectedItemChangedEventArgs.cs | 36 +++++++++++++++++++ src/Avalonia.Controls/TreeView.cs | 27 ++++++++++++++ .../TreeViewTests.cs | 32 +++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 src/Avalonia.Controls/SelectedItemChangedEventArgs.cs diff --git a/src/Avalonia.Controls/SelectedItemChangedEventArgs.cs b/src/Avalonia.Controls/SelectedItemChangedEventArgs.cs new file mode 100644 index 0000000000..6fb8a2d313 --- /dev/null +++ b/src/Avalonia.Controls/SelectedItemChangedEventArgs.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using Avalonia; +using Avalonia.Interactivity; + +namespace Avalonia.Controls +{ + /// + /// Provides data for the event. + /// + public class SelectedItemChangedEventArgs : RoutedEventArgs + { + /// + /// Initializes a new instance of the class. + /// + /// The event being raised. + /// The items added to the selection. + /// The items removed from the selection. + public SelectedItemChangedEventArgs(RoutedEvent routedEvent, object newItem, object oldItem) + : base(routedEvent) + { + NewItem = newItem; + OldItem = oldItem; + } + + /// + /// Gets the items that were added to the selection. + /// + public object NewItem { get; } + + /// + /// Gets the items that were removed from the selection. + /// + public object OldItem { get; } + } +} diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 2e1c011685..50b45cbb9a 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -32,6 +32,14 @@ namespace Avalonia.Controls o => o.SelectedItem, (o, v) => o.SelectedItem = v); + /// + /// Defines the event. + /// + public static readonly RoutedEvent SelectedItemChangedEvent = + RoutedEvent.Register( + "SelectedItemChanged", + RoutingStrategies.Bubble); + private object _selectedItem; /// @@ -42,6 +50,15 @@ namespace Avalonia.Controls // HACK: Needed or SelectedItem property will not be found in Release build. } + /// + /// Occurs when the control's selection changes. + /// + public event EventHandler SelectedItemChanged + { + add { AddHandler(SelectedItemChangedEvent, value); } + remove { RemoveHandler(SelectedItemChangedEvent, value); } + } + /// /// Gets the for the tree view. /// @@ -75,6 +92,7 @@ namespace Avalonia.Controls MarkContainerSelected(container, false); } + var oldItem = _selectedItem; SetAndRaise(SelectedItemProperty, ref _selectedItem, value); if (_selectedItem != null) @@ -87,6 +105,15 @@ namespace Avalonia.Controls container.BringIntoView(); } } + + if (oldItem != _selectedItem) + { + var changed = new SelectedItemChangedEventArgs( + SelectedItemChangedEvent, + _selectedItem, + oldItem); + RaiseEvent(changed); + } } } diff --git a/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs b/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs index c49c343a45..8295409f7e 100644 --- a/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs @@ -166,6 +166,38 @@ namespace Avalonia.Controls.UnitTests Assert.True(container.IsSelected); } + + [Fact] + public void Setting_SelectedItem_Should_Raise_SelectedItemChanged_Event() + { + var tree = CreateTestTreeData(); + var target = new TreeView + { + Template = CreateTreeViewTemplate(), + Items = tree, + }; + + var visualRoot = new TestRoot(); + visualRoot.Child = target; + + CreateNodeDataTemplate(target); + ApplyTemplates(target); + + var item = tree[0].Children[1].Children[0]; + + var called = false; + target.SelectedItemChanged += (s, e) => + { + Assert.Null(e.OldItem); + Assert.Same(item, e.NewItem); + called = true; + }; + + target.SelectedItem = item; + Assert.True(called); + } + + [Fact] public void LogicalChildren_Should_Be_Set() { From 8087f81ea57ee0b955154a61e3d59550c2a20e40 Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Mon, 27 Aug 2018 02:52:04 +0100 Subject: [PATCH 24/80] Cleaned up resources for CalendarDayButton,CalendarItem,DataValidationErrors,DatePicker,Expander,Slider Typeface - Added Typeface.Default. FormattedTextImpl - Fallback to Typeface.Default for null typeface. --- src/Avalonia.Themes.Default/CalendarDayButton.xaml | 6 +++--- src/Avalonia.Themes.Default/CalendarItem.xaml | 4 ++-- src/Avalonia.Themes.Default/DataValidationErrors.xaml | 2 +- src/Avalonia.Themes.Default/DatePicker.xaml | 8 ++++---- src/Avalonia.Themes.Default/Expander.xaml | 4 ++-- src/Avalonia.Themes.Default/Slider.xaml | 3 ++- src/Avalonia.Visuals/Media/Typeface.cs | 2 ++ src/Skia/Avalonia.Skia/FormattedTextImpl.cs | 7 ++++++- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Avalonia.Themes.Default/CalendarDayButton.xaml b/src/Avalonia.Themes.Default/CalendarDayButton.xaml index ee7afdc73b..4a971ef0cb 100644 --- a/src/Avalonia.Themes.Default/CalendarDayButton.xaml +++ b/src/Avalonia.Themes.Default/CalendarDayButton.xaml @@ -42,7 +42,7 @@ HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" - Fill="#FF000000" + Fill="{DynamicResource ThemeForegroundBrush}" Stretch="Fill" Data="M8.1772461,11.029181 L10.433105,11.029181 L11.700684,12.801641 L12.973633,11.029181 L15.191895,11.029181 L12.844727,13.999395 L15.21875,17.060919 L12.962891,17.060919 L11.673828,15.256231 L10.352539,17.060919 L8.1396484,17.060919 L10.519043,14.042364 z" /> @@ -103,7 +103,7 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/CalendarItem.xaml b/src/Avalonia.Themes.Default/CalendarItem.xaml index 3d3d75a39a..b52b7acf53 100644 --- a/src/Avalonia.Themes.Default/CalendarItem.xaml +++ b/src/Avalonia.Themes.Default/CalendarItem.xaml @@ -153,7 +153,7 @@ @@ -180,4 +180,4 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/DataValidationErrors.xaml b/src/Avalonia.Themes.Default/DataValidationErrors.xaml index be45dfd1b9..16c2d6adef 100644 --- a/src/Avalonia.Themes.Default/DataValidationErrors.xaml +++ b/src/Avalonia.Themes.Default/DataValidationErrors.xaml @@ -21,7 +21,7 @@ + Background="Transparent"> - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/Expander.xaml b/src/Avalonia.Themes.Default/Expander.xaml index 0bea0c9763..d12f704cc4 100644 --- a/src/Avalonia.Themes.Default/Expander.xaml +++ b/src/Avalonia.Themes.Default/Expander.xaml @@ -108,7 +108,7 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/Slider.xaml b/src/Avalonia.Themes.Default/Slider.xaml index 58fd67b2f6..95924b31a1 100644 --- a/src/Avalonia.Themes.Default/Slider.xaml +++ b/src/Avalonia.Themes.Default/Slider.xaml @@ -80,10 +80,11 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Visuals/Media/Typeface.cs b/src/Avalonia.Visuals/Media/Typeface.cs index 40e98d1565..6dde2bb591 100644 --- a/src/Avalonia.Visuals/Media/Typeface.cs +++ b/src/Avalonia.Visuals/Media/Typeface.cs @@ -7,6 +7,8 @@ namespace Avalonia.Media /// public class Typeface { + public static Typeface Default = new Typeface(FontFamily.Default); + /// /// Initializes a new instance of the class. /// diff --git a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs index d835c83aa6..8ad88da7f4 100644 --- a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs +++ b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs @@ -30,6 +30,11 @@ namespace Avalonia.Skia SKTypeface skiaTypeface = TypefaceCache.Default; + if (typeface == null) + { + typeface = Typeface.Default; + } + if (typeface.FontFamily.Key != null) { var typefaces = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(typeface.FontFamily); @@ -723,4 +728,4 @@ namespace Avalonia.Skia } } } -} \ No newline at end of file +} From 0befa22692d1fa32652f621042bc54188a7b5769 Mon Sep 17 00:00:00 2001 From: Nicolas Musset Date: Tue, 28 Aug 2018 21:49:34 +0900 Subject: [PATCH 25/80] Support invoking a task in the dispatcher. --- src/Avalonia.Base/Threading/Dispatcher.cs | 14 ++++++++++++++ src/Avalonia.Base/Threading/IDispatcher.cs | 18 ++++++++++++++++++ .../Avalonia.UnitTests/ImmediateDispatcher.cs | 19 ++++++++++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Base/Threading/Dispatcher.cs b/src/Avalonia.Base/Threading/Dispatcher.cs index aa2a7a7a8e..55a9b6984a 100644 --- a/src/Avalonia.Base/Threading/Dispatcher.cs +++ b/src/Avalonia.Base/Threading/Dispatcher.cs @@ -92,6 +92,20 @@ namespace Avalonia.Threading return _jobRunner.InvokeAsync(function, priority); } + /// + public Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal) + { + Contract.Requires(function != null); + return _jobRunner.InvokeAsync(function, priority).Unwrap(); + } + + /// + public Task InvokeAsync(Func> function, DispatcherPriority priority = DispatcherPriority.Normal) + { + Contract.Requires(function != null); + return _jobRunner.InvokeAsync(function, priority).Unwrap(); + } + /// public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { diff --git a/src/Avalonia.Base/Threading/IDispatcher.cs b/src/Avalonia.Base/Threading/IDispatcher.cs index 1fdc9da5fe..8f46f99283 100644 --- a/src/Avalonia.Base/Threading/IDispatcher.cs +++ b/src/Avalonia.Base/Threading/IDispatcher.cs @@ -40,5 +40,23 @@ namespace Avalonia.Threading /// The method. /// The priority with which to invoke the method. Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal); + + /// + /// Queues the specified work to run on the dispatcher thread and returns a proxy for the + /// task returned by . + /// + /// The work to execute asynchronously. + /// The priority with which to invoke the method. + /// A task that represents a proxy for the task returned by . + Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal); + + /// + /// Queues the specified work to run on the dispatcher thread and returns a proxy for the + /// task returned by . + /// + /// The work to execute asynchronously. + /// The priority with which to invoke the method. + /// A task that represents a proxy for the task returned by . + Task InvokeAsync(Func> function, DispatcherPriority priority = DispatcherPriority.Normal); } } \ No newline at end of file diff --git a/tests/Avalonia.UnitTests/ImmediateDispatcher.cs b/tests/Avalonia.UnitTests/ImmediateDispatcher.cs index 44d8c78054..fac4ee64e7 100644 --- a/tests/Avalonia.UnitTests/ImmediateDispatcher.cs +++ b/tests/Avalonia.UnitTests/ImmediateDispatcher.cs @@ -9,28 +9,45 @@ namespace Avalonia.UnitTests /// public class ImmediateDispatcher : IDispatcher { + /// public bool CheckAccess() { return true; } + /// public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { action(); } + /// public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal) { action(); - return Task.FromResult(null); + return Task.CompletedTask; } + /// public Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal) { var result = function(); return Task.FromResult(result); } + /// + public Task InvokeAsync(Func function, DispatcherPriority priority = DispatcherPriority.Normal) + { + return function(); + } + + /// + public Task InvokeAsync(Func> function, DispatcherPriority priority = DispatcherPriority.Normal) + { + return function(); + } + + /// public void VerifyAccess() { } From a161f6a095eb990b48d9b7173326b6fcd7fceac4 Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Tue, 28 Aug 2018 22:31:46 +0100 Subject: [PATCH 26/80] ScreenPage.cs - Bug fix. TreeViewItem - Added Depth property. BaseLight.xaml - Added InvisibleSelectionColor/Brush. DatePicker.xaml - Improvments. TreeViewItem.xaml - Reworked styling. FormattedTextImpl.cs - Reverted previous changes. --- samples/ControlCatalog/Pages/ScreenPage.cs | 8 +- src/Avalonia.Controls/TreeViewItem.cs | 40 ++++- .../Accents/BaseLight.xaml | 6 +- src/Avalonia.Themes.Default/DatePicker.xaml | 27 +-- src/Avalonia.Themes.Default/TreeViewItem.xaml | 154 ++++++++++-------- src/Skia/Avalonia.Skia/FormattedTextImpl.cs | 5 - 6 files changed, 153 insertions(+), 87 deletions(-) diff --git a/samples/ControlCatalog/Pages/ScreenPage.cs b/samples/ControlCatalog/Pages/ScreenPage.cs index 34aa85b8aa..fd66185832 100644 --- a/samples/ControlCatalog/Pages/ScreenPage.cs +++ b/samples/ControlCatalog/Pages/ScreenPage.cs @@ -42,7 +42,11 @@ namespace ControlCatalog.Pages context.DrawRectangle(p, boundsRect); context.DrawRectangle(p, workingAreaRect); - FormattedText text = new FormattedText(); + FormattedText text = new FormattedText() + { + Typeface = Typeface.Default + }; + text.Text = $"Bounds: {screen.Bounds.Width}:{screen.Bounds.Height}"; context.DrawText(Brushes.Black, boundsRect.Position.WithY(boundsRect.Size.Height), text); @@ -59,4 +63,4 @@ namespace ControlCatalog.Pages context.DrawRectangle(p, new Rect(w.Position.X / 10f + Math.Abs(_leftMost), w.Position.Y / 10, w.Bounds.Width / 10, w.Bounds.Height / 10)); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Controls/TreeViewItem.cs b/src/Avalonia.Controls/TreeViewItem.cs index 0886c05038..33b0e54868 100644 --- a/src/Avalonia.Controls/TreeViewItem.cs +++ b/src/Avalonia.Controls/TreeViewItem.cs @@ -6,6 +6,7 @@ using Avalonia.Controls.Generators; using Avalonia.Controls.Mixins; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; +using Avalonia.Data; using Avalonia.Input; using Avalonia.LogicalTree; @@ -21,7 +22,7 @@ namespace Avalonia.Controls /// public static readonly DirectProperty IsExpandedProperty = AvaloniaProperty.RegisterDirect( - "IsExpanded", + nameof(IsExpanded), o => o.IsExpanded, (o, v) => o.IsExpanded = v); @@ -31,11 +32,20 @@ namespace Avalonia.Controls public static readonly StyledProperty IsSelectedProperty = ListBoxItem.IsSelectedProperty.AddOwner(); + /// + /// Defines the property. + /// + public static readonly DirectProperty DepthProperty = + AvaloniaProperty.RegisterDirect( + nameof(Depth), + o => o.Depth); + private static readonly ITemplate DefaultPanel = new FuncTemplate(() => new StackPanel()); private TreeView _treeView; private bool _isExpanded; + private int _depth; /// /// Initializes static members of the class. @@ -65,6 +75,34 @@ namespace Avalonia.Controls set { SetValue(IsSelectedProperty, value); } } + /// + /// Gets or sets the depth of the item. + /// + public int Depth + { + get { return this.GetDepth(this); } + } + + private int GetDepth(TreeViewItem item) + { + TreeViewItem parent; + while ((parent = GetParent(item)) != null) + { + return GetDepth(parent) + 1; + } + return 0; + } + + private static TreeViewItem GetParent(TreeViewItem item) + { + var parent = item.InheritanceParent; + while (!(parent == null || parent is TreeViewItem || parent is TreeView)) + { + parent = item.Parent; + } + return parent as TreeViewItem; + } + /// /// Gets the for the tree view. /// diff --git a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml index afac69c9b3..5aac023708 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml @@ -25,6 +25,8 @@ #FFFF0000 #10FF0000 + #01000000 + @@ -45,7 +47,9 @@ - + + + 2 0.5 diff --git a/src/Avalonia.Themes.Default/DatePicker.xaml b/src/Avalonia.Themes.Default/DatePicker.xaml index 8e0bb5f0b0..93bafdb56f 100644 --- a/src/Avalonia.Themes.Default/DatePicker.xaml +++ b/src/Avalonia.Themes.Default/DatePicker.xaml @@ -6,7 +6,8 @@ --> + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:sys="clr-namespace:System;assembly=mscorlib"> + + - + - - - - - - - + + + - - \ No newline at end of file + + + + + + + + + + + + diff --git a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs index 8ad88da7f4..c8d051ed74 100644 --- a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs +++ b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs @@ -30,11 +30,6 @@ namespace Avalonia.Skia SKTypeface skiaTypeface = TypefaceCache.Default; - if (typeface == null) - { - typeface = Typeface.Default; - } - if (typeface.FontFamily.Key != null) { var typefaces = SKTypefaceCollectionCache.GetOrAddTypefaceCollection(typeface.FontFamily); From d4b9ef504248585a4b34b874e8a435cf40cd6625 Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Tue, 28 Aug 2018 22:32:11 +0100 Subject: [PATCH 27/80] Added missing Converter. --- .../Converters/MarginMultiplierConverter.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs diff --git a/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs b/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs new file mode 100644 index 0000000000..54bd6bcf39 --- /dev/null +++ b/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs @@ -0,0 +1,32 @@ +using System; +using System.Globalization; +using Avalonia.Data.Converters; + +namespace Avalonia.Controls.Converters +{ + public class MarginMultiplierConverter : IValueConverter + { + public double Indent { get; set; } + + public bool Left { get; set; } = false; + + public bool Top { get; set; } = false; + + public bool Right { get; set; } = false; + + public bool Bottom { get; set; } = false; + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (!(value is int depth)) + return new Thickness(0); + + return new Thickness(Left ? Indent * depth : 0, Top ? Indent * depth : 0, Right ? Indent * depth : 0, Bottom ? Indent * depth : 0); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new System.NotImplementedException(); + } + } +} From f180ec4dd7fed1cbadcc8fa4aba4875fec4530fc Mon Sep 17 00:00:00 2001 From: Jeffrey Ye Date: Wed, 29 Aug 2018 14:22:00 -0700 Subject: [PATCH 28/80] Use SelectionChangedEventArgs instead of SelectedItemChangedEventArgs --- .../SelectedItemChangedEventArgs.cs | 36 ------------------- src/Avalonia.Controls/TreeView.cs | 26 ++++++++++---- .../TreeViewTests.cs | 5 +-- 3 files changed, 23 insertions(+), 44 deletions(-) delete mode 100644 src/Avalonia.Controls/SelectedItemChangedEventArgs.cs diff --git a/src/Avalonia.Controls/SelectedItemChangedEventArgs.cs b/src/Avalonia.Controls/SelectedItemChangedEventArgs.cs deleted file mode 100644 index 6fb8a2d313..0000000000 --- a/src/Avalonia.Controls/SelectedItemChangedEventArgs.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using Avalonia; -using Avalonia.Interactivity; - -namespace Avalonia.Controls -{ - /// - /// Provides data for the event. - /// - public class SelectedItemChangedEventArgs : RoutedEventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// The event being raised. - /// The items added to the selection. - /// The items removed from the selection. - public SelectedItemChangedEventArgs(RoutedEvent routedEvent, object newItem, object oldItem) - : base(routedEvent) - { - NewItem = newItem; - OldItem = oldItem; - } - - /// - /// Gets the items that were added to the selection. - /// - public object NewItem { get; } - - /// - /// Gets the items that were removed from the selection. - /// - public object OldItem { get; } - } -} diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 50b45cbb9a..d449a7cd38 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; +using System.Collections.Generic; using System.Linq; using Avalonia.Controls.Generators; using Avalonia.Controls.Primitives; @@ -35,8 +36,8 @@ namespace Avalonia.Controls /// /// Defines the event. /// - public static readonly RoutedEvent SelectedItemChangedEvent = - RoutedEvent.Register( + public static readonly RoutedEvent SelectedItemChangedEvent = + RoutedEvent.Register( "SelectedItemChanged", RoutingStrategies.Bubble); @@ -53,7 +54,7 @@ namespace Avalonia.Controls /// /// Occurs when the control's selection changes. /// - public event EventHandler SelectedItemChanged + public event EventHandler SelectedItemChanged { add { AddHandler(SelectedItemChangedEvent, value); } remove { RemoveHandler(SelectedItemChangedEvent, value); } @@ -108,10 +109,23 @@ namespace Avalonia.Controls if (oldItem != _selectedItem) { - var changed = new SelectedItemChangedEventArgs( + // Fire the SelectionChanged event + List removed = new List(); + if (oldItem != null) + { + removed.Add(oldItem); + } + + List added = new List(); + if (_selectedItem != null) + { + added.Add(_selectedItem); + } + + var changed = new SelectionChangedEventArgs( SelectedItemChangedEvent, - _selectedItem, - oldItem); + added, + removed); RaiseEvent(changed); } } diff --git a/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs b/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs index 8295409f7e..1a913865cb 100644 --- a/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs +++ b/tests/Avalonia.Controls.UnitTests/TreeViewTests.cs @@ -188,8 +188,9 @@ namespace Avalonia.Controls.UnitTests var called = false; target.SelectedItemChanged += (s, e) => { - Assert.Null(e.OldItem); - Assert.Same(item, e.NewItem); + Assert.Empty(e.RemovedItems); + Assert.Equal(1, e.AddedItems.Count); + Assert.Same(item, e.AddedItems[0]); called = true; }; From f6dfd1688ef7ec2014503b70daa65ea84f80b838 Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Thu, 30 Aug 2018 01:03:58 +0100 Subject: [PATCH 29/80] TreeViewItem updates. --- src/Avalonia.Controls/TreeViewItem.cs | 29 +--- .../LogicalTree/LogicalExtensions.cs | 15 ++ src/Avalonia.Themes.Default/TreeViewItem.xaml | 163 +++++++++--------- 3 files changed, 102 insertions(+), 105 deletions(-) diff --git a/src/Avalonia.Controls/TreeViewItem.cs b/src/Avalonia.Controls/TreeViewItem.cs index 33b0e54868..c5d3313117 100644 --- a/src/Avalonia.Controls/TreeViewItem.cs +++ b/src/Avalonia.Controls/TreeViewItem.cs @@ -6,7 +6,6 @@ using Avalonia.Controls.Generators; using Avalonia.Controls.Mixins; using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; -using Avalonia.Data; using Avalonia.Input; using Avalonia.LogicalTree; @@ -37,8 +36,7 @@ namespace Avalonia.Controls /// public static readonly DirectProperty DepthProperty = AvaloniaProperty.RegisterDirect( - nameof(Depth), - o => o.Depth); + nameof(Depth), o => o.Depth); private static readonly ITemplate DefaultPanel = new FuncTemplate(() => new StackPanel()); @@ -80,27 +78,8 @@ namespace Avalonia.Controls /// public int Depth { - get { return this.GetDepth(this); } - } - - private int GetDepth(TreeViewItem item) - { - TreeViewItem parent; - while ((parent = GetParent(item)) != null) - { - return GetDepth(parent) + 1; - } - return 0; - } - - private static TreeViewItem GetParent(TreeViewItem item) - { - var parent = item.InheritanceParent; - while (!(parent == null || parent is TreeViewItem || parent is TreeView)) - { - parent = item.Parent; - } - return parent as TreeViewItem; + get { return _depth; } + private set { SetAndRaise(DepthProperty, ref _depth, value); } } /// @@ -127,6 +106,8 @@ namespace Avalonia.Controls base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType().FirstOrDefault(); + Depth = this.CalculateDistanceFromLogicalParent() - 1; + if (ItemTemplate == null && _treeView?.ItemTemplate != null) { ItemTemplate = _treeView.ItemTemplate; diff --git a/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs b/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs index 276ea6c060..47550a876d 100644 --- a/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs +++ b/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs @@ -87,5 +87,20 @@ namespace Avalonia.LogicalTree { return target.GetLogicalAncestors().Any(x => x == logical); } + + public static int CalculateDistanceFromLogicalParent(this ILogical logical, int @default = -1) where T : class + { + Contract.Requires(logical != null); + + var result = 0; + + while (logical != null && logical.GetType() != typeof(T)) + { + ++result; + logical = logical.LogicalParent; + } + + return logical != null ? result : @default; + } } } diff --git a/src/Avalonia.Themes.Default/TreeViewItem.xaml b/src/Avalonia.Themes.Default/TreeViewItem.xaml index a51b6c0aca..5c5012e685 100644 --- a/src/Avalonia.Themes.Default/TreeViewItem.xaml +++ b/src/Avalonia.Themes.Default/TreeViewItem.xaml @@ -1,91 +1,92 @@ - + xmlns:converters="clr-namespace:Avalonia.Controls.Converters;assembly=Avalonia.Controls"> + - + - - - + - + - + - + - - - + - + + + + + From 22b373948a821ddb0749f2213b15fa2ec67ec34b Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Thu, 30 Aug 2018 01:05:15 +0100 Subject: [PATCH 30/80] Reverted some tab indentation. --- src/Avalonia.Themes.Default/TreeViewItem.xaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Themes.Default/TreeViewItem.xaml b/src/Avalonia.Themes.Default/TreeViewItem.xaml index 5c5012e685..ada86d3535 100644 --- a/src/Avalonia.Themes.Default/TreeViewItem.xaml +++ b/src/Avalonia.Themes.Default/TreeViewItem.xaml @@ -47,10 +47,10 @@ Height="12" HorizontalAlignment="Center" VerticalAlignment="Center"> - + From 298eef1c1b8e9950578c14a6b2396551868df0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miha=20Marki=C4=8D?= Date: Sat, 1 Sep 2018 19:23:46 +0200 Subject: [PATCH 31/80] Fixes #1847 PasswordChar change doesn't affect render --- src/Avalonia.Controls/Presenters/TextPresenter.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index 636c836da5..349ae80362 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -36,7 +36,11 @@ namespace Avalonia.Controls.Presenters private int _selectionEnd; private bool _caretBlink; private IBrush _highlightBrush; - + + static TextPresenter() + { + AffectsRender(PasswordCharProperty); + } public TextPresenter() { _caretTimer = new DispatcherTimer(); @@ -50,6 +54,9 @@ namespace Avalonia.Controls.Presenters this.GetObservable(CaretIndexProperty) .Subscribe(CaretIndexChanged); + + this.GetObservable(PasswordCharProperty) + .Subscribe(_ => InvalidateFormattedText()); } public int CaretIndex @@ -116,7 +123,7 @@ namespace Avalonia.Controls.Presenters var start = Math.Min(selectionStart, selectionEnd); var length = Math.Max(selectionStart, selectionEnd) - start; - // issue #600: set constaint before any FormattedText manipulation + // issue #600: set constraint before any FormattedText manipulation // see base.Render(...) implementation FormattedText.Constraint = Bounds.Size; From 993f0a080ad3155c5c526c2ebb377b45797e8911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miha=20Marki=C4=8D?= Date: Sat, 1 Sep 2018 20:07:00 +0200 Subject: [PATCH 32/80] Adds missing newline --- src/Avalonia.Controls/Presenters/TextPresenter.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index 349ae80362..a4dc35f736 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -41,6 +41,7 @@ namespace Avalonia.Controls.Presenters { AffectsRender(PasswordCharProperty); } + public TextPresenter() { _caretTimer = new DispatcherTimer(); From 0a3887659024624743a79161a47a1d4cac57f505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miha=20Marki=C4=8D?= Date: Tue, 4 Sep 2018 15:52:10 +0200 Subject: [PATCH 33/80] Spellchecks all projects except for Base, Controls, Samples and Testing --- .../Avalonia.Android/AndroidPlatform.cs | 6 +--- .../AndroidThreadingInterface.cs | 10 ------- src/Android/Avalonia.Android/AppBuilder.cs | 14 +-------- .../Avalonia.Android/AvaloniaActivity.cs | 9 +----- src/Android/Avalonia.Android/AvaloniaView.cs | 9 +----- src/Android/Avalonia.Android/CursorFactory.cs | 2 +- .../Platform/ClipboardImpl.cs | 4 +-- .../Platform/Input/AndroidKeyboardDevice.cs | 5 ++-- .../SkiaPlatform/AndroidFramebuffer.cs | 2 +- .../InvalidationAwareSurfaceView.cs | 10 +------ .../Platform/SkiaPlatform/PopupImpl.cs | 9 +----- .../Platform/SkiaPlatform/TopLevelImpl.cs | 13 ++++----- .../Helpers/AndroidKeyboardEventsHelper.cs | 8 ++--- .../Helpers/AndroidTouchEventsHelper.cs | 6 ++-- .../Platform/Specific/IAndroidView.cs | 9 +----- .../Avalonia.Android/PlatformIconLoader.cs | 15 ++-------- .../Avalonia.Android/SystemDialogImpl.cs | 2 +- src/Avalonia.Animation/Animatable.cs | 9 ++---- src/Avalonia.Animation/Animation.cs | 12 +++----- src/Avalonia.Animation/AnimatorKeyFrame.cs | 4 --- src/Avalonia.Animation/Animator`1.cs | 17 +++++------ src/Avalonia.Animation/Cue.cs | 2 -- src/Avalonia.Animation/DoubleAnimator.cs | 11 +------ src/Avalonia.Animation/DoubleTransition.cs | 1 - src/Avalonia.Animation/Easing/BounceEaseIn.cs | 1 - src/Avalonia.Animation/Easing/Easing.cs | 5 +--- .../Easing/EasingTypeConverter.cs | 3 +- .../Easing/ElasticEaseIn.cs | 2 +- .../Easing/ElasticEaseOut.cs | 2 +- src/Avalonia.Animation/Easing/SineEaseIn.cs | 2 +- src/Avalonia.Animation/Easing/SineEaseOut.cs | 2 +- src/Avalonia.Animation/FillMode.cs | 6 +--- src/Avalonia.Animation/FloatTransition.cs | 1 - src/Avalonia.Animation/IAnimation.cs | 2 -- src/Avalonia.Animation/IAnimator.cs | 1 - src/Avalonia.Animation/ITransition.cs | 2 -- src/Avalonia.Animation/IntegerTransition.cs | 1 - src/Avalonia.Animation/KeyFrame.cs | 3 -- src/Avalonia.Animation/KeyFramePair`1.cs | 11 ------- src/Avalonia.Animation/PlayState.cs | 8 ++--- src/Avalonia.Animation/PlaybackDirection.cs | 6 +--- src/Avalonia.Animation/RepeatCount.cs | 5 +--- .../RepeatCountTypeConverter.cs | 3 +- src/Avalonia.Animation/Timing.cs | 2 -- src/Avalonia.Animation/Transition`1.cs | 3 +- src/Avalonia.Animation/Utils/DoubleUtils.cs | 2 -- .../Data/Core/Plugins/DataValidationBase.cs | 1 - .../Remote/PreviewerWindowingPlatform.cs | 2 +- .../Remote/RemoteDesignerEntryPoint.cs | 5 +--- src/Avalonia.Diagnostics/Debug.cs | 2 -- .../ViewModels/LogicalTreeNode.cs | 1 - .../ViewModels/ViewModelBase.cs | 3 +- .../Views/PropertyChangedExtenions.cs | 2 +- src/Avalonia.Diagnostics/Views/SimpleGrid.cs | 1 - src/Avalonia.DotNetCoreRuntime/AppBuilder.cs | 9 ++---- src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs | 4 --- src/Avalonia.Input/AccessKeyHandler.cs | 2 +- src/Avalonia.Input/Cursors.cs | 6 +--- src/Avalonia.Input/DataObject.cs | 4 +-- src/Avalonia.Input/DragDrop.cs | 4 +-- .../ICustomKeyboardNavigation.cs | 1 - src/Avalonia.Input/IDataObject.cs | 4 +-- src/Avalonia.Input/IInputManager.cs | 8 ++--- src/Avalonia.Input/IPointerDevice.cs | 2 -- src/Avalonia.Input/InputElement.cs | 1 - src/Avalonia.Input/InputExtensions.cs | 4 +-- src/Avalonia.Input/InputManager.cs | 2 +- src/Avalonia.Input/Key.cs | 2 +- src/Avalonia.Input/KeyBinding.cs | 5 ---- src/Avalonia.Input/KeyEventArgs.cs | 1 - src/Avalonia.Input/KeyGesture.cs | 6 ++-- src/Avalonia.Input/KeyboardDevice.cs | 3 -- .../KeyboardNavigationHandler.cs | 2 +- src/Avalonia.Input/MouseDevice.cs | 5 ++-- src/Avalonia.Input/Platform/IClipboard.cs | 4 --- .../Platform/IPlatformDragSource.cs | 7 +---- .../Platform/IStandardCursorFactory.cs | 5 ---- src/Avalonia.Input/PointerEventArgs.cs | 1 - src/Avalonia.Input/Raw/IDragDropDevice.cs | 6 ++-- src/Avalonia.Input/Raw/RawDragEvent.cs | 8 ++--- .../Raw/RawMouseWheelEventArgs.cs | 2 -- src/Avalonia.Input/TextInputEventArgs.cs | 5 ---- src/Avalonia.Interactivity/IInteractive.cs | 2 +- src/Avalonia.Interactivity/Interactive.cs | 2 +- src/Avalonia.Layout/ILayoutManager.cs | 2 -- src/Avalonia.Layout/LayoutManager.cs | 5 ++-- src/Avalonia.Layout/Layoutable.cs | 5 ++-- .../SerilogExtensions.cs | 3 +- .../AppBuilderExtensions.cs | 3 -- .../AvaloniaRemoteMessageGuidAttribute.cs | 4 --- .../BsonStreamTransport.cs | 1 - .../DefaultMessageTypeResolver.cs | 2 -- src/Avalonia.Remote.Protocol/ITransport.cs | 3 -- src/Avalonia.Remote.Protocol/InputMessages.cs | 4 --- src/Avalonia.Remote.Protocol/MetsysBson.cs | 27 +++++++++-------- .../ViewportMessages.cs | 8 +---- src/Avalonia.Styling/Controls/Classes.cs | 1 - src/Avalonia.Styling/Controls/INameScope.cs | 2 +- .../Controls/IPseudoClasses.cs | 1 - .../Controls/IResourceDictionary.cs | 1 - .../Controls/ResourceProviderExtensions.cs | 2 -- src/Avalonia.Styling/IStyledElement.cs | 2 -- src/Avalonia.Styling/StyledElement.cs | 7 ++--- .../Styling/IRequiresTemplateInSetter.cs | 6 +--- .../Styling/ISetStyleParent.cs | 5 +--- src/Avalonia.Styling/Styling/IStyleHost.cs | 1 - src/Avalonia.Styling/Styling/IStyleable.cs | 3 +- src/Avalonia.Styling/Styling/IStyler.cs | 1 - .../Styling/ITemplatedControl.cs | 1 - src/Avalonia.Styling/Styling/SelectorMatch.cs | 2 +- src/Avalonia.Styling/Styling/Setter.cs | 1 - src/Avalonia.Styling/Styling/Style.cs | 6 ++-- src/Avalonia.Visuals/Animation/CrossFade.cs | 1 - .../Animation/IPageTransition.cs | 1 - src/Avalonia.Visuals/Animation/PageSlide.cs | 1 - .../Animation/PointTransition.cs | 1 - .../Animation/ThicknessTransition.cs | 1 - .../Animation/TransformAnimator.cs | 9 +----- src/Avalonia.Visuals/CornerRadius.cs | 3 +- src/Avalonia.Visuals/Matrix.cs | 9 +++--- .../Media/BrushMappingMode.cs | 7 +---- src/Avalonia.Visuals/Media/Color.cs | 4 +-- src/Avalonia.Visuals/Media/Colors.cs | 3 +- src/Avalonia.Visuals/Media/DashStyle.cs | 6 +--- src/Avalonia.Visuals/Media/DrawingContext.cs | 4 +-- .../Media/Fonts/FontFamilyLoader.cs | 4 +-- src/Avalonia.Visuals/Media/FormattedText.cs | 3 +- .../Media/FormattedTextStyleSpan.cs | 4 +-- src/Avalonia.Visuals/Media/GradientBrush.cs | 3 +- .../Media/GradientSpreadMethod.cs | 8 +---- src/Avalonia.Visuals/Media/IMutableBrush.cs | 4 +-- .../Media/Imaging/RenderTargetBitmap.cs | 3 +- .../Media/Imaging/WriteableBitmap.cs | 8 +---- .../Media/Immutable/ImmutableGradientBrush.cs | 3 +- .../Immutable/ImmutableLinearGradientBrush.cs | 6 +--- .../Immutable/ImmutableRadialGradientBrush.cs | 3 +- .../Media/LinearGradientBrush.cs | 4 +-- src/Avalonia.Visuals/Media/PathGeometry.cs | 2 +- src/Avalonia.Visuals/Media/PenLineCap.cs | 6 ---- src/Avalonia.Visuals/Media/PenLineJoin.cs | 6 ---- .../Media/PolylineGeometry.cs | 4 +-- src/Avalonia.Visuals/Media/RotateTransform.cs | 2 +- src/Avalonia.Visuals/Media/ScaleTransform.cs | 4 +-- src/Avalonia.Visuals/Media/SkewTransform.cs | 4 +-- src/Avalonia.Visuals/Media/SolidColorBrush.cs | 2 -- .../Media/StreamGeometryContext.cs | 1 - src/Avalonia.Visuals/Media/Transform.cs | 2 +- src/Avalonia.Visuals/Media/TransformGroup.cs | 5 ++-- .../Media/TranslateTransform.cs | 2 +- .../ExportRenderingSubsystemAttribute.cs | 4 --- .../Platform/IDrawingContextImpl.cs | 2 +- .../Platform/IFormattedTextImpl.cs | 1 - .../Platform/IGeometryImpl.cs | 1 - .../Platform/IRenderTargetBitmapImpl.cs | 1 - .../Platform/ITransformedGeometryImpl.cs | 4 +-- .../Platform/IWriteableBitmapImpl.cs | 8 +---- .../Platform/PathGeometryContext.cs | 2 +- src/Avalonia.Visuals/Point.cs | 6 ++-- src/Avalonia.Visuals/Rect.cs | 5 ++-- src/Avalonia.Visuals/RelativePoint.cs | 5 ++-- src/Avalonia.Visuals/RelativeRect.cs | 5 ++-- .../RenderTargetCorruptedException.cs | 4 --- .../Rendering/DeferredRenderer.cs | 12 ++++---- src/Avalonia.Visuals/Rendering/DirtyRects.cs | 5 ++-- .../Rendering/DisplayDirtyRect.cs | 2 +- src/Avalonia.Visuals/Rendering/IRenderRoot.cs | 1 - .../Rendering/IRendererFactory.cs | 1 - .../Rendering/IVisualBrushInitialize.cs | 3 +- .../Rendering/IVisualBrushRenderer.cs | 1 - .../Rendering/ImmediateRenderer.cs | 6 ++-- src/Avalonia.Visuals/Rendering/RenderLayer.cs | 3 +- .../Rendering/RenderLayers.cs | 3 +- .../SceneGraph/BrushDrawOperation.cs | 1 - .../Rendering/SceneGraph/ClipNode.cs | 3 +- .../SceneGraph/DeferredDrawingContextImpl.cs | 2 +- .../Rendering/SceneGraph/GeometryClipNode.cs | 3 +- .../Rendering/SceneGraph/GeometryNode.cs | 1 - .../Rendering/SceneGraph/IVisualNode.cs | 1 - .../Rendering/SceneGraph/ImageNode.cs | 1 - .../Rendering/SceneGraph/LineNode.cs | 1 - .../Rendering/SceneGraph/OpacityMaskNode.cs | 3 +- .../Rendering/SceneGraph/OpacityNode.cs | 3 +- .../Rendering/SceneGraph/RectangleNode.cs | 3 +- .../Rendering/SceneGraph/SceneLayer.cs | 3 +- .../Rendering/SceneGraph/TextNode.cs | 3 +- .../Rendering/SceneGraph/VisualNode.cs | 4 +-- .../Rendering/ZIndexComparer.cs | 3 +- src/Avalonia.Visuals/Size.cs | 11 ++++--- src/Avalonia.Visuals/Thickness.cs | 5 ++-- src/Avalonia.Visuals/Visual.cs | 1 - src/Avalonia.Visuals/VisualExtensions.cs | 9 ------ .../VisualTree/TransformedBounds.cs | 3 +- src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs | 3 -- src/Gtk/Avalonia.Gtk3/FramebufferManager.cs | 4 --- src/Gtk/Avalonia.Gtk3/GdkCursor.cs | 10 ++----- src/Gtk/Avalonia.Gtk3/GdkKey.cs | 8 +---- src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs | 8 ++--- .../Avalonia.Gtk3/ImageSurfaceFramebuffer.cs | 6 ---- src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs | 1 - src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs | 1 - src/Gtk/Avalonia.Gtk3/Interop/GException.cs | 4 --- src/Gtk/Avalonia.Gtk3/Interop/GObject.cs | 4 --- src/Gtk/Avalonia.Gtk3/Interop/GlibPriority.cs | 2 -- src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs | 5 ---- .../ICustomGtk3NativeLibraryResolver.cs | 7 +---- .../Interop/ManagedCairoSurface.cs | 3 +- src/Gtk/Avalonia.Gtk3/Interop/Native.cs | 13 +++------ .../Avalonia.Gtk3/Interop/NativeException.cs | 4 --- src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs | 4 --- src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs | 2 -- src/Gtk/Avalonia.Gtk3/Interop/Signal.cs | 4 --- src/Gtk/Avalonia.Gtk3/KeyTransform.cs | 8 ++--- src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs | 2 +- src/Gtk/Avalonia.Gtk3/PopupImpl.cs | 8 +---- src/Gtk/Avalonia.Gtk3/ScreenImpl.cs | 4 +-- src/Gtk/Avalonia.Gtk3/SystemDialogs.cs | 2 -- src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs | 2 -- src/Gtk/Avalonia.Gtk3/X11Framebuffer.cs | 3 +- .../Avalonia.LinuxFramebuffer/EvDevDevice.cs | 1 - .../FramebufferToplevelImpl.cs | 2 -- .../LinuxFramebuffer.cs | 7 +---- .../LinuxFramebufferPlatform.cs | 6 +--- src/Linux/Avalonia.LinuxFramebuffer/Mice.cs | 5 ---- .../NativeUnsafeMethods.cs | 10 +++---- src/Linux/Avalonia.LinuxFramebuffer/Stubs.cs | 2 -- src/Markup/Avalonia.Markup/Data/Binding.cs | 2 +- .../Avalonia.Markup/Data/MultiBinding.cs | 5 +--- .../Avalonia.Markup/Data/RelativeSource.cs | 4 +-- .../Markup/Data/DelayedBinding.cs | 1 - .../Markup/Parsers/ArgumentListParser.cs | 4 +-- .../Parsers/ExpressionObserverBuilder.cs | 8 ++--- .../Markup/Parsers/Nodes/ElementNameNode.cs | 2 -- .../Markup/Parsers/Nodes/FindAncestorNode.cs | 2 -- .../Markup/Parsers/Nodes/SelfNode.cs | 5 +--- .../Markup/Parsers/Nodes/StringIndexerNode.cs | 29 +++++++++---------- .../Markup/Parsers/SelectorGrammar.cs | 1 - .../Markup/Parsers/SelectorParser.cs | 2 -- src/OSX/Avalonia.MonoMac/ClipboardImpl.cs | 5 +--- src/OSX/Avalonia.MonoMac/Cursor.cs | 2 +- src/OSX/Avalonia.MonoMac/DragSource.cs | 7 +---- src/OSX/Avalonia.MonoMac/DraggingInfo.cs | 5 ++-- .../Avalonia.MonoMac/EmulatedFramebuffer.cs | 6 ++-- src/OSX/Avalonia.MonoMac/Helpers.cs | 8 ++--- .../PlatformThreadingInterface.cs | 1 - src/OSX/Avalonia.MonoMac/RenderLoop.cs | 2 -- src/OSX/Avalonia.MonoMac/ScreenImpl.cs | 6 ++-- src/OSX/Avalonia.MonoMac/Stubs.cs | 2 +- src/OSX/Avalonia.MonoMac/SystemDialogsImpl.cs | 5 +--- src/OSX/Avalonia.MonoMac/TopLevelImpl.cs | 5 ++-- src/OSX/Avalonia.MonoMac/WindowImpl.cs | 2 +- src/Shared/PlatformSupport/AssetLoader.cs | 4 +-- .../StandardRuntimePlatform.cs | 1 - .../StandardRuntimePlatformServices.cs | 3 -- src/Shared/RenderHelpers/ArcToHelper.cs | 4 +-- src/Shared/WindowResizeDragHelper.cs | 3 +- src/Skia/Avalonia.Skia/FormattedTextImpl.cs | 8 ++--- .../Avalonia.Skia/FramebufferRenderTarget.cs | 5 ++-- src/Skia/Avalonia.Skia/GeometryImpl.cs | 2 +- .../Helpers/PixelFormatHelper.cs | 2 +- src/Skia/Avalonia.Skia/IDrawableBitmapImpl.cs | 2 +- .../Avalonia.Skia/SKTypefaceCollection.cs | 2 +- .../SKTypefaceCollectionCache.cs | 2 +- .../SkiaApplicationExtensions.cs | 5 ++-- src/Skia/Avalonia.Skia/SkiaPlatform.cs | 2 -- src/Skia/Avalonia.Skia/TypefaceCache.cs | 4 +-- .../Avalonia.Direct2D1/Direct2D1Platform.cs | 10 +++---- .../Avalonia.Direct2D1/Direct2DChecker.cs | 7 +---- .../ExternalRenderTarget.cs | 3 +- .../FramebufferShimRenderTarget.cs | 4 --- .../Avalonia.Direct2D1/HwndRenderTarget.cs | 8 +---- .../IExternalDirect2DRenderTargetSurface.cs | 8 +---- .../Avalonia.Direct2D1/ILayerFactory.cs | 3 +- .../Media/DWriteResourceFontFileStream.cs | 4 +-- .../Media/DWriteResourceFontLoader.cs | 3 +- .../Media/Imaging/D2DBitmapImpl.cs | 4 +-- .../Imaging/D2DRenderTargetBitmapImpl.cs | 3 +- .../Media/Imaging/WicBitmapImpl.cs | 1 - .../Media/Imaging/WriteableWicBitmapImpl.cs | 4 --- .../Media/StreamGeometryContextImpl.cs | 6 ++-- .../Avalonia.Direct2D1/RenderTarget.cs | 1 - .../SwapChainRenderTarget.cs | 9 +++--- .../Avalonia.Win32.Interop/Wpf/CursorShim.cs | 3 -- .../Wpf/Direct2DImageSurface.cs | 8 ----- .../Avalonia.Win32.Interop/Wpf/IntSize.cs | 4 --- .../Wpf/WpfAvaloniaHost.cs | 13 +-------- .../Wpf/WpfInteropExtensions.cs | 8 +---- .../Wpf/WpfMouseDevice.cs | 2 +- .../Wpf/WpfTopLevelImpl.cs | 3 -- .../Wpf/WritableBitmapSurface.cs | 5 ---- .../Avalonia.Win32/ClipboardFormats.cs | 4 +-- src/Windows/Avalonia.Win32/ClipboardImpl.cs | 5 +--- src/Windows/Avalonia.Win32/CursorFactory.cs | 6 +--- src/Windows/Avalonia.Win32/DataObject.cs | 7 ++--- src/Windows/Avalonia.Win32/DragSource.cs | 5 +--- .../Avalonia.Win32/FramebufferManager.cs | 4 --- src/Windows/Avalonia.Win32/IconImpl.cs | 10 ++----- .../Input/WindowsMouseDevice.cs | 4 +-- src/Windows/Avalonia.Win32/OleDataObject.cs | 2 +- src/Windows/Avalonia.Win32/OleDragSource.cs | 4 +-- src/Windows/Avalonia.Win32/OleDropTarget.cs | 2 +- .../Avalonia.Win32/SystemDialogImpl.cs | 8 ++--- .../Avalonia.Win32/WindowFramebuffer.cs | 4 +-- src/iOS/Avalonia.iOS/AppBuilder.cs | 9 +----- src/iOS/Avalonia.iOS/AvaloniaView.cs | 5 +--- src/iOS/Avalonia.iOS/AvaloniaWindow.cs | 7 +---- src/iOS/Avalonia.iOS/Clipboard.cs | 2 +- src/iOS/Avalonia.iOS/DisplayLinkRenderLoop.cs | 6 +--- src/iOS/Avalonia.iOS/EmbeddableImpl.cs | 3 -- src/iOS/Avalonia.iOS/EmulatedFramebuffer.cs | 2 -- src/iOS/Avalonia.iOS/Extensions.cs | 2 -- src/iOS/Avalonia.iOS/PlatformIconLoader.cs | 6 ++-- src/iOS/Avalonia.iOS/PlatformSettings.cs | 2 -- .../PlatformThreadingInterface.cs | 9 +----- .../Specific/KeyboardEventsHelper.cs | 12 ++++---- src/iOS/Avalonia.iOS/TopLevelImpl.cs | 22 +++++--------- src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs | 2 +- src/iOS/Avalonia.iOS/iOSPlatform.cs | 7 ++--- .../Program.cs | 5 ---- 318 files changed, 354 insertions(+), 1058 deletions(-) diff --git a/src/Android/Avalonia.Android/AndroidPlatform.cs b/src/Android/Avalonia.Android/AndroidPlatform.cs index 7134e7d1b4..2b46bfa492 100644 --- a/src/Android/Avalonia.Android/AndroidPlatform.cs +++ b/src/Android/Avalonia.Android/AndroidPlatform.cs @@ -1,8 +1,4 @@ using System; -using System.IO; -using System.Linq; -using Android.Content; -using Android.Views; using Avalonia.Android.Platform; using Avalonia.Android.Platform.Input; using Avalonia.Android.Platform.SkiaPlatform; @@ -79,4 +75,4 @@ namespace Avalonia.Android return new PopupImpl(); } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/AndroidThreadingInterface.cs b/src/Android/Avalonia.Android/AndroidThreadingInterface.cs index 77dfc60b83..6fe77adca1 100644 --- a/src/Android/Avalonia.Android/AndroidThreadingInterface.cs +++ b/src/Android/Avalonia.Android/AndroidThreadingInterface.cs @@ -1,16 +1,7 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Reactive.Disposables; -using System.Text; using System.Threading; -using Android.App; -using Android.Content; using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Widget; using Avalonia.Platform; using Avalonia.Threading; @@ -88,4 +79,3 @@ namespace Avalonia.Android public event Action Signaled; } } - \ No newline at end of file diff --git a/src/Android/Avalonia.Android/AppBuilder.cs b/src/Android/Avalonia.Android/AppBuilder.cs index 6078e3bb98..805bb61655 100644 --- a/src/Android/Avalonia.Android/AppBuilder.cs +++ b/src/Android/Avalonia.Android/AppBuilder.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Android.App; -using Android.Content; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Widget; using Avalonia.Controls; -using Avalonia.Platform; using Avalonia.Shared.PlatformSupport; namespace Avalonia @@ -23,4 +11,4 @@ namespace Avalonia } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/AvaloniaActivity.cs b/src/Android/Avalonia.Android/AvaloniaActivity.cs index 21ce555086..d3696aa41d 100644 --- a/src/Android/Avalonia.Android/AvaloniaActivity.cs +++ b/src/Android/Avalonia.Android/AvaloniaActivity.cs @@ -1,14 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Android.App; -using Android.Content; using Android.OS; -using Android.Runtime; using Android.Views; -using Android.Widget; namespace Avalonia.Android { @@ -48,4 +41,4 @@ namespace Avalonia.Android return View.DispatchKeyEvent(e); } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/AvaloniaView.cs b/src/Android/Avalonia.Android/AvaloniaView.cs index 6c4274a6e4..fbe027db00 100644 --- a/src/Android/Avalonia.Android/AvaloniaView.cs +++ b/src/Android/Avalonia.Android/AvaloniaView.cs @@ -1,12 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Android.App; using Android.Content; -using Android.OS; -using Android.Runtime; using Android.Views; using Android.Widget; using Avalonia.Android.Platform.SkiaPlatform; @@ -66,4 +59,4 @@ namespace Avalonia.Android public IDisposable ShowDialog() => null; } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/CursorFactory.cs b/src/Android/Avalonia.Android/CursorFactory.cs index e6b9433cca..9eb28c67f9 100644 --- a/src/Android/Avalonia.Android/CursorFactory.cs +++ b/src/Android/Avalonia.Android/CursorFactory.cs @@ -9,4 +9,4 @@ namespace Avalonia.Android public IPlatformHandle GetCursor(StandardCursorType cursorType) => new PlatformHandle(IntPtr.Zero, "ZeroCursor"); } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/ClipboardImpl.cs b/src/Android/Avalonia.Android/Platform/ClipboardImpl.cs index 8c28b48019..51e0a1e799 100644 --- a/src/Android/Avalonia.Android/Platform/ClipboardImpl.cs +++ b/src/Android/Avalonia.Android/Platform/ClipboardImpl.cs @@ -1,9 +1,9 @@ +using System.Threading.Tasks; using Android.Content; using Android.Runtime; using Android.Views; using Avalonia.Input.Platform; using Avalonia.Platform; -using System.Threading.Tasks; namespace Avalonia.Android.Platform { @@ -44,4 +44,4 @@ namespace Avalonia.Android.Platform return Task.FromResult(null); } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/Input/AndroidKeyboardDevice.cs b/src/Android/Avalonia.Android/Platform/Input/AndroidKeyboardDevice.cs index d5494a69ef..726ccdbbdd 100644 --- a/src/Android/Avalonia.Android/Platform/Input/AndroidKeyboardDevice.cs +++ b/src/Android/Avalonia.Android/Platform/Input/AndroidKeyboardDevice.cs @@ -1,12 +1,11 @@ -using System; -using Avalonia.Input; //using Android.InputMethodServices; using System.Collections.Generic; using Android.Views; +using Avalonia.Input; namespace Avalonia.Android.Platform.Input { - public class AndroidKeyboardDevice : KeyboardDevice, IKeyboardDevice { + public class AndroidKeyboardDevice : KeyboardDevice, IKeyboardDevice { private static readonly Dictionary KeyDic = new Dictionary { // { Keycode.Cancel?, Key.Cancel }, diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs index 051a058363..405da12967 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs @@ -102,4 +102,4 @@ namespace Avalonia.Android.Platform.SkiaPlatform uint reserved6; } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs index d2d5909815..02ea702236 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/InvalidationAwareSurfaceView.cs @@ -1,17 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Android.App; using Android.Content; using Android.Graphics; using Android.OS; -using Android.Runtime; using Android.Util; using Android.Views; -using Android.Widget; -using Avalonia.Media; using Avalonia.Platform; namespace Avalonia.Android @@ -90,4 +82,4 @@ namespace Avalonia.Android protected abstract void Draw(); public string HandleDescriptor => "SurfaceView"; } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/PopupImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/PopupImpl.cs index 041d91043a..d55755d6e3 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/PopupImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/PopupImpl.cs @@ -1,15 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Android.App; using Android.Content; using Android.Graphics; -using Android.OS; using Android.Runtime; using Android.Views; -using Android.Widget; using Avalonia.Controls; using Avalonia.Platform; @@ -116,4 +109,4 @@ namespace Avalonia.Android.Platform.SkiaPlatform //Not supported } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs index 6c8db17c71..8e8886269c 100644 --- a/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs +++ b/src/Android/Avalonia.Android/Platform/SkiaPlatform/TopLevelImpl.cs @@ -1,18 +1,15 @@ -using Android.App; +using System; +using System.Collections.Generic; using Android.Content; using Android.Graphics; using Android.Views; +using Avalonia.Android.Platform.Input; using Avalonia.Android.Platform.Specific; using Avalonia.Android.Platform.Specific.Helpers; +using Avalonia.Controls.Platform.Surfaces; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; -using System; -using System.Collections.Generic; -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 @@ -196,4 +193,4 @@ namespace Avalonia.Android.Platform.SkiaPlatform ILockedFramebuffer IFramebufferPlatformSurface.Lock()=>new AndroidFramebuffer(_view.Holder.Surface); } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs b/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs index ab990066de..c7b01413a9 100644 --- a/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs +++ b/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidKeyboardEventsHelper.cs @@ -1,3 +1,5 @@ +using System; +using System.ComponentModel; using Android.Content; using Android.Runtime; using Android.Views; @@ -7,8 +9,6 @@ using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; -using System; -using System.ComponentModel; namespace Avalonia.Android.Platform.Specific.Helpers { @@ -120,7 +120,7 @@ namespace Avalonia.Android.Platform.Specific.Helpers _lastFocusedElement = element; } - public void ActivateAutoShowKeybord() + public void ActivateAutoShowKeyboard() { var kbDevice = (KeyboardDevice.Instance as INotifyPropertyChanged); @@ -142,4 +142,4 @@ namespace Avalonia.Android.Platform.Specific.Helpers HandleEvents = false; } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidTouchEventsHelper.cs b/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidTouchEventsHelper.cs index 71822a6f47..112925ab0f 100644 --- a/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidTouchEventsHelper.cs +++ b/src/Android/Avalonia.Android/Platform/Specific/Helpers/AndroidTouchEventsHelper.cs @@ -1,10 +1,8 @@ -using Android.Graphics; +using System; using Android.Views; using Avalonia.Input; using Avalonia.Input.Raw; -using Avalonia.Media; using Avalonia.Platform; -using System; namespace Avalonia.Android.Platform.Specific.Helpers { @@ -131,4 +129,4 @@ namespace Avalonia.Android.Platform.Specific.Helpers HandleEvents = false; } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/Platform/Specific/IAndroidView.cs b/src/Android/Avalonia.Android/Platform/Specific/IAndroidView.cs index 2e7816362d..c72de8e197 100644 --- a/src/Android/Avalonia.Android/Platform/Specific/IAndroidView.cs +++ b/src/Android/Avalonia.Android/Platform/Specific/IAndroidView.cs @@ -1,16 +1,9 @@ -using Android.Graphics; using Android.Views; -using System; -using System.Collections.Generic; namespace Avalonia.Android.Platform.Specific { public interface IAndroidView { - - View View { get; } } - - -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/PlatformIconLoader.cs b/src/Android/Avalonia.Android/PlatformIconLoader.cs index 289025ce1d..88677a9375 100644 --- a/src/Android/Avalonia.Android/PlatformIconLoader.cs +++ b/src/Android/Avalonia.Android/PlatformIconLoader.cs @@ -1,16 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Android.App; -using Android.Content; -using Android.OS; -using Android.Runtime; -using Android.Views; -using Android.Widget; -using Avalonia.Platform; using System.IO; +using Avalonia.Platform; namespace Avalonia.Android { @@ -54,4 +43,4 @@ namespace Avalonia.Android stream.CopyTo(outputStream); } } -} \ No newline at end of file +} diff --git a/src/Android/Avalonia.Android/SystemDialogImpl.cs b/src/Android/Avalonia.Android/SystemDialogImpl.cs index bad45b78fb..a8d201d66e 100644 --- a/src/Android/Avalonia.Android/SystemDialogImpl.cs +++ b/src/Android/Avalonia.Android/SystemDialogImpl.cs @@ -18,4 +18,4 @@ namespace Avalonia.Android throw new NotImplementedException(); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index a27d996301..10cd65132f 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -1,15 +1,12 @@ // 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.Linq; -using Avalonia.Data; using System; +using System.Collections.Generic; +using System.Linq; using System.Reactive.Linq; using Avalonia.Collections; -using Avalonia.Animation; -using System.Collections.Generic; -using System.Threading; -using System.Collections.Concurrent; +using Avalonia.Data; namespace Avalonia.Animation { diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index 3dc5b5c71a..3e90715019 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -1,18 +1,14 @@ // 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.Animation.Easings; -using Avalonia.Animation; -using Avalonia.Collections; -using Avalonia.Metadata; using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Reflection; using System.Linq; -using System.Threading.Tasks; -using System.Reactive.Linq; using System.Reactive.Disposables; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Avalonia.Animation.Easings; +using Avalonia.Collections; namespace Avalonia.Animation { diff --git a/src/Avalonia.Animation/AnimatorKeyFrame.cs b/src/Avalonia.Animation/AnimatorKeyFrame.cs index 0276c6fa92..508a317b71 100644 --- a/src/Avalonia.Animation/AnimatorKeyFrame.cs +++ b/src/Avalonia.Animation/AnimatorKeyFrame.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; using System.ComponentModel; -using Avalonia.Metadata; -using Avalonia.Collections; using Avalonia.Data; using Avalonia.Reactive; diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index eb8b40647d..fb37256a3e 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -1,13 +1,10 @@ using System; using System.Collections.Generic; -using System.Text; -using Avalonia.Collections; -using System.ComponentModel; -using Avalonia.Animation.Utils; -using System.Reactive.Linq; using System.Linq; +using System.Reactive.Linq; +using Avalonia.Animation.Utils; +using Avalonia.Collections; using Avalonia.Data; -using System.Reactive.Disposables; namespace Avalonia.Animation { @@ -21,7 +18,7 @@ namespace Avalonia.Animation /// private readonly SortedList _convertedKeyframes = new SortedList(); - private bool _isVerfifiedAndConverted; + private bool _isVerifiedAndConverted; /// /// Gets or sets the target property for the keyframe. @@ -31,13 +28,13 @@ namespace Avalonia.Animation public Animator() { // Invalidate keyframes when changed. - this.CollectionChanged += delegate { _isVerfifiedAndConverted = false; }; + this.CollectionChanged += delegate { _isVerifiedAndConverted = false; }; } /// public virtual IDisposable Apply(Animation animation, Animatable control, IObservable obsMatch, Action onComplete) { - if (!_isVerfifiedAndConverted) + if (!_isVerifiedAndConverted) VerifyConvertKeyFrames(); return obsMatch @@ -124,7 +121,7 @@ namespace Avalonia.Animation } AddNeutralKeyFramesIfNeeded(); - _isVerfifiedAndConverted = true; + _isVerifiedAndConverted = true; } diff --git a/src/Avalonia.Animation/Cue.cs b/src/Avalonia.Animation/Cue.cs index 5a95c108e3..f61e2cf4a3 100644 --- a/src/Avalonia.Animation/Cue.cs +++ b/src/Avalonia.Animation/Cue.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.Globalization; -using System.Text; namespace Avalonia.Animation { diff --git a/src/Avalonia.Animation/DoubleAnimator.cs b/src/Avalonia.Animation/DoubleAnimator.cs index 154f37360c..aeeb29a7dd 100644 --- a/src/Avalonia.Animation/DoubleAnimator.cs +++ b/src/Avalonia.Animation/DoubleAnimator.cs @@ -1,13 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; -using System.Reactive.Linq; -using System.Diagnostics; -using Avalonia.Animation.Utils; -using Avalonia.Data; - -namespace Avalonia.Animation +namespace Avalonia.Animation { /// /// Animator that handles properties. diff --git a/src/Avalonia.Animation/DoubleTransition.cs b/src/Avalonia.Animation/DoubleTransition.cs index 26f7f975e8..23445e1122 100644 --- a/src/Avalonia.Animation/DoubleTransition.cs +++ b/src/Avalonia.Animation/DoubleTransition.cs @@ -1,7 +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 Avalonia.Metadata; using System; using System.Reactive.Linq; diff --git a/src/Avalonia.Animation/Easing/BounceEaseIn.cs b/src/Avalonia.Animation/Easing/BounceEaseIn.cs index 6aa6f171f5..3fc879b3cf 100644 --- a/src/Avalonia.Animation/Easing/BounceEaseIn.cs +++ b/src/Avalonia.Animation/Easing/BounceEaseIn.cs @@ -1,7 +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 Avalonia.Animation.Utils; namespace Avalonia.Animation.Easings diff --git a/src/Avalonia.Animation/Easing/Easing.cs b/src/Avalonia.Animation/Easing/Easing.cs index 62bcf723fb..5b0dea6c60 100644 --- a/src/Avalonia.Animation/Easing/Easing.cs +++ b/src/Avalonia.Animation/Easing/Easing.cs @@ -1,10 +1,7 @@ -using Avalonia.Collections; using System; using System.Collections.Generic; -using System.Text; -using System.Reflection; -using System.Linq; using System.ComponentModel; +using System.Linq; namespace Avalonia.Animation.Easings { diff --git a/src/Avalonia.Animation/Easing/EasingTypeConverter.cs b/src/Avalonia.Animation/Easing/EasingTypeConverter.cs index 70ddfd2699..ee15761eff 100644 --- a/src/Avalonia.Animation/Easing/EasingTypeConverter.cs +++ b/src/Avalonia.Animation/Easing/EasingTypeConverter.cs @@ -1,7 +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 Avalonia.Animation.Easings; using System; using System.ComponentModel; using System.Globalization; @@ -20,4 +19,4 @@ namespace Avalonia.Animation.Easings return Easing.Parse((string)value); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Animation/Easing/ElasticEaseIn.cs b/src/Avalonia.Animation/Easing/ElasticEaseIn.cs index 0dea7b20a7..654ac6991b 100644 --- a/src/Avalonia.Animation/Easing/ElasticEaseIn.cs +++ b/src/Avalonia.Animation/Easing/ElasticEaseIn.cs @@ -1,8 +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 Avalonia.Animation.Utils; using System; +using Avalonia.Animation.Utils; namespace Avalonia.Animation.Easings { diff --git a/src/Avalonia.Animation/Easing/ElasticEaseOut.cs b/src/Avalonia.Animation/Easing/ElasticEaseOut.cs index 31e31374a0..1cc38a9dea 100644 --- a/src/Avalonia.Animation/Easing/ElasticEaseOut.cs +++ b/src/Avalonia.Animation/Easing/ElasticEaseOut.cs @@ -1,8 +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 Avalonia.Animation.Utils; using System; +using Avalonia.Animation.Utils; namespace Avalonia.Animation.Easings { diff --git a/src/Avalonia.Animation/Easing/SineEaseIn.cs b/src/Avalonia.Animation/Easing/SineEaseIn.cs index 31a8f0ca94..a4b496e4b6 100644 --- a/src/Avalonia.Animation/Easing/SineEaseIn.cs +++ b/src/Avalonia.Animation/Easing/SineEaseIn.cs @@ -1,8 +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 Avalonia.Animation.Utils; using System; +using Avalonia.Animation.Utils; namespace Avalonia.Animation.Easings { diff --git a/src/Avalonia.Animation/Easing/SineEaseOut.cs b/src/Avalonia.Animation/Easing/SineEaseOut.cs index ed5a998e30..267b4b3809 100644 --- a/src/Avalonia.Animation/Easing/SineEaseOut.cs +++ b/src/Avalonia.Animation/Easing/SineEaseOut.cs @@ -1,8 +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 Avalonia.Animation.Utils; using System; +using Avalonia.Animation.Utils; namespace Avalonia.Animation.Easings { diff --git a/src/Avalonia.Animation/FillMode.cs b/src/Avalonia.Animation/FillMode.cs index 047d185db5..001e1cdeb4 100644 --- a/src/Avalonia.Animation/FillMode.cs +++ b/src/Avalonia.Animation/FillMode.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Avalonia.Animation +namespace Avalonia.Animation { public enum FillMode { diff --git a/src/Avalonia.Animation/FloatTransition.cs b/src/Avalonia.Animation/FloatTransition.cs index b94295d311..825a3f958f 100644 --- a/src/Avalonia.Animation/FloatTransition.cs +++ b/src/Avalonia.Animation/FloatTransition.cs @@ -1,7 +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 Avalonia.Metadata; using System; using System.Reactive.Linq; diff --git a/src/Avalonia.Animation/IAnimation.cs b/src/Avalonia.Animation/IAnimation.cs index 905d90fa52..1d545a322a 100644 --- a/src/Avalonia.Animation/IAnimation.cs +++ b/src/Avalonia.Animation/IAnimation.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using System.Threading.Tasks; namespace Avalonia.Animation diff --git a/src/Avalonia.Animation/IAnimator.cs b/src/Avalonia.Animation/IAnimator.cs index 8b763db603..9a4da35a02 100644 --- a/src/Avalonia.Animation/IAnimator.cs +++ b/src/Avalonia.Animation/IAnimator.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; namespace Avalonia.Animation { diff --git a/src/Avalonia.Animation/ITransition.cs b/src/Avalonia.Animation/ITransition.cs index 76f45e0c87..e2ffe7fc6e 100644 --- a/src/Avalonia.Animation/ITransition.cs +++ b/src/Avalonia.Animation/ITransition.cs @@ -1,9 +1,7 @@ // 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.Metadata; using System; -using System.Reactive.Linq; namespace Avalonia.Animation { diff --git a/src/Avalonia.Animation/IntegerTransition.cs b/src/Avalonia.Animation/IntegerTransition.cs index 200b93a3df..e3dca5b26d 100644 --- a/src/Avalonia.Animation/IntegerTransition.cs +++ b/src/Avalonia.Animation/IntegerTransition.cs @@ -1,7 +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 Avalonia.Metadata; using System; using System.Reactive.Linq; diff --git a/src/Avalonia.Animation/KeyFrame.cs b/src/Avalonia.Animation/KeyFrame.cs index ea04aa0aab..5eb0d2e901 100644 --- a/src/Avalonia.Animation/KeyFrame.cs +++ b/src/Avalonia.Animation/KeyFrame.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; -using System.ComponentModel; -using Avalonia.Metadata; using Avalonia.Collections; namespace Avalonia.Animation diff --git a/src/Avalonia.Animation/KeyFramePair`1.cs b/src/Avalonia.Animation/KeyFramePair`1.cs index 408b13e0d8..b0622a1580 100644 --- a/src/Avalonia.Animation/KeyFramePair`1.cs +++ b/src/Avalonia.Animation/KeyFramePair`1.cs @@ -1,14 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Avalonia.Collections; -using System.ComponentModel; -using Avalonia.Animation.Utils; -using System.Reactive.Linq; -using System.Linq; -using Avalonia.Data; -using System.Reactive.Disposables; - namespace Avalonia.Animation { /// diff --git a/src/Avalonia.Animation/PlayState.cs b/src/Avalonia.Animation/PlayState.cs index a3a6eb34d7..313d33d586 100644 --- a/src/Avalonia.Animation/PlayState.cs +++ b/src/Avalonia.Animation/PlayState.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Avalonia.Animation +namespace Avalonia.Animation { /// /// Determines the playback state of an animation. @@ -24,4 +20,4 @@ namespace Avalonia.Animation /// Stop } -} \ No newline at end of file +} diff --git a/src/Avalonia.Animation/PlaybackDirection.cs b/src/Avalonia.Animation/PlaybackDirection.cs index 39529323da..bbce6106e1 100644 --- a/src/Avalonia.Animation/PlaybackDirection.cs +++ b/src/Avalonia.Animation/PlaybackDirection.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Avalonia.Animation +namespace Avalonia.Animation { /// /// Determines the playback direction of an animation. diff --git a/src/Avalonia.Animation/RepeatCount.cs b/src/Avalonia.Animation/RepeatCount.cs index 2050513df2..9794fe8f36 100644 --- a/src/Avalonia.Animation/RepeatCount.cs +++ b/src/Avalonia.Animation/RepeatCount.cs @@ -1,12 +1,9 @@ // 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.Utilities; using System; -using System.Collections.Generic; using System.ComponentModel; using System.Globalization; -using System.Linq; namespace Avalonia.Animation { @@ -199,4 +196,4 @@ namespace Avalonia.Animation } } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Animation/RepeatCountTypeConverter.cs b/src/Avalonia.Animation/RepeatCountTypeConverter.cs index 604e9b54e7..4eab50c1c7 100644 --- a/src/Avalonia.Animation/RepeatCountTypeConverter.cs +++ b/src/Avalonia.Animation/RepeatCountTypeConverter.cs @@ -1,7 +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 Avalonia.Animation.Easings; using System; using System.ComponentModel; using System.Globalization; @@ -20,4 +19,4 @@ namespace Avalonia.Animation return RepeatCount.Parse((string)value); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Animation/Timing.cs b/src/Avalonia.Animation/Timing.cs index 10d65cca7f..f1b8e3aacf 100644 --- a/src/Avalonia.Animation/Timing.cs +++ b/src/Avalonia.Animation/Timing.cs @@ -2,10 +2,8 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Diagnostics; using System.Linq; using System.Reactive.Linq; -using Avalonia.Data; using Avalonia.Threading; namespace Avalonia.Animation diff --git a/src/Avalonia.Animation/Transition`1.cs b/src/Avalonia.Animation/Transition`1.cs index 5db3082deb..240740a746 100644 --- a/src/Avalonia.Animation/Transition`1.cs +++ b/src/Avalonia.Animation/Transition`1.cs @@ -1,7 +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 Avalonia.Metadata; using System; using System.Reactive.Linq; using Avalonia.Animation.Easings; @@ -65,4 +64,4 @@ namespace Avalonia.Animation return control.Bind(Property, transition, Data.BindingPriority.Animation); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Animation/Utils/DoubleUtils.cs b/src/Avalonia.Animation/Utils/DoubleUtils.cs index 67943b687d..d2e74376a3 100644 --- a/src/Avalonia.Animation/Utils/DoubleUtils.cs +++ b/src/Avalonia.Animation/Utils/DoubleUtils.cs @@ -2,8 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Text; namespace Avalonia.Animation.Utils { diff --git a/src/Avalonia.Base/Data/Core/Plugins/DataValidationBase.cs b/src/Avalonia.Base/Data/Core/Plugins/DataValidationBase.cs index faec981eed..2e0d1aa805 100644 --- a/src/Avalonia.Base/Data/Core/Plugins/DataValidationBase.cs +++ b/src/Avalonia.Base/Data/Core/Plugins/DataValidationBase.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using Avalonia.Data; namespace Avalonia.Data.Core.Plugins { diff --git a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowingPlatform.cs b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowingPlatform.cs index ca3bb2b97f..01998052d9 100644 --- a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowingPlatform.cs +++ b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowingPlatform.cs @@ -63,4 +63,4 @@ namespace Avalonia.DesignerSupport.Remote public Size DoubleClickSize { get; } = new Size(2, 2); public TimeSpan DoubleClickTime { get; } = TimeSpan.FromMilliseconds(500); } -} \ No newline at end of file +} diff --git a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs index 2857272ac1..4536748836 100644 --- a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs +++ b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Net; using System.Reflection; using Avalonia.Controls; -using Avalonia.Controls.Shapes; -using Avalonia.DesignerSupport; using Avalonia.Input; using Avalonia.Remote.Protocol; using Avalonia.Remote.Protocol.Designer; @@ -207,4 +204,4 @@ namespace Avalonia.DesignerSupport.Remote } }); } -} \ No newline at end of file +} diff --git a/src/Avalonia.Diagnostics/Debug.cs b/src/Avalonia.Diagnostics/Debug.cs index 4313c3f0a2..af3b5a8552 100644 --- a/src/Avalonia.Diagnostics/Debug.cs +++ b/src/Avalonia.Diagnostics/Debug.cs @@ -2,10 +2,8 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Data; using Avalonia.VisualTree; diff --git a/src/Avalonia.Diagnostics/ViewModels/LogicalTreeNode.cs b/src/Avalonia.Diagnostics/ViewModels/LogicalTreeNode.cs index e8a8951f0d..638cf6c88f 100644 --- a/src/Avalonia.Diagnostics/ViewModels/LogicalTreeNode.cs +++ b/src/Avalonia.Diagnostics/ViewModels/LogicalTreeNode.cs @@ -1,7 +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; using Avalonia.Collections; using Avalonia.Controls; using Avalonia.LogicalTree; diff --git a/src/Avalonia.Diagnostics/ViewModels/ViewModelBase.cs b/src/Avalonia.Diagnostics/ViewModels/ViewModelBase.cs index 349404603a..00660754c0 100644 --- a/src/Avalonia.Diagnostics/ViewModels/ViewModelBase.cs +++ b/src/Avalonia.Diagnostics/ViewModels/ViewModelBase.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using JetBrains.Annotations; diff --git a/src/Avalonia.Diagnostics/Views/PropertyChangedExtenions.cs b/src/Avalonia.Diagnostics/Views/PropertyChangedExtenions.cs index 1d4ad24fd0..2d833763a6 100644 --- a/src/Avalonia.Diagnostics/Views/PropertyChangedExtenions.cs +++ b/src/Avalonia.Diagnostics/Views/PropertyChangedExtenions.cs @@ -5,7 +5,7 @@ using System.Reflection; namespace Avalonia.Diagnostics.Views { - internal static class PropertyChangedExtenions + internal static class PropertyChangedExtensions { public static IObservable GetObservable(this INotifyPropertyChanged source, string propertyName) { diff --git a/src/Avalonia.Diagnostics/Views/SimpleGrid.cs b/src/Avalonia.Diagnostics/Views/SimpleGrid.cs index fb5b7821f3..33d9d81ed7 100644 --- a/src/Avalonia.Diagnostics/Views/SimpleGrid.cs +++ b/src/Avalonia.Diagnostics/Views/SimpleGrid.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System.Collections.Generic; -using System.Linq; using Avalonia.Controls; namespace Avalonia.Diagnostics.Views diff --git a/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs b/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs index 5ae836eb24..5f1e845134 100644 --- a/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs +++ b/src/Avalonia.DotNetCoreRuntime/AppBuilder.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; +using System.Reflection; using Avalonia.Controls; using Avalonia.Platform; using Avalonia.Shared.PlatformSupport; @@ -60,4 +55,4 @@ namespace Avalonia void LoadWin32() => this.UseWin32(); void LoadGtk3() => this.UseGtk3(); } -} \ No newline at end of file +} diff --git a/src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs b/src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs index 348c3f6e25..0e70f09296 100644 --- a/src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs +++ b/src/Avalonia.DotNetCoreRuntime/RuntimeInfo.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using Avalonia.Platform; diff --git a/src/Avalonia.Input/AccessKeyHandler.cs b/src/Avalonia.Input/AccessKeyHandler.cs index b78e5a9f98..b36e145d44 100644 --- a/src/Avalonia.Input/AccessKeyHandler.cs +++ b/src/Avalonia.Input/AccessKeyHandler.cs @@ -49,7 +49,7 @@ namespace Avalonia.Input private bool _altIsDown; /// - /// Element to restore folowing AltKey taking focus. + /// Element to restore following AltKey taking focus. /// private IInputElement _restoreFocusElement; diff --git a/src/Avalonia.Input/Cursors.cs b/src/Avalonia.Input/Cursors.cs index f38f653503..6f67f3b08c 100644 --- a/src/Avalonia.Input/Cursors.cs +++ b/src/Avalonia.Input/Cursors.cs @@ -2,10 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Platform; namespace Avalonia.Input @@ -69,7 +65,7 @@ namespace Avalonia.Input { return Enum.TryParse(s, true, out var t) ? new Cursor(t) : - throw new ArgumentException($"Unrecognised cursor type '{s}'."); + throw new ArgumentException($"Unrecognized cursor type '{s}'."); } private static IPlatformHandle GetCursor(StandardCursorType type) diff --git a/src/Avalonia.Input/DataObject.cs b/src/Avalonia.Input/DataObject.cs index cb642f4d65..60d7d67606 100644 --- a/src/Avalonia.Input/DataObject.cs +++ b/src/Avalonia.Input/DataObject.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Avalonia.Input { diff --git a/src/Avalonia.Input/DragDrop.cs b/src/Avalonia.Input/DragDrop.cs index c312732afa..b5aba55f6c 100644 --- a/src/Avalonia.Input/DragDrop.cs +++ b/src/Avalonia.Input/DragDrop.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -using Avalonia.Interactivity; using Avalonia.Input.Platform; +using Avalonia.Interactivity; namespace Avalonia.Input { @@ -51,4 +51,4 @@ namespace Avalonia.Input return src?.DoDragDrop(data, allowedEffects) ?? Task.FromResult(DragDropEffects.None); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/ICustomKeyboardNavigation.cs b/src/Avalonia.Input/ICustomKeyboardNavigation.cs index de5f98e04b..ff4c2094b3 100644 --- a/src/Avalonia.Input/ICustomKeyboardNavigation.cs +++ b/src/Avalonia.Input/ICustomKeyboardNavigation.cs @@ -1,7 +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; namespace Avalonia.Input { diff --git a/src/Avalonia.Input/IDataObject.cs b/src/Avalonia.Input/IDataObject.cs index 1b12323d99..1aa8fd63d5 100644 --- a/src/Avalonia.Input/IDataObject.cs +++ b/src/Avalonia.Input/IDataObject.cs @@ -14,7 +14,7 @@ namespace Avalonia.Input IEnumerable GetDataFormats(); /// - /// Checks wether a given DataFormat is present in this object + /// Checks whether a given DataFormat is present in this object /// /// bool Contains(string dataFormat); @@ -36,4 +36,4 @@ namespace Avalonia.Input /// object Get(string dataFormat); } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/IInputManager.cs b/src/Avalonia.Input/IInputManager.cs index bc8ccbed5a..cdd72a7f3e 100644 --- a/src/Avalonia.Input/IInputManager.cs +++ b/src/Avalonia.Input/IInputManager.cs @@ -7,24 +7,24 @@ using Avalonia.Input.Raw; namespace Avalonia.Input { /// - /// Recieves input from the windowing subsystem and dispatches it to interested parties + /// Receives input from the windowing subsystem and dispatches it to interested parties /// for processing. /// public interface IInputManager { /// - /// Gets an observable that notifies on each input event recieved before + /// Gets an observable that notifies on each input event received before /// . /// IObservable PreProcess { get; } /// - /// Gets an observable that notifies on each input event recieved. + /// Gets an observable that notifies on each input event received. /// IObservable Process { get; } /// - /// Gets an observable that notifies on each input event recieved after + /// Gets an observable that notifies on each input event received after /// . /// IObservable PostProcess { get; } diff --git a/src/Avalonia.Input/IPointerDevice.cs b/src/Avalonia.Input/IPointerDevice.cs index 4ffbd1c6e3..8613717f60 100644 --- a/src/Avalonia.Input/IPointerDevice.cs +++ b/src/Avalonia.Input/IPointerDevice.cs @@ -1,8 +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; -using Avalonia.Interactivity; using Avalonia.VisualTree; namespace Avalonia.Input diff --git a/src/Avalonia.Input/InputElement.cs b/src/Avalonia.Input/InputElement.cs index 3aff5d0a8b..5aa0c1fe39 100644 --- a/src/Avalonia.Input/InputElement.cs +++ b/src/Avalonia.Input/InputElement.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Linq; using Avalonia.Interactivity; -using Avalonia.Rendering; using Avalonia.VisualTree; namespace Avalonia.Input diff --git a/src/Avalonia.Input/InputExtensions.cs b/src/Avalonia.Input/InputExtensions.cs index 01098e754e..a861bae528 100644 --- a/src/Avalonia.Input/InputExtensions.cs +++ b/src/Avalonia.Input/InputExtensions.cs @@ -1,10 +1,10 @@ // 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.VisualTree; using System; using System.Collections.Generic; using System.Linq; +using Avalonia.VisualTree; namespace Avalonia.Input { @@ -48,4 +48,4 @@ namespace Avalonia.Input element.IsEnabledCore; } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/InputManager.cs b/src/Avalonia.Input/InputManager.cs index 9e2d5ffea3..4fbdfd56c0 100644 --- a/src/Avalonia.Input/InputManager.cs +++ b/src/Avalonia.Input/InputManager.cs @@ -8,7 +8,7 @@ using Avalonia.Input.Raw; namespace Avalonia.Input { /// - /// Recieves input from the windowing subsystem and dispatches it to interested parties + /// Receives input from the windowing subsystem and dispatches it to interested parties /// for processing. /// public class InputManager : IInputManager diff --git a/src/Avalonia.Input/Key.cs b/src/Avalonia.Input/Key.cs index c10cbc0a6c..d4f95dbd5c 100644 --- a/src/Avalonia.Input/Key.cs +++ b/src/Avalonia.Input/Key.cs @@ -77,7 +77,7 @@ namespace Avalonia.Input KanaMode = 9, /// - /// The IME Janja mode key. + /// The IME Junja mode key. /// JunjaMode = 10, diff --git a/src/Avalonia.Input/KeyBinding.cs b/src/Avalonia.Input/KeyBinding.cs index 035b6978f4..856157eafa 100644 --- a/src/Avalonia.Input/KeyBinding.cs +++ b/src/Avalonia.Input/KeyBinding.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; namespace Avalonia.Input diff --git a/src/Avalonia.Input/KeyEventArgs.cs b/src/Avalonia.Input/KeyEventArgs.cs index c44f2b2fca..89053c6f61 100644 --- a/src/Avalonia.Input/KeyEventArgs.cs +++ b/src/Avalonia.Input/KeyEventArgs.cs @@ -1,7 +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; using Avalonia.Interactivity; namespace Avalonia.Input diff --git a/src/Avalonia.Input/KeyGesture.cs b/src/Avalonia.Input/KeyGesture.cs index 954333b80f..bb3b15c64f 100644 --- a/src/Avalonia.Input/KeyGesture.cs +++ b/src/Avalonia.Input/KeyGesture.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Input { @@ -45,7 +43,7 @@ namespace Avalonia.Input public InputModifiers Modifiers { get; set; } - static readonly Dictionary KeySynonims = new Dictionary + static readonly Dictionary KeySynonyms = new Dictionary { {"+", Key.OemPlus }, {"-", Key.OemMinus}, @@ -56,7 +54,7 @@ namespace Avalonia.Input static Key ParseKey(string key) { Key rv; - if (KeySynonims.TryGetValue(key.ToLower(), out rv)) + if (KeySynonyms.TryGetValue(key.ToLower(), out rv)) return rv; return (Key)Enum.Parse(typeof (Key), key, true); } diff --git a/src/Avalonia.Input/KeyboardDevice.cs b/src/Avalonia.Input/KeyboardDevice.cs index 2a1cdec1c0..00606bd9b1 100644 --- a/src/Avalonia.Input/KeyboardDevice.cs +++ b/src/Avalonia.Input/KeyboardDevice.cs @@ -1,10 +1,7 @@ // 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.ComponentModel; -using System.Linq; -using System.Reactive.Linq; using System.Runtime.CompilerServices; using Avalonia.Input.Raw; using Avalonia.Interactivity; diff --git a/src/Avalonia.Input/KeyboardNavigationHandler.cs b/src/Avalonia.Input/KeyboardNavigationHandler.cs index bc3098a7fb..32faf98603 100644 --- a/src/Avalonia.Input/KeyboardNavigationHandler.cs +++ b/src/Avalonia.Input/KeyboardNavigationHandler.cs @@ -46,7 +46,7 @@ namespace Avalonia.Input /// The navigation direction. /// /// The next element in the specified direction, or null if - /// was the last in therequested direction. + /// was the last in the requested direction. /// public static IInputElement GetNext( IInputElement element, diff --git a/src/Avalonia.Input/MouseDevice.cs b/src/Avalonia.Input/MouseDevice.cs index 7689f55d80..e581772978 100644 --- a/src/Avalonia.Input/MouseDevice.cs +++ b/src/Avalonia.Input/MouseDevice.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; using System.Linq; using System.Reactive.Linq; using Avalonia.Input.Raw; @@ -27,7 +26,7 @@ namespace Avalonia.Input /// Gets the control that is currently capturing by the mouse, if any. /// /// - /// When an element captures the mouse, it recieves mouse input whether the cursor is + /// When an element captures the mouse, it receives mouse input whether the cursor is /// within the control's bounds or not. To set the mouse capture, call the /// method. /// @@ -66,7 +65,7 @@ namespace Avalonia.Input /// /// The control. /// - /// When an element captures the mouse, it recieves mouse input whether the cursor is + /// When an element captures the mouse, it receives mouse input whether the cursor is /// within the control's bounds or not. The current mouse capture control is exposed /// by the property. /// diff --git a/src/Avalonia.Input/Platform/IClipboard.cs b/src/Avalonia.Input/Platform/IClipboard.cs index 2426af7f5a..4afb69f509 100644 --- a/src/Avalonia.Input/Platform/IClipboard.cs +++ b/src/Avalonia.Input/Platform/IClipboard.cs @@ -1,10 +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; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Avalonia.Input.Platform diff --git a/src/Avalonia.Input/Platform/IPlatformDragSource.cs b/src/Avalonia.Input/Platform/IPlatformDragSource.cs index 669251c50b..bfe69f3a90 100644 --- a/src/Avalonia.Input/Platform/IPlatformDragSource.cs +++ b/src/Avalonia.Input/Platform/IPlatformDragSource.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Input; -using Avalonia.Interactivity; +using System.Threading.Tasks; namespace Avalonia.Input.Platform { diff --git a/src/Avalonia.Input/Platform/IStandardCursorFactory.cs b/src/Avalonia.Input/Platform/IStandardCursorFactory.cs index 7510c0681e..393ba6b40a 100644 --- a/src/Avalonia.Input/Platform/IStandardCursorFactory.cs +++ b/src/Avalonia.Input/Platform/IStandardCursorFactory.cs @@ -1,11 +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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Input; namespace Avalonia.Platform diff --git a/src/Avalonia.Input/PointerEventArgs.cs b/src/Avalonia.Input/PointerEventArgs.cs index c4964897dd..7b2497c460 100644 --- a/src/Avalonia.Input/PointerEventArgs.cs +++ b/src/Avalonia.Input/PointerEventArgs.cs @@ -1,7 +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; using Avalonia.Interactivity; using Avalonia.VisualTree; diff --git a/src/Avalonia.Input/Raw/IDragDropDevice.cs b/src/Avalonia.Input/Raw/IDragDropDevice.cs index 6aab1b868d..f7b7914bd1 100644 --- a/src/Avalonia.Input/Raw/IDragDropDevice.cs +++ b/src/Avalonia.Input/Raw/IDragDropDevice.cs @@ -1,8 +1,6 @@ -using Avalonia.Input; - -namespace Avalonia.Input.Raw +namespace Avalonia.Input.Raw { public interface IDragDropDevice : IInputDevice { } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/Raw/RawDragEvent.cs b/src/Avalonia.Input/Raw/RawDragEvent.cs index 80653b4873..d251fe8640 100644 --- a/src/Avalonia.Input/Raw/RawDragEvent.cs +++ b/src/Avalonia.Input/Raw/RawDragEvent.cs @@ -1,8 +1,4 @@ -using System; -using Avalonia.Input; -using Avalonia.Input.Raw; - -namespace Avalonia.Input.Raw +namespace Avalonia.Input.Raw { public class RawDragEvent : RawInputEventArgs { @@ -25,4 +21,4 @@ namespace Avalonia.Input.Raw Modifiers = modifiers; } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Input/Raw/RawMouseWheelEventArgs.cs b/src/Avalonia.Input/Raw/RawMouseWheelEventArgs.cs index d0ea8e5b93..f4078af9e1 100644 --- a/src/Avalonia.Input/Raw/RawMouseWheelEventArgs.cs +++ b/src/Avalonia.Input/Raw/RawMouseWheelEventArgs.cs @@ -1,8 +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; -using Avalonia.Layout; namespace Avalonia.Input.Raw { diff --git a/src/Avalonia.Input/TextInputEventArgs.cs b/src/Avalonia.Input/TextInputEventArgs.cs index 17df088bdd..b7203b54d5 100644 --- a/src/Avalonia.Input/TextInputEventArgs.cs +++ b/src/Avalonia.Input/TextInputEventArgs.cs @@ -1,11 +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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Interactivity; namespace Avalonia.Input diff --git a/src/Avalonia.Interactivity/IInteractive.cs b/src/Avalonia.Interactivity/IInteractive.cs index dee8396f39..47046b58e2 100644 --- a/src/Avalonia.Interactivity/IInteractive.cs +++ b/src/Avalonia.Interactivity/IInteractive.cs @@ -11,7 +11,7 @@ namespace Avalonia.Interactivity public interface IInteractive { /// - /// Gets the interactive parent of the object for bubbling and tunnelling events. + /// Gets the interactive parent of the object for bubbling and tunneling events. /// IInteractive InteractiveParent { get; } diff --git a/src/Avalonia.Interactivity/Interactive.cs b/src/Avalonia.Interactivity/Interactive.cs index 78df6f6151..911fc2130e 100644 --- a/src/Avalonia.Interactivity/Interactive.cs +++ b/src/Avalonia.Interactivity/Interactive.cs @@ -19,7 +19,7 @@ namespace Avalonia.Interactivity private Dictionary> _eventHandlers; /// - /// Gets the interactive parent of the object for bubbling and tunnelling events. + /// Gets the interactive parent of the object for bubbling and tunneling events. /// IInteractive IInteractive.InteractiveParent => ((IVisual)this).VisualParent as IInteractive; diff --git a/src/Avalonia.Layout/ILayoutManager.cs b/src/Avalonia.Layout/ILayoutManager.cs index b41cfd9f91..a255fb155c 100644 --- a/src/Avalonia.Layout/ILayoutManager.cs +++ b/src/Avalonia.Layout/ILayoutManager.cs @@ -1,8 +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; -using System.Reactive; namespace Avalonia.Layout { diff --git a/src/Avalonia.Layout/LayoutManager.cs b/src/Avalonia.Layout/LayoutManager.cs index 9cf8521008..f3540ea631 100644 --- a/src/Avalonia.Layout/LayoutManager.cs +++ b/src/Avalonia.Layout/LayoutManager.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Avalonia.Logging; using Avalonia.Threading; @@ -100,7 +99,7 @@ namespace Avalonia.Layout } stopwatch.Stop(); - Logger.Information(LogArea.Layout, this, "Layout pass finised in {Time}", stopwatch.Elapsed); + Logger.Information(LogArea.Layout, this, "Layout pass finished in {Time}", stopwatch.Elapsed); } _queued = false; @@ -150,7 +149,7 @@ namespace Avalonia.Layout // Controls closest to the visual root need to be arranged first. We don't try to store // ordered invalidation lists, instead we traverse the tree upwards, measuring the // controls closest to the root first. This has been shown by benchmarks to be the - // fastest and most memory-efficent algorithm. + // fastest and most memory-efficient algorithm. if (control.VisualParent is ILayoutable parent) { Measure(parent); diff --git a/src/Avalonia.Layout/Layoutable.cs b/src/Avalonia.Layout/Layoutable.cs index 7112e216ff..54bdbb5d48 100644 --- a/src/Avalonia.Layout/Layoutable.cs +++ b/src/Avalonia.Layout/Layoutable.cs @@ -4,7 +4,6 @@ using System; using System.Linq; using Avalonia.Logging; -using Avalonia.Platform; using Avalonia.VisualTree; namespace Avalonia.Layout @@ -654,7 +653,7 @@ namespace Avalonia.Layout } /// - /// Tests whether any of a 's properties incude nagative values, + /// Tests whether any of a 's properties include negative values, /// a NaN or Infinity. /// /// The rect. @@ -669,7 +668,7 @@ namespace Avalonia.Layout } /// - /// Tests whether any of a 's properties incude nagative values, + /// Tests whether any of a 's properties include negative values, /// a NaN or Infinity. /// /// The size. diff --git a/src/Avalonia.Logging.Serilog/SerilogExtensions.cs b/src/Avalonia.Logging.Serilog/SerilogExtensions.cs index 6abc7e4684..7382421dc6 100644 --- a/src/Avalonia.Logging.Serilog/SerilogExtensions.cs +++ b/src/Avalonia.Logging.Serilog/SerilogExtensions.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Controls; +using Avalonia.Controls; using Serilog; using SerilogLevel = Serilog.Events.LogEventLevel; diff --git a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs index e081763e99..3eab54115a 100644 --- a/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs +++ b/src/Avalonia.ReactiveUI/AppBuilderExtensions.cs @@ -4,9 +4,6 @@ using Avalonia.Controls; using Avalonia.Threading; using ReactiveUI; -using System; -using System.Reactive.Concurrency; -using System.Threading; namespace Avalonia { diff --git a/src/Avalonia.Remote.Protocol/AvaloniaRemoteMessageGuidAttribute.cs b/src/Avalonia.Remote.Protocol/AvaloniaRemoteMessageGuidAttribute.cs index 12ee3178d3..98a843bad1 100644 --- a/src/Avalonia.Remote.Protocol/AvaloniaRemoteMessageGuidAttribute.cs +++ b/src/Avalonia.Remote.Protocol/AvaloniaRemoteMessageGuidAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Remote.Protocol { diff --git a/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs b/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs index 93a3b60599..78712985d9 100644 --- a/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs +++ b/src/Avalonia.Remote.Protocol/BsonStreamTransport.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Threading; using System.Threading.Tasks; diff --git a/src/Avalonia.Remote.Protocol/DefaultMessageTypeResolver.cs b/src/Avalonia.Remote.Protocol/DefaultMessageTypeResolver.cs index 9d44f33627..fb909dd58d 100644 --- a/src/Avalonia.Remote.Protocol/DefaultMessageTypeResolver.cs +++ b/src/Avalonia.Remote.Protocol/DefaultMessageTypeResolver.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Remote.Protocol { diff --git a/src/Avalonia.Remote.Protocol/ITransport.cs b/src/Avalonia.Remote.Protocol/ITransport.cs index afc7d86845..0f419b95ae 100644 --- a/src/Avalonia.Remote.Protocol/ITransport.cs +++ b/src/Avalonia.Remote.Protocol/ITransport.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading.Tasks; namespace Avalonia.Remote.Protocol diff --git a/src/Avalonia.Remote.Protocol/InputMessages.cs b/src/Avalonia.Remote.Protocol/InputMessages.cs index f1996372fc..e612eb3730 100644 --- a/src/Avalonia.Remote.Protocol/InputMessages.cs +++ b/src/Avalonia.Remote.Protocol/InputMessages.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; /* We are keeping copies of core events here, so they can be used without referencing Avalonia itself, e. g. from projects that diff --git a/src/Avalonia.Remote.Protocol/MetsysBson.cs b/src/Avalonia.Remote.Protocol/MetsysBson.cs index eb6445c3a5..f6bb73129f 100644 --- a/src/Avalonia.Remote.Protocol/MetsysBson.cs +++ b/src/Avalonia.Remote.Protocol/MetsysBson.cs @@ -28,20 +28,19 @@ Code imported from https://github.com/elaberge/Metsys.Bson without any changes */ -using System.Text; -using System.Text.RegularExpressions; -using System.IO; +using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Net; -using System.Security.Cryptography; +using System.IO; using System.Linq; using System.Linq.Expressions; +using System.Net; using System.Reflection; -using System; using System.Runtime.Serialization; - +using System.Security.Cryptography; +using System.Text; +using System.Text.RegularExpressions; using Metsys.Bson.Configuration; // ReSharper disable All @@ -251,7 +250,7 @@ namespace Metsys.Bson _writer.Write((long)((DateTime)value).ToUniversalTime().Subtract(Helper.Epoch).TotalMilliseconds); return; case Types.Binary: - WriteBinnary(value); + WriteBinary(value); return; case Types.ScopedCode: Write((ScopedCode)value); @@ -309,7 +308,7 @@ namespace Metsys.Bson } } - private void WriteBinnary(object value) + private void WriteBinary(object value) { if (value is byte[]) { @@ -833,14 +832,14 @@ namespace Metsys.Bson return enumerableType.IsGenericType ? enumerableType.GetGenericArguments()[0] : typeof(object); } - public static Type GetDictionarKeyType(Type enumerableType) + public static Type GetDictionaryKeyType(Type enumerableType) { return enumerableType.IsGenericType ? enumerableType.GetGenericArguments()[0] : typeof(object); } - public static Type GetDictionarValueType(Type enumerableType) + public static Type GetDictionaryValueType(Type enumerableType) { return enumerableType.IsGenericType ? enumerableType.GetGenericArguments()[1] @@ -1259,9 +1258,9 @@ namespace Metsys.Bson private object ReadDictionary(Type listType, object existingContainer, Options options) { - var valueType = ListHelper.GetDictionarValueType(listType); + var valueType = ListHelper.GetDictionaryValueType(listType); var isObject = typeof(object) == valueType; - var container = existingContainer == null ? ListHelper.CreateDictionary(listType, ListHelper.GetDictionarKeyType(listType), valueType) : (IDictionary)existingContainer; + var container = existingContainer == null ? ListHelper.CreateDictionary(listType, ListHelper.GetDictionaryKeyType(listType), valueType) : (IDictionary)existingContainer; while (!IsDone()) { @@ -1310,7 +1309,7 @@ namespace Metsys.Bson private string ReadString() { var length = _reader.ReadInt32(); - var buffer = _reader.ReadBytes(length - 1); //todo: again, look at fragementation prevention + var buffer = _reader.ReadBytes(length - 1); //todo: again, look at fragmentation prevention _reader.ReadByte(); //null; Read(4 + length); diff --git a/src/Avalonia.Remote.Protocol/ViewportMessages.cs b/src/Avalonia.Remote.Protocol/ViewportMessages.cs index f71e893d26..0627e9d629 100644 --- a/src/Avalonia.Remote.Protocol/ViewportMessages.cs +++ b/src/Avalonia.Remote.Protocol/ViewportMessages.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Avalonia.Remote.Protocol.Viewport +namespace Avalonia.Remote.Protocol.Viewport { public enum PixelFormat { diff --git a/src/Avalonia.Styling/Controls/Classes.cs b/src/Avalonia.Styling/Controls/Classes.cs index 85935b030b..3981ec01ad 100644 --- a/src/Avalonia.Styling/Controls/Classes.cs +++ b/src/Avalonia.Styling/Controls/Classes.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Avalonia.Collections; namespace Avalonia.Controls diff --git a/src/Avalonia.Styling/Controls/INameScope.cs b/src/Avalonia.Styling/Controls/INameScope.cs index e88186e276..e4ff90c573 100644 --- a/src/Avalonia.Styling/Controls/INameScope.cs +++ b/src/Avalonia.Styling/Controls/INameScope.cs @@ -21,7 +21,7 @@ namespace Avalonia.Controls event EventHandler Unregistered; /// - /// Registers an element eith the name scope. + /// Registers an element in the name scope. /// /// The element name. /// The element. diff --git a/src/Avalonia.Styling/Controls/IPseudoClasses.cs b/src/Avalonia.Styling/Controls/IPseudoClasses.cs index 56320a6f6f..6c59078ebc 100644 --- a/src/Avalonia.Styling/Controls/IPseudoClasses.cs +++ b/src/Avalonia.Styling/Controls/IPseudoClasses.cs @@ -1,7 +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; namespace Avalonia.Controls { diff --git a/src/Avalonia.Styling/Controls/IResourceDictionary.cs b/src/Avalonia.Styling/Controls/IResourceDictionary.cs index d7c86b7d74..2a395f44b4 100644 --- a/src/Avalonia.Styling/Controls/IResourceDictionary.cs +++ b/src/Avalonia.Styling/Controls/IResourceDictionary.cs @@ -1,7 +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; using System.Collections.Generic; namespace Avalonia.Controls diff --git a/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs b/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs index 1586c61185..52309b87a2 100644 --- a/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs +++ b/src/Avalonia.Styling/Controls/ResourceProviderExtensions.cs @@ -1,6 +1,4 @@ using System; -using System.Reactive; -using System.Reactive.Linq; using Avalonia.Reactive; namespace Avalonia.Controls diff --git a/src/Avalonia.Styling/IStyledElement.cs b/src/Avalonia.Styling/IStyledElement.cs index 8369717233..bcf1898c4c 100644 --- a/src/Avalonia.Styling/IStyledElement.cs +++ b/src/Avalonia.Styling/IStyledElement.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Controls; using Avalonia.LogicalTree; using Avalonia.Styling; diff --git a/src/Avalonia.Styling/StyledElement.cs b/src/Avalonia.Styling/StyledElement.cs index bd0d0b8c1f..1964078b56 100644 --- a/src/Avalonia.Styling/StyledElement.cs +++ b/src/Avalonia.Styling/StyledElement.cs @@ -4,7 +4,6 @@ using System.Collections.Specialized; using System.Linq; using System.Reactive.Linq; using System.Reactive.Subjects; -using System.Text; using Avalonia.Animation; using Avalonia.Collections; using Avalonia.Controls; @@ -160,7 +159,7 @@ namespace Avalonia /// /// Even though this property can be set, the setter is only intended for use in object /// initializers. Assigning to this property does not change the underlying collection, - /// it simply clears the existing collection and addds the contents of the assigned + /// it simply clears the existing collection and adds the contents of the assigned /// collection. /// /// @@ -469,7 +468,7 @@ namespace Avalonia if (newRoot == null) { - throw new AvaloniaInternalException("Parent is atttached to logical tree but cannot find root."); + throw new AvaloniaInternalException("Parent is attached to logical tree but cannot find root."); } var e = new LogicalTreeAttachmentEventArgs(newRoot); @@ -749,7 +748,7 @@ namespace Avalonia break; case NotifyCollectionChangedAction.Reset: - throw new NotSupportedException("Reset should not be signalled on LogicalChildren collection"); + throw new NotSupportedException("Reset should not be signaled on LogicalChildren collection"); } } diff --git a/src/Avalonia.Styling/Styling/IRequiresTemplateInSetter.cs b/src/Avalonia.Styling/Styling/IRequiresTemplateInSetter.cs index 1f64326526..2d562b78d9 100644 --- a/src/Avalonia.Styling/Styling/IRequiresTemplateInSetter.cs +++ b/src/Avalonia.Styling/Styling/IRequiresTemplateInSetter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Avalonia.Styling +namespace Avalonia.Styling { /// /// This is an interface for advanced scenarios to assist users in correct style development. diff --git a/src/Avalonia.Styling/Styling/ISetStyleParent.cs b/src/Avalonia.Styling/Styling/ISetStyleParent.cs index 9f5855b401..bca3d9d714 100644 --- a/src/Avalonia.Styling/Styling/ISetStyleParent.cs +++ b/src/Avalonia.Styling/Styling/ISetStyleParent.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Avalonia.Controls; +using Avalonia.Controls; namespace Avalonia.Styling { diff --git a/src/Avalonia.Styling/Styling/IStyleHost.cs b/src/Avalonia.Styling/Styling/IStyleHost.cs index b225419c2d..fa722aeb41 100644 --- a/src/Avalonia.Styling/Styling/IStyleHost.cs +++ b/src/Avalonia.Styling/Styling/IStyleHost.cs @@ -1,7 +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; namespace Avalonia.Styling { diff --git a/src/Avalonia.Styling/Styling/IStyleable.cs b/src/Avalonia.Styling/Styling/IStyleable.cs index 98c8501681..5ad97d8a61 100644 --- a/src/Avalonia.Styling/Styling/IStyleable.cs +++ b/src/Avalonia.Styling/Styling/IStyleable.cs @@ -3,7 +3,6 @@ using System; using Avalonia.Collections; -using Avalonia.LogicalTree; namespace Avalonia.Styling { @@ -13,7 +12,7 @@ namespace Avalonia.Styling public interface IStyleable : IAvaloniaObject, INamed { /// - /// Signalled when the control's style should be removed. + /// Signaled when the control's style should be removed. /// IObservable StyleDetach { get; } diff --git a/src/Avalonia.Styling/Styling/IStyler.cs b/src/Avalonia.Styling/Styling/IStyler.cs index 0789c3d3cc..97fe1497c8 100644 --- a/src/Avalonia.Styling/Styling/IStyler.cs +++ b/src/Avalonia.Styling/Styling/IStyler.cs @@ -1,7 +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; namespace Avalonia.Styling { diff --git a/src/Avalonia.Styling/Styling/ITemplatedControl.cs b/src/Avalonia.Styling/Styling/ITemplatedControl.cs index 3bf981b69b..4e1a51e18a 100644 --- a/src/Avalonia.Styling/Styling/ITemplatedControl.cs +++ b/src/Avalonia.Styling/Styling/ITemplatedControl.cs @@ -1,7 +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; namespace Avalonia.Styling { diff --git a/src/Avalonia.Styling/Styling/SelectorMatch.cs b/src/Avalonia.Styling/Styling/SelectorMatch.cs index f73c1497ce..f325578389 100644 --- a/src/Avalonia.Styling/Styling/SelectorMatch.cs +++ b/src/Avalonia.Styling/Styling/SelectorMatch.cs @@ -41,7 +41,7 @@ namespace Avalonia.Styling } /// - /// Gets the immedate result of the selector match, in the case of selectors that cannot + /// Gets the immediate result of the selector match, in the case of selectors that cannot /// change over time. /// public bool? ImmediateResult { get; } diff --git a/src/Avalonia.Styling/Styling/Setter.cs b/src/Avalonia.Styling/Styling/Setter.cs index c75bae4db8..54d0a7d40f 100644 --- a/src/Avalonia.Styling/Styling/Setter.cs +++ b/src/Avalonia.Styling/Styling/Setter.cs @@ -3,7 +3,6 @@ using System; using System.Reactive.Disposables; -using System.Reactive.Subjects; using System.Reflection; using Avalonia.Animation; using Avalonia.Controls; diff --git a/src/Avalonia.Styling/Styling/Style.cs b/src/Avalonia.Styling/Styling/Style.cs index 203f679683..399be5470d 100644 --- a/src/Avalonia.Styling/Styling/Style.cs +++ b/src/Avalonia.Styling/Styling/Style.cs @@ -3,12 +3,10 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; using System.Reactive.Linq; +using Avalonia.Animation; using Avalonia.Controls; using Avalonia.Metadata; -using Avalonia.Animation; -using System.Diagnostics; namespace Avalonia.Styling { @@ -200,7 +198,7 @@ namespace Avalonia.Styling } /// - /// Called when a control's is signalled to remove + /// Called when a control's is signaled to remove /// all applied styles. /// /// The control. diff --git a/src/Avalonia.Visuals/Animation/CrossFade.cs b/src/Avalonia.Visuals/Animation/CrossFade.cs index 2230f8534b..3795d66d05 100644 --- a/src/Avalonia.Visuals/Animation/CrossFade.cs +++ b/src/Avalonia.Visuals/Animation/CrossFade.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using Avalonia.Styling; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Animation/IPageTransition.cs b/src/Avalonia.Visuals/Animation/IPageTransition.cs index 88912c1931..4f598fa08e 100644 --- a/src/Avalonia.Visuals/Animation/IPageTransition.cs +++ b/src/Avalonia.Visuals/Animation/IPageTransition.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System.Threading.Tasks; -using Avalonia.VisualTree; namespace Avalonia.Animation { diff --git a/src/Avalonia.Visuals/Animation/PageSlide.cs b/src/Avalonia.Visuals/Animation/PageSlide.cs index 5f03dc6b0c..dc2c64f1c7 100644 --- a/src/Avalonia.Visuals/Animation/PageSlide.cs +++ b/src/Avalonia.Visuals/Animation/PageSlide.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Reactive.Threading.Tasks; using System.Threading.Tasks; using Avalonia.Media; using Avalonia.Styling; diff --git a/src/Avalonia.Visuals/Animation/PointTransition.cs b/src/Avalonia.Visuals/Animation/PointTransition.cs index 4412852781..a883c517dd 100644 --- a/src/Avalonia.Visuals/Animation/PointTransition.cs +++ b/src/Avalonia.Visuals/Animation/PointTransition.cs @@ -1,7 +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 Avalonia.Metadata; using System; using System.Reactive.Linq; diff --git a/src/Avalonia.Visuals/Animation/ThicknessTransition.cs b/src/Avalonia.Visuals/Animation/ThicknessTransition.cs index 22876dd8e2..6c2ca22b74 100644 --- a/src/Avalonia.Visuals/Animation/ThicknessTransition.cs +++ b/src/Avalonia.Visuals/Animation/ThicknessTransition.cs @@ -1,7 +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 Avalonia.Metadata; using System; using System.Reactive.Linq; diff --git a/src/Avalonia.Visuals/Animation/TransformAnimator.cs b/src/Avalonia.Visuals/Animation/TransformAnimator.cs index 61cac695b1..2be1226abe 100644 --- a/src/Avalonia.Visuals/Animation/TransformAnimator.cs +++ b/src/Avalonia.Visuals/Animation/TransformAnimator.cs @@ -1,13 +1,6 @@ using System; -using System.Collections.Generic; -using System.Text; -using Avalonia.Collections; -using System.ComponentModel; -using Avalonia.Animation.Utils; -using System.Reactive.Linq; -using System.Linq; -using Avalonia.Media; using Avalonia.Logging; +using Avalonia.Media; namespace Avalonia.Animation { diff --git a/src/Avalonia.Visuals/CornerRadius.cs b/src/Avalonia.Visuals/CornerRadius.cs index 33a553d477..2d41acb5bc 100644 --- a/src/Avalonia.Visuals/CornerRadius.cs +++ b/src/Avalonia.Visuals/CornerRadius.cs @@ -3,7 +3,6 @@ using System; using System.Globalization; -using System.Linq; using Avalonia.Utilities; namespace Avalonia @@ -90,4 +89,4 @@ namespace Avalonia return !(cr1 == cr2); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Matrix.cs b/src/Avalonia.Visuals/Matrix.cs index 9ed5923109..287ad1b3a2 100644 --- a/src/Avalonia.Visuals/Matrix.cs +++ b/src/Avalonia.Visuals/Matrix.cs @@ -1,10 +1,9 @@ // 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.Utilities; using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -56,7 +55,7 @@ namespace Avalonia public bool IsIdentity => Equals(Identity); /// - /// HasInverse Property - returns true if this matrix is invertable, false otherwise. + /// HasInverse Property - returns true if this matrix is invertible, false otherwise. /// public bool HasInverse => GetDeterminant() != 0; @@ -207,7 +206,7 @@ namespace Avalonia } /// - /// Converts an ange in degrees to radians. + /// Converts an angle in degrees to radians. /// /// The angle in degrees. /// The angle in radians. @@ -330,4 +329,4 @@ namespace Avalonia } } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/BrushMappingMode.cs b/src/Avalonia.Visuals/Media/BrushMappingMode.cs index 15fb9700ca..eb64a063a1 100644 --- a/src/Avalonia.Visuals/Media/BrushMappingMode.cs +++ b/src/Avalonia.Visuals/Media/BrushMappingMode.cs @@ -1,11 +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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Media { @@ -14,4 +9,4 @@ namespace Avalonia.Media Absolute, RelativeToBoundingBox } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/Color.cs b/src/Avalonia.Visuals/Media/Color.cs index 1ee5da1324..8294934751 100644 --- a/src/Avalonia.Visuals/Media/Color.cs +++ b/src/Avalonia.Visuals/Media/Color.cs @@ -3,8 +3,6 @@ using System; using System.Globalization; -using System.Linq; -using System.Reflection; namespace Avalonia.Media { @@ -140,4 +138,4 @@ namespace Avalonia.Media return ((uint)A << 24) | ((uint)R << 16) | ((uint)G << 8) | (uint)B; } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/Colors.cs b/src/Avalonia.Visuals/Media/Colors.cs index 1067cf66aa..ca4a0793cb 100644 --- a/src/Avalonia.Visuals/Media/Colors.cs +++ b/src/Avalonia.Visuals/Media/Colors.cs @@ -1,7 +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.Linq; namespace Avalonia.Media { @@ -715,4 +714,4 @@ namespace Avalonia.Media /// public static Color YellowGreen => KnownColor.YellowGreen.ToColor(); } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/DashStyle.cs b/src/Avalonia.Visuals/Media/DashStyle.cs index 3fcfcaee70..c7e1db57b2 100644 --- a/src/Avalonia.Visuals/Media/DashStyle.cs +++ b/src/Avalonia.Visuals/Media/DashStyle.cs @@ -1,11 +1,7 @@ namespace Avalonia.Media { - using Avalonia.Animation; - using System; using System.Collections.Generic; - using System.Linq; - using System.Text; - using System.Threading.Tasks; + using Avalonia.Animation; public class DashStyle : Animatable { diff --git a/src/Avalonia.Visuals/Media/DrawingContext.cs b/src/Avalonia.Visuals/Media/DrawingContext.cs index 60a7a2e518..6b19167381 100644 --- a/src/Avalonia.Visuals/Media/DrawingContext.cs +++ b/src/Avalonia.Visuals/Media/DrawingContext.cs @@ -5,7 +5,7 @@ using Avalonia.Platform; using Avalonia.Visuals.Media.Imaging; namespace Avalonia.Media -{ +{ public sealed class DrawingContext : IDisposable { private int _currentLevel; @@ -205,7 +205,7 @@ namespace Avalonia.Media /// - /// Pushes a clip rectange. + /// Pushes a clip rectangle. /// /// The clip rectangle. /// A disposable used to undo the clip rectangle. diff --git a/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs b/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs index 2b77371bb5..57e6c756cc 100644 --- a/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs +++ b/src/Avalonia.Visuals/Media/Fonts/FontFamilyLoader.cs @@ -26,7 +26,7 @@ namespace Avalonia.Media.Fonts } /// - /// Searches for font assets at a given location and returns a quanity of found assets + /// Searches for font assets at a given location and returns a quantity of found assets /// /// /// @@ -69,4 +69,4 @@ namespace Avalonia.Media.Fonts return new Uri("resm:" + absolutePath + "?assembly=" + assembly.GetName().Name, UriKind.RelativeOrAbsolute); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/FormattedText.cs b/src/Avalonia.Visuals/Media/FormattedText.cs index 9a052f4eb9..0d456eb3b7 100644 --- a/src/Avalonia.Visuals/Media/FormattedText.cs +++ b/src/Avalonia.Visuals/Media/FormattedText.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Platform; @@ -76,7 +75,7 @@ namespace Avalonia.Media } /// - /// Gets or sets the aligment of the text. + /// Gets or sets the alignment of the text. /// public TextAlignment TextAlignment { diff --git a/src/Avalonia.Visuals/Media/FormattedTextStyleSpan.cs b/src/Avalonia.Visuals/Media/FormattedTextStyleSpan.cs index 96a5c05c74..92fdd651c3 100644 --- a/src/Avalonia.Visuals/Media/FormattedTextStyleSpan.cs +++ b/src/Avalonia.Visuals/Media/FormattedTextStyleSpan.cs @@ -1,6 +1,4 @@ -using System; - -namespace Avalonia.Media +namespace Avalonia.Media { /// /// Describes the formatting for a span of text in a object. diff --git a/src/Avalonia.Visuals/Media/GradientBrush.cs b/src/Avalonia.Visuals/Media/GradientBrush.cs index fb29f68373..41c3afc8c3 100644 --- a/src/Avalonia.Visuals/Media/GradientBrush.cs +++ b/src/Avalonia.Visuals/Media/GradientBrush.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Metadata; @@ -52,4 +51,4 @@ namespace Avalonia.Media set { SetValue(GradientStopsProperty, value); } } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/GradientSpreadMethod.cs b/src/Avalonia.Visuals/Media/GradientSpreadMethod.cs index 4020a6afbd..f9506d78a0 100644 --- a/src/Avalonia.Visuals/Media/GradientSpreadMethod.cs +++ b/src/Avalonia.Visuals/Media/GradientSpreadMethod.cs @@ -1,12 +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; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Avalonia.Media { public enum GradientSpreadMethod @@ -15,4 +9,4 @@ namespace Avalonia.Media Reflect, Repeat } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/IMutableBrush.cs b/src/Avalonia.Visuals/Media/IMutableBrush.cs index f9cd97077c..39dd8b80c4 100644 --- a/src/Avalonia.Visuals/Media/IMutableBrush.cs +++ b/src/Avalonia.Visuals/Media/IMutableBrush.cs @@ -1,6 +1,4 @@ -using System; - -namespace Avalonia.Media +namespace Avalonia.Media { /// /// Represents a mutable brush which can return an immutable clone of itself. diff --git a/src/Avalonia.Visuals/Media/Imaging/RenderTargetBitmap.cs b/src/Avalonia.Visuals/Media/Imaging/RenderTargetBitmap.cs index 52bd8a3c04..db2259dde3 100644 --- a/src/Avalonia.Visuals/Media/Imaging/RenderTargetBitmap.cs +++ b/src/Avalonia.Visuals/Media/Imaging/RenderTargetBitmap.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Runtime.CompilerServices; using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Utilities; @@ -44,7 +43,7 @@ namespace Avalonia.Media.Imaging public void Render(IVisual visual) => ImmediateRenderer.Render(visual, this); /// - /// Creates a platform-specific imlementation for a . + /// Creates a platform-specific implementation for a . /// /// The width of the bitmap. /// The height of the bitmap. diff --git a/src/Avalonia.Visuals/Media/Imaging/WriteableBitmap.cs b/src/Avalonia.Visuals/Media/Imaging/WriteableBitmap.cs index af6fde6876..529c2efa42 100644 --- a/src/Avalonia.Visuals/Media/Imaging/WriteableBitmap.cs +++ b/src/Avalonia.Visuals/Media/Imaging/WriteableBitmap.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Platform; -using Avalonia.Utilities; +using Avalonia.Platform; namespace Avalonia.Media.Imaging { diff --git a/src/Avalonia.Visuals/Media/Immutable/ImmutableGradientBrush.cs b/src/Avalonia.Visuals/Media/Immutable/ImmutableGradientBrush.cs index ca67789c7f..6664a2b30e 100644 --- a/src/Avalonia.Visuals/Media/Immutable/ImmutableGradientBrush.cs +++ b/src/Avalonia.Visuals/Media/Immutable/ImmutableGradientBrush.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; namespace Avalonia.Media.Immutable diff --git a/src/Avalonia.Visuals/Media/Immutable/ImmutableLinearGradientBrush.cs b/src/Avalonia.Visuals/Media/Immutable/ImmutableLinearGradientBrush.cs index 39ddc305fb..142eb34625 100644 --- a/src/Avalonia.Visuals/Media/Immutable/ImmutableLinearGradientBrush.cs +++ b/src/Avalonia.Visuals/Media/Immutable/ImmutableLinearGradientBrush.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Avalonia.Media.Immutable { diff --git a/src/Avalonia.Visuals/Media/Immutable/ImmutableRadialGradientBrush.cs b/src/Avalonia.Visuals/Media/Immutable/ImmutableRadialGradientBrush.cs index 672a45ebc4..f36a1cd2de 100644 --- a/src/Avalonia.Visuals/Media/Immutable/ImmutableRadialGradientBrush.cs +++ b/src/Avalonia.Visuals/Media/Immutable/ImmutableRadialGradientBrush.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Avalonia.Media.Immutable { diff --git a/src/Avalonia.Visuals/Media/LinearGradientBrush.cs b/src/Avalonia.Visuals/Media/LinearGradientBrush.cs index 344e05e16e..d092bebf0f 100644 --- a/src/Avalonia.Visuals/Media/LinearGradientBrush.cs +++ b/src/Avalonia.Visuals/Media/LinearGradientBrush.cs @@ -1,8 +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; - namespace Avalonia.Media { /// @@ -50,4 +48,4 @@ namespace Avalonia.Media return new Immutable.ImmutableLinearGradientBrush(this); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/PathGeometry.cs b/src/Avalonia.Visuals/Media/PathGeometry.cs index e7a2c8577a..3a91c924d2 100644 --- a/src/Avalonia.Visuals/Media/PathGeometry.cs +++ b/src/Avalonia.Visuals/Media/PathGeometry.cs @@ -113,4 +113,4 @@ namespace Avalonia.Media _figuresPropertiesObserver = figures?.TrackItemPropertyChanged(_ => InvalidateGeometry()); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/PenLineCap.cs b/src/Avalonia.Visuals/Media/PenLineCap.cs index 66b43f1b32..56c5c040eb 100644 --- a/src/Avalonia.Visuals/Media/PenLineCap.cs +++ b/src/Avalonia.Visuals/Media/PenLineCap.cs @@ -1,9 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Avalonia.Media { public enum PenLineCap diff --git a/src/Avalonia.Visuals/Media/PenLineJoin.cs b/src/Avalonia.Visuals/Media/PenLineJoin.cs index 2ea098383b..7395ea284a 100644 --- a/src/Avalonia.Visuals/Media/PenLineJoin.cs +++ b/src/Avalonia.Visuals/Media/PenLineJoin.cs @@ -1,9 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace Avalonia.Media { public enum PenLineJoin diff --git a/src/Avalonia.Visuals/Media/PolylineGeometry.cs b/src/Avalonia.Visuals/Media/PolylineGeometry.cs index 06dbcccf3e..5ed16ca957 100644 --- a/src/Avalonia.Visuals/Media/PolylineGeometry.cs +++ b/src/Avalonia.Visuals/Media/PolylineGeometry.cs @@ -3,9 +3,9 @@ using System; using System.Collections.Generic; -using Avalonia.Platform; -using Avalonia.Metadata; using Avalonia.Collections; +using Avalonia.Metadata; +using Avalonia.Platform; namespace Avalonia.Media { diff --git a/src/Avalonia.Visuals/Media/RotateTransform.cs b/src/Avalonia.Visuals/Media/RotateTransform.cs index 4fe615a6df..c3babcfbab 100644 --- a/src/Avalonia.Visuals/Media/RotateTransform.cs +++ b/src/Avalonia.Visuals/Media/RotateTransform.cs @@ -45,7 +45,7 @@ namespace Avalonia.Media } /// - /// Gets the tranform's . + /// Gets the transform's . /// public override Matrix Value => Matrix.CreateRotation(Matrix.ToRadians(Angle)); } diff --git a/src/Avalonia.Visuals/Media/ScaleTransform.cs b/src/Avalonia.Visuals/Media/ScaleTransform.cs index dc7d38fde0..fd301802e0 100644 --- a/src/Avalonia.Visuals/Media/ScaleTransform.cs +++ b/src/Avalonia.Visuals/Media/ScaleTransform.cs @@ -63,8 +63,8 @@ namespace Avalonia.Media } /// - /// Gets the tranform's . + /// Gets the transform's . /// public override Matrix Value => Matrix.CreateScale(ScaleX, ScaleY); } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/SkewTransform.cs b/src/Avalonia.Visuals/Media/SkewTransform.cs index 880b73750b..405e3947e8 100644 --- a/src/Avalonia.Visuals/Media/SkewTransform.cs +++ b/src/Avalonia.Visuals/Media/SkewTransform.cs @@ -62,8 +62,8 @@ namespace Avalonia.Media } /// - /// Gets the tranform's . + /// Gets the transform's . /// public override Matrix Value => Matrix.CreateSkew(Matrix.ToRadians(AngleX), Matrix.ToRadians(AngleY)); } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/SolidColorBrush.cs b/src/Avalonia.Visuals/Media/SolidColorBrush.cs index d090f63069..d84e407cb4 100644 --- a/src/Avalonia.Visuals/Media/SolidColorBrush.cs +++ b/src/Avalonia.Visuals/Media/SolidColorBrush.cs @@ -1,8 +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; - namespace Avalonia.Media { /// diff --git a/src/Avalonia.Visuals/Media/StreamGeometryContext.cs b/src/Avalonia.Visuals/Media/StreamGeometryContext.cs index 7521582067..9df67c226e 100644 --- a/src/Avalonia.Visuals/Media/StreamGeometryContext.cs +++ b/src/Avalonia.Visuals/Media/StreamGeometryContext.cs @@ -1,7 +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; using Avalonia.Platform; namespace Avalonia.Media diff --git a/src/Avalonia.Visuals/Media/Transform.cs b/src/Avalonia.Visuals/Media/Transform.cs index c17810fc4a..677514763c 100644 --- a/src/Avalonia.Visuals/Media/Transform.cs +++ b/src/Avalonia.Visuals/Media/Transform.cs @@ -23,7 +23,7 @@ namespace Avalonia.Media public event EventHandler Changed; /// - /// Gets the tranform's . + /// Gets the transform's . /// public abstract Matrix Value { get; } diff --git a/src/Avalonia.Visuals/Media/TransformGroup.cs b/src/Avalonia.Visuals/Media/TransformGroup.cs index dd9a3f9abf..3a47f40045 100644 --- a/src/Avalonia.Visuals/Media/TransformGroup.cs +++ b/src/Avalonia.Visuals/Media/TransformGroup.cs @@ -3,7 +3,6 @@ using Avalonia.Collections; using Avalonia.Metadata; -using System.Collections.Specialized; namespace Avalonia.Media { @@ -47,7 +46,7 @@ namespace Avalonia.Media } /// - /// Gets the tranform's . + /// Gets the transform's . /// public override Matrix Value { @@ -68,4 +67,4 @@ namespace Avalonia.Media public sealed class Transforms : AvaloniaList { } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Media/TranslateTransform.cs b/src/Avalonia.Visuals/Media/TranslateTransform.cs index b66ca7939c..6ffbdb9623 100644 --- a/src/Avalonia.Visuals/Media/TranslateTransform.cs +++ b/src/Avalonia.Visuals/Media/TranslateTransform.cs @@ -63,7 +63,7 @@ namespace Avalonia.Media } /// - /// Gets the tranform's . + /// Gets the transform's . /// public override Matrix Value => Matrix.CreateTranslation(X, Y); } diff --git a/src/Avalonia.Visuals/Platform/ExportRenderingSubsystemAttribute.cs b/src/Avalonia.Visuals/Platform/ExportRenderingSubsystemAttribute.cs index 73526d7622..57f9c68456 100644 --- a/src/Avalonia.Visuals/Platform/ExportRenderingSubsystemAttribute.cs +++ b/src/Avalonia.Visuals/Platform/ExportRenderingSubsystemAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Platform { diff --git a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs index b11d9f52ab..57b974f900 100644 --- a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs +++ b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs @@ -98,7 +98,7 @@ namespace Avalonia.Platform IRenderTargetBitmapImpl CreateLayer(Size size); /// - /// Pushes a clip rectange. + /// Pushes a clip rectangle. /// /// The clip rectangle. void PushClip(Rect clip); diff --git a/src/Avalonia.Visuals/Platform/IFormattedTextImpl.cs b/src/Avalonia.Visuals/Platform/IFormattedTextImpl.cs index 606da02c49..2a4e9cde4f 100644 --- a/src/Avalonia.Visuals/Platform/IFormattedTextImpl.cs +++ b/src/Avalonia.Visuals/Platform/IFormattedTextImpl.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Media; diff --git a/src/Avalonia.Visuals/Platform/IGeometryImpl.cs b/src/Avalonia.Visuals/Platform/IGeometryImpl.cs index d93bdc0c20..4e8e6521bd 100644 --- a/src/Avalonia.Visuals/Platform/IGeometryImpl.cs +++ b/src/Avalonia.Visuals/Platform/IGeometryImpl.cs @@ -1,7 +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; using Avalonia.Media; namespace Avalonia.Platform diff --git a/src/Avalonia.Visuals/Platform/IRenderTargetBitmapImpl.cs b/src/Avalonia.Visuals/Platform/IRenderTargetBitmapImpl.cs index c3c19ac150..6464fdd41b 100644 --- a/src/Avalonia.Visuals/Platform/IRenderTargetBitmapImpl.cs +++ b/src/Avalonia.Visuals/Platform/IRenderTargetBitmapImpl.cs @@ -1,7 +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; namespace Avalonia.Platform { diff --git a/src/Avalonia.Visuals/Platform/ITransformedGeometryImpl.cs b/src/Avalonia.Visuals/Platform/ITransformedGeometryImpl.cs index ca68005906..1ed025b571 100644 --- a/src/Avalonia.Visuals/Platform/ITransformedGeometryImpl.cs +++ b/src/Avalonia.Visuals/Platform/ITransformedGeometryImpl.cs @@ -1,6 +1,4 @@ -using System; - -namespace Avalonia.Platform +namespace Avalonia.Platform { /// /// Represents a geometry with a transform applied. diff --git a/src/Avalonia.Visuals/Platform/IWriteableBitmapImpl.cs b/src/Avalonia.Visuals/Platform/IWriteableBitmapImpl.cs index 7ab5a7c100..c4e2e4915f 100644 --- a/src/Avalonia.Visuals/Platform/IWriteableBitmapImpl.cs +++ b/src/Avalonia.Visuals/Platform/IWriteableBitmapImpl.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Avalonia.Platform +namespace Avalonia.Platform { /// /// Defines the platform-specific interface for a . diff --git a/src/Avalonia.Visuals/Platform/PathGeometryContext.cs b/src/Avalonia.Visuals/Platform/PathGeometryContext.cs index cc881094fd..19322b9620 100644 --- a/src/Avalonia.Visuals/Platform/PathGeometryContext.cs +++ b/src/Avalonia.Visuals/Platform/PathGeometryContext.cs @@ -1,9 +1,9 @@ // 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 Avalonia.Media; using Avalonia.Platform; -using System; namespace Avalonia.Visuals.Platform { diff --git a/src/Avalonia.Visuals/Point.cs b/src/Avalonia.Visuals/Point.cs index 34070ac71f..e74094fe50 100644 --- a/src/Avalonia.Visuals/Point.cs +++ b/src/Avalonia.Visuals/Point.cs @@ -1,10 +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 Avalonia.Utilities; -using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -75,7 +73,7 @@ namespace Avalonia } /// - /// Checks for unequality between two s. + /// Checks for inequality between two s. /// /// The first point. /// The second point. diff --git a/src/Avalonia.Visuals/Rect.cs b/src/Avalonia.Visuals/Rect.cs index d28fff0216..63d34b474b 100644 --- a/src/Avalonia.Visuals/Rect.cs +++ b/src/Avalonia.Visuals/Rect.cs @@ -1,10 +1,9 @@ // 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.Utilities; using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -173,7 +172,7 @@ namespace Avalonia } /// - /// Checks for unequality between two s. + /// Checks for inequality between two s. /// /// The first rect. /// The second rect. diff --git a/src/Avalonia.Visuals/RelativePoint.cs b/src/Avalonia.Visuals/RelativePoint.cs index 5d3cb23a90..d38bb1d496 100644 --- a/src/Avalonia.Visuals/RelativePoint.cs +++ b/src/Avalonia.Visuals/RelativePoint.cs @@ -1,10 +1,9 @@ // 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.Utilities; using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -93,7 +92,7 @@ namespace Avalonia } /// - /// Checks for unequality between two s. + /// Checks for inequality between two s. /// /// The first point. /// The second point. diff --git a/src/Avalonia.Visuals/RelativeRect.cs b/src/Avalonia.Visuals/RelativeRect.cs index 0afe74f0be..927ec3ef75 100644 --- a/src/Avalonia.Visuals/RelativeRect.cs +++ b/src/Avalonia.Visuals/RelativeRect.cs @@ -1,10 +1,9 @@ // 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.Utilities; using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -102,7 +101,7 @@ namespace Avalonia } /// - /// Checks for unequality between two s. + /// Checks for inequality between two s. /// /// The first rectangle. /// The second rectangle. diff --git a/src/Avalonia.Visuals/RenderTargetCorruptedException.cs b/src/Avalonia.Visuals/RenderTargetCorruptedException.cs index f67a866be2..966aaf352f 100644 --- a/src/Avalonia.Visuals/RenderTargetCorruptedException.cs +++ b/src/Avalonia.Visuals/RenderTargetCorruptedException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia { diff --git a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs index a14923b410..61aa1c6131 100644 --- a/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/DeferredRenderer.cs @@ -2,17 +2,17 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; using Avalonia.Media; +using Avalonia.Media.Immutable; using Avalonia.Platform; using Avalonia.Rendering.SceneGraph; using Avalonia.Threading; -using Avalonia.VisualTree; -using System.Collections.Generic; -using System.IO; -using Avalonia.Media.Immutable; -using System.Threading; -using System.Linq; using Avalonia.Utilities; +using Avalonia.VisualTree; namespace Avalonia.Rendering { diff --git a/src/Avalonia.Visuals/Rendering/DirtyRects.cs b/src/Avalonia.Visuals/Rendering/DirtyRects.cs index 473d002c76..d206d23a24 100644 --- a/src/Avalonia.Visuals/Rendering/DirtyRects.cs +++ b/src/Avalonia.Visuals/Rendering/DirtyRects.cs @@ -1,7 +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; using System.Collections; using System.Collections.Generic; @@ -21,12 +20,12 @@ namespace Avalonia.Rendering /// /// The dirt rectangle. /// - /// We probably want to do this more intellegently because: + /// We probably want to do this more intelligently because: /// - Adding e.g. the top left quarter of a scene and the bottom left quarter of a scene /// will cause the whole scene to be invalidated if they overlap by a single pixel /// - Adding two adjacent rectangles that don't overlap will not cause them to be /// coalesced - /// - It only coaleces the first intersecting rectangle found - one needs to + /// - It only coalesces the first intersecting rectangle found - one needs to /// call at the end of the draw cycle to coalesce the rest. /// public void Add(Rect rect) diff --git a/src/Avalonia.Visuals/Rendering/DisplayDirtyRect.cs b/src/Avalonia.Visuals/Rendering/DisplayDirtyRect.cs index 03b8e95825..7e6c3062cd 100644 --- a/src/Avalonia.Visuals/Rendering/DisplayDirtyRect.cs +++ b/src/Avalonia.Visuals/Rendering/DisplayDirtyRect.cs @@ -30,7 +30,7 @@ namespace Avalonia.Rendering public DateTimeOffset Born { get; private set; } /// - /// Gets the time at which the rectagle should no longer be displayed. + /// Gets the time at which the rectangle should no longer be displayed. /// public DateTimeOffset Dies { get; private set; } diff --git a/src/Avalonia.Visuals/Rendering/IRenderRoot.cs b/src/Avalonia.Visuals/Rendering/IRenderRoot.cs index 2982a5d081..2b364e5d22 100644 --- a/src/Avalonia.Visuals/Rendering/IRenderRoot.cs +++ b/src/Avalonia.Visuals/Rendering/IRenderRoot.cs @@ -1,7 +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; using Avalonia.Platform; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Rendering/IRendererFactory.cs b/src/Avalonia.Visuals/Rendering/IRendererFactory.cs index 0d7044e125..27af39e40d 100644 --- a/src/Avalonia.Visuals/Rendering/IRendererFactory.cs +++ b/src/Avalonia.Visuals/Rendering/IRendererFactory.cs @@ -1,7 +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; namespace Avalonia.Rendering { diff --git a/src/Avalonia.Visuals/Rendering/IVisualBrushInitialize.cs b/src/Avalonia.Visuals/Rendering/IVisualBrushInitialize.cs index b3209e2462..2949c9c051 100644 --- a/src/Avalonia.Visuals/Rendering/IVisualBrushInitialize.cs +++ b/src/Avalonia.Visuals/Rendering/IVisualBrushInitialize.cs @@ -1,13 +1,12 @@ // 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 Avalonia.Media; namespace Avalonia.Rendering { /// - /// Internal interface for initializing controls that are to be used as the viusal in a + /// Internal interface for initializing controls that are to be used as the visual in a /// . /// public interface IVisualBrushInitialize diff --git a/src/Avalonia.Visuals/Rendering/IVisualBrushRenderer.cs b/src/Avalonia.Visuals/Rendering/IVisualBrushRenderer.cs index 3d9b20713c..84f540ca8e 100644 --- a/src/Avalonia.Visuals/Rendering/IVisualBrushRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/IVisualBrushRenderer.cs @@ -1,7 +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; using Avalonia.Media; using Avalonia.Platform; diff --git a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs index 2118b66de2..c6e81e675a 100644 --- a/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs +++ b/src/Avalonia.Visuals/Rendering/ImmediateRenderer.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using Avalonia.Platform; -using Avalonia.VisualTree; using System.Collections.Generic; -using Avalonia.Media; using System.Linq; +using Avalonia.Media; +using Avalonia.Platform; +using Avalonia.VisualTree; namespace Avalonia.Rendering { diff --git a/src/Avalonia.Visuals/Rendering/RenderLayer.cs b/src/Avalonia.Visuals/Rendering/RenderLayer.cs index d1b1f1440a..cd09bdee10 100644 --- a/src/Avalonia.Visuals/Rendering/RenderLayer.cs +++ b/src/Avalonia.Visuals/Rendering/RenderLayer.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Media; +using Avalonia.Media; using Avalonia.Platform; using Avalonia.Utilities; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Rendering/RenderLayers.cs b/src/Avalonia.Visuals/Rendering/RenderLayers.cs index 6a45ecd912..9b0ce944e7 100644 --- a/src/Avalonia.Visuals/Rendering/RenderLayers.cs +++ b/src/Avalonia.Visuals/Rendering/RenderLayers.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections; +using System.Collections; using System.Collections.Generic; using Avalonia.Platform; using Avalonia.Rendering.SceneGraph; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/BrushDrawOperation.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/BrushDrawOperation.cs index f56e7448a7..4c09dc2ddd 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/BrushDrawOperation.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/BrushDrawOperation.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Media; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/ClipNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/ClipNode.cs index 14e6b4ab63..34f042e334 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/ClipNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/ClipNode.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Platform; +using Avalonia.Platform; namespace Avalonia.Rendering.SceneGraph { diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs index 42ecde6a6d..dfed0d911c 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/DeferredDrawingContextImpl.cs @@ -6,8 +6,8 @@ using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; using Avalonia.Utilities; -using Avalonia.VisualTree; using Avalonia.Visuals.Media.Imaging; +using Avalonia.VisualTree; namespace Avalonia.Rendering.SceneGraph { diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryClipNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryClipNode.cs index 2c1decf5dc..a2ad83d845 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryClipNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryClipNode.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Platform; +using Avalonia.Platform; namespace Avalonia.Rendering.SceneGraph { diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs index 7b79ebab4f..46d264e518 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/GeometryNode.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs index 75ef49f8e7..e640925b3a 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/IVisualNode.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using Avalonia.Media; using Avalonia.Platform; using Avalonia.Utilities; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs index 9e8fca5f84..1abd966a9f 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/ImageNode.cs @@ -1,7 +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; using Avalonia.Platform; using Avalonia.Utilities; using Avalonia.Visuals.Media.Imaging; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs index d3df478a63..11c763fcc9 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/LineNode.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityMaskNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityMaskNode.cs index 28b8f53e26..d6dbc1a8cb 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityMaskNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityMaskNode.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityNode.cs index ef49ac8879..8fc630588f 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/OpacityNode.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Platform; +using Avalonia.Platform; namespace Avalonia.Rendering.SceneGraph { diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs index 1730621c55..33cc39cbe3 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/RectangleNode.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; @@ -20,7 +19,7 @@ namespace Avalonia.Rendering.SceneGraph /// The transform. /// The fill brush. /// The stroke pen. - /// The rectanle to draw. + /// The rectangle to draw. /// The rectangle corner radius. /// Child scenes for drawing visual brushes. public RectangleNode( diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/SceneLayer.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/SceneLayer.cs index 77ad96a222..02fae562ef 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/SceneLayer.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/SceneLayer.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Media; +using Avalonia.Media; using Avalonia.Platform; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs index 6328d7dd14..c06d0d26b4 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/TextNode.cs @@ -1,7 +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; using System.Collections.Generic; using Avalonia.Media; using Avalonia.Platform; @@ -71,7 +70,7 @@ namespace Avalonia.Rendering.SceneGraph /// Determines if this draw operation equals another. /// /// The transform of the other draw operation. - /// The foregroundof the other draw operation. + /// The foreground of the other draw operation. /// The draw origin of the other draw operation. /// The text of the other draw operation. /// True if the draw operations are the same, otherwise false. diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs index 306036ca2c..760cedcbf0 100644 --- a/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs +++ b/src/Avalonia.Visuals/Rendering/SceneGraph/VisualNode.cs @@ -82,7 +82,7 @@ namespace Avalonia.Rendering.SceneGraph } /// - /// Gets or sets the opacity mask for the scnee graph node. + /// Gets or sets the opacity mask for the scene graph node. /// public IBrush OpacityMask { get; set; } @@ -159,7 +159,7 @@ namespace Avalonia.Rendering.SceneGraph /// /// Replaces an item in the collection. /// - /// The opeation to be replaced. + /// The operation to be replaced. /// The operation to add. public void ReplaceDrawOperation(int index, IRef operation) { diff --git a/src/Avalonia.Visuals/Rendering/ZIndexComparer.cs b/src/Avalonia.Visuals/Rendering/ZIndexComparer.cs index 491541cd2e..3ed076f22e 100644 --- a/src/Avalonia.Visuals/Rendering/ZIndexComparer.cs +++ b/src/Avalonia.Visuals/Rendering/ZIndexComparer.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using Avalonia.VisualTree; namespace Avalonia.Rendering diff --git a/src/Avalonia.Visuals/Size.cs b/src/Avalonia.Visuals/Size.cs index 50a3973a5c..8057571bf1 100644 --- a/src/Avalonia.Visuals/Size.cs +++ b/src/Avalonia.Visuals/Size.cs @@ -1,10 +1,9 @@ // 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.Utilities; using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -71,7 +70,7 @@ namespace Avalonia } /// - /// Checks for unequality between two s. + /// Checks for inequality between two s. /// /// The first size. /// The second size. @@ -141,9 +140,9 @@ namespace Avalonia return new Size(size._width + toAdd._width, size._height + toAdd._height); } - public static Size operator -(Size size, Size toSubstract) + public static Size operator -(Size size, Size toSubtract) { - return new Size(size._width - toSubstract._width, size._height - toSubstract._height); + return new Size(size._width - toSubtract._width, size._height - toSubtract._height); } /// @@ -260,4 +259,4 @@ namespace Avalonia return string.Format(CultureInfo.InvariantCulture, "{0}, {1}", _width, _height); } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Visuals/Thickness.cs b/src/Avalonia.Visuals/Thickness.cs index 759abd5943..3e70ecafb1 100644 --- a/src/Avalonia.Visuals/Thickness.cs +++ b/src/Avalonia.Visuals/Thickness.cs @@ -1,10 +1,9 @@ // 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.Utilities; using System; using System.Globalization; -using System.Linq; +using Avalonia.Utilities; namespace Avalonia { @@ -114,7 +113,7 @@ namespace Avalonia /// /// The first thickness. /// The second thickness. - /// The unequality. + /// The inequality. public static bool operator !=(Thickness a, Thickness b) { return !a.Equals(b); diff --git a/src/Avalonia.Visuals/Visual.cs b/src/Avalonia.Visuals/Visual.cs index 2be39d4522..81e1a93a6f 100644 --- a/src/Avalonia.Visuals/Visual.cs +++ b/src/Avalonia.Visuals/Visual.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Specialized; using System.Linq; using System.Reactive.Linq; -using Avalonia.Animation; using Avalonia.Collections; using Avalonia.Data; using Avalonia.Logging; diff --git a/src/Avalonia.Visuals/VisualExtensions.cs b/src/Avalonia.Visuals/VisualExtensions.cs index d69785cc59..7c5d011ce8 100644 --- a/src/Avalonia.Visuals/VisualExtensions.cs +++ b/src/Avalonia.Visuals/VisualExtensions.cs @@ -2,15 +2,6 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Reactive.Linq; -using Avalonia.Animation; -using Avalonia.Collections; -using Avalonia.Data; -using Avalonia.Media; -using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.VisualTree; diff --git a/src/Avalonia.Visuals/VisualTree/TransformedBounds.cs b/src/Avalonia.Visuals/VisualTree/TransformedBounds.cs index f8356bbcd6..da21a416e1 100644 --- a/src/Avalonia.Visuals/VisualTree/TransformedBounds.cs +++ b/src/Avalonia.Visuals/VisualTree/TransformedBounds.cs @@ -1,7 +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 Avalonia.Media; namespace Avalonia.VisualTree { @@ -52,4 +51,4 @@ namespace Avalonia.VisualTree } } } -} \ No newline at end of file +} diff --git a/src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs b/src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs index 333391a064..a3e7590cf5 100644 --- a/src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/ClipboardImpl.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Threading.Tasks; using Avalonia.Gtk3.Interop; using Avalonia.Input.Platform; diff --git a/src/Gtk/Avalonia.Gtk3/FramebufferManager.cs b/src/Gtk/Avalonia.Gtk3/FramebufferManager.cs index 82dbf53579..e3bbe19978 100644 --- a/src/Gtk/Avalonia.Gtk3/FramebufferManager.cs +++ b/src/Gtk/Avalonia.Gtk3/FramebufferManager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Platform; using Avalonia.Threading; diff --git a/src/Gtk/Avalonia.Gtk3/GdkCursor.cs b/src/Gtk/Avalonia.Gtk3/GdkCursor.cs index 48815e1273..4fad8208b3 100644 --- a/src/Gtk/Avalonia.Gtk3/GdkCursor.cs +++ b/src/Gtk/Avalonia.Gtk3/GdkCursor.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Avalonia.Gtk3 +namespace Avalonia.Gtk3 { enum GdkCursorType { @@ -88,4 +82,4 @@ namespace Avalonia.Gtk3 Xterm = 152, LastCursor = 153, } -} \ No newline at end of file +} diff --git a/src/Gtk/Avalonia.Gtk3/GdkKey.cs b/src/Gtk/Avalonia.Gtk3/GdkKey.cs index b4a0f31b92..7aa165a1da 100644 --- a/src/Gtk/Avalonia.Gtk3/GdkKey.cs +++ b/src/Gtk/Avalonia.Gtk3/GdkKey.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Avalonia.Gtk3 +namespace Avalonia.Gtk3 { enum GdkKey { diff --git a/src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs b/src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs index b687d9d447..ca8a1ad3a4 100644 --- a/src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs +++ b/src/Gtk/Avalonia.Gtk3/Gtk3Platform.cs @@ -1,18 +1,14 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Threading; -using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Controls.Platform; +using Avalonia.Gtk3; using Avalonia.Gtk3.Interop; using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.Platform; using Avalonia.Rendering; -using Avalonia.Gtk3; using Avalonia.Threading; namespace Avalonia.Gtk3 @@ -133,4 +129,4 @@ namespace Avalonia return builder.UseWindowingSubsystem(Gtk3Platform.Initialize, "GTK3"); } } -} \ No newline at end of file +} diff --git a/src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs b/src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs index efda21c753..cd0074c287 100644 --- a/src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs +++ b/src/Gtk/Avalonia.Gtk3/ImageSurfaceFramebuffer.cs @@ -1,10 +1,4 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Controls.Platform.Surfaces; using Avalonia.Gtk3.Interop; using Avalonia.Platform; using Avalonia.Threading; diff --git a/src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs b/src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs index 87a70c4d35..7838be9305 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/CairoSurface.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; namespace Avalonia.Gtk3.Interop diff --git a/src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs b/src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs index 93fb82d285..112e00c879 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/DynLoader.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; /* diff --git a/src/Gtk/Avalonia.Gtk3/Interop/GException.cs b/src/Gtk/Avalonia.Gtk3/Interop/GException.cs index ab08df4ec3..b0c171089e 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/GException.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/GException.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Gtk3.Interop { diff --git a/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs b/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs index 24bcfd71e9..bb272b06d5 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Gtk3.Interop { diff --git a/src/Gtk/Avalonia.Gtk3/Interop/GlibPriority.cs b/src/Gtk/Avalonia.Gtk3/Interop/GlibPriority.cs index add4ba3c02..08448e30d5 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/GlibPriority.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/GlibPriority.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Threading; namespace Avalonia.Gtk3.Interop diff --git a/src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs b/src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs index 971edb1364..6e3840914c 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/GlibTimeout.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Threading; namespace Avalonia.Gtk3.Interop { diff --git a/src/Gtk/Avalonia.Gtk3/Interop/ICustomGtk3NativeLibraryResolver.cs b/src/Gtk/Avalonia.Gtk3/Interop/ICustomGtk3NativeLibraryResolver.cs index 2f88b09896..3b78953d1b 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/ICustomGtk3NativeLibraryResolver.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/ICustomGtk3NativeLibraryResolver.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Gtk3.Interop; +using Avalonia.Gtk3.Interop; namespace Avalonia.Gtk3 { diff --git a/src/Gtk/Avalonia.Gtk3/Interop/ManagedCairoSurface.cs b/src/Gtk/Avalonia.Gtk3/Interop/ManagedCairoSurface.cs index 2cde99afa5..2b0a7eae12 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/ManagedCairoSurface.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/ManagedCairoSurface.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; using Avalonia.Platform; namespace Avalonia.Gtk3.Interop @@ -35,4 +34,4 @@ namespace Avalonia.Gtk3.Interop } } -} \ No newline at end of file +} diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs index f57769c224..914d0feafc 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Native.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Native.cs @@ -1,19 +1,14 @@ #pragma warning disable 649 using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using Avalonia.Controls; -using gint8 = System.Byte; -using gint16 = System.Int16; -using gint32 = System.Int32; +using gdouble = System.Double; using gint = System.Int32; +using gint16 = System.Int16; +using gint8 = System.Byte; +using guint = System.UInt32; using guint16 = System.UInt16; using guint32 = System.UInt32; -using guint = System.UInt32; -using gdouble = System.Double; namespace Avalonia.Gtk3.Interop { diff --git a/src/Gtk/Avalonia.Gtk3/Interop/NativeException.cs b/src/Gtk/Avalonia.Gtk3/Interop/NativeException.cs index 43659f8f83..64cbccbd26 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/NativeException.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/NativeException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Gtk3.Interop { diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs b/src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs index 1a0a772522..989a96a4f0 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Pixbuf.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using Avalonia.Platform; namespace Avalonia.Gtk3.Interop diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs b/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs index 31625e3f27..57c8ac7c3a 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Resolver.cs @@ -4,8 +4,6 @@ using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using Avalonia.Platform; namespace Avalonia.Gtk3.Interop diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Signal.cs b/src/Gtk/Avalonia.Gtk3/Interop/Signal.cs index 5f173000a2..bc55558551 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Signal.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Signal.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Gtk3.Interop { diff --git a/src/Gtk/Avalonia.Gtk3/KeyTransform.cs b/src/Gtk/Avalonia.Gtk3/KeyTransform.cs index 69c5a1bf5f..29ee6aaeb5 100644 --- a/src/Gtk/Avalonia.Gtk3/KeyTransform.cs +++ b/src/Gtk/Avalonia.Gtk3/KeyTransform.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Input; +using System.Collections.Generic; using Avalonia.Gtk3; +using Avalonia.Input; namespace Avalonia.Gtk.Common { diff --git a/src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs b/src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs index b4e293cdff..6965e7c812 100644 --- a/src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs +++ b/src/Gtk/Avalonia.Gtk3/PlatformIconLoader.cs @@ -17,4 +17,4 @@ namespace Avalonia.Gtk3 return Pixbuf.NewFromBytes(ms.ToArray()); } } -} \ No newline at end of file +} diff --git a/src/Gtk/Avalonia.Gtk3/PopupImpl.cs b/src/Gtk/Avalonia.Gtk3/PopupImpl.cs index 13beff580e..ef17407dd6 100644 --- a/src/Gtk/Avalonia.Gtk3/PopupImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/PopupImpl.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Gtk3.Interop; +using Avalonia.Gtk3.Interop; using Avalonia.Platform; namespace Avalonia.Gtk3 diff --git a/src/Gtk/Avalonia.Gtk3/ScreenImpl.cs b/src/Gtk/Avalonia.Gtk3/ScreenImpl.cs index 786c9a2cf0..97b5029219 100644 --- a/src/Gtk/Avalonia.Gtk3/ScreenImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/ScreenImpl.cs @@ -1,8 +1,6 @@ using System; -using Avalonia.Controls; using Avalonia.Gtk3.Interop; using Avalonia.Platform; -using Avalonia.Utilities; namespace Avalonia.Gtk3 { @@ -54,4 +52,4 @@ namespace Avalonia.Gtk3 _allScreens = null; } } -} \ No newline at end of file +} diff --git a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs index cff376ad1f..d4bd878d53 100644 --- a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs +++ b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs @@ -2,12 +2,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Controls.Platform; using Avalonia.Gtk3.Interop; -using Avalonia.Input.Platform; using Avalonia.Platform; namespace Avalonia.Gtk3 diff --git a/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs b/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs index 8a880fd306..67ddcf1e5f 100644 --- a/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs +++ b/src/Gtk/Avalonia.Gtk3/WindowBaseImpl.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Threading; using Avalonia.Controls; using Avalonia.Gtk3.Interop; diff --git a/src/Gtk/Avalonia.Gtk3/X11Framebuffer.cs b/src/Gtk/Avalonia.Gtk3/X11Framebuffer.cs index 4b27920d64..dde29f85c2 100644 --- a/src/Gtk/Avalonia.Gtk3/X11Framebuffer.cs +++ b/src/Gtk/Avalonia.Gtk3/X11Framebuffer.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; using Avalonia.Platform; namespace Avalonia.Gtk3 @@ -55,4 +54,4 @@ namespace Avalonia.Gtk3 public Vector Dpi { get; } public PixelFormat Format { get; } } -} \ No newline at end of file +} diff --git a/src/Linux/Avalonia.LinuxFramebuffer/EvDevDevice.cs b/src/Linux/Avalonia.LinuxFramebuffer/EvDevDevice.cs index 7b399863f7..f28dca81b8 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/EvDevDevice.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/EvDevDevice.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; namespace Avalonia.LinuxFramebuffer { diff --git a/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs b/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs index 627b508aa8..968873abc0 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/FramebufferToplevelImpl.cs @@ -1,7 +1,5 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Text; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; diff --git a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs index 8d04360edf..87b55be488 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Linq; using System.Runtime.InteropServices; using System.Text; -using System.Threading.Tasks; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Platform; @@ -135,4 +130,4 @@ namespace Avalonia.LinuxFramebuffer ReleaseUnmanagedResources(); } } -} \ No newline at end of file +} diff --git a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs index 896c91d087..810be77b2b 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs @@ -1,18 +1,14 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Text; using System.Threading; using Avalonia.Controls; using Avalonia.Controls.Embedding; +using Avalonia.Controls.Platform; using Avalonia.Input; -using Avalonia.Input.Platform; using Avalonia.LinuxFramebuffer; using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Threading; -using Avalonia; -using Avalonia.Controls.Platform; namespace Avalonia.LinuxFramebuffer { diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Mice.cs b/src/Linux/Avalonia.LinuxFramebuffer/Mice.cs index 7e85796c0c..291374a75e 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Mice.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/Mice.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; using System.Threading; using Avalonia.Input; using Avalonia.Input.Raw; diff --git a/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs b/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs index fbbf036b74..5427af7d44 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/NativeUnsafeMethods.cs @@ -1,8 +1,8 @@ -using __u32 = System.UInt32; +using System; +using System.Runtime.InteropServices; using __s32 = System.Int32; using __u16 = System.UInt16; -using System; -using System.Runtime.InteropServices; +using __u32 = System.UInt32; // ReSharper disable FieldCanBeMadeReadOnly.Local // ReSharper disable ArrangeTypeMemberModifiers // ReSharper disable BuiltInTypeReferenceStyle @@ -69,7 +69,7 @@ namespace Avalonia.LinuxFramebuffer FB_VBLANK_HAVE_VCOUNT = 0x020 /* the vcount field is valid */, FB_VBLANK_HAVE_HCOUNT = 0x040 /* the hcount field is valid */, FB_VBLANK_VSYNCING = 0x080 /* currently in a vsync */, - FB_VBLANK_HAVE_VSYNC = 0x100 /* verical syncs can be detected */ + FB_VBLANK_HAVE_VSYNC = 0x100 /* vertical syncs can be detected */ } [StructLayout(LayoutKind.Sequential)] @@ -252,4 +252,4 @@ namespace Avalonia.LinuxFramebuffer public __s32 resolution; } -} \ No newline at end of file +} diff --git a/src/Linux/Avalonia.LinuxFramebuffer/Stubs.cs b/src/Linux/Avalonia.LinuxFramebuffer/Stubs.cs index 67d62e3410..7a257da0dd 100644 --- a/src/Linux/Avalonia.LinuxFramebuffer/Stubs.cs +++ b/src/Linux/Avalonia.LinuxFramebuffer/Stubs.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Input; using Avalonia.Platform; diff --git a/src/Markup/Avalonia.Markup/Data/Binding.cs b/src/Markup/Avalonia.Markup/Data/Binding.cs index cb43873cee..0b85e3224d 100644 --- a/src/Markup/Avalonia.Markup/Data/Binding.cs +++ b/src/Markup/Avalonia.Markup/Data/Binding.cs @@ -322,7 +322,7 @@ namespace Avalonia.Data private IObservable GetParentDataContext(IAvaloniaObject target) { // The DataContext is based on the visual parent and not the logical parent: this may - // seem unintuitive considering the fact that property inheritance works on the logical + // seem counter intuitive considering the fact that property inheritance works on the logical // tree, but consider a ContentControl with a ContentPresenter. The ContentControl's // Content property is bound to a value which becomes the ContentPresenter's // DataContext - it is from this that the child hosted by the ContentPresenter needs to diff --git a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs index a3fa6880ac..4c47ef32e0 100644 --- a/src/Markup/Avalonia.Markup/Data/MultiBinding.cs +++ b/src/Markup/Avalonia.Markup/Data/MultiBinding.cs @@ -6,11 +6,8 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Reactive.Linq; -using System.Reactive.Subjects; -using Avalonia.Controls; using Avalonia.Data.Converters; using Avalonia.Metadata; -using JetBrains.Annotations; namespace Avalonia.Data { @@ -92,4 +89,4 @@ namespace Avalonia.Data return converted; } } -} \ No newline at end of file +} diff --git a/src/Markup/Avalonia.Markup/Data/RelativeSource.cs b/src/Markup/Avalonia.Markup/Data/RelativeSource.cs index 42b43622da..369bd8112c 100644 --- a/src/Markup/Avalonia.Markup/Data/RelativeSource.cs +++ b/src/Markup/Avalonia.Markup/Data/RelativeSource.cs @@ -21,7 +21,7 @@ namespace Avalonia.Data TemplatedParent, /// - /// The binding will be to the control iself. + /// The binding will be to the control itself. /// Self, @@ -106,4 +106,4 @@ namespace Avalonia.Data public TreeType Tree { get; set; } = TreeType.Visual; } -} \ No newline at end of file +} diff --git a/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs b/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs index fb126622c1..e03427c161 100644 --- a/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs +++ b/src/Markup/Avalonia.Markup/Markup/Data/DelayedBinding.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; -using Avalonia.Controls; using Avalonia.Data; using Avalonia.Logging; diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/ArgumentListParser.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/ArgumentListParser.cs index 23bc463e39..cb9c81caa1 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/ArgumentListParser.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/ArgumentListParser.cs @@ -1,11 +1,9 @@ // 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.Collections.Generic; using Avalonia.Data.Core; using Avalonia.Utilities; -using System; -using System.Collections.Generic; -using System.Text; namespace Avalonia.Markup.Parsers { diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionObserverBuilder.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionObserverBuilder.cs index 90627fe14d..8cb14277ff 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionObserverBuilder.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/ExpressionObserverBuilder.cs @@ -1,9 +1,7 @@ -using Avalonia.Data.Core; -using Avalonia.Utilities; -using System; -using System.Collections.Generic; +using System; using System.Reactive; -using System.Text; +using Avalonia.Data.Core; +using Avalonia.Utilities; namespace Avalonia.Markup.Parsers { diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/ElementNameNode.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/ElementNameNode.cs index bd70c1b222..f09efca7d0 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/ElementNameNode.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/ElementNameNode.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Data.Core; using Avalonia.LogicalTree; diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/FindAncestorNode.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/FindAncestorNode.cs index 6a5f5a5751..221df44327 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/FindAncestorNode.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/FindAncestorNode.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Data.Core; using Avalonia.LogicalTree; diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/SelfNode.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/SelfNode.cs index 88163eda44..2cb87efa65 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/SelfNode.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/SelfNode.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Avalonia.Data.Core; +using Avalonia.Data.Core; namespace Avalonia.Markup.Parsers.Nodes { diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/StringIndexerNode.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/StringIndexerNode.cs index b3d0555f14..ea847bde11 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/StringIndexerNode.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/Nodes/StringIndexerNode.cs @@ -1,18 +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 Avalonia.Utilities; using System; using System.Collections; using System.Collections.Generic; -using System.Collections.Specialized; using System.ComponentModel; using System.Globalization; using System.Linq; -using System.Reflection; using System.Reactive.Linq; +using System.Reflection; using Avalonia.Data; using Avalonia.Data.Core; +using Avalonia.Utilities; namespace Avalonia.Markup.Parsers.Nodes { @@ -51,7 +50,7 @@ namespace Avalonia.Markup.Parsers.Nodes var intArgs = convertedObjectArray.OfType().ToArray(); - // Try special cases where we can validate indicies + // Try special cases where we can validate indices if (typeInfo.IsArray) { return SetValueInArray((Array)Target.Target, intArgs, value); @@ -114,11 +113,11 @@ namespace Avalonia.Markup.Parsers.Nodes } - private bool SetValueInArray(Array array, int[] indicies, object value) + private bool SetValueInArray(Array array, int[] indices, object value) { - if (ValidBounds(indicies, array)) + if (ValidBounds(indices, array)) { - array.SetValue(value, indicies); + array.SetValue(value, indices); return true; } return false; @@ -155,7 +154,7 @@ namespace Avalonia.Markup.Parsers.Nodes var intArgs = convertedObjectArray.OfType().ToArray(); - // Try special cases where we can validate indicies + // Try special cases where we can validate indices if (typeInfo.IsArray) { return GetValueFromArray((Array)target, intArgs); @@ -210,11 +209,11 @@ namespace Avalonia.Markup.Parsers.Nodes return GetValueFromArray(array, intArgs); } - private object GetValueFromArray(Array array, int[] indicies) + private object GetValueFromArray(Array array, int[] indices) { - if (ValidBounds(indicies, array)) + if (ValidBounds(indices, array)) { - return array.GetValue(indicies); + return array.GetValue(indices); } return AvaloniaProperty.UnsetValue; } @@ -262,13 +261,13 @@ namespace Avalonia.Markup.Parsers.Nodes return null; } - private bool ValidBounds(int[] indicies, Array array) + private bool ValidBounds(int[] indices, Array array) { - if (indicies.Length == array.Rank) + if (indices.Length == array.Rank) { - for (var i = 0; i < indicies.Length; ++i) + for (var i = 0; i < indices.Length; ++i) { - if (indicies[i] >= array.GetLength(i)) + if (indices[i] >= array.GetLength(i)) { return false; } diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs index 214e61ae37..f66d3e51fc 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using Avalonia.Data.Core; using Avalonia.Utilities; diff --git a/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorParser.cs b/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorParser.cs index 94ce61b5c3..bf5b396bec 100644 --- a/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorParser.cs +++ b/src/Markup/Avalonia.Markup/Markup/Parsers/SelectorParser.cs @@ -2,9 +2,7 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; using System.Globalization; -using Avalonia.Data.Core; using Avalonia.Styling; using Avalonia.Utilities; diff --git a/src/OSX/Avalonia.MonoMac/ClipboardImpl.cs b/src/OSX/Avalonia.MonoMac/ClipboardImpl.cs index 29eb3720ec..475083b469 100644 --- a/src/OSX/Avalonia.MonoMac/ClipboardImpl.cs +++ b/src/OSX/Avalonia.MonoMac/ClipboardImpl.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; using Avalonia.Input.Platform; using MonoMac.AppKit; diff --git a/src/OSX/Avalonia.MonoMac/Cursor.cs b/src/OSX/Avalonia.MonoMac/Cursor.cs index d9370e527b..fff2d92e63 100644 --- a/src/OSX/Avalonia.MonoMac/Cursor.cs +++ b/src/OSX/Avalonia.MonoMac/Cursor.cs @@ -63,4 +63,4 @@ namespace Avalonia.MonoMac return new Cursor(_cache[cursorType]); } } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/DragSource.cs b/src/OSX/Avalonia.MonoMac/DragSource.cs index 41a206b580..5d799d3fbe 100644 --- a/src/OSX/Avalonia.MonoMac/DragSource.cs +++ b/src/OSX/Avalonia.MonoMac/DragSource.cs @@ -1,23 +1,18 @@ using System; using System.Collections.Generic; -using System.Data; using System.IO; using System.Linq; -using System.Linq.Expressions; using System.Reactive.Linq; using System.Reactive.Subjects; -using System.Runtime.InteropServices; using System.Runtime.Serialization.Formatters.Binary; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.Input.Raw; -using MonoMac; using MonoMac.AppKit; using MonoMac.CoreGraphics; using MonoMac.Foundation; -using MonoMac.OpenGL; namespace Avalonia.MonoMac { @@ -121,4 +116,4 @@ namespace Avalonia.MonoMac _result.OnCompleted(); } } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/DraggingInfo.cs b/src/OSX/Avalonia.MonoMac/DraggingInfo.cs index fc5f52713e..5ea7169a1e 100644 --- a/src/OSX/Avalonia.MonoMac/DraggingInfo.cs +++ b/src/OSX/Avalonia.MonoMac/DraggingInfo.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using Avalonia.Input; using MonoMac.AppKit; @@ -87,4 +86,4 @@ namespace Avalonia.MonoMac return _info.DraggingPasteboard.GetDataForType(dataFormat).ToArray(); } } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/EmulatedFramebuffer.cs b/src/OSX/Avalonia.MonoMac/EmulatedFramebuffer.cs index 6cd2b16afa..4da67ae1dd 100644 --- a/src/OSX/Avalonia.MonoMac/EmulatedFramebuffer.cs +++ b/src/OSX/Avalonia.MonoMac/EmulatedFramebuffer.cs @@ -1,8 +1,8 @@ using System; -using Avalonia.Platform; -using MonoMac.AppKit; using System.Runtime.InteropServices; +using Avalonia.Platform; using Avalonia.Threading; +using MonoMac.AppKit; using MonoMac.CoreGraphics; namespace Avalonia.MonoMac @@ -103,4 +103,4 @@ namespace Avalonia.MonoMac Image = null; } } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/Helpers.cs b/src/OSX/Avalonia.MonoMac/Helpers.cs index 454b775cc0..527eccafdc 100644 --- a/src/OSX/Avalonia.MonoMac/Helpers.cs +++ b/src/OSX/Avalonia.MonoMac/Helpers.cs @@ -1,8 +1,6 @@ -using System; - using System.ComponentModel; - using MonoMac.AppKit; - using MonoMac.CoreGraphics; - using MonoMac.OpenGL; +using System; +using MonoMac.AppKit; +using MonoMac.CoreGraphics; namespace Avalonia.MonoMac { diff --git a/src/OSX/Avalonia.MonoMac/PlatformThreadingInterface.cs b/src/OSX/Avalonia.MonoMac/PlatformThreadingInterface.cs index b02a3192de..04a36d9f0f 100644 --- a/src/OSX/Avalonia.MonoMac/PlatformThreadingInterface.cs +++ b/src/OSX/Avalonia.MonoMac/PlatformThreadingInterface.cs @@ -3,7 +3,6 @@ using System.Threading; using Avalonia.Platform; using Avalonia.Threading; using MonoMac.AppKit; -using MonoMac.CoreFoundation; using MonoMac.CoreGraphics; using MonoMac.Foundation; using MonoMac.ObjCRuntime; diff --git a/src/OSX/Avalonia.MonoMac/RenderLoop.cs b/src/OSX/Avalonia.MonoMac/RenderLoop.cs index a6f3e9f493..4d1f9b4201 100644 --- a/src/OSX/Avalonia.MonoMac/RenderLoop.cs +++ b/src/OSX/Avalonia.MonoMac/RenderLoop.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Platform; using Avalonia.Rendering; using MonoMac.Foundation; diff --git a/src/OSX/Avalonia.MonoMac/ScreenImpl.cs b/src/OSX/Avalonia.MonoMac/ScreenImpl.cs index bf8545a300..46cd200cab 100644 --- a/src/OSX/Avalonia.MonoMac/ScreenImpl.cs +++ b/src/OSX/Avalonia.MonoMac/ScreenImpl.cs @@ -1,6 +1,4 @@ -using Avalonia.Controls; -using Avalonia.Platform; -using Avalonia.Utilities; +using Avalonia.Platform; using MonoMac.AppKit; using MonoMac.Foundation; @@ -48,4 +46,4 @@ namespace Avalonia.MonoMac _allScreens = null; } } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/Stubs.cs b/src/OSX/Avalonia.MonoMac/Stubs.cs index f3ff6a260c..188ceeaab1 100644 --- a/src/OSX/Avalonia.MonoMac/Stubs.cs +++ b/src/OSX/Avalonia.MonoMac/Stubs.cs @@ -44,4 +44,4 @@ namespace Avalonia.MonoMac return LoadIcon(ms); } } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/SystemDialogsImpl.cs b/src/OSX/Avalonia.MonoMac/SystemDialogsImpl.cs index 16a0b25ef1..382311e28a 100644 --- a/src/OSX/Avalonia.MonoMac/SystemDialogsImpl.cs +++ b/src/OSX/Avalonia.MonoMac/SystemDialogsImpl.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Controls.Platform; diff --git a/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs b/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs index b528d84e4c..fb4c5afc2d 100644 --- a/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs +++ b/src/OSX/Avalonia.MonoMac/TopLevelImpl.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; +using Avalonia.Controls.Platform.Surfaces; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; -using Avalonia.Controls.Platform.Surfaces; using Avalonia.Rendering; using Avalonia.Threading; using MonoMac.AppKit; -using MonoMac.CoreFoundation; using MonoMac.CoreGraphics; using MonoMac.Foundation; using MonoMac.ObjCRuntime; @@ -503,4 +502,4 @@ namespace Avalonia.MonoMac public ILockedFramebuffer Lock() => new EmulatedFramebuffer(View); } -} \ No newline at end of file +} diff --git a/src/OSX/Avalonia.MonoMac/WindowImpl.cs b/src/OSX/Avalonia.MonoMac/WindowImpl.cs index 89b5550688..f276e07c99 100644 --- a/src/OSX/Avalonia.MonoMac/WindowImpl.cs +++ b/src/OSX/Avalonia.MonoMac/WindowImpl.cs @@ -1,9 +1,9 @@ using System; using Avalonia.Controls; using Avalonia.Platform; +using Avalonia.Threading; using MonoMac.AppKit; using MonoMac.CoreGraphics; -using Avalonia.Threading; namespace Avalonia.MonoMac { diff --git a/src/Shared/PlatformSupport/AssetLoader.cs b/src/Shared/PlatformSupport/AssetLoader.cs index b4d17b22a1..d73c98415e 100644 --- a/src/Shared/PlatformSupport/AssetLoader.cs +++ b/src/Shared/PlatformSupport/AssetLoader.cs @@ -119,7 +119,7 @@ namespace Avalonia.Shared.PlatformSupport { throw new ArgumentException( "No default assembly, entry assembly or explicit assembly specified; " + - "don't know where to look up for the resource, try specifiyng assembly explicitly."); + "don't know where to look up for the resource, try specifying assembly explicitly."); } IAssetDescriptor rv; @@ -233,4 +233,4 @@ namespace Avalonia.Shared.PlatformSupport public string Name { get; } } } -} \ No newline at end of file +} diff --git a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs index 16977d5f97..beed847539 100644 --- a/src/Shared/PlatformSupport/StandardRuntimePlatform.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatform.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Reflection; -using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; diff --git a/src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs b/src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs index 70601fdf4a..9ccf097ffd 100644 --- a/src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs +++ b/src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; using System.Reflection; -using System.Text; using Avalonia.Platform; namespace Avalonia.Shared.PlatformSupport diff --git a/src/Shared/RenderHelpers/ArcToHelper.cs b/src/Shared/RenderHelpers/ArcToHelper.cs index 2457606f9d..8445da8dd5 100644 --- a/src/Shared/RenderHelpers/ArcToHelper.cs +++ b/src/Shared/RenderHelpers/ArcToHelper.cs @@ -595,7 +595,7 @@ namespace Avalonia.RenderHelpers double cos4 = Math.Cos(4 * eta); double cos6 = Math.Cos(6 * eta); - // select the right coeficients set according to degree and b/a + // select the right coefficients set according to degree and b/a double[][][] coeffs; double[] safety; if (degree == 2) @@ -654,7 +654,7 @@ namespace Avalonia.RenderHelpers if (IsPieSlice) { // check the location of the test point with respect to the - // angular sector counted from the centre of the ellipse + // angular sector counted from the center of the ellipse double dxC = x - Cx; double dyC = y - Cy; double u = dxC * _cosTheta + dyC * _sinTheta; diff --git a/src/Shared/WindowResizeDragHelper.cs b/src/Shared/WindowResizeDragHelper.cs index c133e493fa..e0e0936b69 100644 --- a/src/Shared/WindowResizeDragHelper.cs +++ b/src/Shared/WindowResizeDragHelper.cs @@ -1,6 +1,5 @@ using System; using Avalonia.Controls; -using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; @@ -82,4 +81,4 @@ namespace Avalonia } } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs index d835c83aa6..2a8f517995 100644 --- a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs +++ b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs @@ -1,12 +1,12 @@ // 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.Media; -using Avalonia.Platform; -using SkiaSharp; using System; using System.Collections.Generic; using System.Linq; +using Avalonia.Media; +using Avalonia.Platform; +using SkiaSharp; namespace Avalonia.Skia { @@ -723,4 +723,4 @@ namespace Avalonia.Skia } } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs index 99dbbefd4d..829b9097c9 100644 --- a/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs +++ b/src/Skia/Avalonia.Skia/FramebufferRenderTarget.cs @@ -6,7 +6,6 @@ using System.Reactive.Disposables; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Platform; using Avalonia.Rendering; -using Avalonia.Skia.Helpers; using SkiaSharp; namespace Avalonia.Skia @@ -95,7 +94,7 @@ namespace Avalonia.Skia var surface = SKSurface.Create(desiredImageInfo, _currentFramebufferAddress, framebuffer.RowBytes); - // If surface cannot be created - try to create a compatibilty shim first + // If surface cannot be created - try to create a compatibility shim first if (surface == null) { _conversionShim = new PixelFormatConversionShim(desiredImageInfo, framebuffer.Address); @@ -196,4 +195,4 @@ namespace Avalonia.Skia } } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/GeometryImpl.cs b/src/Skia/Avalonia.Skia/GeometryImpl.cs index af4cdb8056..fbbd6eb58c 100644 --- a/src/Skia/Avalonia.Skia/GeometryImpl.cs +++ b/src/Skia/Avalonia.Skia/GeometryImpl.cs @@ -108,7 +108,7 @@ namespace Avalonia.Skia } /// - /// Invalidate all caches. Call after chaning path contents. + /// Invalidate all caches. Call after chaining path contents. /// protected void InvalidateCaches() { diff --git a/src/Skia/Avalonia.Skia/Helpers/PixelFormatHelper.cs b/src/Skia/Avalonia.Skia/Helpers/PixelFormatHelper.cs index 307af708af..04756994f5 100644 --- a/src/Skia/Avalonia.Skia/Helpers/PixelFormatHelper.cs +++ b/src/Skia/Avalonia.Skia/Helpers/PixelFormatHelper.cs @@ -32,4 +32,4 @@ namespace Avalonia.Skia.Helpers return colorType; } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/IDrawableBitmapImpl.cs b/src/Skia/Avalonia.Skia/IDrawableBitmapImpl.cs index 5aa5de2abc..f900e7af77 100644 --- a/src/Skia/Avalonia.Skia/IDrawableBitmapImpl.cs +++ b/src/Skia/Avalonia.Skia/IDrawableBitmapImpl.cs @@ -20,4 +20,4 @@ namespace Avalonia.Skia /// Paint to use. void Draw(DrawingContextImpl context, SKRect sourceRect, SKRect destRect, SKPaint paint); } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs b/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs index bd951ef3a3..687fe7feca 100644 --- a/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs +++ b/src/Skia/Avalonia.Skia/SKTypefaceCollection.cs @@ -71,4 +71,4 @@ namespace Avalonia.Skia } } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs b/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs index dc533cbf3c..b9a8c9b98b 100644 --- a/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs +++ b/src/Skia/Avalonia.Skia/SKTypefaceCollectionCache.cs @@ -50,4 +50,4 @@ namespace Avalonia.Skia return typeFaceCollection; } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs b/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs index 0086671880..f4412df473 100644 --- a/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs +++ b/src/Skia/Avalonia.Skia/SkiaApplicationExtensions.cs @@ -8,7 +8,7 @@ using Avalonia.Skia; namespace Avalonia { /// - /// Skia appication extensions. + /// Skia application extensions. /// public static class SkiaApplicationExtensions { @@ -17,7 +17,6 @@ namespace Avalonia /// /// Builder type. /// Builder. - /// Preferred backend type. /// Configure builder. public static T UseSkia(this T builder) where T : AppBuilderBase, new() { @@ -25,4 +24,4 @@ namespace Avalonia return builder; } } -} \ No newline at end of file +} diff --git a/src/Skia/Avalonia.Skia/SkiaPlatform.cs b/src/Skia/Avalonia.Skia/SkiaPlatform.cs index 06679478cb..a9d69aea31 100644 --- a/src/Skia/Avalonia.Skia/SkiaPlatform.cs +++ b/src/Skia/Avalonia.Skia/SkiaPlatform.cs @@ -1,8 +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; -using Avalonia.Logging; using Avalonia.Platform; namespace Avalonia.Skia diff --git a/src/Skia/Avalonia.Skia/TypefaceCache.cs b/src/Skia/Avalonia.Skia/TypefaceCache.cs index f85dd84055..cf862f3400 100644 --- a/src/Skia/Avalonia.Skia/TypefaceCache.cs +++ b/src/Skia/Avalonia.Skia/TypefaceCache.cs @@ -1,9 +1,7 @@ // 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.Collections.Generic; -using System.Linq; using Avalonia.Media; using SkiaSharp; @@ -94,4 +92,4 @@ namespace Avalonia.Skia } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 296edcb2d9..81a70f8311 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -4,14 +4,12 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using Avalonia.Direct2D1.Media; -using Avalonia.Media; -using Avalonia.Platform; using Avalonia.Controls; using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; -using Avalonia.Rendering; +using Avalonia.Media; +using Avalonia.Platform; namespace Avalonia { @@ -193,4 +191,4 @@ namespace Avalonia.Direct2D1 return new WicBitmapImpl(s_imagingFactory, format, data, width, height, stride); } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs b/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs index e7e27493e5..d1233ca4e7 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2DChecker.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Platform; +using Avalonia.Platform; namespace Avalonia.Direct2D1 { diff --git a/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs index 176cedd377..ac18d0943b 100644 --- a/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Direct2D1.Media; +using Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; diff --git a/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs index 523cfeed46..83ce571152 100644 --- a/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Text; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Direct2D1.Media; -using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Win32.Interop; diff --git a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs index 49402d54b9..dc6d8ea016 100644 --- a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Controls.Platform.Surfaces; -using Avalonia.Platform; +using Avalonia.Platform; using Avalonia.Win32.Interop; using SharpDX; using SharpDX.DXGI; diff --git a/src/Windows/Avalonia.Direct2D1/IExternalDirect2DRenderTargetSurface.cs b/src/Windows/Avalonia.Direct2D1/IExternalDirect2DRenderTargetSurface.cs index aad51f46d5..9c7d74ff68 100644 --- a/src/Windows/Avalonia.Direct2D1/IExternalDirect2DRenderTargetSurface.cs +++ b/src/Windows/Avalonia.Direct2D1/IExternalDirect2DRenderTargetSurface.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Avalonia.Direct2D1 +namespace Avalonia.Direct2D1 { public interface IExternalDirect2DRenderTargetSurface { diff --git a/src/Windows/Avalonia.Direct2D1/ILayerFactory.cs b/src/Windows/Avalonia.Direct2D1/ILayerFactory.cs index 99f8d4f7ac..08273f1bb2 100644 --- a/src/Windows/Avalonia.Direct2D1/ILayerFactory.cs +++ b/src/Windows/Avalonia.Direct2D1/ILayerFactory.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Platform; +using Avalonia.Platform; namespace Avalonia.Direct2D1 { diff --git a/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontFileStream.cs b/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontFileStream.cs index 1b1cb85495..1802ef4d21 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontFileStream.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontFileStream.cs @@ -5,7 +5,7 @@ using SharpDX.DirectWrite; namespace Avalonia.Direct2D1.Media { /// - /// This FontFileStream implem is reading data from a . + /// This FontFileStream implementation is reading data from a . /// public class DWriteResourceFontFileStream : CallbackBase, FontFileStream { @@ -81,4 +81,4 @@ namespace Avalonia.Direct2D1.Media return 0; } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs b/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs index 065da8d3e8..e5f87e71a2 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/DWriteResourceFontLoader.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Avalonia.Media.Fonts; using Avalonia.Platform; using SharpDX; using SharpDX.DirectWrite; @@ -96,4 +95,4 @@ namespace Avalonia.Direct2D1.Media return _fontStreams[index]; } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs index 6713cb13be..3835cd16da 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs @@ -1,10 +1,10 @@ using System; using System.IO; using SharpDX.Direct2D1; -using WICFactory = SharpDX.WIC.ImagingFactory; -using ImagingFactory2 = SharpDX.WIC.ImagingFactory2; using ImageParameters = SharpDX.WIC.ImageParameters; +using ImagingFactory2 = SharpDX.WIC.ImagingFactory2; using PngBitmapEncoder = SharpDX.WIC.PngBitmapEncoder; +using WICFactory = SharpDX.WIC.ImagingFactory; namespace Avalonia.Direct2D1.Media { diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs index 2843848fac..18a746436c 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs @@ -1,5 +1,4 @@ -using System; -using Avalonia.Platform; +using Avalonia.Platform; using Avalonia.Rendering; using SharpDX; using SharpDX.Direct2D1; diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs index 371dfcfc3e..ef2177b167 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using System.Runtime.CompilerServices; using Avalonia.Win32.Interop; using SharpDX.WIC; using APixelFormat = Avalonia.Platform.PixelFormat; diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs index fc931c32db..cf7759af28 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Platform; using SharpDX.WIC; using PixelFormat = Avalonia.Platform.PixelFormat; diff --git a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs index 4228745d6b..10b89d79b8 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryContextImpl.cs @@ -1,13 +1,13 @@ // 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 Avalonia.Logging; using Avalonia.Media; using Avalonia.Platform; using SharpDX.Direct2D1; -using SweepDirection = SharpDX.Direct2D1.SweepDirection; using D2D = SharpDX.Direct2D1; -using Avalonia.Logging; -using System; +using SweepDirection = SharpDX.Direct2D1.SweepDirection; namespace Avalonia.Direct2D1.Media { diff --git a/src/Windows/Avalonia.Direct2D1/RenderTarget.cs b/src/Windows/Avalonia.Direct2D1/RenderTarget.cs index 6086b0c67c..f2a83d78e8 100644 --- a/src/Windows/Avalonia.Direct2D1/RenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/RenderTarget.cs @@ -1,7 +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; using Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; diff --git a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs index 0a23c63498..bc330dfcf5 100644 --- a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs @@ -1,16 +1,15 @@ -using System; +using Avalonia.Direct2D1.Media; +using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; +using Avalonia.Rendering; using SharpDX; using SharpDX.Direct2D1; using SharpDX.DXGI; -using PixelFormat = SharpDX.Direct2D1.PixelFormat; using AlphaMode = SharpDX.Direct2D1.AlphaMode; using Device = SharpDX.Direct2D1.Device; using Factory = SharpDX.Direct2D1.Factory; using Factory2 = SharpDX.DXGI.Factory2; -using Avalonia.Rendering; -using Avalonia.Direct2D1.Media; -using Avalonia.Direct2D1.Media.Imaging; +using PixelFormat = SharpDX.Direct2D1.PixelFormat; namespace Avalonia.Direct2D1 { diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/CursorShim.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/CursorShim.cs index 6ae898ae3d..2ad6287689 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/CursorShim.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/CursorShim.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; using System.Windows.Input; namespace Avalonia.Win32.Interop.Wpf diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs index 8fe7275a0f..400dd59ea9 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/Direct2DImageSurface.cs @@ -1,13 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Interop; using Avalonia.Direct2D1; -using SharpDX; using SharpDX.Direct2D1; using SharpDX.Direct3D11; using SharpDX.Direct3D9; @@ -15,13 +10,10 @@ using SharpDX.DXGI; using AlphaMode = SharpDX.Direct2D1.AlphaMode; using Device = SharpDX.Direct3D11.Device; using Format = SharpDX.DXGI.Format; -using MapFlags = SharpDX.Direct3D11.MapFlags; -using PresentParameters = SharpDX.DXGI.PresentParameters; using Query = SharpDX.Direct3D11.Query; using QueryType = SharpDX.Direct3D11.QueryType; using RenderTarget = SharpDX.Direct2D1.RenderTarget; using Surface = SharpDX.DXGI.Surface; -using SwapEffect = SharpDX.DXGI.SwapEffect; using Usage = SharpDX.Direct3D9.Usage; namespace Avalonia.Win32.Interop.Wpf diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs index 3fdbdedfd9..b8648dfc50 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/IntSize.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Win32.Interop.Wpf { diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfAvaloniaHost.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfAvaloniaHost.cs index 6dc9ba9e09..7883c28153 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfAvaloniaHost.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfAvaloniaHost.cs @@ -1,18 +1,7 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; using System.Windows.Markup; -using System.Windows.Media; -using Avalonia.Markup.Xaml.Styling; -using Avalonia.Platform; -using Avalonia.Styling; namespace Avalonia.Win32.Interop.Wpf { @@ -55,7 +44,7 @@ namespace Avalonia.Win32.Interop.Wpf set => _impl.ControlRoot.Content = value; } - //Separate class is needed to prevent accidential resurrection + //Separate class is needed to prevent accidental resurrection class Disposer { private readonly WpfTopLevelImpl _impl; diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfInteropExtensions.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfInteropExtensions.cs index 6433ff05e0..44c4c84cd6 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfInteropExtensions.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfInteropExtensions.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Avalonia.Win32.Interop.Wpf +namespace Avalonia.Win32.Interop.Wpf { static class WpfInteropExtensions { diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs index 4aad80f8a5..0d93115714 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs @@ -27,4 +27,4 @@ namespace Avalonia.Win32.Interop.Wpf base.Capture(control); } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfTopLevelImpl.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfTopLevelImpl.cs index 7c0e0311a6..b5fb158168 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfTopLevelImpl.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfTopLevelImpl.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/WritableBitmapSurface.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/WritableBitmapSurface.cs index 0f8752fb8d..79340fa335 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/WritableBitmapSurface.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/WritableBitmapSurface.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; diff --git a/src/Windows/Avalonia.Win32/ClipboardFormats.cs b/src/Windows/Avalonia.Win32/ClipboardFormats.cs index 5e0bbab975..a18116aade 100644 --- a/src/Windows/Avalonia.Win32/ClipboardFormats.cs +++ b/src/Windows/Avalonia.Win32/ClipboardFormats.cs @@ -7,7 +7,7 @@ using Avalonia.Input; using Avalonia.Win32.Interop; namespace Avalonia.Win32 -{ +{ static class ClipboardFormats { private const int MAX_FORMAT_NAME_LENGTH = 260; @@ -77,4 +77,4 @@ namespace Avalonia.Win32 } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Win32/ClipboardImpl.cs b/src/Windows/Avalonia.Win32/ClipboardImpl.cs index a908c9e1e2..ad000f11eb 100644 --- a/src/Windows/Avalonia.Win32/ClipboardImpl.cs +++ b/src/Windows/Avalonia.Win32/ClipboardImpl.cs @@ -2,13 +2,10 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Runtime.InteropServices; using System.Threading.Tasks; using Avalonia.Input.Platform; using Avalonia.Win32.Interop; -using System.Runtime.InteropServices; namespace Avalonia.Win32 { diff --git a/src/Windows/Avalonia.Win32/CursorFactory.cs b/src/Windows/Avalonia.Win32/CursorFactory.cs index fa2fbe4810..e582b5fb82 100644 --- a/src/Windows/Avalonia.Win32/CursorFactory.cs +++ b/src/Windows/Avalonia.Win32/CursorFactory.cs @@ -1,15 +1,11 @@ // 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.Win32.Interop; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Input; using Avalonia.Platform; -using System.Runtime.InteropServices; +using Avalonia.Win32.Interop; namespace Avalonia.Win32 { diff --git a/src/Windows/Avalonia.Win32/DataObject.cs b/src/Windows/Avalonia.Win32/DataObject.cs index 13d5f662c2..e78a99cc03 100644 --- a/src/Windows/Avalonia.Win32/DataObject.cs +++ b/src/Windows/Avalonia.Win32/DataObject.cs @@ -1,14 +1,13 @@ using System; -using System.Linq; using System.Collections.Generic; +using System.IO; +using System.Linq; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; -using System.Text; +using System.Runtime.Serialization.Formatters.Binary; using Avalonia.Input; using Avalonia.Win32.Interop; using IDataObject = Avalonia.Input.IDataObject; -using System.IO; -using System.Runtime.Serialization.Formatters.Binary; namespace Avalonia.Win32 { diff --git a/src/Windows/Avalonia.Win32/DragSource.cs b/src/Windows/Avalonia.Win32/DragSource.cs index ea124e5f29..a1bc5023a5 100644 --- a/src/Windows/Avalonia.Win32/DragSource.cs +++ b/src/Windows/Avalonia.Win32/DragSource.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.Threading; diff --git a/src/Windows/Avalonia.Win32/FramebufferManager.cs b/src/Windows/Avalonia.Win32/FramebufferManager.cs index bdc6fb29fd..bb0bde34ff 100644 --- a/src/Windows/Avalonia.Win32/FramebufferManager.cs +++ b/src/Windows/Avalonia.Win32/FramebufferManager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Platform; using Avalonia.Win32.Interop; diff --git a/src/Windows/Avalonia.Win32/IconImpl.cs b/src/Windows/Avalonia.Win32/IconImpl.cs index b7293397d7..8548801555 100644 --- a/src/Windows/Avalonia.Win32/IconImpl.cs +++ b/src/Windows/Avalonia.Win32/IconImpl.cs @@ -1,12 +1,8 @@ -using Avalonia.Platform; -using System; -using System.Collections.Generic; +using System; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.IO; using System.Drawing.Imaging; +using System.IO; +using Avalonia.Platform; namespace Avalonia.Win32 { diff --git a/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs b/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs index 3d8d04d6cc..2b4105efee 100644 --- a/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs +++ b/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs @@ -1,9 +1,7 @@ // 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 Avalonia.Input; -using Avalonia.Interactivity; using Avalonia.Win32.Interop; namespace Avalonia.Win32.Input @@ -32,4 +30,4 @@ namespace Avalonia.Win32.Input } } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Win32/OleDataObject.cs b/src/Windows/Avalonia.Win32/OleDataObject.cs index d7b663e7bf..70d651b2aa 100644 --- a/src/Windows/Avalonia.Win32/OleDataObject.cs +++ b/src/Windows/Avalonia.Win32/OleDataObject.cs @@ -167,4 +167,4 @@ namespace Avalonia.Win32 } } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Win32/OleDragSource.cs b/src/Windows/Avalonia.Win32/OleDragSource.cs index a87995952a..c903a9ca57 100644 --- a/src/Windows/Avalonia.Win32/OleDragSource.cs +++ b/src/Windows/Avalonia.Win32/OleDragSource.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Linq; using Avalonia.Win32.Interop; namespace Avalonia.Win32 diff --git a/src/Windows/Avalonia.Win32/OleDropTarget.cs b/src/Windows/Avalonia.Win32/OleDropTarget.cs index 6a10cc7e98..7013931be9 100644 --- a/src/Windows/Avalonia.Win32/OleDropTarget.cs +++ b/src/Windows/Avalonia.Win32/OleDropTarget.cs @@ -181,4 +181,4 @@ namespace Avalonia.Win32 return _target.PointToClient(screenPt); } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Win32/SystemDialogImpl.cs b/src/Windows/Avalonia.Win32/SystemDialogImpl.cs index dec5e3a544..d792ad9991 100644 --- a/src/Windows/Avalonia.Win32/SystemDialogImpl.cs +++ b/src/Windows/Avalonia.Win32/SystemDialogImpl.cs @@ -1,12 +1,12 @@ -using Avalonia.Controls; -using Avalonia.Controls.Platform; -using Avalonia.Platform; -using Avalonia.Win32.Interop; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; +using Avalonia.Controls; +using Avalonia.Controls.Platform; +using Avalonia.Platform; +using Avalonia.Win32.Interop; namespace Avalonia.Win32 { diff --git a/src/Windows/Avalonia.Win32/WindowFramebuffer.cs b/src/Windows/Avalonia.Win32/WindowFramebuffer.cs index 83ab288c54..6193ebd02b 100644 --- a/src/Windows/Avalonia.Win32/WindowFramebuffer.cs +++ b/src/Windows/Avalonia.Win32/WindowFramebuffer.cs @@ -1,6 +1,4 @@ using System; -using System.Runtime.InteropServices; -using Avalonia.Controls.Platform.Surfaces; using Avalonia.Platform; using Avalonia.Win32.Interop; using PixelFormat = Avalonia.Platform.PixelFormat; @@ -101,4 +99,4 @@ namespace Avalonia.Win32 public void Deallocate() => _bitmapBlob.Dispose(); } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/AppBuilder.cs b/src/iOS/Avalonia.iOS/AppBuilder.cs index 06ac7ed6cd..a68dd6387a 100644 --- a/src/iOS/Avalonia.iOS/AppBuilder.cs +++ b/src/iOS/Avalonia.iOS/AppBuilder.cs @@ -1,12 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Avalonia.Controls; -using Avalonia.Platform; using Avalonia.Shared.PlatformSupport; -using Foundation; -using UIKit; namespace Avalonia { @@ -18,4 +11,4 @@ namespace Avalonia } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/AvaloniaView.cs b/src/iOS/Avalonia.iOS/AvaloniaView.cs index d70a31a706..b1de4b8d47 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaView.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaView.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Avalonia.Controls.Embedding; +using Avalonia.Controls.Embedding; using CoreGraphics; using UIKit; diff --git a/src/iOS/Avalonia.iOS/AvaloniaWindow.cs b/src/iOS/Avalonia.iOS/AvaloniaWindow.cs index d3f88e0e1e..19e2bb494c 100644 --- a/src/iOS/Avalonia.iOS/AvaloniaWindow.cs +++ b/src/iOS/Avalonia.iOS/AvaloniaWindow.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Avalonia.Media; -using Foundation; using UIKit; namespace Avalonia.iOS @@ -28,4 +23,4 @@ namespace Avalonia.iOS set { _controller.StatusBarColor = value; } } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/Clipboard.cs b/src/iOS/Avalonia.iOS/Clipboard.cs index 498b671cb8..c66b379453 100644 --- a/src/iOS/Avalonia.iOS/Clipboard.cs +++ b/src/iOS/Avalonia.iOS/Clipboard.cs @@ -23,4 +23,4 @@ namespace Avalonia.iOS return Task.FromResult(0); } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/DisplayLinkRenderLoop.cs b/src/iOS/Avalonia.iOS/DisplayLinkRenderLoop.cs index a6d1bf1670..4f275dd8ea 100644 --- a/src/iOS/Avalonia.iOS/DisplayLinkRenderLoop.cs +++ b/src/iOS/Avalonia.iOS/DisplayLinkRenderLoop.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using Avalonia.Rendering; using CoreAnimation; using Foundation; -using UIKit; namespace Avalonia.iOS { @@ -32,4 +28,4 @@ namespace Avalonia.iOS } } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/EmbeddableImpl.cs b/src/iOS/Avalonia.iOS/EmbeddableImpl.cs index 7d34cf40f7..65a6c15971 100644 --- a/src/iOS/Avalonia.iOS/EmbeddableImpl.cs +++ b/src/iOS/Avalonia.iOS/EmbeddableImpl.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.Reactive.Disposables; -using System.Text; using Avalonia.Platform; -using UIKit; namespace Avalonia.iOS { diff --git a/src/iOS/Avalonia.iOS/EmulatedFramebuffer.cs b/src/iOS/Avalonia.iOS/EmulatedFramebuffer.cs index 517b372ba4..b3b41fe724 100644 --- a/src/iOS/Avalonia.iOS/EmulatedFramebuffer.cs +++ b/src/iOS/Avalonia.iOS/EmulatedFramebuffer.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; using Avalonia.Platform; using CoreGraphics; using UIKit; diff --git a/src/iOS/Avalonia.iOS/Extensions.cs b/src/iOS/Avalonia.iOS/Extensions.cs index 5364129911..28708b20d8 100644 --- a/src/iOS/Avalonia.iOS/Extensions.cs +++ b/src/iOS/Avalonia.iOS/Extensions.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Media; using CoreGraphics; using UIKit; diff --git a/src/iOS/Avalonia.iOS/PlatformIconLoader.cs b/src/iOS/Avalonia.iOS/PlatformIconLoader.cs index ca54a660b3..c539aba846 100644 --- a/src/iOS/Avalonia.iOS/PlatformIconLoader.cs +++ b/src/iOS/Avalonia.iOS/PlatformIconLoader.cs @@ -1,5 +1,5 @@ -using Avalonia.Platform; -using System.IO; +using System.IO; +using Avalonia.Platform; namespace Avalonia.iOS { @@ -43,4 +43,4 @@ namespace Avalonia.iOS stream.CopyTo(outputStream); } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/PlatformSettings.cs b/src/iOS/Avalonia.iOS/PlatformSettings.cs index 9f238d4d30..9545795629 100644 --- a/src/iOS/Avalonia.iOS/PlatformSettings.cs +++ b/src/iOS/Avalonia.iOS/PlatformSettings.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Avalonia.Platform; using UIKit; diff --git a/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs b/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs index 43a620cccd..7762e0e03b 100644 --- a/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs +++ b/src/iOS/Avalonia.iOS/PlatformThreadingInterface.cs @@ -1,15 +1,8 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reactive.Disposables; -using System.Text; using System.Threading; -using CoreAnimation; -using Foundation; using Avalonia.Platform; -using Avalonia.Shared.PlatformSupport; using Avalonia.Threading; +using Foundation; namespace Avalonia.iOS { diff --git a/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs b/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs index 567bb9a5e0..be32d12315 100644 --- a/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs +++ b/src/iOS/Avalonia.iOS/Specific/KeyboardEventsHelper.cs @@ -1,11 +1,11 @@ -using ObjCRuntime; +using System; +using System.ComponentModel; +using System.Linq; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Raw; using Avalonia.Platform; -using System; -using System.ComponentModel; -using System.Linq; +using ObjCRuntime; using UIKit; namespace Avalonia.iOS.Specific @@ -122,7 +122,7 @@ namespace Avalonia.iOS.Specific _lastFocusedElement = element; } - public void ActivateAutoShowKeybord() + public void ActivateAutoShowKeyboard() { var kbDevice = (KeyboardDevice.Instance as INotifyPropertyChanged); @@ -144,4 +144,4 @@ namespace Avalonia.iOS.Specific HandleEvents = false; } } -} \ No newline at end of file +} diff --git a/src/iOS/Avalonia.iOS/TopLevelImpl.cs b/src/iOS/Avalonia.iOS/TopLevelImpl.cs index 3a2d2a33c6..1101f53222 100644 --- a/src/iOS/Avalonia.iOS/TopLevelImpl.cs +++ b/src/iOS/Avalonia.iOS/TopLevelImpl.cs @@ -1,23 +1,15 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reactive.Disposables; -using System.Text; -using CoreAnimation; -using CoreGraphics; -using Foundation; -using Avalonia.Controls.Platform; +using Avalonia.Controls.Platform.Surfaces; using Avalonia.Input; using Avalonia.Input.Raw; -using Avalonia.Media; -using Avalonia.Platform; -using UIKit; using Avalonia.iOS.Specific; -using ObjCRuntime; -using Avalonia.Controls; -using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Platform; using Avalonia.Rendering; +using CoreGraphics; +using Foundation; +using ObjCRuntime; +using UIKit; namespace Avalonia.iOS { @@ -31,7 +23,7 @@ namespace Avalonia.iOS { _keyboardHelper = new KeyboardEventsHelper(this); AutoresizingMask = UIViewAutoresizing.All; - _keyboardHelper.ActivateAutoShowKeybord(); + _keyboardHelper.ActivateAutoShowKeyboard(); } [Export("hasText")] diff --git a/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs b/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs index 5cac259ce7..9a40b7162e 100644 --- a/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs +++ b/src/iOS/Avalonia.iOS/WindowingPlatformImpl.cs @@ -1,5 +1,5 @@ -using Avalonia.Platform; using System; +using Avalonia.Platform; namespace Avalonia.iOS { diff --git a/src/iOS/Avalonia.iOS/iOSPlatform.cs b/src/iOS/Avalonia.iOS/iOSPlatform.cs index 91e3bcc041..abaebca489 100644 --- a/src/iOS/Avalonia.iOS/iOSPlatform.cs +++ b/src/iOS/Avalonia.iOS/iOSPlatform.cs @@ -1,13 +1,10 @@ -using System; -using System.Reflection; +using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Platform; using Avalonia.iOS; using Avalonia.Platform; -using Avalonia.Shared.PlatformSupport; -using UIKit; -using Avalonia.Controls; using Avalonia.Rendering; +using Avalonia.Shared.PlatformSupport; namespace Avalonia { diff --git a/src/tools/Avalonia.Designer.HostApp.NetFX/Program.cs b/src/tools/Avalonia.Designer.HostApp.NetFX/Program.cs index bef53bb685..da1c5a1da3 100644 --- a/src/tools/Avalonia.Designer.HostApp.NetFX/Program.cs +++ b/src/tools/Avalonia.Designer.HostApp.NetFX/Program.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Avalonia.Designer.HostApp.NetFX { From 9d89bfdfaba3c3332a010919d69a2f6740cbe711 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 5 Sep 2018 09:50:37 +0100 Subject: [PATCH 34/80] fix slider not updating value. --- src/Avalonia.Controls/Slider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index 31113812d1..f1919dc236 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -172,7 +172,7 @@ namespace Avalonia.Controls private void MoveToNextTick(double value) { double next = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); - if (next != value) + if (Value != next) { Value = next; } From 39931f5fdeeb265efdf5b10fe93e2b4739ea82bb Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Wed, 5 Sep 2018 10:28:41 +0100 Subject: [PATCH 35/80] use same fix as upcoming pr to prevent conflict. --- src/Avalonia.Controls/Slider.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index f1919dc236..32b0a1f259 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -171,11 +171,7 @@ namespace Avalonia.Controls /// Value that want to snap to closest Tick. private void MoveToNextTick(double value) { - double next = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); - if (Value != next) - { - Value = next; - } + Value = SnapToTick(Math.Max(Minimum, Math.Min(Maximum, value))); } /// @@ -194,4 +190,4 @@ namespace Avalonia.Controls return value; } } -} \ No newline at end of file +} From 66bebd0c1b5a5c4ece8c08c675c0ef926b41e3c9 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Wed, 5 Sep 2018 16:45:27 +0200 Subject: [PATCH 36/80] Initial --- .../Avalonia.Direct2D1/Direct2D1Platform.cs | 91 ++++++++++--------- .../ExternalRenderTarget.cs | 22 +---- .../FramebufferShimRenderTarget.cs | 27 +----- .../Avalonia.Direct2D1/HwndRenderTarget.cs | 10 +- .../Media/Direct2D1FontCollectionCache.cs | 13 +-- .../Media/DrawingContextImpl.cs | 10 +- .../Media/FormattedTextImpl.cs | 4 +- .../Avalonia.Direct2D1/Media/GeometryImpl.cs | 3 +- .../Media/Imaging/BitmapImpl.cs | 7 -- .../Media/Imaging/D2DBitmapImpl.cs | 28 +++--- .../Imaging/D2DRenderTargetBitmapImpl.cs | 39 +++----- .../Media/Imaging/WicBitmapImpl.cs | 33 +++---- .../Imaging/WicRenderTargetBitmapImpl.cs | 22 ++--- .../Media/Imaging/WriteableWicBitmapImpl.cs | 8 +- .../Media/StreamGeometryImpl.cs | 6 +- .../Avalonia.Direct2D1/RenderTarget.cs | 19 +--- .../SwapChainRenderTarget.cs | 55 +++-------- 17 files changed, 132 insertions(+), 265 deletions(-) diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 296edcb2d9..437bae6fd1 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -4,14 +4,12 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using Avalonia.Direct2D1.Media; -using Avalonia.Media; -using Avalonia.Platform; using Avalonia.Controls; using Avalonia.Controls.Platform.Surfaces; +using Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; -using Avalonia.Rendering; +using Avalonia.Media; +using Avalonia.Platform; namespace Avalonia { @@ -31,15 +29,16 @@ namespace Avalonia.Direct2D1 { private static readonly Direct2D1Platform s_instance = new Direct2D1Platform(); - private static SharpDX.Direct2D1.Factory s_d2D1Factory; + public static SharpDX.Direct2D1.Factory1 Direct2D1Factory { get; private set; } - private static SharpDX.DirectWrite.Factory s_dwfactory; + public static SharpDX.Direct2D1.Device1 Direct2D1Device { get; private set; } - private static SharpDX.WIC.ImagingFactory s_imagingFactory; + public static SharpDX.DirectWrite.Factory1 DirectWriteFactory { get; private set; } - private static SharpDX.DXGI.Device s_dxgiDevice; + public static SharpDX.WIC.ImagingFactory ImagingFactory { get; private set; } + + public static SharpDX.DXGI.Device1 DxgiDevice { get; private set; } - private static SharpDX.Direct2D1.Device s_d2D1Device; private static readonly object s_initLock = new object(); private static bool s_initialized = false; @@ -49,13 +48,14 @@ namespace Avalonia.Direct2D1 lock (s_initLock) { if (s_initialized) + { return; + } #if DEBUG try { - s_d2D1Factory = - - new SharpDX.Direct2D1.Factory1(SharpDX.Direct2D1.FactoryType.MultiThreaded, + Direct2D1Factory = new SharpDX.Direct2D1.Factory1( + SharpDX.Direct2D1.FactoryType.MultiThreaded, SharpDX.Direct2D1.DebugLevel.Error); } catch @@ -63,12 +63,19 @@ namespace Avalonia.Direct2D1 // } #endif - s_dwfactory = new SharpDX.DirectWrite.Factory(); - s_imagingFactory = new SharpDX.WIC.ImagingFactory(); - if (s_d2D1Factory == null) - s_d2D1Factory = new SharpDX.Direct2D1.Factory1(SharpDX.Direct2D1.FactoryType.MultiThreaded, + if (Direct2D1Factory == null) + { + Direct2D1Factory = new SharpDX.Direct2D1.Factory1( + SharpDX.Direct2D1.FactoryType.MultiThreaded, SharpDX.Direct2D1.DebugLevel.None); + } + using (var factory = new SharpDX.DirectWrite.Factory()) + { + DirectWriteFactory = factory.QueryInterface(); + } + + ImagingFactory = new SharpDX.WIC.ImagingFactory(); var featureLevels = new[] { @@ -83,17 +90,18 @@ namespace Avalonia.Direct2D1 using (var d3dDevice = new SharpDX.Direct3D11.Device( SharpDX.Direct3D.DriverType.Hardware, - SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport | + SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport | SharpDX.Direct3D11.DeviceCreationFlags.VideoSupport, featureLevels)) { - s_dxgiDevice = d3dDevice.QueryInterface(); + DxgiDevice = d3dDevice.QueryInterface(); } - using (var factory1 = s_d2D1Factory.QueryInterface()) + using (var device = new SharpDX.Direct2D1.Device(Direct2D1Factory, DxgiDevice)) { - s_d2D1Device = new SharpDX.Direct2D1.Device(factory1, s_dxgiDevice); + Direct2D1Device = device.QueryInterface(); } + s_initialized = true; } } @@ -101,19 +109,13 @@ namespace Avalonia.Direct2D1 public static void Initialize() { InitializeDirect2D(); - AvaloniaLocator.CurrentMutable - .Bind().ToConstant(s_instance) - .BindToSelf(s_d2D1Factory) - .BindToSelf(s_dwfactory) - .BindToSelf(s_imagingFactory) - .BindToSelf(s_dxgiDevice) - .BindToSelf(s_d2D1Device); + AvaloniaLocator.CurrentMutable.Bind().ToConstant(s_instance); SharpDX.Configuration.EnableReleaseOnFinalizer = true; } public IBitmapImpl CreateBitmap(int width, int height) { - return new WicBitmapImpl(s_imagingFactory, width, height); + return new WicBitmapImpl(width, height); } public IFormattedTextImpl CreateFormattedText( @@ -140,14 +142,22 @@ namespace Avalonia.Direct2D1 if (s is IPlatformHandle nativeWindow) { if (nativeWindow.HandleDescriptor != "HWND") + { throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from " + nativeWindow.HandleDescriptor); + } + return new HwndRenderTarget(nativeWindow); } if (s is IExternalDirect2DRenderTargetSurface external) - return new ExternalRenderTarget(external, s_dwfactory, s_imagingFactory); + { + return new ExternalRenderTarget(external); + } + if (s is IFramebufferPlatformSurface fb) - return new FramebufferShimRenderTarget(fb, s_imagingFactory, s_d2D1Factory, s_dwfactory); + { + return new FramebufferShimRenderTarget(fb); + } } throw new NotSupportedException("Don't know how to create a Direct2D1 renderer from any of provided surfaces"); } @@ -158,19 +168,12 @@ namespace Avalonia.Direct2D1 double dpiX, double dpiY) { - return new WicRenderTargetBitmapImpl( - s_imagingFactory, - s_d2D1Factory, - s_dwfactory, - width, - height, - dpiX, - dpiY); + return new WicRenderTargetBitmapImpl(width, height, dpiX, dpiY); } public IWriteableBitmapImpl CreateWriteableBitmap(int width, int height, PixelFormat? format = null) { - return new WriteableWicBitmapImpl(s_imagingFactory, width, height, format); + return new WriteableWicBitmapImpl(width, height, format); } public IStreamGeometryImpl CreateStreamGeometry() @@ -180,17 +183,17 @@ namespace Avalonia.Direct2D1 public IBitmapImpl LoadBitmap(string fileName) { - return new WicBitmapImpl(s_imagingFactory, fileName); + return new WicBitmapImpl(fileName); } public IBitmapImpl LoadBitmap(Stream stream) { - return new WicBitmapImpl(s_imagingFactory, stream); + return new WicBitmapImpl(stream); } public IBitmapImpl LoadBitmap(PixelFormat format, IntPtr data, int width, int height, int stride) { - return new WicBitmapImpl(s_imagingFactory, format, data, width, height, stride); + return new WicBitmapImpl(format, data, width, height, stride); } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs index 176cedd377..aad50331d2 100644 --- a/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/ExternalRenderTarget.cs @@ -1,27 +1,19 @@ -using System; -using Avalonia.Direct2D1.Media; +using Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; using SharpDX; -using DirectWriteFactory = SharpDX.DirectWrite.Factory; namespace Avalonia.Direct2D1 { class ExternalRenderTarget : IRenderTarget, ILayerFactory { private readonly IExternalDirect2DRenderTargetSurface _externalRenderTargetProvider; - private readonly DirectWriteFactory _dwFactory; - private readonly SharpDX.WIC.ImagingFactory _wicFactory; public ExternalRenderTarget( - IExternalDirect2DRenderTargetSurface externalRenderTargetProvider, - DirectWriteFactory dwFactory, - SharpDX.WIC.ImagingFactory wicFactory) + IExternalDirect2DRenderTargetSurface externalRenderTargetProvider) { _externalRenderTargetProvider = externalRenderTargetProvider; - _dwFactory = dwFactory; - _wicFactory = wicFactory; } public void Dispose() @@ -33,7 +25,7 @@ namespace Avalonia.Direct2D1 { var target = _externalRenderTargetProvider.GetOrCreateRenderTarget(); _externalRenderTargetProvider.BeforeDrawing(); - return new DrawingContextImpl(visualBrushRenderer, null, target, _dwFactory, _wicFactory, null, () => + return new DrawingContextImpl(visualBrushRenderer, null, target, null, () => { try { @@ -48,12 +40,8 @@ namespace Avalonia.Direct2D1 public IRenderTargetBitmapImpl CreateLayer(Size size) { - var target = _externalRenderTargetProvider.GetOrCreateRenderTarget(); - return D2DRenderTargetBitmapImpl.CreateCompatible( - _wicFactory, - _dwFactory, - target, - size); + var renderTarget = _externalRenderTargetProvider.GetOrCreateRenderTarget(); + return D2DRenderTargetBitmapImpl.CreateCompatible(renderTarget, size); } } } diff --git a/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs index 523cfeed46..5ae174083c 100644 --- a/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/FramebufferShimRenderTarget.cs @@ -1,14 +1,9 @@ using System; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Text; using Avalonia.Controls.Platform.Surfaces; using Avalonia.Direct2D1.Media; -using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; using Avalonia.Win32.Interop; -using SharpDX.Direct2D1; using SharpDX.WIC; using PixelFormat = Avalonia.Platform.PixelFormat; @@ -17,22 +12,14 @@ namespace Avalonia.Direct2D1 class FramebufferShimRenderTarget : IRenderTarget { private readonly IFramebufferPlatformSurface _surface; - private readonly ImagingFactory _imagingFactory; - private readonly Factory _d2DFactory; - private readonly SharpDX.DirectWrite.Factory _dwriteFactory; - public FramebufferShimRenderTarget(IFramebufferPlatformSurface surface, - ImagingFactory imagingFactory, Factory d2dFactory, SharpDX.DirectWrite.Factory dwriteFactory) + public FramebufferShimRenderTarget(IFramebufferPlatformSurface surface) { _surface = surface; - _imagingFactory = imagingFactory; - _d2DFactory = d2dFactory; - _dwriteFactory = dwriteFactory; } public void Dispose() - { - + { } public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer) @@ -44,7 +31,7 @@ namespace Avalonia.Direct2D1 throw new ArgumentException("Unsupported pixel format: " + locked.Format); } - return new FramebufferShim(locked, _imagingFactory, _d2DFactory, _dwriteFactory) + return new FramebufferShim(locked) .CreateDrawingContext(visualBrushRenderer); } @@ -52,10 +39,8 @@ namespace Avalonia.Direct2D1 { private readonly ILockedFramebuffer _target; - public FramebufferShim(ILockedFramebuffer target, - ImagingFactory imagingFactory, Factory d2dFactory, SharpDX.DirectWrite.Factory dwriteFactory - ) : base(imagingFactory, d2dFactory, dwriteFactory, - target.Width, target.Height, target.Dpi.X, target.Dpi.Y, target.Format) + public FramebufferShim(ILockedFramebuffer target) : + base(target.Width, target.Height, target.Dpi.X, target.Dpi.Y, target.Format) { _target = target; } @@ -76,10 +61,8 @@ namespace Avalonia.Direct2D1 } Dispose(); _target.Dispose(); - }); } } - } } diff --git a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs index 49402d54b9..589f85f208 100644 --- a/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/HwndRenderTarget.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Avalonia.Controls.Platform.Surfaces; -using Avalonia.Platform; +using Avalonia.Platform; using Avalonia.Win32.Interop; using SharpDX; using SharpDX.DXGI; @@ -22,7 +16,7 @@ namespace Avalonia.Direct2D1 protected override SwapChain1 CreateSwapChain(Factory2 dxgiFactory, SwapChainDescription1 swapChainDesc) { - return new SwapChain1(dxgiFactory, DxgiDevice, _window.Handle, ref swapChainDesc); + return new SwapChain1(dxgiFactory, Direct2D1Platform.DxgiDevice, _window.Handle, ref swapChainDesc); } protected override Size2F GetWindowDpi() diff --git a/src/Windows/Avalonia.Direct2D1/Media/Direct2D1FontCollectionCache.cs b/src/Windows/Avalonia.Direct2D1/Media/Direct2D1FontCollectionCache.cs index 4199c73c54..d60aa15a5e 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Direct2D1FontCollectionCache.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Direct2D1FontCollectionCache.cs @@ -7,16 +7,13 @@ namespace Avalonia.Direct2D1.Media internal static class Direct2D1FontCollectionCache { private static readonly ConcurrentDictionary s_cachedCollections; - private static readonly SharpDX.DirectWrite.Factory s_factory; private static readonly SharpDX.DirectWrite.FontCollection s_installedFontCollection; static Direct2D1FontCollectionCache() { s_cachedCollections = new ConcurrentDictionary(); - s_factory = AvaloniaLocator.Current.GetService(); - - s_installedFontCollection = s_factory.GetSystemFontCollection(false); + s_installedFontCollection = Direct2D1Platform.DirectWriteFactory.GetSystemFontCollection(false); } public static SharpDX.DirectWrite.TextFormat GetTextFormat(Typeface typeface) @@ -39,7 +36,7 @@ namespace Avalonia.Direct2D1.Media } return new SharpDX.DirectWrite.TextFormat( - s_factory, + Direct2D1Platform.DirectWriteFactory, fontFamilyName, fontCollection, (SharpDX.DirectWrite.FontWeight)typeface.Weight, @@ -57,9 +54,9 @@ namespace Avalonia.Direct2D1.Media { var assets = FontFamilyLoader.LoadFontAssets(key); - var fontLoader = new DWriteResourceFontLoader(s_factory, assets); + var fontLoader = new DWriteResourceFontLoader(Direct2D1Platform.DirectWriteFactory, assets); - return new SharpDX.DirectWrite.FontCollection(s_factory, fontLoader, fontLoader.Key); + return new SharpDX.DirectWrite.FontCollection(Direct2D1Platform.DirectWriteFactory, fontLoader, fontLoader.Key); } } -} \ No newline at end of file +} diff --git a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs index ae5dd3ae13..3aec6c6eb1 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs @@ -24,8 +24,6 @@ namespace Avalonia.Direct2D1.Media private readonly SharpDX.Direct2D1.RenderTarget _renderTarget; private readonly SharpDX.DXGI.SwapChain1 _swapChain; private readonly Action _finishedCallback; - private readonly SharpDX.WIC.ImagingFactory _imagingFactory; - private SharpDX.DirectWrite.Factory _directWriteFactory; /// /// Initializes a new instance of the class. @@ -36,16 +34,12 @@ namespace Avalonia.Direct2D1.Media /// An object to use to create layers. May be null, in which case a /// will created when a new layer is requested. /// - /// The DirectWrite factory. - /// The WIC imaging factory. /// An optional swap chain associated with this drawing context. /// An optional delegate to be called when context is disposed. public DrawingContextImpl( IVisualBrushRenderer visualBrushRenderer, ILayerFactory layerFactory, SharpDX.Direct2D1.RenderTarget renderTarget, - SharpDX.DirectWrite.Factory directWriteFactory, - SharpDX.WIC.ImagingFactory imagingFactory, SharpDX.DXGI.SwapChain1 swapChain = null, Action finishedCallback = null) { @@ -54,8 +48,6 @@ namespace Avalonia.Direct2D1.Media _renderTarget = renderTarget; _swapChain = swapChain; _finishedCallback = finishedCallback; - _directWriteFactory = directWriteFactory; - _imagingFactory = imagingFactory; _renderTarget.BeginDraw(); } @@ -443,7 +435,7 @@ namespace Avalonia.Direct2D1.Media return new ImageBrushImpl( visualBrush, _renderTarget, - new D2DBitmapImpl(_imagingFactory, intermediate.Bitmap), + new D2DBitmapImpl(intermediate.Bitmap), destinationSize); } } diff --git a/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs index c3fe60e790..09b249e19f 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs @@ -21,15 +21,13 @@ namespace Avalonia.Direct2D1.Media { Text = text; - var factory = AvaloniaLocator.Current.GetService(); - var textFormat = Direct2D1FontCollectionCache.GetTextFormat(typeface); textFormat.WordWrapping = wrapping == TextWrapping.Wrap ? DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap; TextLayout = new DWrite.TextLayout( - factory, + Direct2D1Platform.DirectWriteFactory, Text ?? string.Empty, textFormat, (float)constraint.Width, diff --git a/src/Windows/Avalonia.Direct2D1/Media/GeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/GeometryImpl.cs index 120ab71ead..7c8ddaca3f 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/GeometryImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/GeometryImpl.cs @@ -53,10 +53,9 @@ namespace Avalonia.Direct2D1.Media public ITransformedGeometryImpl WithTransform(Matrix transform) { - var factory = AvaloniaLocator.Current.GetService(); return new TransformedGeometryImpl( new TransformedGeometry( - factory, + Direct2D1Platform.Direct2D1Factory, GetSourceGeometry(), transform.ToDirect2D()), this); diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/BitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/BitmapImpl.cs index d58f023391..30af01283a 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/BitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/BitmapImpl.cs @@ -1,19 +1,12 @@ using System; using System.IO; using Avalonia.Platform; -using SharpDX.WIC; using D2DBitmap = SharpDX.Direct2D1.Bitmap; namespace Avalonia.Direct2D1.Media { public abstract class BitmapImpl : IBitmapImpl, IDisposable { - public BitmapImpl(ImagingFactory imagingFactory) - { - WicImagingFactory = imagingFactory; - } - - public ImagingFactory WicImagingFactory { get; } public abstract int PixelWidth { get; } public abstract int PixelHeight { get; } diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs index 6713cb13be..139100490c 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs @@ -1,7 +1,6 @@ using System; using System.IO; using SharpDX.Direct2D1; -using WICFactory = SharpDX.WIC.ImagingFactory; using ImagingFactory2 = SharpDX.WIC.ImagingFactory2; using ImageParameters = SharpDX.WIC.ImageParameters; using PngBitmapEncoder = SharpDX.WIC.PngBitmapEncoder; @@ -13,52 +12,51 @@ namespace Avalonia.Direct2D1.Media /// public class D2DBitmapImpl : BitmapImpl { - private Bitmap _direct2D; + private Bitmap _direct2DBitmap; /// /// Initialize a new instance of the class /// with a bitmap backed by GPU memory. /// - /// The image factory to use when saving out this bitmap. /// The GPU bitmap. /// /// This bitmap must be either from the same render target, /// or if the render target is a , /// the device associated with this context, to be renderable. /// - public D2DBitmapImpl(WICFactory imagingFactory, Bitmap d2DBitmap) - : base(imagingFactory) + public D2DBitmapImpl(Bitmap d2DBitmap) { - _direct2D = d2DBitmap ?? throw new ArgumentNullException(nameof(d2DBitmap)); + _direct2DBitmap = d2DBitmap ?? throw new ArgumentNullException(nameof(d2DBitmap)); } - public override int PixelWidth => _direct2D.PixelSize.Width; - public override int PixelHeight => _direct2D.PixelSize.Height; + public override int PixelWidth => _direct2DBitmap.PixelSize.Width; + public override int PixelHeight => _direct2DBitmap.PixelSize.Height; public override void Dispose() { base.Dispose(); - _direct2D.Dispose(); + _direct2DBitmap.Dispose(); } public override OptionalDispose GetDirect2DBitmap(SharpDX.Direct2D1.RenderTarget target) { - return new OptionalDispose(_direct2D, false); + return new OptionalDispose(_direct2DBitmap, false); } public override void Save(Stream stream) { - using (var encoder = new PngBitmapEncoder(WicImagingFactory, stream)) + using (var encoder = new PngBitmapEncoder(Direct2D1Platform.ImagingFactory, stream)) using (var frameEncode = new SharpDX.WIC.BitmapFrameEncode(encoder)) - using (var imageEncoder = new SharpDX.WIC.ImageEncoder((ImagingFactory2)WicImagingFactory, null)) + //ToDo: Not supported under Windows 7! + using (var imageEncoder = new SharpDX.WIC.ImageEncoder((ImagingFactory2)Direct2D1Platform.ImagingFactory, null)) { var parameters = new ImageParameters( new PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied), - _direct2D.DotsPerInch.Width, - _direct2D.DotsPerInch.Height, + _direct2DBitmap.DotsPerInch.Width, + _direct2DBitmap.DotsPerInch.Height, 0, 0, PixelWidth, PixelHeight); - imageEncoder.WriteFrame(_direct2D, frameEncode, parameters); + imageEncoder.WriteFrame(_direct2DBitmap, frameEncode, parameters); frameEncode.Commit(); encoder.Commit(); } diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs index 2843848fac..7ea303345a 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs @@ -1,35 +1,25 @@ -using System; -using Avalonia.Platform; +using Avalonia.Platform; using Avalonia.Rendering; using SharpDX; using SharpDX.Direct2D1; -using SharpDX.WIC; using D2DBitmap = SharpDX.Direct2D1.Bitmap; -using DirectWriteFactory = SharpDX.DirectWrite.Factory; namespace Avalonia.Direct2D1.Media.Imaging { public class D2DRenderTargetBitmapImpl : D2DBitmapImpl, IRenderTargetBitmapImpl, ILayerFactory { - private readonly DirectWriteFactory _dwriteFactory; - private readonly BitmapRenderTarget _target; + private readonly BitmapRenderTarget _renderTarget; - public D2DRenderTargetBitmapImpl( - ImagingFactory imagingFactory, - DirectWriteFactory dwriteFactory, - BitmapRenderTarget target) - : base(imagingFactory, target.Bitmap) + public D2DRenderTargetBitmapImpl(BitmapRenderTarget renderTarget) + : base(renderTarget.Bitmap) { - _dwriteFactory = dwriteFactory; - _target = target; + _renderTarget = renderTarget; } - public override int PixelWidth => _target.PixelSize.Width; - public override int PixelHeight => _target.PixelSize.Height; + public override int PixelWidth => _renderTarget.PixelSize.Width; + public override int PixelHeight => _renderTarget.PixelSize.Height; public static D2DRenderTargetBitmapImpl CreateCompatible( - ImagingFactory imagingFactory, - DirectWriteFactory dwriteFactory, SharpDX.Direct2D1.RenderTarget renderTarget, Size size) { @@ -37,32 +27,27 @@ namespace Avalonia.Direct2D1.Media.Imaging renderTarget, CompatibleRenderTargetOptions.None, new Size2F((float)size.Width, (float)size.Height)); - return new D2DRenderTargetBitmapImpl(imagingFactory, dwriteFactory, bitmapRenderTarget); + return new D2DRenderTargetBitmapImpl(bitmapRenderTarget); } public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer) { - return new DrawingContextImpl( - visualBrushRenderer, - this, - _target, - _dwriteFactory, - WicImagingFactory); + return new DrawingContextImpl(visualBrushRenderer, this, _renderTarget); } public IRenderTargetBitmapImpl CreateLayer(Size size) { - return CreateCompatible(WicImagingFactory, _dwriteFactory, _target, size); + return CreateCompatible(_renderTarget, size); } public override void Dispose() { - _target.Dispose(); + _renderTarget.Dispose(); } public override OptionalDispose GetDirect2DBitmap(SharpDX.Direct2D1.RenderTarget target) { - return new OptionalDispose(_target.Bitmap, false); + return new OptionalDispose(_renderTarget.Bitmap, false); } } } diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs index 371dfcfc3e..2c41f1203f 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicBitmapImpl.cs @@ -19,57 +19,52 @@ namespace Avalonia.Direct2D1.Media /// /// Initializes a new instance of the class. /// - /// The WIC imaging factory to use. /// The filename of the bitmap to load. - public WicBitmapImpl(ImagingFactory factory, string fileName) - : base(factory) + public WicBitmapImpl(string fileName) { - using (BitmapDecoder decoder = new BitmapDecoder(factory, fileName, DecodeOptions.CacheOnDemand)) + using (BitmapDecoder decoder = new BitmapDecoder(Direct2D1Platform.ImagingFactory, fileName, DecodeOptions.CacheOnDemand)) { - WicImpl = new Bitmap(factory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnDemand); + WicImpl = new Bitmap(Direct2D1Platform.ImagingFactory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnDemand); } } /// /// Initializes a new instance of the class. /// - /// The WIC imaging factory to use. /// The stream to read the bitmap from. - public WicBitmapImpl(ImagingFactory factory, Stream stream) - : base(factory) + public WicBitmapImpl(Stream stream) { - using (BitmapDecoder decoder = new BitmapDecoder(factory, stream, DecodeOptions.CacheOnLoad)) + using (BitmapDecoder decoder = new BitmapDecoder(Direct2D1Platform.ImagingFactory, stream, DecodeOptions.CacheOnLoad)) { - WicImpl = new Bitmap(factory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnLoad); + WicImpl = new Bitmap(Direct2D1Platform.ImagingFactory, decoder.GetFrame(0), BitmapCreateCacheOption.CacheOnLoad); } } /// /// Initializes a new instance of the class. /// - /// The WIC imaging factory to use. /// The width of the bitmap. /// The height of the bitmap. /// Pixel format - public WicBitmapImpl(ImagingFactory factory, int width, int height, APixelFormat? pixelFormat = null) - : base(factory) + public WicBitmapImpl(int width, int height, APixelFormat? pixelFormat = null) { if (!pixelFormat.HasValue) + { pixelFormat = APixelFormat.Bgra8888; + } PixelFormat = pixelFormat; WicImpl = new Bitmap( - factory, + Direct2D1Platform.ImagingFactory, width, height, pixelFormat.Value.ToWic(), BitmapCreateCacheOption.CacheOnLoad); } - public WicBitmapImpl(ImagingFactory factory, APixelFormat format, IntPtr data, int width, int height, int stride) - : base(factory) + public WicBitmapImpl(APixelFormat format, IntPtr data, int width, int height, int stride) { - WicImpl = new Bitmap(factory, width, height, format.ToWic(), BitmapCreateCacheOption.CacheOnDemand); + WicImpl = new Bitmap(Direct2D1Platform.ImagingFactory, width, height, format.ToWic(), BitmapCreateCacheOption.CacheOnDemand); PixelFormat = format; using (var l = WicImpl.Lock(BitmapLockFlags.Write)) { @@ -112,14 +107,14 @@ namespace Avalonia.Direct2D1.Media /// The Direct2D bitmap. public override OptionalDispose GetDirect2DBitmap(SharpDX.Direct2D1.RenderTarget renderTarget) { - FormatConverter converter = new FormatConverter(WicImagingFactory); + FormatConverter converter = new FormatConverter(Direct2D1Platform.ImagingFactory); converter.Initialize(WicImpl, SharpDX.WIC.PixelFormat.Format32bppPBGRA); return new OptionalDispose(D2DBitmap.FromWicBitmap(renderTarget, converter), true); } public override void Save(Stream stream) { - using (var encoder = new PngBitmapEncoder(WicImagingFactory, stream)) + using (var encoder = new PngBitmapEncoder(Direct2D1Platform.ImagingFactory, stream)) using (var frame = new BitmapFrameEncode(encoder)) { frame.Initialize(); diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicRenderTargetBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicRenderTargetBitmapImpl.cs index 0eb2608047..aa8b3ead42 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicRenderTargetBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WicRenderTargetBitmapImpl.cs @@ -5,26 +5,20 @@ using System; using Avalonia.Platform; using Avalonia.Rendering; using SharpDX.Direct2D1; -using SharpDX.WIC; -using DirectWriteFactory = SharpDX.DirectWrite.Factory; namespace Avalonia.Direct2D1.Media { public class WicRenderTargetBitmapImpl : WicBitmapImpl, IRenderTargetBitmapImpl { - private readonly DirectWriteFactory _dwriteFactory; - private readonly WicRenderTarget _target; + private readonly WicRenderTarget _renderTarget; public WicRenderTargetBitmapImpl( - ImagingFactory imagingFactory, - Factory d2dFactory, - DirectWriteFactory dwriteFactory, int width, int height, double dpiX, double dpiY, Platform.PixelFormat? pixelFormat = null) - : base(imagingFactory, width, height, pixelFormat) + : base(width, height, pixelFormat) { var props = new RenderTargetProperties { @@ -32,17 +26,16 @@ namespace Avalonia.Direct2D1.Media DpiY = (float)dpiY, }; - _target = new WicRenderTarget( - d2dFactory, + _renderTarget = new WicRenderTarget( + Direct2D1Platform.Direct2D1Factory, WicImpl, props); - - _dwriteFactory = dwriteFactory; } public override void Dispose() { - _target.Dispose(); + _renderTarget.Dispose(); + base.Dispose(); } @@ -51,8 +44,7 @@ namespace Avalonia.Direct2D1.Media public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer, Action finishedCallback) { - return new DrawingContextImpl(visualBrushRenderer, null, _target, _dwriteFactory, WicImagingFactory, - finishedCallback: finishedCallback); + return new DrawingContextImpl(visualBrushRenderer, null, _renderTarget, finishedCallback: finishedCallback); } } } diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs index fc931c32db..075fef5ab2 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Avalonia.Platform; using SharpDX.WIC; using PixelFormat = Avalonia.Platform.PixelFormat; @@ -11,8 +7,8 @@ namespace Avalonia.Direct2D1.Media.Imaging { class WriteableWicBitmapImpl : WicBitmapImpl, IWriteableBitmapImpl { - public WriteableWicBitmapImpl(ImagingFactory factory, int width, int height, PixelFormat? pixelFormat) - : base(factory, width, height, pixelFormat) + public WriteableWicBitmapImpl(int width, int height, PixelFormat? pixelFormat) + : base(width, height, pixelFormat) { } diff --git a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryImpl.cs index 4c1bc3d6f7..a07d5c1c72 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/StreamGeometryImpl.cs @@ -31,8 +31,7 @@ namespace Avalonia.Direct2D1.Media /// public IStreamGeometryImpl Clone() { - Factory factory = AvaloniaLocator.Current.GetService(); - var result = new PathGeometry(factory); + var result = new PathGeometry(Direct2D1Platform.Direct2D1Factory); var sink = result.Open(); ((PathGeometry)Geometry).Stream(sink); sink.Close(); @@ -47,8 +46,7 @@ namespace Avalonia.Direct2D1.Media private static Geometry CreateGeometry() { - Factory factory = AvaloniaLocator.Current.GetService(); - return new PathGeometry(factory); + return new PathGeometry(Direct2D1Platform.Direct2D1Factory); } } } diff --git a/src/Windows/Avalonia.Direct2D1/RenderTarget.cs b/src/Windows/Avalonia.Direct2D1/RenderTarget.cs index 6086b0c67c..a21b5571c6 100644 --- a/src/Windows/Avalonia.Direct2D1/RenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/RenderTarget.cs @@ -1,14 +1,10 @@ // 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 Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; -using SharpDX.Direct2D1; -using DwFactory = SharpDX.DirectWrite.Factory; -using WicFactory = SharpDX.WIC.ImagingFactory; namespace Avalonia.Direct2D1 { @@ -25,32 +21,21 @@ namespace Avalonia.Direct2D1 /// The render target. public RenderTarget(SharpDX.Direct2D1.RenderTarget renderTarget) { - Direct2DFactory = AvaloniaLocator.Current.GetService(); - DirectWriteFactory = AvaloniaLocator.Current.GetService(); - WicFactory = AvaloniaLocator.Current.GetService(); _renderTarget = renderTarget; } - public Factory Direct2DFactory { get; } - public DwFactory DirectWriteFactory { get; } - public WicFactory WicFactory { get; } - /// /// Creates a drawing context for a rendering session. /// /// An . public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer) { - return new DrawingContextImpl(visualBrushRenderer, this, _renderTarget, DirectWriteFactory, WicFactory); + return new DrawingContextImpl(visualBrushRenderer, this, _renderTarget); } public IRenderTargetBitmapImpl CreateLayer(Size size) { - return D2DRenderTargetBitmapImpl.CreateCompatible( - WicFactory, - DirectWriteFactory, - _renderTarget, - size); + return D2DRenderTargetBitmapImpl.CreateCompatible(_renderTarget, size); } public void Dispose() diff --git a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs index 0a23c63498..f820129b8d 100644 --- a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs @@ -1,16 +1,14 @@ -using System; +using Avalonia.Direct2D1.Media; +using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; +using Avalonia.Rendering; + using SharpDX; using SharpDX.Direct2D1; using SharpDX.DXGI; -using PixelFormat = SharpDX.Direct2D1.PixelFormat; + using AlphaMode = SharpDX.Direct2D1.AlphaMode; -using Device = SharpDX.Direct2D1.Device; -using Factory = SharpDX.Direct2D1.Factory; -using Factory2 = SharpDX.DXGI.Factory2; -using Avalonia.Rendering; -using Avalonia.Direct2D1.Media; -using Avalonia.Direct2D1.Media.Imaging; +using PixelFormat = SharpDX.Direct2D1.PixelFormat; namespace Avalonia.Direct2D1 { @@ -21,23 +19,6 @@ namespace Avalonia.Direct2D1 private DeviceContext _deviceContext; private SwapChain1 _swapChain; - protected SwapChainRenderTarget() - { - DxgiDevice = AvaloniaLocator.Current.GetService(); - D2DDevice = AvaloniaLocator.Current.GetService(); - Direct2DFactory = AvaloniaLocator.Current.GetService(); - DirectWriteFactory = AvaloniaLocator.Current.GetService(); - WicImagingFactory = AvaloniaLocator.Current.GetService(); - } - - public Factory Direct2DFactory { get; } - public SharpDX.DirectWrite.Factory DirectWriteFactory { get; } - public SharpDX.WIC.ImagingFactory WicImagingFactory { get; } - - protected SharpDX.DXGI.Device DxgiDevice { get; } - - public Device D2DDevice { get; } - /// /// Creates a drawing context for a rendering session. /// @@ -54,13 +35,7 @@ namespace Avalonia.Direct2D1 CreateSwapChain(); } - return new DrawingContextImpl( - visualBrushRenderer, - this, - _deviceContext, - DirectWriteFactory, - WicImagingFactory, - _swapChain); + return new DrawingContextImpl(visualBrushRenderer, this, _deviceContext, _swapChain); } public IRenderTargetBitmapImpl CreateLayer(Size size) @@ -70,11 +45,7 @@ namespace Avalonia.Direct2D1 CreateSwapChain(); } - return D2DRenderTargetBitmapImpl.CreateCompatible( - WicImagingFactory, - DirectWriteFactory, - _deviceContext, - size); + return D2DRenderTargetBitmapImpl.CreateCompatible(_deviceContext, size); } public void Dispose() @@ -85,11 +56,11 @@ namespace Avalonia.Direct2D1 private void CreateSwapChain() { - using (var dxgiAdaptor = DxgiDevice.Adapter) - using (var dxgiFactory = dxgiAdaptor.GetParent()) + using (var dxgiAdaptor = Direct2D1Platform.DxgiDevice.Adapter) + using (var dxgiFactory = dxgiAdaptor.GetParent()) { _deviceContext?.Dispose(); - _deviceContext = new DeviceContext(D2DDevice, DeviceContextOptions.None) {DotsPerInch = _savedDpi}; + _deviceContext = new DeviceContext(Direct2D1Platform.Direct2D1Device, DeviceContextOptions.None) { DotsPerInch = _savedDpi }; var swapChainDesc = new SwapChainDescription1 { @@ -119,7 +90,7 @@ namespace Avalonia.Direct2D1 new BitmapProperties1( new PixelFormat { - AlphaMode = AlphaMode.Ignore, + AlphaMode = AlphaMode.Premultiplied, Format = Format.B8G8R8A8_UNorm }, _savedDpi.Width, @@ -131,7 +102,7 @@ namespace Avalonia.Direct2D1 } } - protected abstract SwapChain1 CreateSwapChain(Factory2 dxgiFactory, SwapChainDescription1 swapChainDesc); + protected abstract SwapChain1 CreateSwapChain(SharpDX.DXGI.Factory2 dxgiFactory, SwapChainDescription1 swapChainDesc); protected abstract Size2F GetWindowDpi(); From e76b694ebdcc4b2ca79532cb30183ea8aa98fc79 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Wed, 5 Sep 2018 17:02:22 +0200 Subject: [PATCH 37/80] InterpolationMode.HighQuality support --- .../Media/DrawingContextImpl.cs | 103 ++++++++++-------- 1 file changed, 60 insertions(+), 43 deletions(-) diff --git a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs index 3aec6c6eb1..b842f26edb 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs @@ -22,6 +22,7 @@ namespace Avalonia.Direct2D1.Media private readonly IVisualBrushRenderer _visualBrushRenderer; private readonly ILayerFactory _layerFactory; private readonly SharpDX.Direct2D1.RenderTarget _renderTarget; + private readonly DeviceContext _deviceContext; private readonly SharpDX.DXGI.SwapChain1 _swapChain; private readonly Action _finishedCallback; @@ -48,7 +49,17 @@ namespace Avalonia.Direct2D1.Media _renderTarget = renderTarget; _swapChain = swapChain; _finishedCallback = finishedCallback; - _renderTarget.BeginDraw(); + + if (_renderTarget is DeviceContext deviceContext) + { + _deviceContext = deviceContext; + } + else + { + _deviceContext = _renderTarget.QueryInterface(); + } + + _deviceContext.BeginDraw(); } /// @@ -56,14 +67,14 @@ namespace Avalonia.Direct2D1.Media /// public Matrix Transform { - get { return _renderTarget.Transform.ToAvalonia(); } - set { _renderTarget.Transform = value.ToDirect2D(); } + get { return _deviceContext.Transform.ToAvalonia(); } + set { _deviceContext.Transform = value.ToDirect2D(); } } /// public void Clear(Color color) { - _renderTarget.Clear(color.ToDirect2D()); + _deviceContext.Clear(color.ToDirect2D()); } /// @@ -72,10 +83,13 @@ namespace Avalonia.Direct2D1.Media public void Dispose() { foreach (var layer in _layerPool) + { layer.Dispose(); + } + try { - _renderTarget.EndDraw(); + _deviceContext.EndDraw(); _swapChain?.Present(1, SharpDX.DXGI.PresentFlags.None); _finishedCallback?.Invoke(); @@ -96,29 +110,32 @@ namespace Avalonia.Direct2D1.Media /// The bitmap interpolation mode. public void DrawImage(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode) { - using (var d2d = ((BitmapImpl)source.Item).GetDirect2DBitmap(_renderTarget)) + using (var d2d = ((BitmapImpl)source.Item).GetDirect2DBitmap(_deviceContext)) { var interpolationMode = GetInterpolationMode(bitmapInterpolationMode); - _renderTarget.DrawBitmap( + _deviceContext.DrawBitmap( d2d.Value, destRect.ToSharpDX(), (float)opacity, interpolationMode, - sourceRect.ToSharpDX()); + sourceRect.ToSharpDX(), + null); } } - private static SharpDX.Direct2D1.BitmapInterpolationMode GetInterpolationMode(BitmapInterpolationMode interpolationMode) + private static InterpolationMode GetInterpolationMode(BitmapInterpolationMode interpolationMode) { switch (interpolationMode) { case BitmapInterpolationMode.LowQuality: - return SharpDX.Direct2D1.BitmapInterpolationMode.NearestNeighbor; + return InterpolationMode.NearestNeighbor; case BitmapInterpolationMode.MediumQuality: + return InterpolationMode.Linear; case BitmapInterpolationMode.HighQuality: + return InterpolationMode.HighQualityCubic; case BitmapInterpolationMode.Default: - return SharpDX.Direct2D1.BitmapInterpolationMode.Linear; + return InterpolationMode.Linear; default: throw new ArgumentOutOfRangeException(nameof(interpolationMode), interpolationMode, null); } @@ -133,17 +150,17 @@ namespace Avalonia.Direct2D1.Media /// The rect in the output to draw to. public void DrawImage(IRef source, IBrush opacityMask, Rect opacityMaskRect, Rect destRect) { - using (var d2dSource = ((BitmapImpl)source.Item).GetDirect2DBitmap(_renderTarget)) - using (var sourceBrush = new BitmapBrush(_renderTarget, d2dSource.Value)) + using (var d2dSource = ((BitmapImpl)source.Item).GetDirect2DBitmap(_deviceContext)) + using (var sourceBrush = new BitmapBrush(_deviceContext, d2dSource.Value)) using (var d2dOpacityMask = CreateBrush(opacityMask, opacityMaskRect.Size)) - using (var geometry = new SharpDX.Direct2D1.RectangleGeometry(_renderTarget.Factory, destRect.ToDirect2D())) + using (var geometry = new SharpDX.Direct2D1.RectangleGeometry(_deviceContext.Factory, destRect.ToDirect2D())) { if (d2dOpacityMask.PlatformBrush != null) { d2dOpacityMask.PlatformBrush.Transform = Matrix.CreateTranslation(opacityMaskRect.Position).ToDirect2D(); } - _renderTarget.FillGeometry( + _deviceContext.FillGeometry( geometry, sourceBrush, d2dOpacityMask.PlatformBrush); @@ -163,11 +180,11 @@ namespace Avalonia.Direct2D1.Media var size = new Rect(p1, p2).Size; using (var d2dBrush = CreateBrush(pen.Brush, size)) - using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) + using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) { if (d2dBrush.PlatformBrush != null) { - _renderTarget.DrawLine( + _deviceContext.DrawLine( p1.ToSharpDX(), p2.ToSharpDX(), d2dBrush.PlatformBrush, @@ -193,7 +210,7 @@ namespace Avalonia.Direct2D1.Media if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry; - _renderTarget.FillGeometry(impl.Geometry, d2dBrush.PlatformBrush); + _deviceContext.FillGeometry(impl.Geometry, d2dBrush.PlatformBrush); } } } @@ -201,12 +218,12 @@ namespace Avalonia.Direct2D1.Media if (pen != null) { using (var d2dBrush = CreateBrush(pen.Brush, geometry.GetRenderBounds(pen).Size)) - using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) + using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry; - _renderTarget.DrawGeometry(impl.Geometry, d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); + _deviceContext.DrawGeometry(impl.Geometry, d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } @@ -221,13 +238,13 @@ namespace Avalonia.Direct2D1.Media public void DrawRectangle(Pen pen, Rect rect, float cornerRadius) { using (var brush = CreateBrush(pen.Brush, rect.Size)) - using (var d2dStroke = pen.ToDirect2DStrokeStyle(_renderTarget)) + using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) { if (brush.PlatformBrush != null) { if (cornerRadius == 0) { - _renderTarget.DrawRectangle( + _deviceContext.DrawRectangle( rect.ToDirect2D(), brush.PlatformBrush, (float)pen.Thickness, @@ -235,7 +252,7 @@ namespace Avalonia.Direct2D1.Media } else { - _renderTarget.DrawRoundedRectangle( + _deviceContext.DrawRoundedRectangle( new RoundedRectangle { Rect = rect.ToDirect2D(), RadiusX = cornerRadius, RadiusY = cornerRadius }, brush.PlatformBrush, (float)pen.Thickness, @@ -258,7 +275,7 @@ namespace Avalonia.Direct2D1.Media var impl = (FormattedTextImpl)text; using (var brush = CreateBrush(foreground, impl.Size)) - using (var renderer = new AvaloniaTextRenderer(this, _renderTarget, brush.PlatformBrush)) + using (var renderer = new AvaloniaTextRenderer(this, _deviceContext, brush.PlatformBrush)) { if (brush.PlatformBrush != null) { @@ -282,11 +299,11 @@ namespace Avalonia.Direct2D1.Media { if (cornerRadius == 0) { - _renderTarget.FillRectangle(rect.ToDirect2D(), b.PlatformBrush); + _deviceContext.FillRectangle(rect.ToDirect2D(), b.PlatformBrush); } else { - _renderTarget.FillRoundedRectangle( + _deviceContext.FillRoundedRectangle( new RoundedRectangle { Rect = new RawRectangleF( @@ -312,7 +329,7 @@ namespace Avalonia.Direct2D1.Media else { var platform = AvaloniaLocator.Current.GetService(); - var dpi = new Vector(_renderTarget.DotsPerInch.Width, _renderTarget.DotsPerInch.Height); + var dpi = new Vector(_deviceContext.DotsPerInch.Width, _deviceContext.DotsPerInch.Height); var pixelSize = size * (dpi / 96); return platform.CreateRenderTargetBitmap( (int)pixelSize.Width, @@ -329,12 +346,12 @@ namespace Avalonia.Direct2D1.Media /// A disposable used to undo the clip rectangle. public void PushClip(Rect clip) { - _renderTarget.PushAxisAlignedClip(clip.ToSharpDX(), AntialiasMode.PerPrimitive); + _deviceContext.PushAxisAlignedClip(clip.ToSharpDX(), AntialiasMode.PerPrimitive); } public void PopClip() { - _renderTarget.PopAxisAlignedClip(); + _deviceContext.PopAxisAlignedClip(); } readonly Stack _layers = new Stack(); @@ -355,8 +372,8 @@ namespace Avalonia.Direct2D1.Media Opacity = (float)opacity, }; - var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_renderTarget); - _renderTarget.PushLayer(ref parameters, layer); + var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_deviceContext); + _deviceContext.PushLayer(ref parameters, layer); _layers.Push(layer); } @@ -374,7 +391,7 @@ namespace Avalonia.Direct2D1.Media var layer = _layers.Pop(); if (layer != null) { - _renderTarget.PopLayer(); + _deviceContext.PopLayer(); _layerPool.Push(layer); } } @@ -395,21 +412,21 @@ namespace Avalonia.Direct2D1.Media if (solidColorBrush != null) { - return new SolidColorBrushImpl(solidColorBrush, _renderTarget); + return new SolidColorBrushImpl(solidColorBrush, _deviceContext); } else if (linearGradientBrush != null) { - return new LinearGradientBrushImpl(linearGradientBrush, _renderTarget, destinationSize); + return new LinearGradientBrushImpl(linearGradientBrush, _deviceContext, destinationSize); } else if (radialGradientBrush != null) { - return new RadialGradientBrushImpl(radialGradientBrush, _renderTarget, destinationSize); + return new RadialGradientBrushImpl(radialGradientBrush, _deviceContext, destinationSize); } else if (imageBrush?.Source != null) { return new ImageBrushImpl( imageBrush, - _renderTarget, + _deviceContext, (BitmapImpl)imageBrush.Source.PlatformImpl.Item, destinationSize); } @@ -422,7 +439,7 @@ namespace Avalonia.Direct2D1.Media if (intermediateSize.Width >= 1 && intermediateSize.Height >= 1) { using (var intermediate = new BitmapRenderTarget( - _renderTarget, + _deviceContext, CompatibleRenderTargetOptions.None, intermediateSize.ToSharpDX())) { @@ -434,7 +451,7 @@ namespace Avalonia.Direct2D1.Media return new ImageBrushImpl( visualBrush, - _renderTarget, + _deviceContext, new D2DBitmapImpl(intermediate.Bitmap), destinationSize); } @@ -446,7 +463,7 @@ namespace Avalonia.Direct2D1.Media } } - return new SolidColorBrushImpl(null, _renderTarget); + return new SolidColorBrushImpl(null, _deviceContext); } public void PushGeometryClip(IGeometryImpl clip) @@ -458,8 +475,8 @@ namespace Avalonia.Direct2D1.Media Opacity = 1, GeometricMask = ((GeometryImpl)clip).Geometry }; - var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_renderTarget); - _renderTarget.PushLayer(ref parameters, layer); + var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_deviceContext); + _deviceContext.PushLayer(ref parameters, layer); _layers.Push(layer); @@ -479,8 +496,8 @@ namespace Avalonia.Direct2D1.Media Opacity = 1, OpacityBrush = CreateBrush(mask, bounds.Size).PlatformBrush }; - var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_renderTarget); - _renderTarget.PushLayer(ref parameters, layer); + var layer = _layerPool.Count != 0 ? _layerPool.Pop() : new Layer(_deviceContext); + _deviceContext.PushLayer(ref parameters, layer); _layers.Push(layer); } From 0646106f8fe9d6ead0e433024ed909405cd93c6a Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Wed, 5 Sep 2018 19:53:57 +0200 Subject: [PATCH 38/80] Introduce ResizeBuffers to prevent SwapChain recreation --- .../SwapChainRenderTarget.cs | 105 ++++++++++-------- 1 file changed, 61 insertions(+), 44 deletions(-) diff --git a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs index f820129b8d..94d407ed0b 100644 --- a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs @@ -7,11 +7,13 @@ using SharpDX; using SharpDX.Direct2D1; using SharpDX.DXGI; -using AlphaMode = SharpDX.Direct2D1.AlphaMode; -using PixelFormat = SharpDX.Direct2D1.PixelFormat; - namespace Avalonia.Direct2D1 { + + using AlphaMode = SharpDX.Direct2D1.AlphaMode; + using DeviceContext = SharpDX.Direct2D1.DeviceContext; + using PixelFormat = SharpDX.Direct2D1.PixelFormat; + public abstract class SwapChainRenderTarget : IRenderTarget, ILayerFactory { private Size2 _savedSize; @@ -32,7 +34,8 @@ namespace Avalonia.Direct2D1 { _savedSize = size; _savedDpi = dpi; - CreateSwapChain(); + + Resize(); } return new DrawingContextImpl(visualBrushRenderer, this, _deviceContext, _swapChain); @@ -42,7 +45,7 @@ namespace Avalonia.Direct2D1 { if (_deviceContext == null) { - CreateSwapChain(); + CreateDeviceContext(); } return D2DRenderTargetBitmapImpl.CreateCompatible(_deviceContext, size); @@ -51,54 +54,68 @@ namespace Avalonia.Direct2D1 public void Dispose() { _deviceContext?.Dispose(); + _swapChain?.Dispose(); } + private void Resize() + { + _deviceContext?.Dispose(); + _deviceContext = null; + + _swapChain?.ResizeBuffers(0, 0, 0, Format.Unknown, SwapChainFlags.None); + + CreateDeviceContext(); + } + private void CreateSwapChain() { - using (var dxgiAdaptor = Direct2D1Platform.DxgiDevice.Adapter) - using (var dxgiFactory = dxgiAdaptor.GetParent()) + var swapChainDescription = new SwapChainDescription1 { - _deviceContext?.Dispose(); - _deviceContext = new DeviceContext(Direct2D1Platform.Direct2D1Device, DeviceContextOptions.None) { DotsPerInch = _savedDpi }; - - var swapChainDesc = new SwapChainDescription1 + Width = _savedSize.Width, + Height = _savedSize.Height, + Format = Format.B8G8R8A8_UNorm, + SampleDescription = new SampleDescription { - Width = _savedSize.Width, - Height = _savedSize.Height, - Format = Format.B8G8R8A8_UNorm, - Stereo = false, - SampleDescription = new SampleDescription + Count = 1, + Quality = 0, + }, + Usage = Usage.RenderTargetOutput, + BufferCount = 1, + SwapEffect = SwapEffect.Discard, + }; + + using (var dxgiAdapter = Direct2D1Platform.DxgiDevice.Adapter) + using (var dxgiFactory = dxgiAdapter.GetParent()) + { + _swapChain = CreateSwapChain(dxgiFactory, swapChainDescription); + } + } + + private void CreateDeviceContext() + { + _deviceContext = new DeviceContext(Direct2D1Platform.Direct2D1Device, DeviceContextOptions.None) { DotsPerInch = _savedDpi }; + + if (_swapChain == null) + { + CreateSwapChain(); + } + + using (var dxgiBackBuffer = _swapChain.GetBackBuffer(0)) + using (var d2dBackBuffer = new Bitmap1( + _deviceContext, + dxgiBackBuffer, + new BitmapProperties1( + new PixelFormat { - Count = 1, - Quality = 0, + AlphaMode = AlphaMode.Premultiplied, + Format = Format.B8G8R8A8_UNorm }, - Usage = Usage.RenderTargetOutput, - BufferCount = 1, - Scaling = Scaling.Stretch, - SwapEffect = SwapEffect.Discard, - Flags = 0, - }; - - _swapChain?.Dispose(); - _swapChain = CreateSwapChain(dxgiFactory, swapChainDesc); - - using (var dxgiBackBuffer = _swapChain.GetBackBuffer(0)) - using (var d2dBackBuffer = new Bitmap1( - _deviceContext, - dxgiBackBuffer, - new BitmapProperties1( - new PixelFormat - { - AlphaMode = AlphaMode.Premultiplied, - Format = Format.B8G8R8A8_UNorm - }, - _savedDpi.Width, - _savedDpi.Height, - BitmapOptions.Target | BitmapOptions.CannotDraw))) - { - _deviceContext.Target = d2dBackBuffer; - } + _savedSize.Width, + _savedSize.Height, + BitmapOptions.Target | BitmapOptions.CannotDraw))) + { + _deviceContext.Target = d2dBackBuffer; } } From 71d74fe7cdb20811e32dccf882c7cb5fcd0c4dba Mon Sep 17 00:00:00 2001 From: William David Cossey Date: Thu, 6 Sep 2018 01:11:29 +0100 Subject: [PATCH 39/80] TreeViewItem.cs - Renamed Depth to Level. TreeViewItem.cs - Moved CalculateDistanceFromLogicalParent from LogicalExtensions. TreeViewItem.xaml - Cleaned up selectors. PropertyEqualsSelector.cs - Default null to string.Empty. ContentControl.cs - Added valid & invalid pseudoclasses for ContentProperty. BaseLight.xaml - Removed unused resources. CheckBox.xaml - Hide ContentPresenter#PART_ContentPresenter when Content is null. --- src/Avalonia.Controls/ContentControl.cs | 2 + src/Avalonia.Controls/TreeViewItem.cs | 33 ++-- .../LogicalTree/LogicalExtensions.cs | 15 -- .../Styling/PropertyEqualsSelector.cs | 6 +- .../Accents/BaseLight.xaml | 102 ++++++----- src/Avalonia.Themes.Default/CheckBox.xaml | 5 +- src/Avalonia.Themes.Default/TreeViewItem.xaml | 158 +++++++++--------- 7 files changed, 160 insertions(+), 161 deletions(-) diff --git a/src/Avalonia.Controls/ContentControl.cs b/src/Avalonia.Controls/ContentControl.cs index 6da6da54a5..f9241956bd 100644 --- a/src/Avalonia.Controls/ContentControl.cs +++ b/src/Avalonia.Controls/ContentControl.cs @@ -45,6 +45,8 @@ namespace Avalonia.Controls static ContentControl() { ContentControlMixin.Attach(ContentProperty, x => x.LogicalChildren); + PseudoClass(ContentProperty, x => x != null, ":valid"); + PseudoClass(ContentProperty, x => x == null, ":invalid"); } /// diff --git a/src/Avalonia.Controls/TreeViewItem.cs b/src/Avalonia.Controls/TreeViewItem.cs index c5d3313117..4d229390cb 100644 --- a/src/Avalonia.Controls/TreeViewItem.cs +++ b/src/Avalonia.Controls/TreeViewItem.cs @@ -32,24 +32,24 @@ namespace Avalonia.Controls ListBoxItem.IsSelectedProperty.AddOwner(); /// - /// Defines the property. + /// Defines the property. /// - public static readonly DirectProperty DepthProperty = + public static readonly DirectProperty LevelProperty = AvaloniaProperty.RegisterDirect( - nameof(Depth), o => o.Depth); + nameof(Level), o => o.Level); private static readonly ITemplate DefaultPanel = new FuncTemplate(() => new StackPanel()); private TreeView _treeView; private bool _isExpanded; - private int _depth; + private int _level; /// /// Initializes static members of the class. /// static TreeViewItem() - { + { SelectableMixin.Attach(IsSelectedProperty); FocusableProperty.OverrideDefaultValue(true); ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); @@ -74,12 +74,12 @@ namespace Avalonia.Controls } /// - /// Gets or sets the depth of the item. + /// Gets the level/indentation of the item. /// - public int Depth + public int Level { - get { return _depth; } - private set { SetAndRaise(DepthProperty, ref _depth, value); } + get { return _level; } + private set { SetAndRaise(LevelProperty, ref _level, value); } } /// @@ -106,7 +106,7 @@ namespace Avalonia.Controls base.OnAttachedToLogicalTree(e); _treeView = this.GetLogicalAncestors().OfType().FirstOrDefault(); - Depth = this.CalculateDistanceFromLogicalParent() - 1; + Level = CalculateDistanceFromLogicalParent(this) - 1; if (ItemTemplate == null && _treeView?.ItemTemplate != null) { @@ -145,5 +145,18 @@ namespace Avalonia.Controls // Don't call base.OnKeyDown - let events bubble up to containing TreeView. } + + private static int CalculateDistanceFromLogicalParent(ILogical logical, int @default = -1) where T : class + { + var result = 0; + + while (logical != null && logical.GetType() != typeof(T)) + { + ++result; + logical = logical.LogicalParent; + } + + return logical != null ? result : @default; + } } } diff --git a/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs b/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs index 47550a876d..276ea6c060 100644 --- a/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs +++ b/src/Avalonia.Styling/LogicalTree/LogicalExtensions.cs @@ -87,20 +87,5 @@ namespace Avalonia.LogicalTree { return target.GetLogicalAncestors().Any(x => x == logical); } - - public static int CalculateDistanceFromLogicalParent(this ILogical logical, int @default = -1) where T : class - { - Contract.Requires(logical != null); - - var result = 0; - - while (logical != null && logical.GetType() != typeof(T)) - { - ++result; - logical = logical.LogicalParent; - } - - return logical != null ? result : @default; - } } } diff --git a/src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs b/src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs index 57d5ad9271..25f12ffa57 100644 --- a/src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs +++ b/src/Avalonia.Styling/Styling/PropertyEqualsSelector.cs @@ -60,7 +60,7 @@ namespace Avalonia.Styling builder.Append(_property.Name); builder.Append('='); - builder.Append(_value); + builder.Append(_value ?? string.Empty); builder.Append(']'); _selectorString = builder.ToString(); @@ -78,11 +78,11 @@ namespace Avalonia.Styling } else if (subscribe) { - return new SelectorMatch(control.GetObservable(_property).Select(v => Equals(v, _value))); + return new SelectorMatch(control.GetObservable(_property).Select(v => Equals(v ?? string.Empty, _value))); } else { - return new SelectorMatch(control.GetValue(_property).Equals(_value)); + return new SelectorMatch((control.GetValue(_property) ?? string.Empty).Equals(_value)); } } diff --git a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml index 5aac023708..46767feca0 100644 --- a/src/Avalonia.Themes.Default/Accents/BaseLight.xaml +++ b/src/Avalonia.Themes.Default/Accents/BaseLight.xaml @@ -1,60 +1,56 @@ diff --git a/src/Avalonia.Themes.Default/CheckBox.xaml b/src/Avalonia.Themes.Default/CheckBox.xaml index 62a05a3525..3d14dd8e51 100644 --- a/src/Avalonia.Themes.Default/CheckBox.xaml +++ b/src/Avalonia.Themes.Default/CheckBox.xaml @@ -40,6 +40,9 @@ + @@ -58,4 +61,4 @@ - \ No newline at end of file + diff --git a/src/Avalonia.Themes.Default/TreeViewItem.xaml b/src/Avalonia.Themes.Default/TreeViewItem.xaml index ada86d3535..b5e0e7a005 100644 --- a/src/Avalonia.Themes.Default/TreeViewItem.xaml +++ b/src/Avalonia.Themes.Default/TreeViewItem.xaml @@ -1,92 +1,92 @@ - + - + - + - + - + - + - + - + - + - + From e7dc15239288ff4e466f585406765269e1cba9c4 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 6 Sep 2018 00:21:24 -0500 Subject: [PATCH 40/80] Fix case where timing lands on exactly a new keyframe. --- src/Avalonia.Animation/Animator`1.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 8079ac69b5..e674ac84e1 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -86,10 +86,18 @@ namespace Avalonia.Animation double t0 = firstCue.Key; double t1 = lastCue.Key; - var intraframeTime = (t - t0) / (t1 - t0); - var firstFrameData = (firstCue.Value.frame.GetTypedValue(), firstCue.Value.isNeutral); - var lastFrameData = (lastCue.Value.frame.GetTypedValue(), lastCue.Value.isNeutral); - return (intraframeTime, new KeyFramePair(firstFrameData, lastFrameData)); + if (t0 != t1) + { + var intraframeTime = (t - t0) / (t1 - t0); + var firstFrameData = (firstCue.Value.frame.GetTypedValue(), firstCue.Value.isNeutral); + var lastFrameData = (lastCue.Value.frame.GetTypedValue(), lastCue.Value.isNeutral); + return (intraframeTime, new KeyFramePair(firstFrameData, lastFrameData)); + } + else + { + var frameData = (firstCue.Value.frame.GetTypedValue(), firstCue.Value.isNeutral); + return (0.0, new KeyFramePair(frameData, frameData)); + } } From 5f4a38842c37693a783712ba2116efbdeeec7217 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 6 Sep 2018 13:26:17 +0800 Subject: [PATCH 41/80] Finally fixed the flickering heart bug! Simplify the Keyframe selection and removed all LINQ code. Use the Cue property on AnimatorKeyFrame as the time index and integrate the IsNeutral value as an internal property. --- src/Avalonia.Animation/AnimatorKeyFrame.cs | 1 + src/Avalonia.Animation/Animator`1.cs | 61 ++++++++++++++-------- src/Avalonia.Animation/Cue.cs | 5 +- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/Avalonia.Animation/AnimatorKeyFrame.cs b/src/Avalonia.Animation/AnimatorKeyFrame.cs index 0276c6fa92..0dc15da49c 100644 --- a/src/Avalonia.Animation/AnimatorKeyFrame.cs +++ b/src/Avalonia.Animation/AnimatorKeyFrame.cs @@ -29,6 +29,7 @@ namespace Avalonia.Animation Cue = cue; } + internal bool isNeutral; public Type AnimatorType { get; } public Cue Cue { get; } public AvaloniaProperty Property { get; private set; } diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 8079ac69b5..7631a11d9c 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -19,7 +19,7 @@ namespace Avalonia.Animation /// /// List of type-converted keyframes. /// - private readonly SortedList _convertedKeyframes = new SortedList(); + private readonly List _convertedKeyframes = new List(); private bool isVerfifiedAndConverted; @@ -58,41 +58,49 @@ namespace Avalonia.Animation /// The time parameter, relative to the total animation time protected (double IntraKFTime, KeyFramePair KFPair) GetKFPairAndIntraKFTime(double t) { - KeyValuePair firstCue, lastCue; + AnimatorKeyFrame firstCue, lastCue ; int kvCount = _convertedKeyframes.Count; if (kvCount > 2) { if (DoubleUtils.AboutEqual(t, 0.0) || t < 0.0) { - firstCue = _convertedKeyframes.First(); - lastCue = _convertedKeyframes.Skip(1).First(); + firstCue = _convertedKeyframes[0]; + lastCue = _convertedKeyframes[1]; } else if (DoubleUtils.AboutEqual(t, 1.0) || t > 1.0) { - firstCue = _convertedKeyframes.Skip(kvCount - 2).First(); - lastCue = _convertedKeyframes.Last(); + firstCue = _convertedKeyframes[_convertedKeyframes.Count - 2]; + lastCue = _convertedKeyframes[_convertedKeyframes.Count - 1]; } else { - firstCue = _convertedKeyframes.Last(j => j.Key <= t); - lastCue = _convertedKeyframes.First(j => j.Key >= t); + (double time, int index) maxval = (0.0d, 0); + for (int i = 0; i < _convertedKeyframes.Count; i++) + { + var comp = _convertedKeyframes[i].Cue.CueValue; + if (t >= comp) + { + maxval = (comp, i); + } + } + firstCue = _convertedKeyframes[maxval.index]; + lastCue = _convertedKeyframes[maxval.index + 1]; } } else { - firstCue = _convertedKeyframes.First(); - lastCue = _convertedKeyframes.Last(); + firstCue = _convertedKeyframes[0]; + lastCue = _convertedKeyframes[1]; } - double t0 = firstCue.Key; - double t1 = lastCue.Key; + double t0 = firstCue.Cue.CueValue; + double t1 = lastCue.Cue.CueValue; var intraframeTime = (t - t0) / (t1 - t0); - var firstFrameData = (firstCue.Value.frame.GetTypedValue(), firstCue.Value.isNeutral); - var lastFrameData = (lastCue.Value.frame.GetTypedValue(), lastCue.Value.isNeutral); + var firstFrameData = (firstCue.GetTypedValue(), firstCue.isNeutral); + var lastFrameData = (lastCue.GetTypedValue(), lastCue.isNeutral); return (intraframeTime, new KeyFramePair(firstFrameData, lastFrameData)); } - /// /// Runs the KeyFrames Animation. /// @@ -113,16 +121,25 @@ namespace Avalonia.Animation protected abstract T DoInterpolation(double time, T neutralValue); /// - /// Verifies and converts keyframe values according to this class's target type. + /// Verifies, converts and sorts keyframe values according to this class's target type. /// private void VerifyConvertKeyFrames() { foreach (AnimatorKeyFrame keyframe in this) { - _convertedKeyframes.Add(keyframe.Cue.CueValue, (keyframe, false)); + _convertedKeyframes.Add(keyframe); } AddNeutralKeyFramesIfNeeded(); + + var copy = _convertedKeyframes.ToList().OrderBy(p => p.Cue.CueValue); + _convertedKeyframes.Clear(); + + foreach (AnimatorKeyFrame keyframe in copy) + { + _convertedKeyframes.Add(keyframe); + } + isVerfifiedAndConverted = true; } @@ -133,13 +150,13 @@ namespace Avalonia.Animation hasStartKey = hasEndKey = false; // Check if there's start and end keyframes. - foreach (var converted in _convertedKeyframes.Keys) + foreach (var frame in _convertedKeyframes) { - if (DoubleUtils.AboutEqual(converted, 0.0)) + if (DoubleUtils.AboutEqual(frame.Cue.CueValue, 0.0)) { hasStartKey = true; } - else if (DoubleUtils.AboutEqual(converted, 1.0)) + else if (DoubleUtils.AboutEqual(frame.Cue.CueValue, 1.0)) { hasEndKey = true; } @@ -153,12 +170,12 @@ namespace Avalonia.Animation { if (!hasStartKey) { - _convertedKeyframes.Add(0.0d, (new AnimatorKeyFrame { Value = default(T) }, true)); + _convertedKeyframes.Add(new AnimatorKeyFrame(null, new Cue(0.0d)) { Value = default(T), isNeutral = true }); } if (!hasEndKey) { - _convertedKeyframes.Add(1.0d, (new AnimatorKeyFrame { Value = default(T) }, true)); + _convertedKeyframes.Add(new AnimatorKeyFrame(null, new Cue(1.0d)) { Value = default(T), isNeutral = true }); } } } diff --git a/src/Avalonia.Animation/Cue.cs b/src/Avalonia.Animation/Cue.cs index 5a95c108e3..de77475c2c 100644 --- a/src/Avalonia.Animation/Cue.cs +++ b/src/Avalonia.Animation/Cue.cs @@ -7,7 +7,7 @@ using System.Text; namespace Avalonia.Animation { /// - /// A Cue object for . + /// Determines the time index for a . /// [TypeConverter(typeof(CueTypeConverter))] public readonly struct Cue : IEquatable, IEquatable @@ -84,5 +84,4 @@ namespace Avalonia.Animation return Cue.Parse((string)value, culture); } } - -} +} \ No newline at end of file From 8a800cadfa1917d6a34bd023b3ee07ce7e2cbeac Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 6 Sep 2018 19:52:47 +0800 Subject: [PATCH 42/80] Fix nits & polish up some code --- src/Avalonia.Animation/Animatable.cs | 25 +-- src/Avalonia.Animation/Animation.cs | 2 - src/Avalonia.Animation/AnimationsEngine`1.cs | 208 +++++++++---------- src/Avalonia.Animation/Animator`1.cs | 11 +- src/Avalonia.Animation/TransitionsEngine.cs | 30 ++- 5 files changed, 123 insertions(+), 153 deletions(-) diff --git a/src/Avalonia.Animation/Animatable.cs b/src/Avalonia.Animation/Animatable.cs index 4176bf01e5..3e030bf765 100644 --- a/src/Avalonia.Animation/Animatable.cs +++ b/src/Avalonia.Animation/Animatable.cs @@ -14,15 +14,7 @@ namespace Avalonia.Animation /// Base class for control which can have property transitions. /// public class Animatable : AvaloniaObject - { - /// - /// Initializes this object. - /// - public Animatable() - { - Transitions = new Transitions(); - } - + { /// /// Defines the property. /// @@ -42,27 +34,25 @@ namespace Avalonia.Animation { get { return _playState; } set { SetAndRaise(PlayStateProperty, ref _playState, value); } - } - /// /// Defines the property. /// - public static readonly DirectProperty> TransitionsProperty = - AvaloniaProperty.RegisterDirect>( + public static readonly DirectProperty TransitionsProperty = + AvaloniaProperty.RegisterDirect( nameof(Transitions), o => o.Transitions, (o, v) => o.Transitions = v); - private IEnumerable _transitions = new AvaloniaList(); + private Transitions _transitions; /// /// Gets or sets the property transitions for the control. /// - public IEnumerable Transitions + public Transitions Transitions { - get { return _transitions; } + get { return _transitions ?? (_transitions = new Transitions()); } set { SetAndRaise(TransitionsProperty, ref _transitions, value); } } @@ -83,6 +73,5 @@ namespace Avalonia.Animation } } } - } -} +} \ No newline at end of file diff --git a/src/Avalonia.Animation/Animation.cs b/src/Avalonia.Animation/Animation.cs index e23caf95f1..2c359ecac3 100644 --- a/src/Avalonia.Animation/Animation.cs +++ b/src/Avalonia.Animation/Animation.cs @@ -22,8 +22,6 @@ namespace Avalonia.Animation /// public static PlayState GlobalPlayState { get; set; } = PlayState.Run; - public AvaloniaList _animators { get; set; } = new AvaloniaList(); - /// /// Gets or sets the active time of this animation. /// diff --git a/src/Avalonia.Animation/AnimationsEngine`1.cs b/src/Avalonia.Animation/AnimationsEngine`1.cs index cccb3098c0..156056d765 100644 --- a/src/Avalonia.Animation/AnimationsEngine`1.cs +++ b/src/Avalonia.Animation/AnimationsEngine`1.cs @@ -1,7 +1,9 @@ using System; using System.Linq; +using System.Reactive.Linq; using Avalonia.Animation.Utils; using Avalonia.Data; +using Avalonia.Reactive; namespace Avalonia.Animation { @@ -9,182 +11,184 @@ namespace Avalonia.Animation /// Handles interpolatoin and time-related functions /// for keyframe animations. /// - internal class AnimationsEngine : IObservable, IDisposable + internal class AnimationsEngine : SingleSubscriberObservableBase { - T lastInterpValue; - T firstKFValue; - - private long repeatCount; - private double currentIteration; - - private bool isLooping; - private bool gotFirstKFValue; - private bool gotFirstFrameCount; - private bool iterationDelay; - - private FillMode fillMode; - private PlaybackDirection animationDirection; - private Animator parent; - private Animatable targetControl; - private T neutralValue; - private double speedRatio; - internal bool unsubscribe; - private bool isDisposed; - - private TimeSpan delay; - private TimeSpan duration; - private TimeSpan firstFrameCount; - private TimeSpan internalClock; - private TimeSpan? previousClock; - - private Easings.Easing easeFunc; - private IObserver targetObserver; - private readonly Action onCompleteAction; - - public AnimationsEngine(Animation animation, Animatable control, Animator animator, Action OnComplete) + private T _lastInterpValue; + private T _firstKFValue; + private long _repeatCount; + private double _currentIteration; + private bool _isLooping; + private bool _gotFirstKFValue; + private bool _gotFirstFrameCount; + private bool _iterationDelay; + private FillMode _fillMode; + private PlaybackDirection _animationDirection; + private Animator _parent; + private Animatable _targetControl; + private T _neutralValue; + private double _speedRatio; + private TimeSpan _delay; + private TimeSpan _duration; + private TimeSpan _firstFrameCount; + private TimeSpan _internalClock; + private TimeSpan? _previousClock; + private Easings.Easing _easeFunc; + private Action _onCompleteAction; + private Func _interpolator; + private IDisposable _timerSubscription; + + public AnimationsEngine(Animation animation, Animatable control, Animator animator, Action OnComplete, Func Interpolator) { if (animation.SpeedRatio <= 0 || DoubleUtils.AboutEqual(animation.SpeedRatio, 0)) throw new InvalidOperationException("Speed ratio cannot be negative or zero."); if (animation.Duration.TotalSeconds <= 0 || DoubleUtils.AboutEqual(animation.Duration.TotalSeconds, 0)) throw new InvalidOperationException("Duration cannot be negative or zero."); - - parent = animator; - easeFunc = animation.Easing; - targetControl = control; - neutralValue = (T)targetControl.GetValue(parent.Property); - speedRatio = animation.SpeedRatio; + _parent = animator; + _easeFunc = animation.Easing; + _targetControl = control; + _neutralValue = (T)_targetControl.GetValue(_parent.Property); + + _speedRatio = animation.SpeedRatio; - delay = animation.Delay; - duration = animation.Duration; - iterationDelay = animation.DelayBetweenIterations; + _delay = animation.Delay; + _duration = animation.Duration; + _iterationDelay = animation.DelayBetweenIterations; switch (animation.RepeatCount.RepeatType) { case RepeatType.None: - repeatCount = 1; + _repeatCount = 1; break; case RepeatType.Loop: - isLooping = true; + _isLooping = true; break; case RepeatType.Repeat: - repeatCount = (long)animation.RepeatCount.Value; + _repeatCount = (long)animation.RepeatCount.Value; break; } - animationDirection = animation.PlaybackDirection; - fillMode = animation.FillMode; - onCompleteAction = OnComplete; + _animationDirection = animation.PlaybackDirection; + _fillMode = animation.FillMode; + _onCompleteAction = OnComplete; + _interpolator = Interpolator; + } + + protected override void Unsubscribed() + { + _timerSubscription?.Dispose(); } - public void Step(TimeSpan frameTick, Func Interpolator) + protected override void Subscribed() + { + _timerSubscription = Timing.AnimationsTimer + .Subscribe(p => this.Step(p)); + } + + public void Step(TimeSpan frameTick) { try { - InternalStep(frameTick, Interpolator); + InternalStep(frameTick); } catch (Exception e) { - targetObserver?.OnError(e); + PublishError(e); } } private void DoComplete() { - if (fillMode == FillMode.Forward || fillMode == FillMode.Both) - targetControl.SetValue(parent.Property, lastInterpValue, BindingPriority.LocalValue); + if (_fillMode == FillMode.Forward || _fillMode == FillMode.Both) + _targetControl.SetValue(_parent.Property, _lastInterpValue, BindingPriority.LocalValue); - targetObserver.OnCompleted(); - onCompleteAction?.Invoke(); - Dispose(); + _onCompleteAction?.Invoke(); + PublishCompleted(); } private void DoDelay() { - if (fillMode == FillMode.Backward || fillMode == FillMode.Both) - if (currentIteration == 0) - targetObserver.OnNext(firstKFValue); + if (_fillMode == FillMode.Backward || _fillMode == FillMode.Both) + if (_currentIteration == 0) + PublishNext(_firstKFValue); else - targetObserver.OnNext(lastInterpValue); + PublishNext(_lastInterpValue); } private void DoPlayStatesAndTime(TimeSpan systemTime) { - if (Animation.GlobalPlayState == PlayState.Stop || targetControl.PlayState == PlayState.Stop) + if (Animation.GlobalPlayState == PlayState.Stop || _targetControl.PlayState == PlayState.Stop) DoComplete(); - if (!previousClock.HasValue) + if (!_previousClock.HasValue) { - previousClock = systemTime; - internalClock = TimeSpan.Zero; + _previousClock = systemTime; + _internalClock = TimeSpan.Zero; } else { - if (Animation.GlobalPlayState == PlayState.Pause || targetControl.PlayState == PlayState.Pause) + if (Animation.GlobalPlayState == PlayState.Pause || _targetControl.PlayState == PlayState.Pause) { - previousClock = systemTime; + _previousClock = systemTime; return; } - var delta = systemTime - previousClock; - internalClock += delta.Value; - previousClock = systemTime; + var delta = systemTime - _previousClock; + _internalClock += delta.Value; + _previousClock = systemTime; } - if (!gotFirstKFValue) + if (!_gotFirstKFValue) { - firstKFValue = (T)parent.First().Value; - gotFirstKFValue = true; + _firstKFValue = (T)_parent.First().Value; + _gotFirstKFValue = true; } - if (!gotFirstFrameCount) + if (!_gotFirstFrameCount) { - firstFrameCount = internalClock; - gotFirstFrameCount = true; + _firstFrameCount = _internalClock; + _gotFirstFrameCount = true; } } - private void InternalStep(TimeSpan systemTime, Func Interpolator) + private void InternalStep(TimeSpan systemTime) { DoPlayStatesAndTime(systemTime); - - if (isDisposed) - throw new InvalidProgramException("This KeyFrames Animation is already disposed."); - - var time = internalClock - firstFrameCount; - var delayEndpoint = delay; - var iterationEndpoint = delayEndpoint + duration; + + var time = _internalClock - _firstFrameCount; + var delayEndpoint = _delay; + var iterationEndpoint = delayEndpoint + _duration; //determine if time is currently in the first iteration. if (time >= TimeSpan.Zero & time <= iterationEndpoint) { - currentIteration = 1; + _currentIteration = 1; } else if (time > iterationEndpoint) { //Subtract first iteration to properly get the subsequent iteration time time -= iterationEndpoint; - if (!iterationDelay & delayEndpoint > TimeSpan.Zero) + if (!_iterationDelay & delayEndpoint > TimeSpan.Zero) { delayEndpoint = TimeSpan.Zero; - iterationEndpoint = duration; + iterationEndpoint = _duration; } //Calculate the current iteration number - currentIteration = (int)Math.Floor((double)time.Ticks / iterationEndpoint.Ticks) + 2; + _currentIteration = (int)Math.Floor((double)time.Ticks / iterationEndpoint.Ticks) + 2; } else { - previousClock = systemTime; + _previousClock = systemTime; return; } time = TimeSpan.FromTicks(time.Ticks % iterationEndpoint.Ticks); - if (!isLooping) + if (!_isLooping) { - if (currentIteration > repeatCount) + if (_currentIteration > _repeatCount) DoComplete(); if (time > iterationEndpoint) @@ -192,10 +196,10 @@ namespace Avalonia.Animation } // Determine if the current iteration should have its normalized time inverted. - bool isCurIterReverse = animationDirection == PlaybackDirection.Normal ? false : - animationDirection == PlaybackDirection.Alternate ? (currentIteration % 2 == 0) ? false : true : - animationDirection == PlaybackDirection.AlternateReverse ? (currentIteration % 2 == 0) ? true : false : - animationDirection == PlaybackDirection.Reverse ? true : false; + bool isCurIterReverse = _animationDirection == PlaybackDirection.Normal ? false : + _animationDirection == PlaybackDirection.Alternate ? (_currentIteration % 2 == 0) ? false : true : + _animationDirection == PlaybackDirection.AlternateReverse ? (_currentIteration % 2 == 0) ? true : false : + _animationDirection == PlaybackDirection.Reverse ? true : false; if (delayEndpoint > TimeSpan.Zero & time < delayEndpoint) { @@ -214,23 +218,11 @@ namespace Avalonia.Animation interpVal = 1 - interpVal; // Ease and interpolate - var easedTime = easeFunc.Ease(interpVal); - lastInterpValue = Interpolator(easedTime, neutralValue); + var easedTime = _easeFunc.Ease(interpVal); + _lastInterpValue = _interpolator(easedTime, _neutralValue); - targetObserver.OnNext(lastInterpValue); + PublishNext(_lastInterpValue); } } - - public IDisposable Subscribe(IObserver observer) - { - targetObserver = observer; - return this; - } - - public void Dispose() - { - unsubscribe = true; - isDisposed = true; - } } } \ No newline at end of file diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 051b1e50cf..77d761ce4c 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -32,12 +32,12 @@ namespace Avalonia.Animation } /// - public virtual IDisposable Apply(Animation animation, Animatable control, IObservable Match, Action onComplete) + public virtual IDisposable Apply(Animation animation, Animatable control, IObservable match, Action onComplete) { if (!_isVerifiedAndConverted) VerifyConvertKeyFrames(); - return Match + return match .Where(p => p) .Subscribe(_ => { @@ -103,12 +103,7 @@ namespace Avalonia.Animation /// private IDisposable RunKeyFrames(Animation animation, Animatable control, Action onComplete) { - var stateMachine = new AnimationsEngine(animation, control, this, onComplete); - - Timing.AnimationsTimer - .TakeWhile(_ => !stateMachine.unsubscribe) - .Subscribe(p => stateMachine.Step(p, DoInterpolation)); - + var stateMachine = new AnimationsEngine(animation, control, this, onComplete, DoInterpolation); return control.Bind((AvaloniaProperty)Property, stateMachine, BindingPriority.Animation); } diff --git a/src/Avalonia.Animation/TransitionsEngine.cs b/src/Avalonia.Animation/TransitionsEngine.cs index 4d52b2bd48..34863e4146 100644 --- a/src/Avalonia.Animation/TransitionsEngine.cs +++ b/src/Avalonia.Animation/TransitionsEngine.cs @@ -6,12 +6,15 @@ using System; using System.Reactive.Linq; using Avalonia.Animation.Easings; using Avalonia.Animation.Utils; +using Avalonia.Reactive; namespace Avalonia.Animation { - public class TransitionsEngine : IObservable, IDisposable + /// + /// Handles the timing and lifetime of a . + /// + public class TransitionsEngine : SingleSubscriberObservableBase { - private IObserver observer; private IDisposable timerSubscription; private readonly TimeSpan startTime; private readonly TimeSpan duration; @@ -20,10 +23,6 @@ namespace Avalonia.Animation { startTime = Timing.GetTickCount(); duration = Duration; - - timerSubscription = Timing - .AnimationsTimer - .Subscribe(t => TimerTick(t)); } private void TimerTick(TimeSpan t) @@ -33,26 +32,23 @@ namespace Avalonia.Animation if (interpVal > 1d || interpVal < 0d) { - this.Dispose(); + PublishCompleted(); return; } - observer?.OnNext(interpVal); + PublishNext(interpVal); } - - public void Dispose() + + protected override void Unsubscribed() { timerSubscription?.Dispose(); - observer?.OnCompleted(); } - public IDisposable Subscribe(IObserver Observer) + protected override void Subscribed() { - if (Observer is null) - throw new InvalidProgramException("Can only set the subscription once."); - - observer = Observer; - return this; + timerSubscription = Timing + .AnimationsTimer + .Subscribe(t => TimerTick(t)); } } } \ No newline at end of file From 98ee428d6f4c31e5e7bfa0c2cda49a11a4a86459 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Thu, 6 Sep 2018 14:05:56 +0200 Subject: [PATCH 43/80] Merge fix --- .../SwapChainRenderTarget.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs index 000ce23cd2..ffa0f5c8bc 100644 --- a/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs +++ b/src/Windows/Avalonia.Direct2D1/SwapChainRenderTarget.cs @@ -1,19 +1,13 @@ -using Avalonia.Direct2D1.Media; +// 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.Direct2D1.Media; using Avalonia.Direct2D1.Media.Imaging; using Avalonia.Platform; using Avalonia.Rendering; using SharpDX; using SharpDX.Direct2D1; using SharpDX.DXGI; -using AlphaMode = SharpDX.Direct2D1.AlphaMode; -using Device = SharpDX.Direct2D1.Device; -using Factory = SharpDX.Direct2D1.Factory; -using Factory2 = SharpDX.DXGI.Factory2; -using PixelFormat = SharpDX.Direct2D1.PixelFormat; - -using AlphaMode = SharpDX.Direct2D1.AlphaMode; -using DeviceContext = SharpDX.Direct2D1.DeviceContext; -using PixelFormat = SharpDX.Direct2D1.PixelFormat; namespace Avalonia.Direct2D1 { @@ -109,9 +103,9 @@ namespace Avalonia.Direct2D1 _deviceContext, dxgiBackBuffer, new BitmapProperties1( - new PixelFormat + new SharpDX.Direct2D1.PixelFormat { - AlphaMode = AlphaMode.Premultiplied, + AlphaMode = SharpDX.Direct2D1.AlphaMode.Premultiplied, Format = Format.B8G8R8A8_UNorm }, _savedSize.Width, From 45ca6af21cdd15031228f4c5bbbe8c9876f606ec Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 6 Sep 2018 21:29:45 +0800 Subject: [PATCH 44/80] Remove Epsilon equality checking since the animations dont require such precision. --- src/Avalonia.Animation/AnimationsEngine`1.cs | 4 ++-- src/Avalonia.Animation/Animator`1.cs | 8 ++++---- src/Avalonia.Animation/Utils/DoubleUtils.cs | 16 ---------------- src/Avalonia.Animation/Utils/EasingUtils.cs | 2 +- 4 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 src/Avalonia.Animation/Utils/DoubleUtils.cs diff --git a/src/Avalonia.Animation/AnimationsEngine`1.cs b/src/Avalonia.Animation/AnimationsEngine`1.cs index 156056d765..e724fe52d5 100644 --- a/src/Avalonia.Animation/AnimationsEngine`1.cs +++ b/src/Avalonia.Animation/AnimationsEngine`1.cs @@ -39,10 +39,10 @@ namespace Avalonia.Animation public AnimationsEngine(Animation animation, Animatable control, Animator animator, Action OnComplete, Func Interpolator) { - if (animation.SpeedRatio <= 0 || DoubleUtils.AboutEqual(animation.SpeedRatio, 0)) + if (animation.SpeedRatio <= 0) throw new InvalidOperationException("Speed ratio cannot be negative or zero."); - if (animation.Duration.TotalSeconds <= 0 || DoubleUtils.AboutEqual(animation.Duration.TotalSeconds, 0)) + if (animation.Duration.TotalSeconds <= 0) throw new InvalidOperationException("Duration cannot be negative or zero."); _parent = animator; diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 77d761ce4c..2c95571dc8 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -59,12 +59,12 @@ namespace Avalonia.Animation int kvCount = _convertedKeyframes.Count; if (kvCount > 2) { - if (DoubleUtils.AboutEqual(t, 0.0) || t < 0.0) + if (t <= 0.0) { firstCue = _convertedKeyframes[0]; lastCue = _convertedKeyframes[1]; } - else if (DoubleUtils.AboutEqual(t, 1.0) || t > 1.0) + else if (t >= 1.0) { firstCue = _convertedKeyframes[_convertedKeyframes.Count - 2]; lastCue = _convertedKeyframes[_convertedKeyframes.Count - 1]; @@ -143,11 +143,11 @@ namespace Avalonia.Animation // Check if there's start and end keyframes. foreach (var frame in _convertedKeyframes) { - if (DoubleUtils.AboutEqual(frame.Cue.CueValue, 0.0)) + if (frame.Cue.CueValue == 0.0d) { hasStartKey = true; } - else if (DoubleUtils.AboutEqual(frame.Cue.CueValue, 1.0)) + else if (frame.Cue.CueValue == 1.0d) { hasEndKey = true; } diff --git a/src/Avalonia.Animation/Utils/DoubleUtils.cs b/src/Avalonia.Animation/Utils/DoubleUtils.cs deleted file mode 100644 index d2e74376a3..0000000000 --- a/src/Avalonia.Animation/Utils/DoubleUtils.cs +++ /dev/null @@ -1,16 +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; - -namespace Avalonia.Animation.Utils -{ - internal static class DoubleUtils - { - internal static bool AboutEqual(double x, double y) - { - double epsilon = Math.Max(Math.Abs(x), Math.Abs(y)) * 1E-15; - return Math.Abs(x - y) <= epsilon; - } - } -} diff --git a/src/Avalonia.Animation/Utils/EasingUtils.cs b/src/Avalonia.Animation/Utils/EasingUtils.cs index d07ec3cdf4..1a7688cace 100644 --- a/src/Avalonia.Animation/Utils/EasingUtils.cs +++ b/src/Avalonia.Animation/Utils/EasingUtils.cs @@ -13,6 +13,6 @@ namespace Avalonia.Animation.Utils /// /// Half of /// - internal static double HALFPI = Math.PI / 2d; + internal const double HALFPI = Math.PI / 2d; } } From 024e0da1da398b765422344cbb768f1efef4cfe9 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Thu, 6 Sep 2018 15:47:02 +0200 Subject: [PATCH 45/80] Direct3DInterop fixes --- .../Direct3DInteropSample/MainWindow.cs | 276 ++++++++++-------- .../Avalonia.Direct2D1/Direct2D1Platform.cs | 14 +- .../Media/Imaging/D2DBitmapImpl.cs | 29 +- .../Imaging/D2DRenderTargetBitmapImpl.cs | 5 +- .../Media/Imaging/WriteableWicBitmapImpl.cs | 5 +- 5 files changed, 176 insertions(+), 153 deletions(-) diff --git a/samples/interop/Direct3DInteropSample/MainWindow.cs b/samples/interop/Direct3DInteropSample/MainWindow.cs index 19c31a3af1..065f1a285a 100644 --- a/samples/interop/Direct3DInteropSample/MainWindow.cs +++ b/samples/interop/Direct3DInteropSample/MainWindow.cs @@ -1,81 +1,83 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// 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 Avalonia; using Avalonia.Controls; +using Avalonia.Direct2D1; using Avalonia.Direct2D1.Media; using Avalonia.Markup.Xaml; using Avalonia.Platform; using Avalonia.Rendering; + using SharpDX; using SharpDX.D3DCompiler; using SharpDX.Direct2D1; using SharpDX.Direct3D; using SharpDX.Direct3D11; using SharpDX.DXGI; -using SharpDX.WIC; -using SharpDX.Mathematics; + using AlphaMode = SharpDX.Direct2D1.AlphaMode; using Buffer = SharpDX.Direct3D11.Buffer; -using DeviceContext = SharpDX.Direct3D11.DeviceContext; -using Factory1 = SharpDX.DXGI.Factory1; +using DeviceContext = SharpDX.Direct2D1.DeviceContext; +using Factory2 = SharpDX.DXGI.Factory2; using InputElement = SharpDX.Direct3D11.InputElement; using Matrix = SharpDX.Matrix; using PixelFormat = SharpDX.Direct2D1.PixelFormat; +using Resource = SharpDX.Direct3D11.Resource; namespace Direct3DInteropSample { - class MainWindow : Window + public class MainWindow : Window { - private SharpDX.Direct3D11.Device _d3dDevice; - private SharpDX.DXGI.Device _dxgiDevice; - Texture2D backBuffer = null; - RenderTargetView renderView = null; - Texture2D depthBuffer = null; - DepthStencilView depthView = null; + Texture2D _backBuffer; + RenderTargetView _renderView; + Texture2D _depthBuffer; + DepthStencilView _depthView; private readonly SwapChain _swapChain; - private SwapChainDescription _desc; + private SwapChainDescription1 _desc; private Matrix _proj = Matrix.Identity; - private Matrix _view; + private readonly Matrix _view; private Buffer _contantBuffer; - private SharpDX.Direct2D1.Device _d2dDevice; - private SharpDX.Direct2D1.DeviceContext _d2dContext; - private RenderTarget _d2dRenderTarget; - private MainWindowViewModel _model; + private DeviceContext _deviceContext; + private readonly MainWindowViewModel _model; public MainWindow() { - _dxgiDevice = AvaloniaLocator.Current.GetService(); - _d3dDevice = _dxgiDevice.QueryInterface(); - _d2dDevice = AvaloniaLocator.Current.GetService(); DataContext = _model = new MainWindowViewModel(); - _desc = new SwapChainDescription() + + _desc = new SwapChainDescription1() { BufferCount = 1, - ModeDescription = - new ModeDescription((int)ClientSize.Width, (int)ClientSize.Height, - new Rational(60, 1), Format.R8G8B8A8_UNorm), - IsWindowed = true, - OutputHandle = PlatformImpl?.Handle.Handle ?? IntPtr.Zero, + Width = (int)ClientSize.Width, + Height = (int)ClientSize.Height, + Format = Format.R8G8B8A8_UNorm, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; - _swapChain = new SwapChain(new Factory1(), _d3dDevice, _desc); + using (var factory = Direct2D1Platform.DxgiDevice.Adapter.GetParent()) + { + _swapChain = new SwapChain1(factory, Direct2D1Platform.DxgiDevice, PlatformImpl?.Handle.Handle ?? IntPtr.Zero, ref _desc); + } - _d2dContext = new SharpDX.Direct2D1.DeviceContext(_d2dDevice, DeviceContextOptions.None) + _deviceContext = new DeviceContext(Direct2D1Platform.Direct2D1Device, DeviceContextOptions.None) { DotsPerInch = new Size2F(96, 96) }; CreateMesh(); + _view = Matrix.LookAtLH(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.UnitY); + this.GetObservable(ClientSizeProperty).Subscribe(Resize); + Resize(ClientSize); + AvaloniaXamlLoader.Load(this); + Background = Avalonia.Media.Brushes.Transparent; } @@ -83,29 +85,32 @@ namespace Direct3DInteropSample protected override void HandlePaint(Rect rect) { var viewProj = Matrix.Multiply(_view, _proj); - var context = _d3dDevice.ImmediateContext; + var context = Direct2D1Platform.Direct3D11Device.ImmediateContext; + // Clear views - context.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0); - context.ClearRenderTargetView(renderView, Color.White); + context.ClearDepthStencilView(_depthView, DepthStencilClearFlags.Depth, 1.0f, 0); + context.ClearRenderTargetView(_renderView, Color.White); // Update WorldViewProj Matrix - var worldViewProj = Matrix.RotationX((float) _model.RotationX) * Matrix.RotationY((float) _model.RotationY) * - Matrix.RotationZ((float) _model.RotationZ) - * Matrix.Scaling((float) _model.Zoom) * viewProj; + var worldViewProj = Matrix.RotationX((float)_model.RotationX) * Matrix.RotationY((float)_model.RotationY) + * Matrix.RotationZ((float)_model.RotationZ) + * Matrix.Scaling((float)_model.Zoom) + * viewProj; worldViewProj.Transpose(); context.UpdateSubresource(ref worldViewProj, _contantBuffer); // Draw the cube context.Draw(36, 0); base.HandlePaint(rect); + // Present! _swapChain.Present(0, PresentFlags.None); } - - void CreateMesh() + private void CreateMesh() { - var device = _d3dDevice; + var device = Direct2D1Platform.Direct3D11Device; + // Compile Vertex and Pixel shaders var vertexShaderByteCode = ShaderBytecode.CompileFromFile("MiniCube.fx", "VS", "vs_4_0"); var vertexShader = new VertexShader(device, vertexShaderByteCode); @@ -114,63 +119,72 @@ namespace Direct3DInteropSample var pixelShader = new PixelShader(device, pixelShaderByteCode); var signature = ShaderSignature.GetInputSignature(vertexShaderByteCode); + + var inputElements = new[] + { + new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), + new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) + }; + // Layout from VertexShader input signature - var layout = new InputLayout(device, signature, new[] - { - new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), - new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 16, 0) - }); - + var layout = new InputLayout( + device, + signature, + inputElements); + // Instantiate Vertex buiffer from vertex data - var vertices = Buffer.Create(device, BindFlags.VertexBuffer, new[] - { - new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), // Front - new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), - new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), - new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), - new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), - new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), - - new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), // BACK - new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), - new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), - new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), - new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), - new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), - - new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), // Top - new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), - new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), - new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), - new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), - new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), - - new Vector4(-1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), // Bottom - new Vector4( 1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), - new Vector4(-1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), - new Vector4(-1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), - new Vector4( 1.0f,-1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), - new Vector4( 1.0f,-1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), - - new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), // Left - new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), - new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), - new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), - new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), - new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), - - new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), // Right - new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), - new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), - new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), - new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), - new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), - }); + var vertices = Buffer.Create( + device, + BindFlags.VertexBuffer, + new[] + { + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), // Front + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 0.0f, 1.0f), + + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), // BACK + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 0.0f, 1.0f), + + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), // Top + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 0.0f, 1.0f, 1.0f), + + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), // Bottom + new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 1.0f, 0.0f, 1.0f), + + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), // Left + new Vector4(-1.0f, -1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, -1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, 1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + new Vector4(-1.0f, 1.0f, -1.0f, 1.0f), new Vector4(1.0f, 0.0f, 1.0f, 1.0f), + + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), // Right + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, -1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, -1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, -1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + new Vector4( 1.0f, 1.0f, 1.0f, 1.0f), new Vector4(0.0f, 1.0f, 1.0f, 1.0f), + }); // Create Constant Buffer _contantBuffer = new Buffer(device, Utilities.SizeOf(), ResourceUsage.Default, BindFlags.ConstantBuffer, CpuAccessFlags.None, ResourceOptionFlags.None, 0); - var context = _d3dDevice.ImmediateContext; + var context = Direct2D1Platform.Direct3D11Device.ImmediateContext; // Prepare All the stages context.InputAssembler.InputLayout = layout; @@ -181,63 +195,73 @@ namespace Direct3DInteropSample context.PixelShader.Set(pixelShader); } - void Resize(Size size) + private void Resize(Size size) { - Utilities.Dispose(ref _d2dRenderTarget); - Utilities.Dispose(ref backBuffer); - Utilities.Dispose(ref renderView); - Utilities.Dispose(ref depthBuffer); - Utilities.Dispose(ref depthView); - var context = _d3dDevice.ImmediateContext; + Utilities.Dispose(ref _deviceContext); + Utilities.Dispose(ref _backBuffer); + Utilities.Dispose(ref _renderView); + Utilities.Dispose(ref _depthBuffer); + Utilities.Dispose(ref _depthView); + var context = Direct2D1Platform.Direct3D11Device.ImmediateContext; + // Resize the backbuffer - _swapChain.ResizeBuffers(_desc.BufferCount, (int)size.Width, (int)size.Height, Format.Unknown, SwapChainFlags.None); + _swapChain.ResizeBuffers(0, 0, 0, Format.Unknown, SwapChainFlags.None); // Get the backbuffer from the swapchain - backBuffer = Texture2D.FromSwapChain(_swapChain, 0); + _backBuffer = Resource.FromSwapChain(_swapChain, 0); // Renderview on the backbuffer - renderView = new RenderTargetView(_d3dDevice, backBuffer); + _renderView = new RenderTargetView(Direct2D1Platform.Direct3D11Device, _backBuffer); // Create the depth buffer - depthBuffer = new Texture2D(_d3dDevice, new Texture2DDescription() - { - Format = Format.D32_Float_S8X24_UInt, - ArraySize = 1, - MipLevels = 1, - Width = (int)size.Width, - Height = (int)size.Height, - SampleDescription = new SampleDescription(1, 0), - Usage = ResourceUsage.Default, - BindFlags = BindFlags.DepthStencil, - CpuAccessFlags = CpuAccessFlags.None, - OptionFlags = ResourceOptionFlags.None - }); + _depthBuffer = new Texture2D( + Direct2D1Platform.Direct3D11Device, + new Texture2DDescription() + { + Format = Format.D32_Float_S8X24_UInt, + ArraySize = 1, + MipLevels = 1, + Width = (int)size.Width, + Height = (int)size.Height, + SampleDescription = new SampleDescription(1, 0), + Usage = ResourceUsage.Default, + BindFlags = BindFlags.DepthStencil, + CpuAccessFlags = CpuAccessFlags.None, + OptionFlags = ResourceOptionFlags.None + }); // Create the depth buffer view - depthView = new DepthStencilView(_d3dDevice, depthBuffer); + _depthView = new DepthStencilView(Direct2D1Platform.Direct3D11Device, _depthBuffer); // Setup targets and viewport for rendering context.Rasterizer.SetViewport(new Viewport(0, 0, (int)size.Width, (int)size.Height, 0.0f, 1.0f)); - context.OutputMerger.SetTargets(depthView, renderView); + context.OutputMerger.SetTargets(_depthView, _renderView); // Setup new projection matrix with correct aspect ratio _proj = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)(size.Width / size.Height), 0.1f, 100.0f); using (var dxgiBackBuffer = _swapChain.GetBackBuffer(0)) { - _d2dRenderTarget = new RenderTarget(AvaloniaLocator.Current.GetService() - , dxgiBackBuffer, new RenderTargetProperties + var renderTarget = new SharpDX.Direct2D1.RenderTarget( + Direct2D1Platform.Direct2D1Factory, + dxgiBackBuffer, + new RenderTargetProperties { DpiX = 96, DpiY = 96, Type = RenderTargetType.Default, - PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied) + PixelFormat = new PixelFormat( + Format.Unknown, + AlphaMode.Premultiplied) }); - } + _deviceContext = renderTarget.QueryInterface(); + + renderTarget.Dispose(); + } } - class D3DRenderTarget: IRenderTarget + private class D3DRenderTarget : IRenderTarget { private readonly MainWindow _window; @@ -245,16 +269,14 @@ namespace Direct3DInteropSample { _window = window; } + public void Dispose() { - } public IDrawingContextImpl CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer) { - return new DrawingContextImpl(visualBrushRenderer, null, _window._d2dRenderTarget, - AvaloniaLocator.Current.GetService(), - AvaloniaLocator.Current.GetService()); + return new DrawingContextImpl(visualBrushRenderer, null, _window._deviceContext); } } diff --git a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs index 437bae6fd1..38c49924bc 100644 --- a/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs +++ b/src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs @@ -29,6 +29,8 @@ namespace Avalonia.Direct2D1 { private static readonly Direct2D1Platform s_instance = new Direct2D1Platform(); + public static SharpDX.Direct3D11.Device Direct3D11Device { get; private set; } + public static SharpDX.Direct2D1.Factory1 Direct2D1Factory { get; private set; } public static SharpDX.Direct2D1.Device1 Direct2D1Device { get; private set; } @@ -88,14 +90,12 @@ namespace Avalonia.Direct2D1 SharpDX.Direct3D.FeatureLevel.Level_9_1, }; - using (var d3dDevice = new SharpDX.Direct3D11.Device( + Direct3D11Device = new SharpDX.Direct3D11.Device( SharpDX.Direct3D.DriverType.Hardware, - SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport | - SharpDX.Direct3D11.DeviceCreationFlags.VideoSupport, - featureLevels)) - { - DxgiDevice = d3dDevice.QueryInterface(); - } + SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport | SharpDX.Direct3D11.DeviceCreationFlags.VideoSupport, + featureLevels); + + DxgiDevice = Direct3D11Device.QueryInterface(); using (var device = new SharpDX.Direct2D1.Device(Direct2D1Factory, DxgiDevice)) { diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs index 5711a79c2e..b65e32bbbb 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DBitmapImpl.cs @@ -1,19 +1,20 @@ using System; using System.IO; using SharpDX.Direct2D1; -using ImageParameters = SharpDX.WIC.ImageParameters; -using ImagingFactory2 = SharpDX.WIC.ImagingFactory2; -using PngBitmapEncoder = SharpDX.WIC.PngBitmapEncoder; -using WICFactory = SharpDX.WIC.ImagingFactory; namespace Avalonia.Direct2D1.Media { + using SharpDX.WIC; + + using Bitmap = SharpDX.Direct2D1.Bitmap; + using PixelFormat = SharpDX.Direct2D1.PixelFormat; + /// /// A Direct2D Bitmap implementation that uses a GPU memory bitmap as its image. /// public class D2DBitmapImpl : BitmapImpl { - private Bitmap _direct2DBitmap; + private readonly Bitmap _direct2DBitmap; /// /// Initialize a new instance of the class @@ -29,7 +30,7 @@ namespace Avalonia.Direct2D1.Media { _direct2DBitmap = d2DBitmap ?? throw new ArgumentNullException(nameof(d2DBitmap)); } - + public override int PixelWidth => _direct2DBitmap.PixelSize.Width; public override int PixelHeight => _direct2DBitmap.PixelSize.Height; @@ -47,18 +48,12 @@ namespace Avalonia.Direct2D1.Media public override void Save(Stream stream) { using (var encoder = new PngBitmapEncoder(Direct2D1Platform.ImagingFactory, stream)) - using (var frameEncode = new SharpDX.WIC.BitmapFrameEncode(encoder)) - //ToDo: Not supported under Windows 7! - using (var imageEncoder = new SharpDX.WIC.ImageEncoder((ImagingFactory2)Direct2D1Platform.ImagingFactory, null)) + using (var frame = new BitmapFrameEncode(encoder)) + using (var bitmapSource = _direct2DBitmap.QueryInterface()) { - var parameters = new ImageParameters( - new PixelFormat(SharpDX.DXGI.Format.R8G8B8A8_UNorm, AlphaMode.Premultiplied), - _direct2DBitmap.DotsPerInch.Width, - _direct2DBitmap.DotsPerInch.Height, - 0, 0, PixelWidth, PixelHeight); - - imageEncoder.WriteFrame(_direct2DBitmap, frameEncode, parameters); - frameEncode.Commit(); + frame.Initialize(); + frame.WriteSource(bitmapSource); + frame.Commit(); encoder.Commit(); } } diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs index 7ea303345a..3646d9e9e1 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/D2DRenderTargetBitmapImpl.cs @@ -1,4 +1,7 @@ -using Avalonia.Platform; +// 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.Platform; using Avalonia.Rendering; using SharpDX; using SharpDX.Direct2D1; diff --git a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs index 075fef5ab2..5ca78ef278 100644 --- a/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs +++ b/src/Windows/Avalonia.Direct2D1/Media/Imaging/WriteableWicBitmapImpl.cs @@ -1,4 +1,7 @@ -using System; +// 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 Avalonia.Platform; using SharpDX.WIC; using PixelFormat = Avalonia.Platform.PixelFormat; From 06a4fe7312b7b7759902b855c90616797cae683a Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Thu, 6 Sep 2018 23:15:56 +0800 Subject: [PATCH 46/80] Minor fix on TransitionsEngine --- src/Avalonia.Animation/TransitionsEngine.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Animation/TransitionsEngine.cs b/src/Avalonia.Animation/TransitionsEngine.cs index 34863e4146..81b5b28820 100644 --- a/src/Avalonia.Animation/TransitionsEngine.cs +++ b/src/Avalonia.Animation/TransitionsEngine.cs @@ -16,12 +16,11 @@ namespace Avalonia.Animation public class TransitionsEngine : SingleSubscriberObservableBase { private IDisposable timerSubscription; - private readonly TimeSpan startTime; - private readonly TimeSpan duration; + private TimeSpan startTime; + private TimeSpan duration; public TransitionsEngine(TimeSpan Duration) { - startTime = Timing.GetTickCount(); duration = Duration; } @@ -46,6 +45,7 @@ namespace Avalonia.Animation protected override void Subscribed() { + startTime = Timing.GetTickCount(); timerSubscription = Timing .AnimationsTimer .Subscribe(t => TimerTick(t)); From 544d2e26c7268325fddbc58e55a912e17b60f213 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 6 Sep 2018 20:25:49 +0200 Subject: [PATCH 47/80] Fix NRE when VirtualizingStackPanel used with ItemsControl. There is no `ScrollViewer` in the template for `ItemsControl` which means that if a `VirtualizingStackPanel` is used for `ItemsControl.ItemsPanel` then `InvalidateScroll` won't be set. Just do nothing in this case. Fixes #1829. --- src/Avalonia.Controls/Presenters/ItemVirtualizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs b/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs index c5344b29d9..46da8fe3f8 100644 --- a/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs +++ b/src/Avalonia.Controls/Presenters/ItemVirtualizer.cs @@ -279,6 +279,6 @@ namespace Avalonia.Controls.Presenters /// /// Invalidates the current scroll. /// - protected void InvalidateScroll() => ((ILogicalScrollable)Owner).InvalidateScroll(); + protected void InvalidateScroll() => ((ILogicalScrollable)Owner).InvalidateScroll?.Invoke(); } } From a0d2d7f70b4cccf2984c317a48b66040f003521a Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 7 Sep 2018 01:48:57 +0200 Subject: [PATCH 48/80] Added failing test for #1865. And similar test for Grid. --- .../DockPanelTests.cs | 24 +++++++++++++++++ .../Avalonia.Controls.UnitTests/GridTests.cs | 26 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/DockPanelTests.cs b/tests/Avalonia.Controls.UnitTests/DockPanelTests.cs index 3de67839a7..59f047abae 100644 --- a/tests/Avalonia.Controls.UnitTests/DockPanelTests.cs +++ b/tests/Avalonia.Controls.UnitTests/DockPanelTests.cs @@ -58,5 +58,29 @@ namespace Avalonia.Controls.UnitTests Assert.Equal(new Rect(50, 350, 500, 50), target.Children[3].Bounds); Assert.Equal(new Rect(50, 50, 500, 300), target.Children[4].Bounds); } + + [Fact] + public void Changing_Child_Dock_Invalidates_Measure() + { + Border child; + var target = new DockPanel + { + Children = + { + (child = new Border + { + [DockPanel.DockProperty] = Dock.Left, + }), + } + }; + + target.Measure(Size.Infinity); + target.Arrange(new Rect(target.DesiredSize)); + Assert.True(target.IsMeasureValid); + + DockPanel.SetDock(child, Dock.Right); + + Assert.False(target.IsMeasureValid); + } } } diff --git a/tests/Avalonia.Controls.UnitTests/GridTests.cs b/tests/Avalonia.Controls.UnitTests/GridTests.cs index 4c79b7775b..5799cb91c4 100644 --- a/tests/Avalonia.Controls.UnitTests/GridTests.cs +++ b/tests/Avalonia.Controls.UnitTests/GridTests.cs @@ -154,5 +154,31 @@ namespace Avalonia.Controls.UnitTests GridAssert.ChildrenHeight(rowGrid, 200, 300, 300); GridAssert.ChildrenWidth(columnGrid, 200, 300, 300); } + + [Fact] + public void Changing_Child_Column_Invalidates_Measure() + { + Border child; + var target = new Grid + { + ColumnDefinitions = new ColumnDefinitions("*,*"), + Children = + { + (child = new Border + { + [Grid.ColumnProperty] = 0, + }), + } + }; + + target.Measure(Size.Infinity); + target.Arrange(new Rect(target.DesiredSize)); + Assert.True(target.IsMeasureValid); + + Grid.SetColumn(child, 1); + + Assert.False(target.IsMeasureValid); + } + } } From a6a80c205ce351cfa8d61905b4b69cec050a1e62 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 7 Sep 2018 01:50:30 +0200 Subject: [PATCH 49/80] Make attached panel properties invalidate parent layout. Fixes #1865. --- src/Avalonia.Controls/Canvas.cs | 26 +----------------- src/Avalonia.Controls/DockPanel.cs | 4 +-- src/Avalonia.Controls/Grid.cs | 5 ++++ src/Avalonia.Controls/Panel.cs | 42 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/Avalonia.Controls/Canvas.cs b/src/Avalonia.Controls/Canvas.cs index 5c9a97cb27..e16a0b074b 100644 --- a/src/Avalonia.Controls/Canvas.cs +++ b/src/Avalonia.Controls/Canvas.cs @@ -48,7 +48,7 @@ namespace Avalonia.Controls static Canvas() { ClipToBoundsProperty.OverrideDefaultValue(false); - AffectsCanvasArrange(LeftProperty, TopProperty, RightProperty, BottomProperty); + AffectsParentArrange(LeftProperty, TopProperty, RightProperty, BottomProperty); } /// @@ -207,29 +207,5 @@ namespace Avalonia.Controls return finalSize; } - - /// - /// Marks a property on a child as affecting the canvas' arrangement. - /// - /// The properties. - private static void AffectsCanvasArrange(params AvaloniaProperty[] properties) - { - foreach (var property in properties) - { - property.Changed.Subscribe(AffectsCanvasArrangeInvalidate); - } - } - - /// - /// Calls on the parent of the control whose - /// property changed, if that parent is a canvas. - /// - /// The event args. - private static void AffectsCanvasArrangeInvalidate(AvaloniaPropertyChangedEventArgs e) - { - var control = e.Sender as IControl; - var canvas = control?.VisualParent as Canvas; - canvas?.InvalidateArrange(); - } } } diff --git a/src/Avalonia.Controls/DockPanel.cs b/src/Avalonia.Controls/DockPanel.cs index 66e84c1110..e147fe1a52 100644 --- a/src/Avalonia.Controls/DockPanel.cs +++ b/src/Avalonia.Controls/DockPanel.cs @@ -37,7 +37,7 @@ namespace Avalonia.Controls /// static DockPanel() { - AffectsArrange(DockProperty); + AffectsParentMeasure(DockProperty); } /// @@ -173,4 +173,4 @@ namespace Avalonia.Controls return arrangeSize; } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs index 5f194bdd71..1a07ccaf7e 100644 --- a/src/Avalonia.Controls/Grid.cs +++ b/src/Avalonia.Controls/Grid.cs @@ -48,6 +48,11 @@ namespace Avalonia.Controls private RowDefinitions _rowDefinitions; + static Grid() + { + AffectsParentMeasure(ColumnProperty, ColumnSpanProperty, RowProperty, RowSpanProperty); + } + /// /// Gets or sets the columns definitions for the grid. /// diff --git a/src/Avalonia.Controls/Panel.cs b/src/Avalonia.Controls/Panel.cs index a2cb013300..c0d211effb 100644 --- a/src/Avalonia.Controls/Panel.cs +++ b/src/Avalonia.Controls/Panel.cs @@ -72,6 +72,32 @@ namespace Avalonia.Controls base.Render(context); } + /// + /// Marks a property on a child as affecting the parent panel's arrangement. + /// + /// The properties. + protected static void AffectsParentArrange(params AvaloniaProperty[] properties) + where TPanel : class, IPanel + { + foreach (var property in properties) + { + property.Changed.Subscribe(AffectsParentArrangeInvalidate); + } + } + + /// + /// Marks a property on a child as affecting the parent panel's measurement. + /// + /// The properties. + protected static void AffectsParentMeasure(params AvaloniaProperty[] properties) + where TPanel : class, IPanel + { + foreach (var property in properties) + { + property.Changed.Subscribe(AffectsParentMeasureInvalidate); + } + } + /// /// Called when the collection changes. /// @@ -116,5 +142,21 @@ namespace Avalonia.Controls InvalidateMeasure(); } + + private static void AffectsParentArrangeInvalidate(AvaloniaPropertyChangedEventArgs e) + where TPanel : class, IPanel + { + var control = e.Sender as IControl; + var panel = control?.VisualParent as TPanel; + panel?.InvalidateArrange(); + } + + private static void AffectsParentMeasureInvalidate(AvaloniaPropertyChangedEventArgs e) + where TPanel : class, IPanel + { + var control = e.Sender as IControl; + var panel = control?.VisualParent as TPanel; + panel?.InvalidateMeasure(); + } } } From fad2e317ba413b0624de7600ebc1bdeaa02a3272 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 7 Sep 2018 02:13:57 +0200 Subject: [PATCH 50/80] Make AffectsMeasure/Arrange/Render typed. --- src/Avalonia.Controls/Border.cs | 4 ++-- src/Avalonia.Controls/Decorator.cs | 2 +- src/Avalonia.Controls/DrawingPresenter.cs | 6 ++--- src/Avalonia.Controls/Image.cs | 3 +-- .../Presenters/ContentPresenter.cs | 4 ++-- .../Presenters/ScrollContentPresenter.cs | 2 +- .../Presenters/TextPresenter.cs | 2 +- .../Primitives/AccessText.cs | 2 +- src/Avalonia.Controls/Primitives/Track.cs | 2 +- src/Avalonia.Controls/Shapes/Shape.cs | 5 ++--- src/Avalonia.Controls/StackPanel.cs | 4 ++-- src/Avalonia.Controls/TabControl.cs | 2 +- src/Avalonia.Controls/TextBlock.cs | 9 ++++---- src/Avalonia.Controls/TopLevel.cs | 2 +- src/Avalonia.Controls/WrapPanel.cs | 2 +- src/Avalonia.Layout/Layoutable.cs | 22 +++++++++++-------- src/Avalonia.Visuals/Visual.cs | 12 +++++----- 17 files changed, 45 insertions(+), 40 deletions(-) diff --git a/src/Avalonia.Controls/Border.cs b/src/Avalonia.Controls/Border.cs index 5f84421c64..8b2a45b090 100644 --- a/src/Avalonia.Controls/Border.cs +++ b/src/Avalonia.Controls/Border.cs @@ -43,8 +43,8 @@ namespace Avalonia.Controls /// static Border() { - AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty, CornerRadiusProperty); - AffectsMeasure(BorderThicknessProperty); + AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty, CornerRadiusProperty); + AffectsMeasure(BorderThicknessProperty); } /// diff --git a/src/Avalonia.Controls/Decorator.cs b/src/Avalonia.Controls/Decorator.cs index 389cf66d34..15651b918e 100644 --- a/src/Avalonia.Controls/Decorator.cs +++ b/src/Avalonia.Controls/Decorator.cs @@ -28,7 +28,7 @@ namespace Avalonia.Controls /// static Decorator() { - AffectsMeasure(ChildProperty, PaddingProperty); + AffectsMeasure(ChildProperty, PaddingProperty); ChildProperty.Changed.AddClassHandler(x => x.ChildChanged); } diff --git a/src/Avalonia.Controls/DrawingPresenter.cs b/src/Avalonia.Controls/DrawingPresenter.cs index af3665fabc..34ce598218 100644 --- a/src/Avalonia.Controls/DrawingPresenter.cs +++ b/src/Avalonia.Controls/DrawingPresenter.cs @@ -8,8 +8,8 @@ namespace Avalonia.Controls { static DrawingPresenter() { - AffectsMeasure(DrawingProperty); - AffectsRender(DrawingProperty); + AffectsMeasure(DrawingProperty); + AffectsRender(DrawingProperty); } public static readonly StyledProperty DrawingProperty = @@ -56,4 +56,4 @@ namespace Avalonia.Controls } } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Controls/Image.cs b/src/Avalonia.Controls/Image.cs index f146e3571c..802b700a07 100644 --- a/src/Avalonia.Controls/Image.cs +++ b/src/Avalonia.Controls/Image.cs @@ -25,8 +25,7 @@ namespace Avalonia.Controls static Image() { - AffectsRender(SourceProperty); - AffectsRender(StretchProperty); + AffectsRender(SourceProperty, StretchProperty); } /// diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index 6badf91367..8d703cfc1c 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -90,8 +90,8 @@ namespace Avalonia.Controls.Presenters /// static ContentPresenter() { - AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty, CornerRadiusProperty); - AffectsMeasure(BorderThicknessProperty, PaddingProperty); + AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty, CornerRadiusProperty); + AffectsMeasure(BorderThicknessProperty, PaddingProperty); ContentProperty.Changed.AddClassHandler(x => x.ContentChanged); ContentTemplateProperty.Changed.AddClassHandler(x => x.ContentChanged); TemplatedParentProperty.Changed.AddClassHandler(x => x.TemplatedParentChanged); diff --git a/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs b/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs index 2ef7941b55..c05c1672f8 100644 --- a/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs @@ -72,7 +72,7 @@ namespace Avalonia.Controls.Presenters { ClipToBoundsProperty.OverrideDefaultValue(typeof(ScrollContentPresenter), true); ChildProperty.Changed.AddClassHandler(x => x.ChildChanged); - AffectsArrange(OffsetProperty); + AffectsArrange(OffsetProperty); } /// diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index a30d9bfc48..f73a335de5 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -38,7 +38,7 @@ namespace Avalonia.Controls.Presenters static TextPresenter() { - AffectsRender(PasswordCharProperty); + AffectsRender(PasswordCharProperty); } public TextPresenter() diff --git a/src/Avalonia.Controls/Primitives/AccessText.cs b/src/Avalonia.Controls/Primitives/AccessText.cs index 32a0efc440..5adc8d2448 100644 --- a/src/Avalonia.Controls/Primitives/AccessText.cs +++ b/src/Avalonia.Controls/Primitives/AccessText.cs @@ -28,7 +28,7 @@ namespace Avalonia.Controls.Primitives /// static AccessText() { - AffectsRender(ShowAccessKeyProperty); + AffectsRender(ShowAccessKeyProperty); } /// diff --git a/src/Avalonia.Controls/Primitives/Track.cs b/src/Avalonia.Controls/Primitives/Track.cs index 648fe5f4b0..8ff3ced770 100644 --- a/src/Avalonia.Controls/Primitives/Track.cs +++ b/src/Avalonia.Controls/Primitives/Track.cs @@ -42,7 +42,7 @@ namespace Avalonia.Controls.Primitives ThumbProperty.Changed.AddClassHandler(x => x.ThumbChanged); IncreaseButtonProperty.Changed.AddClassHandler(x => x.ButtonChanged); DecreaseButtonProperty.Changed.AddClassHandler(x => x.ButtonChanged); - AffectsArrange(MinimumProperty, MaximumProperty, ValueProperty, OrientationProperty); + AffectsArrange(MinimumProperty, MaximumProperty, ValueProperty, OrientationProperty); } public double Minimum diff --git a/src/Avalonia.Controls/Shapes/Shape.cs b/src/Avalonia.Controls/Shapes/Shape.cs index 604051ef28..f77c43acd0 100644 --- a/src/Avalonia.Controls/Shapes/Shape.cs +++ b/src/Avalonia.Controls/Shapes/Shape.cs @@ -30,11 +30,10 @@ namespace Avalonia.Controls.Shapes private Geometry _renderedGeometry; bool _calculateTransformOnArrange = false; - static Shape() { - AffectsMeasure(StretchProperty, StrokeThicknessProperty); - AffectsRender(FillProperty, StrokeProperty, StrokeDashArrayProperty); + AffectsMeasure(StretchProperty, StrokeThicknessProperty); + AffectsRender(FillProperty, StrokeProperty, StrokeDashArrayProperty); } public Geometry DefiningGeometry diff --git a/src/Avalonia.Controls/StackPanel.cs b/src/Avalonia.Controls/StackPanel.cs index 645cdbd926..df0c113cc0 100644 --- a/src/Avalonia.Controls/StackPanel.cs +++ b/src/Avalonia.Controls/StackPanel.cs @@ -29,8 +29,8 @@ namespace Avalonia.Controls /// static StackPanel() { - AffectsMeasure(SpacingProperty); - AffectsMeasure(OrientationProperty); + AffectsMeasure(SpacingProperty); + AffectsMeasure(OrientationProperty); } /// diff --git a/src/Avalonia.Controls/TabControl.cs b/src/Avalonia.Controls/TabControl.cs index 70cf8b4e05..3aae256858 100644 --- a/src/Avalonia.Controls/TabControl.cs +++ b/src/Avalonia.Controls/TabControl.cs @@ -44,7 +44,7 @@ namespace Avalonia.Controls { SelectionModeProperty.OverrideDefaultValue(SelectionMode.AlwaysSelected); FocusableProperty.OverrideDefaultValue(false); - AffectsMeasure(TabStripPlacementProperty); + AffectsMeasure(TabStripPlacementProperty); } /// diff --git a/src/Avalonia.Controls/TextBlock.cs b/src/Avalonia.Controls/TextBlock.cs index e91d2e8fa7..541e55625a 100644 --- a/src/Avalonia.Controls/TextBlock.cs +++ b/src/Avalonia.Controls/TextBlock.cs @@ -99,10 +99,11 @@ namespace Avalonia.Controls static TextBlock() { ClipToBoundsProperty.OverrideDefaultValue(true); - AffectsRender(ForegroundProperty); - AffectsRender(FontWeightProperty); - AffectsRender(FontSizeProperty); - AffectsRender(FontStyleProperty); + AffectsRender( + ForegroundProperty, + FontWeightProperty, + FontSizeProperty, + FontStyleProperty); } /// diff --git a/src/Avalonia.Controls/TopLevel.cs b/src/Avalonia.Controls/TopLevel.cs index 1161ded25f..5f8eac1fe3 100644 --- a/src/Avalonia.Controls/TopLevel.cs +++ b/src/Avalonia.Controls/TopLevel.cs @@ -59,7 +59,7 @@ namespace Avalonia.Controls /// static TopLevel() { - AffectsMeasure(ClientSizeProperty); + AffectsMeasure(ClientSizeProperty); } /// diff --git a/src/Avalonia.Controls/WrapPanel.cs b/src/Avalonia.Controls/WrapPanel.cs index 8ee0636124..597734d400 100644 --- a/src/Avalonia.Controls/WrapPanel.cs +++ b/src/Avalonia.Controls/WrapPanel.cs @@ -30,7 +30,7 @@ namespace Avalonia.Controls /// static WrapPanel() { - AffectsMeasure(OrientationProperty); + AffectsMeasure(OrientationProperty); } /// diff --git a/src/Avalonia.Layout/Layoutable.cs b/src/Avalonia.Layout/Layoutable.cs index 54bdbb5d48..b8b24e6d31 100644 --- a/src/Avalonia.Layout/Layoutable.cs +++ b/src/Avalonia.Layout/Layoutable.cs @@ -140,7 +140,7 @@ namespace Avalonia.Layout /// static Layoutable() { - AffectsMeasure( + AffectsMeasure( IsVisibleProperty, WidthProperty, HeightProperty, @@ -427,11 +427,12 @@ namespace Avalonia.Layout /// After a call to this method in a control's static constructor, any change to the /// property will cause to be called on the element. /// - protected static void AffectsMeasure(params AvaloniaProperty[] properties) + protected static void AffectsMeasure(params AvaloniaProperty[] properties) + where T : class, ILayoutable { foreach (var property in properties) { - property.Changed.Subscribe(AffectsMeasureInvalidate); + property.Changed.Subscribe(AffectsMeasureInvalidate); } } @@ -443,11 +444,12 @@ namespace Avalonia.Layout /// After a call to this method in a control's static constructor, any change to the /// property will cause to be called on the element. /// - protected static void AffectsArrange(params AvaloniaProperty[] properties) + protected static void AffectsArrange(params AvaloniaProperty[] properties) + where T : class, ILayoutable { foreach (var property in properties) { - property.Changed.Subscribe(AffectsArrangeInvalidate); + property.Changed.Subscribe(AffectsArrangeInvalidate); } } @@ -636,9 +638,10 @@ namespace Avalonia.Layout /// Calls on the control on which a property changed. /// /// The event args. - private static void AffectsMeasureInvalidate(AvaloniaPropertyChangedEventArgs e) + private static void AffectsMeasureInvalidate(AvaloniaPropertyChangedEventArgs e) + where T : class, ILayoutable { - ILayoutable control = e.Sender as ILayoutable; + var control = e.Sender as T; control?.InvalidateMeasure(); } @@ -646,9 +649,10 @@ namespace Avalonia.Layout /// Calls on the control on which a property changed. /// /// The event args. - private static void AffectsArrangeInvalidate(AvaloniaPropertyChangedEventArgs e) + private static void AffectsArrangeInvalidate(AvaloniaPropertyChangedEventArgs e) + where T : class, ILayoutable { - ILayoutable control = e.Sender as ILayoutable; + var control = e.Sender as T; control?.InvalidateArrange(); } diff --git a/src/Avalonia.Visuals/Visual.cs b/src/Avalonia.Visuals/Visual.cs index 81e1a93a6f..c2db20306e 100644 --- a/src/Avalonia.Visuals/Visual.cs +++ b/src/Avalonia.Visuals/Visual.cs @@ -100,7 +100,7 @@ namespace Avalonia /// static Visual() { - AffectsRender( + AffectsRender( BoundsProperty, ClipProperty, ClipToBoundsProperty, @@ -320,11 +320,12 @@ namespace Avalonia /// on the control which when changed should cause a redraw. This is similar to WPF's /// FrameworkPropertyMetadata.AffectsRender flag. /// - protected static void AffectsRender(params AvaloniaProperty[] properties) + protected static void AffectsRender(params AvaloniaProperty[] properties) + where T : class, IVisual { foreach (var property in properties) { - property.Changed.Subscribe(AffectsRenderInvalidate); + property.Changed.Subscribe(AffectsRenderInvalidate); } } @@ -416,9 +417,10 @@ namespace Avalonia /// Called when a property changes that should invalidate the visual. /// /// The event args. - private static void AffectsRenderInvalidate(AvaloniaPropertyChangedEventArgs e) + private static void AffectsRenderInvalidate(AvaloniaPropertyChangedEventArgs e) + where T : class, IVisual { - (e.Sender as Visual)?.InvalidateVisual(); + (e.Sender as T)?.InvalidateVisual(); } /// From 576cc915731892c2c6f55b928ed0588d5ecac889 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 7 Sep 2018 02:30:00 +0200 Subject: [PATCH 51/80] Make Pseudoclass method typed. --- src/Avalonia.Controls/Button.cs | 2 +- src/Avalonia.Controls/ButtonSpinner.cs | 6 +++--- src/Avalonia.Controls/ContentControl.cs | 4 ++-- src/Avalonia.Controls/Expander.cs | 10 +++++----- src/Avalonia.Controls/Primitives/ScrollBar.cs | 4 ++-- .../Primitives/ToggleButton.cs | 6 +++--- src/Avalonia.Controls/Primitives/Track.cs | 2 ++ src/Avalonia.Controls/ProgressBar.cs | 6 +++--- src/Avalonia.Controls/Slider.cs | 2 ++ src/Avalonia.Input/InputElement.cs | 6 +++--- src/Avalonia.Styling/StyledElement.cs | 20 +++++++++++-------- 11 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs index fa69d72d67..24b2af7996 100644 --- a/src/Avalonia.Controls/Button.cs +++ b/src/Avalonia.Controls/Button.cs @@ -80,7 +80,7 @@ namespace Avalonia.Controls FocusableProperty.OverrideDefaultValue(typeof(Button), true); CommandProperty.Changed.Subscribe(CommandChanged); IsDefaultProperty.Changed.Subscribe(IsDefaultChanged); - PseudoClass(IsPressedProperty, ":pressed"); + PseudoClass