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)"> |
|||
<Setter Property="FocusAdorner"> |
|||
<FocusAdornerTemplate> |
|||
<Rectangle Stroke="Black" |
|||
StrokeThickness="1" |
|||
StrokeDashArray="1,2" |
|||
Margin="1"/> |
|||
</FocusAdornerTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Styles.Resources> |
|||
<Thickness x:Key="SystemControlFocusVisualMargin">0</Thickness> |
|||
<Thickness x:Key="SystemControlFocusVisualPrimaryThickness">2</Thickness> |
|||
<Thickness x:Key="SystemControlFocusVisualSecondaryThickness">1</Thickness> |
|||
</Styles.Resources> |
|||
|
|||
<!-- HighVisibility FocusAdorner --> |
|||
<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"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush4}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeAccentBrush}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource SystemControlHighlightAccentBrush}" /> |
|||
<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"> |
|||
<ControlTemplate> |
|||
<Grid> |
|||
<Border Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<Border Name="PART_Indicator" Background="{TemplateBinding Foreground}"/> |
|||
</Border> |
|||
<LayoutTransformControl |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
IsVisible="{Binding ShowProgressText, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Name="PART_LayoutTransformControl"> |
|||
<TextBlock |
|||
Foreground="{DynamicResource ThemeForegroundBrush}" |
|||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, StringFormat={}{0:0}%}" /> |
|||
</LayoutTransformControl> |
|||
</Grid> |
|||
<Border x:Name="ProgressBarRoot" ClipToBounds="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource ControlCornerRadius}"> |
|||
<Panel> |
|||
<Panel x:Name="DeterminateRoot"> |
|||
<Border CornerRadius="{DynamicResource ControlCornerRadius}" x:Name="PART_Indicator" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> |
|||
</Panel> |
|||
<Panel x:Name="IndeterminateRoot"> |
|||
<Border x:Name="IndeterminateProgressBarIndicator" CornerRadius="{DynamicResource ControlCornerRadius}" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> |
|||
<Border x:Name="IndeterminateProgressBarIndicator2" CornerRadius="{DynamicResource ControlCornerRadius}" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Foreground}" /> |
|||
</Panel> |
|||
</Panel> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
<Style Selector="ProgressBar:horizontal /template/ Border#PART_Indicator"> |
|||
<Setter Property="HorizontalAlignment" Value="Left"/> |
|||
<Setter Property="VerticalAlignment" Value="Stretch"/> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Stretch" /> |
|||
</Style> |
|||
<Style Selector="ProgressBar:vertical /template/ Border#PART_Indicator"> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch"/> |
|||
<Setter Property="VerticalAlignment" Value="Bottom"/> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalAlignment" Value="Bottom" /> |
|||
</Style> |
|||
<Style Selector="ProgressBar:horizontal"> |
|||
<Setter Property="MinWidth" Value="200"/> |
|||
<Setter Property="MinHeight" Value="16"/> |
|||
<Setter Property="MinWidth" Value="200" /> |
|||
<Setter Property="MinHeight" Value="4" /> |
|||
</Style> |
|||
<Style Selector="ProgressBar:vertical"> |
|||
<Setter Property="MinWidth" Value="16"/> |
|||
<Setter Property="MinHeight" Value="200"/> |
|||
<Setter Property="MinWidth" Value="4" /> |
|||
<Setter Property="MinHeight" Value="200" /> |
|||
</Style> |
|||
<Style Selector="ProgressBar:vertical /template/ LayoutTransformControl#PART_LayoutTransformControl"> |
|||
<Setter Property="LayoutTransform"> |
|||
<Setter.Value> |
|||
<RotateTransform Angle="90"/> |
|||
<RotateTransform Angle="90" /> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</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> |
|||
<Animation Duration="0:0:3" |
|||
IterationCount="Infinite" |
|||
Easing="LinearEasing"> |
|||
<KeyFrame Cue="0%"> |
|||
<Setter Property="TranslateTransform.X" |
|||
Value="{Binding IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
|||
<Animation Duration="0:0:2" IterationCount="Infinite"> |
|||
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> |
|||
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationStartPosition}" /> |
|||
</KeyFrame> |
|||
<KeyFrame KeyTime="0:0:1.5" KeySpline="0.4,0,0.6,1"> |
|||
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> |
|||
</KeyFrame> |
|||
<KeyFrame Cue="100%"> |
|||
<Setter Property="TranslateTransform.X" |
|||
Value="{Binding IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
|||
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> |
|||
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.ContainerAnimationEndPosition}" /> |
|||
</KeyFrame> |
|||
</Animation> |
|||
</Style.Animations> |
|||
</Style> |
|||
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#PART_Indicator"> |
|||
<Style Selector="ProgressBar:vertical:indeterminate /template/ Border#IndeterminateProgressBarIndicator2"> |
|||
<Style.Animations> |
|||
<Animation Duration="0:0:3" |
|||
IterationCount="Infinite" |
|||
Easing="LinearEasing"> |
|||
<KeyFrame Cue="0%"> |
|||
<Setter Property="TranslateTransform.Y" |
|||
Value="{Binding IndeterminateStartingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
|||
<Animation Duration="0:0:2" IterationCount="Infinite"> |
|||
<KeyFrame KeyTime="0:0:0" KeySpline="0.4,0,0.6,1"> |
|||
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
|||
</KeyFrame> |
|||
<KeyFrame Cue="100%"> |
|||
<Setter Property="TranslateTransform.Y" |
|||
Value="{Binding IndeterminateEndingOffset, RelativeSource={RelativeSource TemplatedParent}}" /> |
|||
<KeyFrame KeyTime="0:0:0.75" KeySpline="0.4,0,0.6,1"> |
|||
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationStartPosition}" /> |
|||
</KeyFrame> |
|||
<KeyFrame KeyTime="0:0:2" KeySpline="0.4,0,0.6,1"> |
|||
<Setter Property="TranslateTransform.Y" Value="{Binding $parent[ProgressBar].TemplateProperties.Container2AnimationEndPosition}" /> |
|||
</KeyFrame> |
|||
</Animation> |
|||
</Style.Animations> |
|||
</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> |
|||
|
|||
Loading…
Reference in new issue