committed by
GitHub
280 changed files with 6020 additions and 3672 deletions
@ -1,66 +1,36 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.ViewboxPage"> |
|||
<UserControl.Resources> |
|||
<StreamGeometry x:Key="Acorn"> |
|||
F1 M 16.6309,18.6563C 17.1309, |
|||
8.15625 29.8809,14.1563 29.8809, |
|||
14.1563C 30.8809,11.1563 34.1308, |
|||
11.4063 34.1308,11.4063C 33.5,12 |
|||
34.6309,13.1563 34.6309,13.1563C |
|||
32.1309,13.1562 31.1309,14.9062 |
|||
31.1309,14.9062C 41.1309,23.9062 |
|||
32.6309,27.9063 32.6309,27.9062C |
|||
24.6309,24.9063 21.1309,22.1562 |
|||
16.6309,18.6563 Z M 16.6309,19.9063C |
|||
21.6309,24.1563 25.1309,26.1562 |
|||
31.6309,28.6562C 31.6309,28.6562 |
|||
26.3809,39.1562 18.3809,36.1563C |
|||
18.3809,36.1563 18,38 16.3809,36.9063C |
|||
15,36 16.3809,34.9063 16.3809,34.9063C |
|||
16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z |
|||
</StreamGeometry> |
|||
</UserControl.Resources> |
|||
|
|||
<Grid RowDefinitions="Auto,*"> |
|||
<Grid RowDefinitions="Auto,*,*"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">Viewbox</TextBlock> |
|||
<TextBlock Classes="h2">A control used to scale single child.</TextBlock> |
|||
</StackPanel> |
|||
<Grid ColumnDefinitions="Auto,*,*" |
|||
RowDefinitions="*,*,*,*" |
|||
Grid.Row="1" Margin="48" |
|||
MaxWidth="400"> |
|||
<TextBlock Grid.Row="0" VerticalAlignment="Center">None</TextBlock> |
|||
<TextBlock Grid.Row="1" VerticalAlignment="Center">Fill</TextBlock> |
|||
<TextBlock Grid.Row="2" VerticalAlignment="Center">Uniform</TextBlock> |
|||
<TextBlock Grid.Row="3" VerticalAlignment="Center">UniformToFill</TextBlock> |
|||
|
|||
<Viewbox Grid.Row="0" Grid.Column="1" Stretch="None"> |
|||
<TextBlock>Hello World!</TextBlock> |
|||
</Viewbox> |
|||
<Viewbox Grid.Row="1" Grid.Column="1" Stretch="Fill"> |
|||
<TextBlock>Hello World!</TextBlock> |
|||
</Viewbox> |
|||
<Viewbox Grid.Row="2" Grid.Column="1" Stretch="Uniform"> |
|||
<TextBlock>Hello World!</TextBlock> |
|||
</Viewbox> |
|||
<Viewbox Grid.Row="3" Grid.Column="1" Stretch="UniformToFill"> |
|||
<TextBlock>Hello World!</TextBlock> |
|||
</Viewbox> |
|||
<Grid Grid.Row="1" ColumnDefinitions="*,Auto" HorizontalAlignment="Center" Margin="0,10,0,0"> |
|||
|
|||
<Viewbox Grid.Row="0" Grid.Column="2" Stretch="None"> |
|||
<Path Fill="Blue" Data="{StaticResource Acorn}"/> |
|||
</Viewbox> |
|||
<Viewbox Grid.Row="1" Grid.Column="2" Stretch="Fill"> |
|||
<Path Fill="Blue" Data="{StaticResource Acorn}"/> |
|||
</Viewbox> |
|||
<Viewbox Grid.Row="2" Grid.Column="2" Stretch="Uniform"> |
|||
<Path Fill="Blue" Data="{StaticResource Acorn}"/> |
|||
</Viewbox> |
|||
<Viewbox Grid.Row="3" Grid.Column="2" Stretch="UniformToFill"> |
|||
<Path Fill="Blue" Data="{StaticResource Acorn}"/> |
|||
</Viewbox> |
|||
<Border HorizontalAlignment="Center" Grid.Column="0" BorderThickness="1" BorderBrush="Orange" Width="200" Height="200"> |
|||
<Border VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Column="0" BorderThickness="1" BorderBrush="CornflowerBlue" Width="{Binding #WidthSlider.Value}" Height="{Binding #HeightSlider.Value}" > |
|||
<Viewbox |
|||
Stretch="{Binding #StretchSelector.SelectedItem}" |
|||
StretchDirection="{Binding #StretchDirectionSelector.SelectedItem}"> |
|||
<Ellipse Width="50" Height="50" Fill="CornflowerBlue" /> |
|||
</Viewbox> |
|||
</Border> |
|||
</Border> |
|||
|
|||
<StackPanel HorizontalAlignment="Left" Orientation="Vertical" Grid.Column="1" Margin="8,0,0,0" Width="150"> |
|||
<TextBlock Text="Width" /> |
|||
<Slider Minimum="10" Maximum="200" Value="100" x:Name="WidthSlider" TickFrequency="25" TickPlacement="TopLeft" /> |
|||
<TextBlock Text="Height" /> |
|||
<Slider Minimum="10" Maximum="200" Value="100" x:Name="HeightSlider" TickFrequency="25" TickPlacement="TopLeft" /> |
|||
<TextBlock Text="Stretch" /> |
|||
<ComboBox x:Name="StretchSelector" HorizontalAlignment="Stretch" Margin="0,0,0,2" /> |
|||
<TextBlock Text="Stretch Direction" /> |
|||
<ComboBox x:Name="StretchDirectionSelector" HorizontalAlignment="Stretch" /> |
|||
</StackPanel> |
|||
</Grid> |
|||
|
|||
</Grid> |
|||
</UserControl> |
|||
|
|||
@ -0,0 +1,25 @@ |
|||
<UserControl |
|||
xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:pages="clr-namespace:RenderDemo.Pages" |
|||
x:Class="RenderDemo.Pages.CustomAnimatorPage" |
|||
MaxWidth="600"> |
|||
<Grid> |
|||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"> |
|||
<TextBlock.Styles> |
|||
<Style Selector="TextBlock"> |
|||
<Style.Animations> |
|||
<Animation Duration="0:0:1" IterationCount="Infinite"> |
|||
<KeyFrame Cue="0%"> |
|||
<Setter Property="Text" Value="" Animation.Animator="{x:Type pages:CustomStringAnimator}"/> |
|||
</KeyFrame> |
|||
<KeyFrame Cue="100%"> |
|||
<Setter Property="Text" Value="0123456789" Animation.Animator="{x:Type pages:CustomStringAnimator}"/> |
|||
</KeyFrame> |
|||
</Animation> |
|||
</Style.Animations> |
|||
</Style> |
|||
</TextBlock.Styles> |
|||
</TextBlock> |
|||
</Grid> |
|||
</UserControl> |
|||
@ -0,0 +1,27 @@ |
|||
using System.Reactive.Linq; |
|||
using Avalonia; |
|||
using Avalonia.Animation; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Shapes; |
|||
using Avalonia.Data; |
|||
using Avalonia.Input; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Media; |
|||
using RenderDemo.ViewModels; |
|||
|
|||
namespace RenderDemo.Pages |
|||
{ |
|||
public class CustomAnimatorPage : UserControl |
|||
{ |
|||
public CustomAnimatorPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using Avalonia.Animation.Animators; |
|||
|
|||
namespace RenderDemo.Pages |
|||
{ |
|||
public class CustomStringAnimator : Animator<string> |
|||
{ |
|||
public override string Interpolate(double progress, string oldValue, string newValue) |
|||
{ |
|||
if (newValue.Length == 0) return ""; |
|||
var step = 1.0 / newValue.Length; |
|||
var length = (int)(progress / step); |
|||
var result = newValue.Substring(0, length + 1); |
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using System; |
|||
using Avalonia.Animation.Animators; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// <see cref="Transition{T}"/> using an <see cref="Animator{T}"/> to transition between values.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">Type of the transitioned value.</typeparam>
|
|||
/// <typeparam name="TAnimator">Type of the animator.</typeparam>
|
|||
public abstract class AnimatorDrivenTransition<T, TAnimator> : Transition<T> where TAnimator : Animator<T>, new() |
|||
{ |
|||
private static readonly TAnimator s_animator = new TAnimator(); |
|||
|
|||
public override IObservable<T> DoTransition(IObservable<double> progress, T oldValue, T newValue) |
|||
{ |
|||
return new AnimatorTransitionObservable<T, TAnimator>(s_animator, progress, Easing, oldValue, newValue); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
using Avalonia.Animation.Animators; |
|||
using Avalonia.Animation.Easings; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Transition observable based on an <see cref="Animator{T}"/> producing a value.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">Type of the transitioned value.</typeparam>
|
|||
/// <typeparam name="TAnimator">Type of the animator.</typeparam>
|
|||
public class AnimatorTransitionObservable<T, TAnimator> : TransitionObservableBase<T> where TAnimator : Animator<T> |
|||
{ |
|||
private readonly TAnimator _animator; |
|||
private readonly Easing _easing; |
|||
private readonly T _oldValue; |
|||
private readonly T _newValue; |
|||
|
|||
public AnimatorTransitionObservable(TAnimator animator, IObservable<double> progress, Easing easing, T oldValue, T newValue) : base(progress, easing) |
|||
{ |
|||
_animator = animator; |
|||
_easing = easing; |
|||
_oldValue = oldValue; |
|||
_newValue = newValue; |
|||
} |
|||
|
|||
protected override T ProduceValue(double progress) |
|||
{ |
|||
return _animator.Interpolate(progress, _oldValue, _newValue); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
Compat issues with assembly Avalonia.Animation: |
|||
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.Animation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract. |
|||
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' is present in the contract but not in the implementation. |
|||
MembersMustExist : Member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock)' does not exist in the implementation but it does exist in the contract. |
|||
InterfacesShouldHaveSameMembers : Interface member 'public System.Threading.Tasks.Task Avalonia.Animation.IAnimation.RunAsync(Avalonia.Animation.Animatable, Avalonia.Animation.IClock, System.Threading.CancellationToken)' is present in the implementation but not in the contract. |
|||
Total Issues: 4 |
|||
@ -0,0 +1,58 @@ |
|||
using System; |
|||
using Avalonia.Animation.Easings; |
|||
using Avalonia.Reactive; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Provides base for observables implementing transitions.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">Type of the transitioned value.</typeparam>
|
|||
public abstract class TransitionObservableBase<T> : SingleSubscriberObservableBase<T>, IObserver<double> |
|||
{ |
|||
private readonly Easing _easing; |
|||
private readonly IObservable<double> _progress; |
|||
private IDisposable? _progressSubscription; |
|||
|
|||
protected TransitionObservableBase(IObservable<double> progress, Easing easing) |
|||
{ |
|||
_progress = progress; |
|||
_easing = easing; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Produces value at given progress time point.
|
|||
/// </summary>
|
|||
/// <param name="progress">Transition progress.</param>
|
|||
protected abstract T ProduceValue(double progress); |
|||
|
|||
protected override void Subscribed() |
|||
{ |
|||
_progressSubscription = _progress.Subscribe(this); |
|||
} |
|||
|
|||
protected override void Unsubscribed() |
|||
{ |
|||
_progressSubscription?.Dispose(); |
|||
} |
|||
|
|||
void IObserver<double>.OnCompleted() |
|||
{ |
|||
PublishCompleted(); |
|||
} |
|||
|
|||
void IObserver<double>.OnError(Exception error) |
|||
{ |
|||
PublishError(error); |
|||
} |
|||
|
|||
void IObserver<double>.OnNext(double value) |
|||
{ |
|||
double progress = _easing.Ease(value); |
|||
|
|||
PublishNext(ProduceValue(progress)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +1,11 @@ |
|||
using System; |
|||
using System.Reactive.Linq; |
|||
using Avalonia.Animation.Animators; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="double"/> types.
|
|||
/// </summary>
|
|||
public class DoubleTransition : Transition<double> |
|||
public class DoubleTransition : AnimatorDrivenTransition<double, DoubleAnimator> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override IObservable<double> DoTransition(IObservable<double> progress, double oldValue, double newValue) |
|||
{ |
|||
return progress |
|||
.Select(p => |
|||
{ |
|||
var f = Easing.Ease(p); |
|||
return ((newValue - oldValue) * f) + oldValue; |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,19 +1,11 @@ |
|||
using System; |
|||
using System.Reactive.Linq; |
|||
using Avalonia.Animation.Animators; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="float"/> types.
|
|||
/// </summary>
|
|||
public class FloatTransition : Transition<float> |
|||
public class FloatTransition : AnimatorDrivenTransition<float, FloatAnimator> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override IObservable<float> DoTransition(IObservable<double> progress, float oldValue, float newValue) |
|||
{ |
|||
var delta = newValue - oldValue; |
|||
return progress |
|||
.Select(p => (float)Easing.Ease(p) * delta + oldValue); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,19 +1,11 @@ |
|||
using System; |
|||
using System.Reactive.Linq; |
|||
using Avalonia.Animation.Animators; |
|||
|
|||
namespace Avalonia.Animation |
|||
{ |
|||
/// <summary>
|
|||
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="int"/> types.
|
|||
/// </summary>
|
|||
public class IntegerTransition : Transition<int> |
|||
public class IntegerTransition : AnimatorDrivenTransition<int, Int32Animator> |
|||
{ |
|||
/// <inheritdocs/>
|
|||
public override IObservable<int> DoTransition(IObservable<double> progress, int oldValue, int newValue) |
|||
{ |
|||
var delta = newValue - oldValue; |
|||
return progress |
|||
.Select(p => (int)(Easing.Ease(p) * delta + oldValue)); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,44 @@ |
|||
#nullable enable |
|||
using System; |
|||
using System.Globalization; |
|||
|
|||
using Avalonia.Data.Converters; |
|||
|
|||
namespace Avalonia.Controls.Converters |
|||
{ |
|||
/// <summary>
|
|||
/// Converts an existing CornerRadius struct to a new CornerRadius struct,
|
|||
/// with filters applied to extract only the specified fields, leaving the others set to 0.
|
|||
/// </summary>
|
|||
public class CornerRadiusFilterConverter : IValueConverter |
|||
{ |
|||
/// <summary>
|
|||
/// Gets or sets the type of the filter applied to the <see cref="CornerRadiusFilterConverter"/>.
|
|||
/// </summary>
|
|||
public CornerRadiusFilterKinds Filter { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the scale multiplier applied to the <see cref="CornerRadiusFilterConverter"/>.
|
|||
/// </summary>
|
|||
public double Scale { get; set; } = 1; |
|||
|
|||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) |
|||
{ |
|||
if (!(value is CornerRadius radius)) |
|||
{ |
|||
return value; |
|||
} |
|||
|
|||
return new CornerRadius( |
|||
Filter.HasAllFlags(CornerRadiusFilterKinds.TopLeft) ? radius.TopLeft * Scale : 0, |
|||
Filter.HasAllFlags(CornerRadiusFilterKinds.TopRight) ? radius.TopRight * Scale : 0, |
|||
Filter.HasAllFlags(CornerRadiusFilterKinds.BottomRight) ? radius.BottomRight * Scale : 0, |
|||
Filter.HasAllFlags(CornerRadiusFilterKinds.BottomLeft) ? radius.BottomLeft * Scale : 0); |
|||
} |
|||
|
|||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Controls.Converters |
|||
{ |
|||
/// <summary>
|
|||
/// Defines constants that specify the filter type for a <see cref="CornerRadiusFilterConverter"/> instance.
|
|||
/// </summary>
|
|||
[Flags] |
|||
public enum CornerRadiusFilterKinds |
|||
{ |
|||
/// <summary>
|
|||
/// No filter applied.
|
|||
/// </summary>
|
|||
None, |
|||
/// <summary>
|
|||
/// Filters TopLeft value.
|
|||
/// </summary>
|
|||
TopLeft = 1, |
|||
/// <summary>
|
|||
/// Filters TopRight value.
|
|||
/// </summary>
|
|||
TopRight = 2, |
|||
/// <summary>
|
|||
/// Filters BottomLeft value.
|
|||
/// </summary>
|
|||
BottomLeft = 4, |
|||
/// <summary>
|
|||
/// Filters BottomRight value.
|
|||
/// </summary>
|
|||
BottomRight = 8 |
|||
} |
|||
} |
|||
@ -1,10 +1,28 @@ |
|||
namespace Avalonia.Controls.Primitives |
|||
{ |
|||
/// <summary>
|
|||
/// Specifies the visibility of a <see cref="ScrollBar"/> for scrollable content.
|
|||
/// </summary>
|
|||
public enum ScrollBarVisibility |
|||
{ |
|||
/// <summary>
|
|||
/// No scrollbars and no scrolling in this dimension.
|
|||
/// </summary>
|
|||
Disabled, |
|||
|
|||
/// <summary>
|
|||
/// The scrollbar should be visible only if there is more content than fits in the viewport.
|
|||
/// </summary>
|
|||
Auto, |
|||
|
|||
/// <summary>
|
|||
/// The scrollbar should never be visible. No space should ever be reserved for the scrollbar.
|
|||
/// </summary>
|
|||
Hidden, |
|||
|
|||
/// <summary>
|
|||
/// The scrollbar should always be visible. Space should always be reserved for the scrollbar.
|
|||
/// </summary>
|
|||
Visible, |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,103 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:controls="using:Avalonia.Diagnostics.Controls" |
|||
x:CompileBindings="True" |
|||
x:DataType="controls:FilterTextBox"> |
|||
|
|||
<Design.PreviewWith> |
|||
<Border Padding="10"> |
|||
<controls:FilterTextBox Width="200" Text="Hello World" /> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Style Selector="TextBox.filter-text-box"> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="InnerRightContent"> |
|||
<Template> |
|||
<StackPanel Orientation="Horizontal" Spacing="1"> |
|||
<Button Margin="0,0,2,0" |
|||
Classes="textBoxClearButton" |
|||
ToolTip.Tip="Clear" |
|||
Cursor="Hand" |
|||
Command="{ReflectionBinding $parent[TextBox].Clear}" |
|||
Opacity="0.5" /> |
|||
<ToggleButton Classes="filter-text-box-toggle" |
|||
ToolTip.Tip="Match Case" |
|||
IsChecked="{Binding $parent[controls:FilterTextBox].UseCaseSensitiveFilter}"> |
|||
<Image> |
|||
<DrawingImage> |
|||
<GeometryDrawing Brush="{Binding $parent[ToggleButton].Foreground}"> |
|||
<GeometryDrawing.Geometry> |
|||
M7.495 9.052L8.386 11.402H9.477L6.237 3H5.217L2 11.402H3.095L3.933 9.052H7.495ZM5.811 4.453L5.855 4.588L7.173 8.162H4.255L5.562 4.588L5.606 4.453L5.644 4.297L5.676 4.145L5.697 4.019H5.72L5.744 4.145L5.773 4.297L5.811 4.453ZM13.795 10.464V11.4H14.755V7.498C14.755 6.779 14.575 6.226 14.216 5.837C13.857 5.448 13.327 5.254 12.628 5.254C12.429 5.254 12.227 5.273 12.022 5.31C11.817 5.347 11.622 5.394 11.439 5.451C11.256 5.508 11.091 5.569 10.944 5.636C10.797 5.703 10.683 5.765 10.601 5.824V6.808C10.867 6.578 11.167 6.397 11.505 6.268C11.843 6.139 12.194 6.075 12.557 6.075C12.745 6.075 12.915 6.103 13.07 6.16C13.225 6.217 13.357 6.306 13.466 6.427C13.575 6.548 13.659 6.706 13.718 6.899C13.777 7.092 13.806 7.326 13.806 7.599L11.995 7.851C11.651 7.898 11.355 7.977 11.107 8.088C10.859 8.199 10.654 8.339 10.492 8.507C10.33 8.675 10.21 8.868 10.132 9.087C10.054 9.306 10.015 9.546 10.015 9.808C10.015 10.054 10.057 10.283 10.139 10.496C10.221 10.709 10.342 10.893 10.502 11.047C10.662 11.201 10.862 11.323 11.1 11.413C11.338 11.503 11.613 11.548 11.926 11.548C12.328 11.548 12.686 11.456 13.001 11.27C13.316 11.084 13.573 10.816 13.772 10.464H13.795ZM11.667 8.721C11.843 8.657 12.068 8.607 12.341 8.572L13.806 8.367V8.976C13.806 9.222 13.765 9.451 13.683 9.664C13.601 9.877 13.486 10.063 13.34 10.221C13.194 10.379 13.019 10.503 12.816 10.593C12.613 10.683 12.39 10.728 12.148 10.728C11.961 10.728 11.795 10.703 11.653 10.652C11.511 10.601 11.392 10.53 11.296 10.441C11.2 10.352 11.127 10.247 11.076 10.125C11.025 10.003 11 9.873 11 9.732C11 9.568 11.018 9.421 11.055 9.292C11.092 9.163 11.16 9.051 11.257 8.958C11.354 8.865 11.491 8.785 11.667 8.721Z |
|||
</GeometryDrawing.Geometry> |
|||
</GeometryDrawing> |
|||
</DrawingImage> |
|||
</Image> |
|||
</ToggleButton> |
|||
<ToggleButton Classes="filter-text-box-toggle" |
|||
ToolTip.Tip="Match Whole Word" |
|||
IsChecked="{Binding $parent[controls:FilterTextBox].UseWholeWordFilter}"> |
|||
<Image> |
|||
<DrawingImage> |
|||
<GeometryDrawing Brush="{Binding $parent[ToggleButton].Foreground}"> |
|||
<GeometryDrawing.Geometry> |
|||
M1 2H15V3H1V2ZM14 4H13V12H14V4ZM11.272 8.387C11.194 8.088 11.073 7.825 10.912 7.601C10.751 7.377 10.547 7.2 10.303 7.071C10.059 6.942 9.769 6.878 9.437 6.878C9.239 6.878 9.057 6.902 8.89 6.951C8.725 7 8.574 7.068 8.437 7.156C8.301 7.244 8.18 7.35 8.072 7.474L7.893 7.732V4.578H7V12H7.893V11.425L8.019 11.6C8.106 11.702 8.208 11.79 8.323 11.869C8.44 11.947 8.572 12.009 8.721 12.055C8.87 12.101 9.035 12.123 9.219 12.123C9.572 12.123 9.885 12.052 10.156 11.911C10.428 11.768 10.655 11.573 10.838 11.325C11.021 11.075 11.159 10.782 11.252 10.446C11.345 10.108 11.392 9.743 11.392 9.349C11.391 9.007 11.352 8.686 11.272 8.387ZM9.793 7.78C9.944 7.851 10.075 7.956 10.183 8.094C10.292 8.234 10.377 8.407 10.438 8.611C10.489 8.785 10.52 8.982 10.527 9.198L10.52 9.323C10.52 9.65 10.487 9.943 10.42 10.192C10.353 10.438 10.259 10.645 10.142 10.806C10.025 10.968 9.882 11.091 9.721 11.172C9.399 11.334 8.961 11.338 8.652 11.187C8.499 11.112 8.366 11.012 8.259 10.891C8.174 10.795 8.103 10.675 8.041 10.524C8.041 10.524 7.862 10.077 7.862 9.577C7.862 9.077 8.041 8.575 8.041 8.575C8.103 8.398 8.177 8.257 8.265 8.145C8.379 8.002 8.521 7.886 8.689 7.8C8.857 7.714 9.054 7.671 9.276 7.671C9.466 7.671 9.64 7.708 9.793 7.78ZM15 13H1V14H15V13ZM2.813 10L2.085 12.031H1L1.025 11.959L3.466 4.87305H4.407L6.892 12.031H5.81L5.032 10H2.813ZM3.934 6.42205H3.912L3.007 9.17505H4.848L3.934 6.42205Z |
|||
</GeometryDrawing.Geometry> |
|||
</GeometryDrawing> |
|||
</DrawingImage> |
|||
</Image> |
|||
</ToggleButton> |
|||
<ToggleButton Classes="filter-text-box-toggle" |
|||
ToolTip.Tip="Use Regular Expression" |
|||
IsChecked="{Binding $parent[controls:FilterTextBox].UseRegexFilter}"> |
|||
<Image> |
|||
<DrawingImage> |
|||
<GeometryDrawing Brush="{Binding $parent[ToggleButton].Foreground}"> |
|||
<GeometryDrawing.Geometry> |
|||
M10.0122 2H10.9879V5.11346L13.5489 3.55609L14.034 4.44095L11.4702 6L14.034 7.55905L13.5489 8.44391L10.9879 6.88654V10H10.0122V6.88654L7.45114 8.44391L6.96606 7.55905L9.5299 6L6.96606 4.44095L7.45114 3.55609L10.0122 5.11346V2ZM2 10H6V14H2V10Z |
|||
</GeometryDrawing.Geometry> |
|||
</GeometryDrawing> |
|||
</DrawingImage> |
|||
</Image> |
|||
</ToggleButton> |
|||
</StackPanel> |
|||
</Template> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="TextBox.filter-text-box Button.textBoxClearButton"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="TextBox.filter-text-box[AcceptsReturn=False][IsReadOnly=False]:focus:not(TextBox:empty) Button.textBoxClearButton"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ToggleButton.filter-text-box-toggle > Image"> |
|||
<Setter Property="Width" Value="16" /> |
|||
<Setter Property="Height" Value="16" /> |
|||
<Setter Property="Opacity" Value="0.5" /> |
|||
</Style> |
|||
<Style Selector="ToggleButton.filter-text-box-toggle:pointerover > Image"> |
|||
<Setter Property="Opacity" Value="0.7" /> |
|||
</Style> |
|||
<Style Selector="ToggleButton.filter-text-box-toggle:pressed > Image, ToggleButton.filter-text-box-toggle:checked > Image"> |
|||
<Setter Property="Opacity" Value="0.7" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ToggleButton.filter-text-box-toggle"> |
|||
<Setter Property="Cursor" Value="Hand" /> |
|||
<Setter Property="Padding" Value="0,1" /> |
|||
<Setter Property="Width" Value="24" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="VerticalAlignment" Value="Top" /> |
|||
</Style> |
|||
<Style Selector="ToggleButton.filter-text-box-toggle /template/ ContentPresenter"> |
|||
<Setter Property="Background" Value="Transparent" /> |
|||
<Setter Property="BorderBrush" Value="Transparent" /> |
|||
<Setter Property="CornerRadius" Value="0" /> |
|||
</Style> |
|||
<Style Selector="ToggleButton.filter-text-box-toggle:pressed /template/ ContentPresenter, ToggleButton.filter-text-box-toggle:checked /template/ ContentPresenter"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeAccentColor}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentColor4}" /> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Data; |
|||
using Avalonia.Styling; |
|||
|
|||
namespace Avalonia.Diagnostics.Controls |
|||
{ |
|||
internal class FilterTextBox : TextBox, IStyleable |
|||
{ |
|||
public static readonly DirectProperty<FilterTextBox, bool> UseRegexFilterProperty = |
|||
AvaloniaProperty.RegisterDirect<FilterTextBox, bool>(nameof(UseRegexFilter), |
|||
o => o.UseRegexFilter, (o, v) => o.UseRegexFilter = v, |
|||
defaultBindingMode: BindingMode.TwoWay); |
|||
|
|||
public static readonly DirectProperty<FilterTextBox, bool> UseCaseSensitiveFilterProperty = |
|||
AvaloniaProperty.RegisterDirect<FilterTextBox, bool>(nameof(UseCaseSensitiveFilter), |
|||
o => o.UseCaseSensitiveFilter, (o, v) => o.UseCaseSensitiveFilter = v, |
|||
defaultBindingMode: BindingMode.TwoWay); |
|||
|
|||
public static readonly DirectProperty<FilterTextBox, bool> UseWholeWordFilterProperty = |
|||
AvaloniaProperty.RegisterDirect<FilterTextBox, bool>(nameof(UseWholeWordFilter), |
|||
o => o.UseWholeWordFilter, (o, v) => o.UseWholeWordFilter = v, |
|||
defaultBindingMode: BindingMode.TwoWay); |
|||
|
|||
private bool _useRegexFilter, _useCaseSensitiveFilter, _useWholeWordFilter; |
|||
|
|||
public FilterTextBox() |
|||
{ |
|||
Classes.Add("filter-text-box"); |
|||
} |
|||
|
|||
public bool UseRegexFilter |
|||
{ |
|||
get => _useRegexFilter; |
|||
set => SetAndRaise(UseRegexFilterProperty, ref _useRegexFilter, value); |
|||
} |
|||
|
|||
public bool UseCaseSensitiveFilter |
|||
{ |
|||
get => _useCaseSensitiveFilter; |
|||
set => SetAndRaise(UseCaseSensitiveFilterProperty, ref _useCaseSensitiveFilter, value); |
|||
} |
|||
|
|||
public bool UseWholeWordFilter |
|||
{ |
|||
get => _useWholeWordFilter; |
|||
set => SetAndRaise(UseWholeWordFilterProperty, ref _useWholeWordFilter, value); |
|||
} |
|||
|
|||
Type IStyleable.StyleKey => typeof(TextBox); |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:controls="clr-namespace:Avalonia.Diagnostics.Controls"> |
|||
|
|||
<Styles.Resources> |
|||
<SolidColorBrush x:Key="HighlightBorderBrush" Color="CornflowerBlue" /> |
|||
<SolidColorBrush x:Key="ThicknessBorderBrush" Color="#666666" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="controls|ThicknessEditor"> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="BorderBrush" Value="{StaticResource ThicknessBorderBrush}" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Panel> |
|||
<Rectangle x:Name="PART_Background" |
|||
Classes.no-content-pointerover="{Binding !#PART_ContentPresenter.IsPointerOver}" /> |
|||
<Border |
|||
x:Name="PART_Border" |
|||
Classes.no-content-pointerover="{Binding !#PART_ContentPresenter.IsPointerOver}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="Auto,*,Auto"> |
|||
<Grid.Styles> |
|||
<Style Selector="TextBox.thickness-edit"> |
|||
<Setter Property="Background" Value="Transparent" /> |
|||
<Setter Property="BorderThickness" Value="0" /> |
|||
<Setter Property="Margin" Value="2" /> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalAlignment" Value="Stretch" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="(ScrollViewer.HorizontalScrollBarVisibility)" |
|||
Value="Disabled" /> |
|||
<Setter Property="(ScrollViewer.VerticalScrollBarVisibility)" Value="Disabled" /> |
|||
<Setter Property="IsVisible" |
|||
Value="{Binding $parent[controls:ThicknessEditor].IsPresent}" /> |
|||
</Style> |
|||
</Grid.Styles> |
|||
<TextBlock IsVisible="{TemplateBinding IsPresent}" Margin="4,0,0,0" |
|||
Text="{TemplateBinding Header}" Grid.Row="0" Grid.Column="0" |
|||
Grid.ColumnSpan="2" /> |
|||
<TextBox Grid.Row="1" Grid.Column="0" |
|||
Text="{Binding Left, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Classes="thickness-edit" /> |
|||
<TextBox x:Name="Right" Grid.Row="0" Grid.Column="1" |
|||
Text="{Binding Top, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Classes="thickness-edit" /> |
|||
<TextBox Grid.Row="1" Grid.Column="2" |
|||
Text="{Binding Right, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Classes="thickness-edit" /> |
|||
<TextBox Grid.Row="2" Grid.Column="1" |
|||
Text="{Binding Bottom, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Classes="thickness-edit" /> |
|||
<ContentPresenter Grid.Row="1" Grid.Column="1" |
|||
Name="PART_ContentPresenter" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Padding="{TemplateBinding Padding}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" /> |
|||
</Grid> |
|||
</Border> |
|||
</Panel> |
|||
|
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="controls|ThicknessEditor[IsPresent=False]"> |
|||
<Setter Property="BorderThickness" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="controls|ThicknessEditor /template/ Rectangle#PART_Background"> |
|||
<Setter Property="Fill" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="controls|ThicknessEditor:pointerover /template/ Rectangle#PART_Background.no-content-pointerover"> |
|||
<Setter Property="Fill" Value="{Binding Highlight, RelativeSource={RelativeSource TemplatedParent}}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="controls|ThicknessEditor:pointerover /template/ Border#PART_Border.no-content-pointerover"> |
|||
<Setter Property="BorderBrush" Value="{StaticResource HighlightBorderBrush}" /> |
|||
</Style> |
|||
</Styles> |
|||
@ -1,22 +0,0 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using Avalonia.Data.Converters; |
|||
using Avalonia.Media; |
|||
|
|||
namespace Avalonia.Diagnostics.Converters |
|||
{ |
|||
internal class BoolToBrushConverter : IValueConverter |
|||
{ |
|||
public IBrush Brush { get; set; } |
|||
|
|||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
return (bool)value ? Brush : Brushes.Transparent; |
|||
} |
|||
|
|||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using Avalonia.Data; |
|||
using Avalonia.Data.Converters; |
|||
|
|||
namespace Avalonia.Diagnostics.Converters |
|||
{ |
|||
internal class EnumToCheckedConverter : IValueConverter |
|||
{ |
|||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) |
|||
{ |
|||
return Equals(value, parameter); |
|||
} |
|||
|
|||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) |
|||
{ |
|||
if (value is bool isChecked && isChecked) |
|||
{ |
|||
return parameter; |
|||
} |
|||
|
|||
return BindingOperations.DoNothing; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue