Browse Source

Merge branch 'master' into spell_other_avalonia

pull/1859/head
Steven Kirk 8 years ago
committed by GitHub
parent
commit
2366975d11
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/Avalonia.Base/Threading/Dispatcher.cs
  2. 18
      src/Avalonia.Base/Threading/IDispatcher.cs
  3. 8
      src/Avalonia.Controls/Presenters/TextPresenter.cs
  4. 8
      src/Avalonia.Controls/Slider.cs
  5. 19
      tests/Avalonia.UnitTests/ImmediateDispatcher.cs

14
src/Avalonia.Base/Threading/Dispatcher.cs

@ -92,6 +92,20 @@ namespace Avalonia.Threading
return _jobRunner.InvokeAsync(function, priority);
}
/// <inheritdoc/>
public Task InvokeAsync(Func<Task> function, DispatcherPriority priority = DispatcherPriority.Normal)
{
Contract.Requires<ArgumentNullException>(function != null);
return _jobRunner.InvokeAsync(function, priority).Unwrap();
}
/// <inheritdoc/>
public Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> function, DispatcherPriority priority = DispatcherPriority.Normal)
{
Contract.Requires<ArgumentNullException>(function != null);
return _jobRunner.InvokeAsync(function, priority).Unwrap();
}
/// <inheritdoc/>
public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{

18
src/Avalonia.Base/Threading/IDispatcher.cs

@ -40,5 +40,23 @@ namespace Avalonia.Threading
/// <param name="function">The method.</param>
/// <param name="priority">The priority with which to invoke the method.</param>
Task<TResult> InvokeAsync<TResult>(Func<TResult> function, DispatcherPriority priority = DispatcherPriority.Normal);
/// <summary>
/// Queues the specified work to run on the dispatcher thread and returns a proxy for the
/// task returned by <paramref name="function"/>.
/// </summary>
/// <param name="function">The work to execute asynchronously.</param>
/// <param name="priority">The priority with which to invoke the method.</param>
/// <returns>A task that represents a proxy for the task returned by <paramref name="function"/>.</returns>
Task InvokeAsync(Func<Task> function, DispatcherPriority priority = DispatcherPriority.Normal);
/// <summary>
/// Queues the specified work to run on the dispatcher thread and returns a proxy for the
/// task returned by <paramref name="function"/>.
/// </summary>
/// <param name="function">The work to execute asynchronously.</param>
/// <param name="priority">The priority with which to invoke the method.</param>
/// <returns>A task that represents a proxy for the task returned by <paramref name="function"/>.</returns>
Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> function, DispatcherPriority priority = DispatcherPriority.Normal);
}
}

8
src/Avalonia.Controls/Presenters/TextPresenter.cs

@ -35,6 +35,11 @@ namespace Avalonia.Controls.Presenters
private int _selectionEnd;
private bool _caretBlink;
private IBrush _highlightBrush;
static TextPresenter()
{
AffectsRender(PasswordCharProperty);
}
public TextPresenter()
{
@ -49,6 +54,9 @@ namespace Avalonia.Controls.Presenters
this.GetObservable(CaretIndexProperty)
.Subscribe(CaretIndexChanged);
this.GetObservable(PasswordCharProperty)
.Subscribe(_ => InvalidateFormattedText());
}
public int CaretIndex

8
src/Avalonia.Controls/Slider.cs

@ -171,11 +171,7 @@ namespace Avalonia.Controls
/// <param name="value">Value that want to snap to closest Tick.</param>
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)));
}
/// <summary>
@ -194,4 +190,4 @@ namespace Avalonia.Controls
return value;
}
}
}
}

19
tests/Avalonia.UnitTests/ImmediateDispatcher.cs

@ -9,28 +9,45 @@ namespace Avalonia.UnitTests
/// </summary>
public class ImmediateDispatcher : IDispatcher
{
/// <inheritdoc/>
public bool CheckAccess()
{
return true;
}
/// <inheritdoc/>
public void Post(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
action();
}
/// <inheritdoc/>
public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
action();
return Task.FromResult<object>(null);
return Task.CompletedTask;
}
/// <inheritdoc/>
public Task<TResult> InvokeAsync<TResult>(Func<TResult> function, DispatcherPriority priority = DispatcherPriority.Normal)
{
var result = function();
return Task.FromResult(result);
}
/// <inheritdoc/>
public Task InvokeAsync(Func<Task> function, DispatcherPriority priority = DispatcherPriority.Normal)
{
return function();
}
/// <inheritdoc/>
public Task<TResult> InvokeAsync<TResult>(Func<Task<TResult>> function, DispatcherPriority priority = DispatcherPriority.Normal)
{
return function();
}
/// <inheritdoc/>
public void VerifyAccess()
{
}

Loading…
Cancel
Save