committed by
GitHub
42 changed files with 700 additions and 301 deletions
@ -0,0 +1,5 @@ |
|||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="reactiveui" Version="8.0.0-alpha0073" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -1,11 +1,10 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="System.Reactive" Version="3.0.0" /> |
<PackageReference Include="System.Reactive" Version="3.1.1" /> |
||||
<PackageReference Include="System.Reactive.Core" Version="3.0.0" /> |
<PackageReference Include="System.Reactive.Core" Version="3.1.1" /> |
||||
<PackageReference Include="System.Reactive.Interfaces" Version="3.0.0" /> |
<PackageReference Include="System.Reactive.Interfaces" Version="3.1.1" /> |
||||
<PackageReference Include="System.Reactive.Linq" Version="3.0.0" /> |
<PackageReference Include="System.Reactive.Linq" Version="3.1.1" /> |
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="3.0.0" /> |
<PackageReference Include="System.Reactive.PlatformServices" Version="3.1.1" /> |
||||
<PackageReference Condition="'$(TargetFramework)' == 'net45'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
<PackageReference Condition="$(TargetFramework.StartsWith('net4'))" Include="System.Reactive.Windows.Threading" Version="3.1.1" /> |
||||
<PackageReference Condition="'$(TargetFramework)' == 'net461'" Include="System.Reactive.Windows.Threading" Version="3.0.0" /> |
|
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,82 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Input; |
||||
|
using Avalonia.Threading; |
||||
|
|
||||
|
namespace Avalonia.Controls |
||||
|
{ |
||||
|
public class RepeatButton : Button |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Defines the <see cref="Delay"/> property.
|
||||
|
/// </summary>
|
||||
|
public static readonly StyledProperty<int> DelayProperty = |
||||
|
AvaloniaProperty.Register<Button, int>(nameof(Delay), 100); |
||||
|
|
||||
|
private DispatcherTimer _repeatTimer; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the amount of time, in milliseconds, of repeating clicks.
|
||||
|
/// </summary>
|
||||
|
public int Delay |
||||
|
{ |
||||
|
get { return GetValue(DelayProperty); } |
||||
|
set { SetValue(DelayProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private void StartTimer() |
||||
|
{ |
||||
|
if (_repeatTimer == null) |
||||
|
{ |
||||
|
_repeatTimer = new DispatcherTimer(); |
||||
|
_repeatTimer.Tick += (o, e) => OnClick(); |
||||
|
} |
||||
|
|
||||
|
if (_repeatTimer.IsEnabled) return; |
||||
|
|
||||
|
_repeatTimer.Interval = TimeSpan.FromMilliseconds(Delay); |
||||
|
_repeatTimer.Start(); |
||||
|
} |
||||
|
|
||||
|
private void StopTimer() |
||||
|
{ |
||||
|
_repeatTimer?.Stop(); |
||||
|
} |
||||
|
|
||||
|
protected override void OnKeyDown(KeyEventArgs e) |
||||
|
{ |
||||
|
base.OnKeyDown(e); |
||||
|
|
||||
|
if (e.Key == Key.Space) |
||||
|
{ |
||||
|
StartTimer(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected override void OnKeyUp(KeyEventArgs e) |
||||
|
{ |
||||
|
base.OnKeyUp(e); |
||||
|
|
||||
|
StopTimer(); |
||||
|
} |
||||
|
|
||||
|
protected override void OnPointerPressed(PointerPressedEventArgs e) |
||||
|
{ |
||||
|
base.OnPointerPressed(e); |
||||
|
|
||||
|
if (e.MouseButton == MouseButton.Left) |
||||
|
{ |
||||
|
StartTimer(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected override void OnPointerReleased(PointerReleasedEventArgs e) |
||||
|
{ |
||||
|
base.OnPointerReleased(e); |
||||
|
|
||||
|
if (e.MouseButton == MouseButton.Left) |
||||
|
{ |
||||
|
StopTimer(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Threading; |
||||
|
using ReactiveUI; |
||||
|
using System; |
||||
|
using System.Reactive.Concurrency; |
||||
|
using System.Threading; |
||||
|
|
||||
|
namespace Avalonia |
||||
|
{ |
||||
|
public static class AppBuilderExtensions |
||||
|
{ |
||||
|
public static TAppBuilder UseReactiveUI<TAppBuilder>(this TAppBuilder builder) |
||||
|
where TAppBuilder : AppBuilderBase<TAppBuilder>, new() |
||||
|
{ |
||||
|
return builder.AfterSetup(_ => |
||||
|
{ |
||||
|
RxApp.MainThreadScheduler = AvaloniaScheduler.Instance; |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,23 +0,0 @@ |
|||||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
||||
|
|
||||
using System; |
|
||||
using System.Reactive.Concurrency; |
|
||||
using System.Threading; |
|
||||
|
|
||||
|
|
||||
namespace ReactiveUI |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Ignore me. This class is a secret handshake between RxUI and RxUI.Xaml
|
|
||||
/// in order to register certain classes on startup that would be difficult
|
|
||||
/// to register otherwise.
|
|
||||
/// </summary>
|
|
||||
public class PlatformRegistrations : IWantsToRegisterStuff |
|
||||
{ |
|
||||
public void Register(Action<Func<object>, Type> registerFunction) |
|
||||
{ |
|
||||
RxApp.MainThreadScheduler = new SynchronizationContextScheduler(SynchronizationContext.Current); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,34 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Text; |
|
||||
|
|
||||
namespace System.Runtime.Serialization |
|
||||
{ |
|
||||
class IgnoreDataMemberAttribute : Attribute |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
class DataMemberAttribute : Attribute |
|
||||
{ |
|
||||
} |
|
||||
class OnDeserializedAttribute : Attribute |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
class DataContractAttribute : Attribute |
|
||||
{ |
|
||||
} |
|
||||
|
|
||||
class StreamingContext { } |
|
||||
} |
|
||||
|
|
||||
namespace System.Diagnostics.Contracts |
|
||||
{ |
|
||||
static class Contract |
|
||||
{ |
|
||||
public static void Requires(bool condition) |
|
||||
{ |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 3f725c808b1d4c8457f0d3204e0a071aa462cd75 |
|
||||
@ -0,0 +1,44 @@ |
|||||
|
<Styles xmlns="https://github.com/avaloniaui"> |
||||
|
<Style Selector="RepeatButton"> |
||||
|
<Setter Property="Background" |
||||
|
Value="{StyleResource ThemeControlMidBrush}" /> |
||||
|
<Setter Property="BorderBrush" |
||||
|
Value="{StyleResource ThemeBorderLightBrush}" /> |
||||
|
<Setter Property="BorderThickness" |
||||
|
Value="{StyleResource ThemeBorderThickness}" /> |
||||
|
<Setter Property="Foreground" |
||||
|
Value="{StyleResource ThemeForegroundBrush}" /> |
||||
|
<Setter Property="HorizontalContentAlignment" |
||||
|
Value="Center" /> |
||||
|
<Setter Property="VerticalContentAlignment" |
||||
|
Value="Center" /> |
||||
|
<Setter Property="Padding" |
||||
|
Value="4" /> |
||||
|
<Setter Property="Template"> |
||||
|
<ControlTemplate> |
||||
|
<ContentPresenter Name="PART_ContentPresenter" |
||||
|
Background="{TemplateBinding Background}" |
||||
|
BorderBrush="{TemplateBinding BorderBrush}" |
||||
|
BorderThickness="{TemplateBinding BorderThickness}" |
||||
|
Content="{TemplateBinding Content}" |
||||
|
ContentTemplate="{TemplateBinding ContentTemplate}" |
||||
|
Padding="{TemplateBinding Padding}" |
||||
|
TextBlock.Foreground="{TemplateBinding Foreground}" |
||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="RepeatButton:pointerover /template/ ContentPresenter"> |
||||
|
<Setter Property="BorderBrush" |
||||
|
Value="{StyleResource ThemeBorderMidBrush}" /> |
||||
|
</Style> |
||||
|
<Style Selector="RepeatButton:pressed /template/ ContentPresenter"> |
||||
|
<Setter Property="Background" |
||||
|
Value="{StyleResource ThemeControlDarkBrush}" /> |
||||
|
</Style> |
||||
|
<Style Selector="RepeatButton:disabled"> |
||||
|
<Setter Property="Opacity" |
||||
|
Value="{StyleResource ThemeDisabledOpacity}" /> |
||||
|
</Style> |
||||
|
</Styles> |
||||
@ -1,35 +1,127 @@ |
|||||
<Styles xmlns="https://github.com/avaloniaui"> |
<Styles xmlns="https://github.com/avaloniaui"> |
||||
<Style Selector="ScrollBar"> |
<Style Selector="ScrollBar"> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<Border Background="{StyleResource ThemeControlMidBrush}"> |
<Border Background="{StyleResource ThemeControlMidBrush}"> |
||||
<Track Minimum="{TemplateBinding Minimum}" |
<Grid RowDefinitions="10,*,10"> |
||||
Maximum="{TemplateBinding Maximum}" |
<RepeatButton Name="PART_LineUpButton" |
||||
Value="{TemplateBinding Path=Value, Mode=TwoWay}" |
Classes="repeat" |
||||
ViewportSize="{TemplateBinding ViewportSize}" |
Grid.Row="0" |
||||
Orientation="{TemplateBinding Orientation}"> |
Grid.Column="0"> |
||||
<Thumb Name="thumb"> |
<Path Data="M 0,4 C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4 z" |
||||
<Thumb.Template> |
Stretch="Uniform" |
||||
<ControlTemplate> |
Fill="Gray" /> |
||||
<Border Background="{StyleResource ThemeControlDarkBrush}"/> |
</RepeatButton> |
||||
</ControlTemplate> |
<Track Grid.Row="1" |
||||
</Thumb.Template> |
Grid.Column="1" |
||||
</Thumb> |
Minimum="{TemplateBinding Minimum}" |
||||
</Track> |
Maximum="{TemplateBinding Maximum}" |
||||
</Border> |
Value="{TemplateBinding Path=Value, Mode=TwoWay}" |
||||
</ControlTemplate> |
ViewportSize="{TemplateBinding ViewportSize}" |
||||
</Setter> |
Orientation="{TemplateBinding Orientation}"> |
||||
</Style> |
<Track.DecreaseButton> |
||||
<Style Selector="ScrollBar:horizontal"> |
<RepeatButton Name="PART_PageUpButton" |
||||
<Setter Property="Height" Value="10"/> |
Classes="repeattrack" /> |
||||
</Style> |
</Track.DecreaseButton> |
||||
<Style Selector="ScrollBar:horizontal /template/ Thumb#thumb"> |
<Track.IncreaseButton> |
||||
<Setter Property="MinWidth" Value="10"/> |
<RepeatButton Name="PART_PageDownButton" |
||||
</Style> |
Classes="repeattrack" /> |
||||
<Style Selector="ScrollBar:vertical"> |
</Track.IncreaseButton> |
||||
<Setter Property="Width" Value="10"/> |
<Thumb Name="thumb"> |
||||
</Style> |
<Thumb.Template> |
||||
<Style Selector="ScrollBar:vertical /template/ Thumb#thumb"> |
<ControlTemplate> |
||||
<Setter Property="MinHeight" Value="10"/> |
<Border Background="{StyleResource ThemeControlDarkBrush}" /> |
||||
</Style> |
</ControlTemplate> |
||||
|
</Thumb.Template> |
||||
|
</Thumb> |
||||
|
</Track> |
||||
|
<RepeatButton Name="PART_LineDownButton" |
||||
|
Classes="repeat" |
||||
|
Grid.Row="2" |
||||
|
Grid.Column="2"> |
||||
|
<Path Data="M 0,2.5 C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5 z" |
||||
|
Stretch="Uniform" |
||||
|
Fill="Gray" /> |
||||
|
</RepeatButton> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ScrollBar:horizontal"> |
||||
|
<Setter Property="Height" |
||||
|
Value="10" /> |
||||
|
<Setter Property="Template"> |
||||
|
<ControlTemplate> |
||||
|
<Border Background="{StyleResource ThemeControlMidBrush}"> |
||||
|
<Grid ColumnDefinitions="10,*,10"> |
||||
|
<RepeatButton Name="PART_LineUpButton" |
||||
|
Classes="repeat" |
||||
|
Grid.Row="0" |
||||
|
Grid.Column="0"> |
||||
|
<Path Data="M 3.18,7 C3.18,7 5,7 5,7 5,7 1.81,3.5 1.81,3.5 1.81,3.5 5,0 5,0 5,0 3.18,0 3.18,0 3.18,0 0,3.5 0,3.5 0,3.5 3.18,7 3.18,7 z" |
||||
|
Stretch="Uniform" |
||||
|
Fill="Gray" /> |
||||
|
</RepeatButton> |
||||
|
<Track Grid.Row="1" |
||||
|
Grid.Column="1" |
||||
|
Minimum="{TemplateBinding Minimum}" |
||||
|
Maximum="{TemplateBinding Maximum}" |
||||
|
Value="{TemplateBinding Path=Value, Mode=TwoWay}" |
||||
|
ViewportSize="{TemplateBinding ViewportSize}" |
||||
|
Orientation="{TemplateBinding Orientation}"> |
||||
|
<Track.DecreaseButton> |
||||
|
<RepeatButton Name="PART_PageUpButton" |
||||
|
Classes="repeattrack" /> |
||||
|
</Track.DecreaseButton> |
||||
|
<Track.IncreaseButton> |
||||
|
<RepeatButton Name="PART_PageDownButton" |
||||
|
Classes="repeattrack" /> |
||||
|
</Track.IncreaseButton> |
||||
|
<Thumb Name="thumb"> |
||||
|
<Thumb.Template> |
||||
|
<ControlTemplate> |
||||
|
<Border Background="{StyleResource ThemeControlDarkBrush}" /> |
||||
|
</ControlTemplate> |
||||
|
</Thumb.Template> |
||||
|
</Thumb> |
||||
|
</Track> |
||||
|
<RepeatButton Name="PART_LineDownButton" |
||||
|
Classes="repeat" |
||||
|
Grid.Row="2" |
||||
|
Grid.Column="2"> |
||||
|
<Path Data="M 1.81,7 C1.81,7 0,7 0,7 0,7 3.18,3.5 3.18,3.5 3.18,3.5 0,0 0,0 0,0 1.81,0 1.81,0 1.81,0 5,3.5 5,3.5 5,3.5 1.81,7 1.81,7 z" |
||||
|
Stretch="Uniform" |
||||
|
Fill="Gray" /> |
||||
|
</RepeatButton> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ScrollBar:horizontal /template/ Thumb#thumb"> |
||||
|
<Setter Property="MinWidth" |
||||
|
Value="10" /> |
||||
|
</Style> |
||||
|
<Style Selector="ScrollBar:vertical"> |
||||
|
<Setter Property="Width" |
||||
|
Value="10" /> |
||||
|
</Style> |
||||
|
<Style Selector="ScrollBar:vertical /template/ Thumb#thumb"> |
||||
|
<Setter Property="MinHeight" |
||||
|
Value="10" /> |
||||
|
</Style> |
||||
|
<Style Selector="ScrollBar /template/ RepeatButton.repeat"> |
||||
|
<Setter Property="Padding" |
||||
|
Value="2" /> |
||||
|
<Setter Property="BorderThickness" |
||||
|
Value="0" /> |
||||
|
</Style> |
||||
|
<Style Selector="ScrollBar /template/ RepeatButton.repeattrack"> |
||||
|
<Setter Property="Template"> |
||||
|
<ControlTemplate> |
||||
|
<Border Background="{TemplateBinding Background}" /> |
||||
|
</ControlTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
</Styles> |
</Styles> |
||||
Loading…
Reference in new issue