Browse Source
# Conflicts: # src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml # src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml # src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml # src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xamlpull/4051/head
27 changed files with 715 additions and 90 deletions
@ -1,17 +1,78 @@ |
|||
<Style xmlns="https://github.com/avaloniaui" Selector="ToolTip"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Padding" Value="4,2"/> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Padding="{TemplateBinding Padding}"/> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Design.PreviewWith> |
|||
<Grid RowDefinitions="Auto,Auto" |
|||
ColumnDefinitions="Auto,Auto" |
|||
HorizontalAlignment="Center"> |
|||
<Border Grid.Column="0" |
|||
Grid.Row="1" |
|||
Background="{DynamicResource ThemeAccentBrush}" |
|||
Margin="5" |
|||
Padding="50" |
|||
ToolTip.Tip="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."> |
|||
<TextBlock>Hover Here</TextBlock> |
|||
</Border> |
|||
<CheckBox Grid.Column="1" |
|||
Margin="5" |
|||
Grid.Row="0" |
|||
IsChecked="{Binding ElementName=Border, Path=(ToolTip.IsOpen)}" |
|||
Content="ToolTip Open" /> |
|||
<Border Name="Border" |
|||
Grid.Column="1" |
|||
Grid.Row="1" |
|||
Background="{DynamicResource ThemeAccentBrush}" |
|||
Margin="5" |
|||
Padding="50" |
|||
ToolTip.Placement="Bottom"> |
|||
<ToolTip.Tip> |
|||
<StackPanel> |
|||
<TextBlock Classes="h1">ToolTip</TextBlock> |
|||
<TextBlock Classes="h2">A control which pops up a hint when a control is hovered</TextBlock> |
|||
</StackPanel> |
|||
</ToolTip.Tip> |
|||
<TextBlock>ToolTip bottom placement</TextBlock> |
|||
</Border> |
|||
</Grid> |
|||
</Design.PreviewWith> |
|||
|
|||
<Style Selector="ToolTip"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ToolTipForeground}" /> |
|||
<Setter Property="Background" Value="{DynamicResource ToolTipBackground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ToolTipBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ToolTipBorderThemeThickness}" /> |
|||
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" /> |
|||
<Setter Property="FontSize" Value="{DynamicResource ToolTipContentThemeFontSize}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource ToolTipBorderThemePadding}" /> |
|||
<Setter Property="Transitions"> |
|||
<Transitions> |
|||
<DoubleTransition Property="Opacity" Duration="0:0:0.15" /> |
|||
</Transitions> |
|||
</Setter> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Name="PART_LayoutRoot" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Padding="{TemplateBinding Padding}" |
|||
CornerRadius="{DynamicResource OverlayCornerRadius}"> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
MaxWidth="320" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" /> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="ToolTip > TextBlock"> |
|||
<Setter Property="TextWrapping" Value="Wrap" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ToolTip"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="ToolTip:open"> |
|||
<Setter Property="Opacity" Value="1" /> |
|||
</Style> |
|||
</Styles> |
|||
|
|||
@ -0,0 +1,88 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Runtime.CompilerServices; |
|||
using Avalonia.Data.Core.Plugins; |
|||
using BenchmarkDotNet.Attributes; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Avalonia.Benchmarks.Data |
|||
{ |
|||
[MemoryDiagnoser, InProcess] |
|||
public class PropertyAccessorBenchmarks |
|||
{ |
|||
private readonly InpcPropertyAccessorPlugin _inpcPlugin = new InpcPropertyAccessorPlugin(); |
|||
private readonly MethodAccessorPlugin _methodPlugin = new MethodAccessorPlugin(); |
|||
private readonly TestObject _targetStrongRef = new TestObject(); |
|||
private readonly WeakReference<object> _targetWeakRef; |
|||
|
|||
public PropertyAccessorBenchmarks() |
|||
{ |
|||
_targetWeakRef = new WeakReference<object>(_targetStrongRef); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void InpcAccessorMatch() |
|||
{ |
|||
_inpcPlugin.Match(_targetWeakRef, nameof(TestObject.Test)); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void InpcAccessorStart() |
|||
{ |
|||
_inpcPlugin.Start(_targetWeakRef, nameof(TestObject.Test)); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void MethodAccessorMatch() |
|||
{ |
|||
_methodPlugin.Match(_targetWeakRef, nameof(TestObject.Execute)); |
|||
} |
|||
|
|||
[Benchmark] |
|||
public void MethodAccessorStart() |
|||
{ |
|||
_methodPlugin.Start(_targetWeakRef, nameof(TestObject.Execute)); |
|||
} |
|||
|
|||
private class TestObject : INotifyPropertyChanged |
|||
{ |
|||
private string _test; |
|||
|
|||
public string Test |
|||
{ |
|||
get => _test; |
|||
set |
|||
{ |
|||
if (_test == value) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_test = value; |
|||
|
|||
OnPropertyChanged(); |
|||
} |
|||
} |
|||
|
|||
public void Execute() |
|||
{ |
|||
} |
|||
|
|||
public void Execute(object p0) |
|||
{ |
|||
} |
|||
|
|||
public void Execute(object p0, object p1) |
|||
{ |
|||
} |
|||
|
|||
public event PropertyChangedEventHandler PropertyChanged; |
|||
|
|||
[NotifyPropertyChangedInvocator] |
|||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) |
|||
{ |
|||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue