committed by
GitHub
20 changed files with 569 additions and 145 deletions
@ -0,0 +1,78 @@ |
|||||
|
using System; |
||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.Specialized; |
||||
|
using System.ComponentModel; |
||||
|
using Avalonia.Collections; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.ViewModels |
||||
|
{ |
||||
|
internal abstract class TreeNodeCollection : IAvaloniaReadOnlyList<TreeNode>, IDisposable |
||||
|
{ |
||||
|
private AvaloniaList<TreeNode> _inner; |
||||
|
|
||||
|
public TreeNodeCollection(TreeNode owner) => Owner = owner; |
||||
|
|
||||
|
public TreeNode this[int index] |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
EnsureInitialized(); |
||||
|
return _inner[index]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public int Count |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
EnsureInitialized(); |
||||
|
return _inner.Count; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected TreeNode Owner { get; } |
||||
|
|
||||
|
public event NotifyCollectionChangedEventHandler CollectionChanged |
||||
|
{ |
||||
|
add => _inner.CollectionChanged += value; |
||||
|
remove => _inner.CollectionChanged -= value; |
||||
|
} |
||||
|
|
||||
|
public event PropertyChangedEventHandler PropertyChanged |
||||
|
{ |
||||
|
add => _inner.PropertyChanged += value; |
||||
|
remove => _inner.PropertyChanged -= value; |
||||
|
} |
||||
|
|
||||
|
public virtual void Dispose() |
||||
|
{ |
||||
|
if (_inner is object) |
||||
|
{ |
||||
|
foreach (var node in _inner) |
||||
|
{ |
||||
|
node.Dispose(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public IEnumerator<TreeNode> GetEnumerator() |
||||
|
{ |
||||
|
EnsureInitialized(); |
||||
|
return _inner.GetEnumerator(); |
||||
|
} |
||||
|
|
||||
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); |
||||
|
|
||||
|
protected abstract void Initialize(AvaloniaList<TreeNode> nodes); |
||||
|
|
||||
|
private void EnsureInitialized() |
||||
|
{ |
||||
|
if (_inner is null) |
||||
|
{ |
||||
|
_inner = new AvaloniaList<TreeNode>(); |
||||
|
Initialize(_inner); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,10 +1,34 @@ |
|||||
<Style xmlns="https://github.com/avaloniaui" Selector=":is(Control)"> |
<Styles xmlns="https://github.com/avaloniaui" |
||||
<Setter Property="FocusAdorner"> |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<FocusAdornerTemplate> |
<Styles.Resources> |
||||
<Rectangle Stroke="Black" |
<Thickness x:Key="SystemControlFocusVisualMargin">0</Thickness> |
||||
StrokeThickness="1" |
<Thickness x:Key="SystemControlFocusVisualPrimaryThickness">2</Thickness> |
||||
StrokeDashArray="1,2" |
<Thickness x:Key="SystemControlFocusVisualSecondaryThickness">1</Thickness> |
||||
Margin="1"/> |
</Styles.Resources> |
||||
</FocusAdornerTemplate> |
|
||||
</Setter> |
<!-- HighVisibility FocusAdorner --> |
||||
</Style> |
<Style Selector=":is(Control)"> |
||||
|
<Setter Property="FocusAdorner"> |
||||
|
<FocusAdornerTemplate> |
||||
|
<Border BorderThickness="{StaticResource SystemControlFocusVisualPrimaryThickness}" |
||||
|
BorderBrush="{DynamicResource SystemControlFocusVisualPrimaryBrush}" |
||||
|
Margin="{StaticResource SystemControlFocusVisualMargin}"> |
||||
|
<Border BorderThickness="{StaticResource SystemControlFocusVisualSecondaryThickness}" |
||||
|
BorderBrush="{DynamicResource SystemControlFocusVisualSecondaryBrush}" /> |
||||
|
</Border> |
||||
|
</FocusAdornerTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
|
||||
|
<!-- DottedLine FocusAdorner --> |
||||
|
<Style Selector="Window.DottedLineFocusAdorner :is(Control)"> |
||||
|
<Setter Property="FocusAdorner"> |
||||
|
<FocusAdornerTemplate> |
||||
|
<Rectangle Stroke="{StaticResource SystemControlFocusVisualPrimaryBrush}" |
||||
|
StrokeThickness="1" |
||||
|
StrokeDashArray="1,2" |
||||
|
Margin="1" /> |
||||
|
</FocusAdornerTemplate> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
</Styles> |
||||
|
|||||
@ -1,81 +1,176 @@ |
|||||
<Styles xmlns="https://github.com/avaloniaui"> |
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
|
<Design.PreviewWith> |
||||
|
<Border Padding="20"> |
||||
|
<StackPanel> |
||||
|
<ProgressBar VerticalAlignment="Center" IsIndeterminate="True" /> |
||||
|
<ProgressBar HorizontalAlignment="Left" IsIndeterminate="True" Orientation="Vertical" /> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</Design.PreviewWith> |
||||
<Style Selector="ProgressBar"> |
<Style Selector="ProgressBar"> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/> |
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAccentBrush}" /> |
||||
<Setter Property="Foreground" Value="{DynamicResource ThemeAccentBrush}"/> |
<Setter Property="Background" Value="{DynamicResource SystemControlBackgroundBaseLowBrush}" /> |
||||
|
<Setter Property="BorderThickness" Value="{DynamicResource ProgressBarBorderThemeThickness}" /> |
||||
|
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlHighlightTransparentBrush}" /> |
||||
|
<Setter Property="Maximum" Value="100" /> |
||||
|
<Setter Property="MinHeight" Value="{DynamicResource ProgressBarThemeMinHeight}" /> |
||||
|
<Setter Property="VerticalAlignment" Value="Center" /> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<Grid> |
<Border x:Name="ProgressBarRoot" ClipToBounds="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource ControlCornerRadius}"> |
||||
<Border Background="{TemplateBinding Background}" |
<Panel> |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
<Panel x:Name="DeterminateRoot"> |
||||
BorderThickness="{TemplateBinding BorderThickness}"> |
<Border CornerRadius="{DynamicResource ControlCornerRadius}" x:Name="PART_Indicator" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> |
||||
<Border Name="PART_Indicator" Background="{TemplateBinding Foreground}"/> |
</Panel> |
||||
</Border> |
<Panel x:Name="IndeterminateRoot"> |
||||
<LayoutTransformControl |
<Border x:Name="IndeterminateProgressBarIndicator" CornerRadius="{DynamicResource ControlCornerRadius}" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> |
||||
HorizontalAlignment="Center" |
<Border x:Name="IndeterminateProgressBarIndicator2" CornerRadius="{DynamicResource ControlCornerRadius}" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> |
||||
VerticalAlignment="Center" |
</Panel> |
||||
IsVisible="{Binding ShowProgressText, RelativeSource={RelativeSource TemplatedParent}}" |
</Panel> |
||||
Name="PART_LayoutTransformControl"> |
</Border> |
||||
<TextBlock |
|
||||
Foreground="{DynamicResource ThemeForegroundBrush}" |
|
||||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat={}{0:0}%}" /> |
|
||||
</LayoutTransformControl> |
|
||||
</Grid> |
|
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:horizontal /template/ Border#PART_Indicator"> |
<Style Selector="ProgressBar:horizontal /template/ Border#PART_Indicator"> |
||||
<Setter Property="HorizontalAlignment" Value="Left"/> |
<Setter Property="HorizontalAlignment" Value="Left" /> |
||||
<Setter Property="VerticalAlignment" Value="Stretch"/> |
<Setter Property="VerticalAlignment" Value="Stretch" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:vertical /template/ Border#PART_Indicator"> |
<Style Selector="ProgressBar:vertical /template/ Border#PART_Indicator"> |
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/> |
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
||||
<Setter Property="VerticalAlignment" Value="Bottom"/> |
<Setter Property="VerticalAlignment" Value="Bottom" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:horizontal"> |
<Style Selector="ProgressBar:horizontal"> |
||||
<Setter Property="MinWidth" Value="200"/> |
<Setter Property="MinWidth" Value="200" /> |
||||
<Setter Property="MinHeight" Value="16"/> |
<Setter Property="MinHeight" Value="4" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:vertical"> |
<Style Selector="ProgressBar:vertical"> |
||||
<Setter Property="MinWidth" Value="16"/> |
<Setter Property="MinWidth" Value="4" /> |
||||
<Setter Property="MinHeight" Value="200"/> |
<Setter Property="MinHeight" Value="200" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:vertical /template/ LayoutTransformControl#PART_LayoutTransformControl"> |
<Style Selector="ProgressBar:vertical /template/ LayoutTransformControl#PART_LayoutTransformControl"> |
||||
<Setter Property="LayoutTransform"> |
<Setter Property="LayoutTransform"> |
||||
<Setter.Value> |
<Setter.Value> |
||||
<RotateTransform Angle="90"/> |
<RotateTransform Angle="90" /> |
||||
</Setter.Value> |
</Setter.Value> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:horizontal:indeterminate /template/ Border#PART_Indicator"> |
<!-- FadeInAnimation mockup--> |
||||
|
<Style Selector="ProgressBar /template/ Panel#DeterminateRoot"> |
||||
|
<Setter Property="Transitions"> |
||||
|
<Transitions> |
||||
|
<DoubleTransition Property="Opacity" Duration="0:0:0.197" /> |
||||
|
</Transitions> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar /template/ Panel#IndeterminateRoot"> |
||||
|
<Setter Property="Transitions"> |
||||
|
<Transitions> |
||||
|
<DoubleTransition Property="Opacity" Duration="0:0:0.197" /> |
||||
|
</Transitions> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar /template/ Panel#DeterminateRoot"> |
||||
|
<Setter Property="Opacity" Value="1" /> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar /template/ Panel#IndeterminateRoot"> |
||||
|
<Setter Property="Opacity" Value="0" /> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:indeterminate /template/ Panel#DeterminateRoot"> |
||||
|
<Setter Property="Opacity" Value="0" /> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:indeterminate /template/ Panel#IndeterminateRoot"> |
||||
|
<Setter Property="Opacity" Value="1" /> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:horizontal:indeterminate /template/ Border#IndeterminateProgressBarIndicator"> |
||||
|
<Style.Animations> |
||||
|
<Animation Duration="0:0:2" IterationCount="Infinite"> |
||||
|
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> |
||||
|
</KeyFrame> |
||||
|
<KeyFrame KeyTime="0:0:1.5" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> |
||||
|
</KeyFrame> |
||||
|
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> |
||||
|
</KeyFrame> |
||||
|
</Animation> |
||||
|
</Style.Animations> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:horizontal:indeterminate /template/ Border#IndeterminateProgressBarIndicator2"> |
||||
|
<Style.Animations> |
||||
|
<Animation Duration="0:0:2" IterationCount="Infinite"> |
||||
|
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
||||
|
</KeyFrame> |
||||
|
<KeyFrame KeyTime="0:0:0.75" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
||||
|
</KeyFrame> |
||||
|
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.X" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" /> |
||||
|
</KeyFrame> |
||||
|
</Animation> |
||||
|
</Style.Animations> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator"> |
||||
<Style.Animations> |
<Style.Animations> |
||||
<Animation Duration="0:0:3" |
<Animation Duration="0:0:2" IterationCount="Infinite"> |
||||
IterationCount="Infinite" |
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> |
||||
Easing="LinearEasing"> |
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> |
||||
<KeyFrame Cue="0%"> |
</KeyFrame> |
||||
<Setter Property="TranslateTransform.X" |
<KeyFrame KeyTime="0:0:1.5" KeySpline="0.4,0,0.6,1"> |
||||
Value="{Binding IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> |
||||
</KeyFrame> |
</KeyFrame> |
||||
<KeyFrame Cue="100%"> |
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> |
||||
<Setter Property="TranslateTransform.X" |
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> |
||||
Value="{Binding IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
|
||||
</KeyFrame> |
</KeyFrame> |
||||
</Animation> |
</Animation> |
||||
</Style.Animations> |
</Style.Animations> |
||||
</Style> |
</Style> |
||||
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#PART_Indicator"> |
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator2"> |
||||
<Style.Animations> |
<Style.Animations> |
||||
<Animation Duration="0:0:3" |
<Animation Duration="0:0:2" IterationCount="Infinite"> |
||||
IterationCount="Infinite" |
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> |
||||
Easing="LinearEasing"> |
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
||||
<KeyFrame Cue="0%"> |
|
||||
<Setter Property="TranslateTransform.Y" |
|
||||
Value="{Binding IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
|
||||
</KeyFrame> |
</KeyFrame> |
||||
<KeyFrame Cue="100%"> |
<KeyFrame KeyTime="0:0:0.75" KeySpline="0.4,0,0.6,1"> |
||||
<Setter Property="TranslateTransform.Y" |
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
||||
Value="{Binding IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
</KeyFrame> |
||||
|
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> |
||||
|
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" /> |
||||
</KeyFrame> |
</KeyFrame> |
||||
</Animation> |
</Animation> |
||||
</Style.Animations> |
</Style.Animations> |
||||
</Style> |
</Style> |
||||
|
<Style Selector="ProgressBar:horizontal /template/ Border#IndeterminateProgressBarIndicator"> |
||||
|
<Setter Property="Width" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerWidth}" /> |
||||
|
<Setter Property="RenderTransform"> |
||||
|
<Setter.Value> |
||||
|
<TranslateTransform X="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:horizontal /template/ Border#IndeterminateProgressBarIndicator2"> |
||||
|
<Setter Property="Width" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2Width}" /> |
||||
|
<Setter Property="RenderTransform"> |
||||
|
<Setter.Value> |
||||
|
<TranslateTransform X="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:vertical /template/ Border#IndeterminateProgressBarIndicator"> |
||||
|
<Setter Property="Height" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerWidth}" /> |
||||
|
<Setter Property="RenderTransform"> |
||||
|
<Setter.Value> |
||||
|
<TranslateTransform Y="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
<Style Selector="ProgressBar:vertical /template/ Border#IndeterminateProgressBarIndicator2"> |
||||
|
<Setter Property="Height" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2Width}" /> |
||||
|
<Setter Property="RenderTransform"> |
||||
|
<Setter.Value> |
||||
|
<TranslateTransform Y="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
</Styles> |
</Styles> |
||||
|
|||||
Loading…
Reference in new issue