Reformat Avalonia.Diagnostics.
This commit is contained in:
+2
-1
@@ -131,13 +131,14 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
csharp_space_between_parentheses = false
|
||||
csharp_space_between_square_brackets = false
|
||||
space_within_single_line_array_initializer_braces = true
|
||||
|
||||
# Wrapping preferences
|
||||
csharp_wrap_before_ternary_opsigns = false
|
||||
|
||||
# Xaml files
|
||||
[*.xaml]
|
||||
indent_size = 4
|
||||
indent_size = 2
|
||||
|
||||
# Xml project files
|
||||
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Avalonia.Diagnostics.DevTools">
|
||||
<Grid RowDefinitions="*,Auto" Margin="4">
|
||||
<Grid RowDefinitions="*,Auto" Margin="4">
|
||||
|
||||
<TabControl Grid.Row="0" Items="{Binding Tools}" SelectedItem="{Binding SelectedTool}">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
</TabControl>
|
||||
<TabControl Grid.Row="0" Items="{Binding Tools}" SelectedItem="{Binding SelectedTool}">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
</TabControl>
|
||||
|
||||
<StackPanel Grid.Row="1" Spacing="4" Orientation="Horizontal">
|
||||
<TextBlock>Hold Ctrl+Shift over a control to inspect.</TextBlock>
|
||||
<Separator Width="8" />
|
||||
<TextBlock>Focused:</TextBlock>
|
||||
<TextBlock Text="{Binding FocusedControl}" />
|
||||
<Separator Width="8" />
|
||||
<TextBlock>Pointer Over:</TextBlock>
|
||||
<TextBlock Text="{Binding PointerOverElement}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="1" Spacing="4" Orientation="Horizontal">
|
||||
<TextBlock>Hold Ctrl+Shift over a control to inspect.</TextBlock>
|
||||
<Separator Width="8" />
|
||||
<TextBlock>Focused:</TextBlock>
|
||||
<TextBlock Text="{Binding FocusedControl}" />
|
||||
<Separator Width="8" />
|
||||
<TextBlock>Pointer Over:</TextBlock>
|
||||
<TextBlock Text="{Binding PointerOverElement}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
@@ -18,22 +17,22 @@ using Avalonia.VisualTree;
|
||||
|
||||
namespace Avalonia
|
||||
{
|
||||
public static class DevToolsExtensions
|
||||
{
|
||||
public static void AttachDevTools(this TopLevel control)
|
||||
{
|
||||
Avalonia.Diagnostics.DevTools.Attach(control);
|
||||
}
|
||||
}
|
||||
public static class DevToolsExtensions
|
||||
{
|
||||
public static void AttachDevTools(this TopLevel control)
|
||||
{
|
||||
Diagnostics.DevTools.Attach(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Avalonia.Diagnostics
|
||||
{
|
||||
public class DevTools : UserControl
|
||||
public class DevTools : UserControl
|
||||
{
|
||||
private static Dictionary<TopLevel, Window> s_open = new Dictionary<TopLevel, Window>();
|
||||
private static HashSet<IRenderRoot> s_visualTreeRoots = new HashSet<IRenderRoot>();
|
||||
private IDisposable _keySubscription;
|
||||
private static readonly Dictionary<TopLevel, Window> s_open = new Dictionary<TopLevel, Window>();
|
||||
private static readonly HashSet<IRenderRoot> s_visualTreeRoots = new HashSet<IRenderRoot>();
|
||||
private readonly IDisposable _keySubscription;
|
||||
|
||||
public DevTools(IControl root)
|
||||
{
|
||||
@@ -49,7 +48,6 @@ namespace Avalonia.Diagnostics
|
||||
// HACK: needed for XAMLIL, will fix that later
|
||||
public DevTools()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IControl Root { get; }
|
||||
@@ -67,9 +65,8 @@ namespace Avalonia.Diagnostics
|
||||
if (e.Key == Key.F12)
|
||||
{
|
||||
var control = (TopLevel)sender;
|
||||
var devToolsWindow = default(Window);
|
||||
|
||||
if (s_open.TryGetValue(control, out devToolsWindow))
|
||||
if (s_open.TryGetValue(control, out var devToolsWindow))
|
||||
{
|
||||
devToolsWindow.Activate();
|
||||
}
|
||||
@@ -82,10 +79,7 @@ namespace Avalonia.Diagnostics
|
||||
Width = 1024,
|
||||
Height = 512,
|
||||
Content = devTools,
|
||||
DataTemplates =
|
||||
{
|
||||
new ViewLocator<ViewModelBase>(),
|
||||
},
|
||||
DataTemplates = { new ViewLocator<ViewModelBase>() },
|
||||
Title = "Avalonia DevTools"
|
||||
};
|
||||
|
||||
@@ -118,7 +112,6 @@ namespace Avalonia.Diagnostics
|
||||
|
||||
if ((e.Modifiers) == modifiers)
|
||||
{
|
||||
|
||||
var point = (Root.VisualRoot as IInputRoot)?.MouseDevice?.GetPosition(Root) ?? default(Point);
|
||||
var control = Root.GetVisualsAt(point, x => (!(x is AdornerLayer) && x.IsVisible))
|
||||
.FirstOrDefault();
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Avalonia.Diagnostics.Models
|
||||
{
|
||||
Contract.Requires<ArgumentNullException>(handler != null);
|
||||
|
||||
this.Handler = handler;
|
||||
this.Handled = handled;
|
||||
this.Route = route;
|
||||
Handler = handler;
|
||||
Handled = handled;
|
||||
Route = route;
|
||||
}
|
||||
|
||||
public object Handler { get; }
|
||||
@@ -27,6 +27,7 @@ namespace Avalonia.Diagnostics.Models
|
||||
{
|
||||
return named.Name + " (" + Handler.GetType().Name + ")";
|
||||
}
|
||||
|
||||
return Handler.GetType().Name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,6 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> Classes
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public IEnumerable<PropertyDetails> Properties
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public IEnumerable<PropertyDetails> Properties { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
|
||||
@@ -13,22 +13,18 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
{
|
||||
internal class EventOwnerTreeNode : EventTreeNodeBase
|
||||
{
|
||||
private static readonly RoutedEvent[] s_defaultEvents = new RoutedEvent[]
|
||||
private static readonly RoutedEvent[] s_defaultEvents =
|
||||
{
|
||||
Button.ClickEvent,
|
||||
InputElement.KeyDownEvent,
|
||||
InputElement.KeyUpEvent,
|
||||
InputElement.TextInputEvent,
|
||||
InputElement.PointerReleasedEvent,
|
||||
InputElement.PointerPressedEvent,
|
||||
Button.ClickEvent, InputElement.KeyDownEvent, InputElement.KeyUpEvent, InputElement.TextInputEvent,
|
||||
InputElement.PointerReleasedEvent, InputElement.PointerPressedEvent
|
||||
};
|
||||
|
||||
public EventOwnerTreeNode(Type type, IEnumerable<RoutedEvent> events, EventsViewModel vm)
|
||||
: base(null, type.Name)
|
||||
{
|
||||
this.Children = new AvaloniaList<EventTreeNodeBase>(events.OrderBy(e => e.Name)
|
||||
Children = new AvaloniaList<EventTreeNodeBase>(events.OrderBy(e => e.Name)
|
||||
.Select(e => new EventTreeNode(this, e, vm) { IsEnabled = s_defaultEvents.Contains(e) }));
|
||||
this.IsExpanded = true;
|
||||
IsExpanded = true;
|
||||
}
|
||||
|
||||
public override bool? IsEnabled
|
||||
@@ -39,6 +35,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
if (base.IsEnabled != value)
|
||||
{
|
||||
base.IsEnabled = value;
|
||||
|
||||
if (_updateChildren && value != null)
|
||||
{
|
||||
foreach (var child in Children)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
|
||||
using Avalonia.Diagnostics.Models;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
@@ -12,8 +11,8 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
{
|
||||
internal class EventTreeNode : EventTreeNodeBase
|
||||
{
|
||||
private RoutedEvent _event;
|
||||
private EventsViewModel _parentViewModel;
|
||||
private readonly RoutedEvent _event;
|
||||
private readonly EventsViewModel _parentViewModel;
|
||||
private bool _isRegistered;
|
||||
private FiredEvent _currentEvent;
|
||||
|
||||
@@ -23,8 +22,8 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
Contract.Requires<ArgumentNullException>(@event != null);
|
||||
Contract.Requires<ArgumentNullException>(vm != null);
|
||||
|
||||
this._event = @event;
|
||||
this._parentViewModel = vm;
|
||||
_event = @event;
|
||||
_parentViewModel = vm;
|
||||
}
|
||||
|
||||
public override bool? IsEnabled
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
private bool _isExpanded;
|
||||
private bool? _isEnabled = false;
|
||||
|
||||
public EventTreeNodeBase(EventTreeNodeBase parent, string text)
|
||||
protected EventTreeNodeBase(EventTreeNodeBase parent, string text)
|
||||
{
|
||||
this.Parent = parent;
|
||||
this.Text = text;
|
||||
Parent = parent;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public IAvaloniaReadOnlyList<EventTreeNodeBase> Children
|
||||
@@ -26,14 +26,14 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get { return _isExpanded; }
|
||||
set { RaiseAndSetIfChanged(ref _isExpanded, value); }
|
||||
get => _isExpanded;
|
||||
set => RaiseAndSetIfChanged(ref _isExpanded, value);
|
||||
}
|
||||
|
||||
public virtual bool? IsEnabled
|
||||
{
|
||||
get { return _isEnabled; }
|
||||
set { RaiseAndSetIfChanged(ref _isEnabled, value); }
|
||||
get => _isEnabled;
|
||||
set => RaiseAndSetIfChanged(ref _isEnabled, value);
|
||||
}
|
||||
|
||||
public EventTreeNodeBase Parent
|
||||
@@ -44,7 +44,6 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
public string Text
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
internal void UpdateChecked()
|
||||
@@ -55,7 +54,9 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
{
|
||||
if (Children == null)
|
||||
return false;
|
||||
|
||||
bool? value = false;
|
||||
|
||||
for (int i = 0; i < Children.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
using Avalonia.Diagnostics.Models;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
@@ -11,7 +10,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
{
|
||||
internal class FiredEvent : ViewModelBase
|
||||
{
|
||||
private RoutedEventArgs _eventArgs;
|
||||
private readonly RoutedEventArgs _eventArgs;
|
||||
private EventChainLink _handledBy;
|
||||
|
||||
public FiredEvent(RoutedEventArgs eventArgs, EventChainLink originator)
|
||||
@@ -19,8 +18,8 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
Contract.Requires<ArgumentNullException>(eventArgs != null);
|
||||
Contract.Requires<ArgumentNullException>(originator != null);
|
||||
|
||||
this._eventArgs = eventArgs;
|
||||
this.Originator = originator;
|
||||
_eventArgs = eventArgs;
|
||||
Originator = originator;
|
||||
AddToChain(originator);
|
||||
}
|
||||
|
||||
@@ -42,8 +41,9 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
if (IsHandled)
|
||||
{
|
||||
return $"{Event.Name} on {Originator.HandlerName};" + Environment.NewLine +
|
||||
$"strategies: {Event.RoutingStrategies}; handled by: {HandledBy.HandlerName}";
|
||||
$"strategies: {Event.RoutingStrategies}; handled by: {HandledBy.HandlerName}";
|
||||
}
|
||||
|
||||
return $"{Event.Name} on {Originator.HandlerName}; strategies: {Event.RoutingStrategies}";
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public EventChainLink HandledBy
|
||||
{
|
||||
get { return _handledBy; }
|
||||
get => _handledBy;
|
||||
set
|
||||
{
|
||||
if (_handledBy != value)
|
||||
|
||||
@@ -17,8 +17,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public static LogicalTreeNode[] Create(object control)
|
||||
{
|
||||
var logical = control as ILogical;
|
||||
return logical != null ? new[] { new LogicalTreeNode(logical, null) } : null;
|
||||
return control is ILogical logical ? new[] { new LogicalTreeNode(logical, null) } : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
Value = diagnostic.Value ?? "(null)";
|
||||
Priority = (diagnostic.Priority != BindingPriority.Unset) ?
|
||||
diagnostic.Priority.ToString() :
|
||||
diagnostic.Property.Inherits ? "Inherited" : "Unset";
|
||||
diagnostic.Property.Inherits ?
|
||||
"Inherited" :
|
||||
"Unset";
|
||||
Diagnostic = diagnostic.Diagnostic;
|
||||
});
|
||||
}
|
||||
@@ -37,20 +39,20 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public string Priority
|
||||
{
|
||||
get { return _priority; }
|
||||
private set { RaiseAndSetIfChanged(ref _priority, value); }
|
||||
get => _priority;
|
||||
private set => RaiseAndSetIfChanged(ref _priority, value);
|
||||
}
|
||||
|
||||
public string Diagnostic
|
||||
{
|
||||
get { return _diagnostic; }
|
||||
private set { RaiseAndSetIfChanged(ref _diagnostic, value); }
|
||||
get => _diagnostic;
|
||||
private set => RaiseAndSetIfChanged(ref _diagnostic, value);
|
||||
}
|
||||
|
||||
public object Value
|
||||
{
|
||||
get { return _value; }
|
||||
private set { RaiseAndSetIfChanged(ref _value, value); }
|
||||
get => _value;
|
||||
private set => RaiseAndSetIfChanged(ref _value, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
var classesChanged = Observable.FromEventPattern<
|
||||
NotifyCollectionChangedEventHandler,
|
||||
NotifyCollectionChangedEventArgs>(
|
||||
x => styleable.Classes.CollectionChanged += x,
|
||||
x => styleable.Classes.CollectionChanged -= x)
|
||||
.TakeUntil(((IStyleable)styleable).StyleDetach);
|
||||
x => styleable.Classes.CollectionChanged += x,
|
||||
x => styleable.Classes.CollectionChanged -= x)
|
||||
.TakeUntil(styleable.StyleDetach);
|
||||
|
||||
classesChanged.Select(_ => Unit.Default)
|
||||
.StartWith(Unit.Default)
|
||||
@@ -55,8 +55,8 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public string Classes
|
||||
{
|
||||
get { return _classes; }
|
||||
private set { RaiseAndSetIfChanged(ref _classes, value); }
|
||||
get => _classes;
|
||||
private set => RaiseAndSetIfChanged(ref _classes, value);
|
||||
}
|
||||
|
||||
public IVisual Visual
|
||||
@@ -66,8 +66,8 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get { return _isExpanded; }
|
||||
set { RaiseAndSetIfChanged(ref _isExpanded, value); }
|
||||
get => _isExpanded;
|
||||
set => RaiseAndSetIfChanged(ref _isExpanded, value);
|
||||
}
|
||||
|
||||
public TreeNode Parent
|
||||
@@ -78,7 +78,6 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
public string Type
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public TreeNode SelectedNode
|
||||
{
|
||||
get { return _selected; }
|
||||
get => _selected;
|
||||
set
|
||||
{
|
||||
if (RaiseAndSetIfChanged(ref _selected, value))
|
||||
@@ -35,8 +35,8 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
|
||||
public ControlDetailsViewModel Details
|
||||
{
|
||||
get { return _details; }
|
||||
private set { RaiseAndSetIfChanged(ref _details, value); }
|
||||
get => _details;
|
||||
private set => RaiseAndSetIfChanged(ref _details, value);
|
||||
}
|
||||
|
||||
public TreeNode FindNode(IControl control)
|
||||
@@ -66,7 +66,7 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
{
|
||||
control = control.GetVisualParent<IControl>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node != null)
|
||||
{
|
||||
@@ -90,16 +90,14 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
{
|
||||
return node;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
var result = FindNode(child, control);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var child in node.Children)
|
||||
{
|
||||
var result = FindNode(child, control);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,11 @@ namespace Avalonia.Diagnostics.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInTemplate { get; private set; }
|
||||
public bool IsInTemplate { get; }
|
||||
|
||||
public static VisualTreeNode[] Create(object control)
|
||||
{
|
||||
var visual = control as IVisual;
|
||||
return visual != null ? new[] { new VisualTreeNode(visual, null) } : null;
|
||||
return control is IVisual visual ? new[] { new VisualTreeNode(visual, null) } : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
{
|
||||
private static readonly StyledProperty<ControlDetailsViewModel> ViewModelProperty =
|
||||
AvaloniaProperty.Register<ControlDetailsView, ControlDetailsViewModel>(nameof(ViewModel));
|
||||
|
||||
private SimpleGrid _grid;
|
||||
|
||||
public ControlDetailsView()
|
||||
@@ -25,7 +26,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
|
||||
public ControlDetailsViewModel ViewModel
|
||||
{
|
||||
get { return GetValue(ViewModelProperty); }
|
||||
get => GetValue(ViewModelProperty);
|
||||
private set
|
||||
{
|
||||
SetValue(ViewModelProperty, value);
|
||||
@@ -37,13 +38,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
{
|
||||
Func<object, IEnumerable<Control>> pt = PropertyTemplate;
|
||||
|
||||
Content = new ScrollViewer
|
||||
{
|
||||
Content = _grid = new SimpleGrid
|
||||
{
|
||||
[GridRepeater.TemplateProperty] = pt,
|
||||
}
|
||||
};
|
||||
Content = new ScrollViewer { Content = _grid = new SimpleGrid { [GridRepeater.TemplateProperty] = pt } };
|
||||
}
|
||||
|
||||
private IEnumerable<Control> PropertyTemplate(object i)
|
||||
@@ -57,7 +52,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
Margin = margin,
|
||||
Text = property.Name,
|
||||
TextWrapping = TextWrapping.NoWrap,
|
||||
[!ToolTip.TipProperty] = property.GetObservable<string>(nameof(property.Diagnostic)).ToBinding(),
|
||||
[!ToolTip.TipProperty] = property.GetObservable<string>(nameof(property.Diagnostic)).ToBinding()
|
||||
};
|
||||
|
||||
yield return new TextBlock
|
||||
@@ -66,14 +61,14 @@ namespace Avalonia.Diagnostics.Views
|
||||
TextWrapping = TextWrapping.NoWrap,
|
||||
[!TextBlock.TextProperty] = property.GetObservable<object>(nameof(property.Value))
|
||||
.Select(v => v?.ToString())
|
||||
.ToBinding(),
|
||||
.ToBinding()
|
||||
};
|
||||
|
||||
yield return new TextBlock
|
||||
{
|
||||
Margin = margin,
|
||||
TextWrapping = TextWrapping.NoWrap,
|
||||
[!TextBlock.TextProperty] = property.GetObservable<string>((nameof(property.Priority))).ToBinding(),
|
||||
[!TextBlock.TextProperty] = property.GetObservable<string>((nameof(property.Priority))).ToBinding()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,53 +2,57 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:Avalonia.Diagnostics.ViewModels"
|
||||
x:Class="Avalonia.Diagnostics.Views.EventsView">
|
||||
<UserControl.Resources>
|
||||
<vm:BoolToBrushConverter x:Key="boolToBrush" />
|
||||
</UserControl.Resources>
|
||||
<Grid ColumnDefinitions="*,4,3*">
|
||||
<TreeView Name="tree" Items="{Binding Nodes}" SelectedItem="{Binding SelectedNode, Mode=TwoWay}" Grid.RowSpan="2">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="vm:EventTreeNodeBase"
|
||||
ItemsSource="{Binding Children}">
|
||||
<CheckBox Content="{Binding Text}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" />
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
</Style>
|
||||
</TreeView.Styles>
|
||||
</TreeView>
|
||||
|
||||
<GridSplitter Width="4" Grid.Column="1" />
|
||||
<Grid RowDefinitions="*,4,2*,Auto" Grid.Column="2">
|
||||
<ListBox Name="eventsList" Items="{Binding RecordedEvents}" SelectedItem="{Binding SelectedEvent, Mode=TwoWay}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Background="{Binding IsHandled, Converter={StaticResource boolToBrush}}" Text="{Binding DisplayText}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<GridSplitter Height="4" Grid.Row="1" />
|
||||
<DockPanel Grid.Row="2" LastChildFill="True">
|
||||
<TextBlock DockPanel.Dock="Top" FontSize="16" Text="Event chain:" />
|
||||
<ListBox Items="{Binding SelectedEvent.EventChain}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Background="{Binding Handled, Converter={StaticResource boolToBrush}}">
|
||||
<TextBlock Text="{Binding Route}" />
|
||||
<TextBlock Text=": " />
|
||||
<TextBlock Text="{Binding HandlerName}" />
|
||||
<TextBlock Text=" handled: " />
|
||||
<TextBlock Text="{Binding Handled}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="3">
|
||||
<Button Content="Clear" Margin="3" Command="{Binding Clear}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<UserControl.Resources>
|
||||
<vm:BoolToBrushConverter x:Key="boolToBrush" />
|
||||
</UserControl.Resources>
|
||||
<Grid ColumnDefinitions="*,4,3*">
|
||||
<TreeView Name="tree" Items="{Binding Nodes}" SelectedItem="{Binding SelectedNode, Mode=TwoWay}"
|
||||
Grid.RowSpan="2">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="vm:EventTreeNodeBase"
|
||||
ItemsSource="{Binding Children}">
|
||||
<CheckBox Content="{Binding Text}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" />
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
||||
</Style>
|
||||
</TreeView.Styles>
|
||||
</TreeView>
|
||||
|
||||
<GridSplitter Width="4" Grid.Column="1" />
|
||||
<Grid RowDefinitions="*,4,2*,Auto" Grid.Column="2">
|
||||
<ListBox Name="eventsList" Items="{Binding RecordedEvents}"
|
||||
SelectedItem="{Binding SelectedEvent, Mode=TwoWay}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Background="{Binding IsHandled, Converter={StaticResource boolToBrush}}"
|
||||
Text="{Binding DisplayText}" />
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<GridSplitter Height="4" Grid.Row="1" />
|
||||
<DockPanel Grid.Row="2" LastChildFill="True">
|
||||
<TextBlock DockPanel.Dock="Top" FontSize="16" Text="Event chain:" />
|
||||
<ListBox Items="{Binding SelectedEvent.EventChain}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Background="{Binding Handled, Converter={StaticResource boolToBrush}}">
|
||||
<TextBlock Text="{Binding Route}" />
|
||||
<TextBlock Text=": " />
|
||||
<TextBlock Text="{Binding HandlerName}" />
|
||||
<TextBlock Text=" handled: " />
|
||||
<TextBlock Text="{Binding Handled}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="3">
|
||||
<Button Content="Clear" Margin="3" Command="{Binding Clear}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
||||
using System.Linq;
|
||||
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Diagnostics.ViewModels;
|
||||
using Avalonia.Markup.Xaml;
|
||||
@@ -11,15 +10,16 @@ namespace Avalonia.Diagnostics.Views
|
||||
{
|
||||
public class EventsView : UserControl
|
||||
{
|
||||
private ListBox _events;
|
||||
private readonly ListBox _events;
|
||||
|
||||
public EventsView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
_events = this.FindControl<ListBox>("events");
|
||||
}
|
||||
|
||||
private void RecordedEvents_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
private void RecordedEvents_CollectionChanged(object sender,
|
||||
System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
_events.ScrollIntoView(_events.Items.OfType<FiredEvent>().LastOrDefault());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Avalonia.Diagnostics.Views
|
||||
AvaloniaProperty.RegisterAttached<SimpleGrid, IEnumerable>("Items", typeof(GridRepeater));
|
||||
|
||||
public static readonly AttachedProperty<Func<object, IEnumerable<Control>>> TemplateProperty =
|
||||
AvaloniaProperty.RegisterAttached<SimpleGrid, Func<object, IEnumerable<Control>>>("Template", typeof(GridRepeater));
|
||||
AvaloniaProperty.RegisterAttached<SimpleGrid, Func<object, IEnumerable<Control>>>("Template",
|
||||
typeof(GridRepeater));
|
||||
|
||||
static GridRepeater()
|
||||
{
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace Avalonia.Diagnostics.Views
|
||||
}
|
||||
|
||||
return Observable.FromEventPattern<PropertyChangedEventHandler, PropertyChangedEventArgs>(
|
||||
e => source.PropertyChanged += e,
|
||||
e => source.PropertyChanged -= e)
|
||||
.Where(e => e.EventArgs.PropertyName == propertyName)
|
||||
.Select(_ => (T)property.GetValue(source))
|
||||
.StartWith((T)property.GetValue(source));
|
||||
e => source.PropertyChanged += e,
|
||||
e => source.PropertyChanged -= e)
|
||||
.Where(e => e.EventArgs.PropertyName == propertyName)
|
||||
.Select(_ => (T)property.GetValue(source))
|
||||
.StartWith((T)property.GetValue(source));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Avalonia.Diagnostics.Views
|
||||
/// </remarks>
|
||||
public class SimpleGrid : Panel
|
||||
{
|
||||
private List<double> _columnWidths = new List<double>();
|
||||
private List<double> _rowHeights = new List<double>();
|
||||
private readonly List<double> _columnWidths = new List<double>();
|
||||
private readonly List<double> _rowHeights = new List<double>();
|
||||
private double _totalWidth;
|
||||
private double _totalHeight;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
/// </summary>
|
||||
public static readonly AttachedProperty<int> RowProperty =
|
||||
AvaloniaProperty.RegisterAttached<SimpleGrid, Control, int>("Row");
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the Column attached property for a control.
|
||||
/// </summary>
|
||||
@@ -62,7 +62,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
control.SetValue(ColumnProperty, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets the value of the Row attached property for a control.
|
||||
/// </summary>
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
xmlns:vm="clr-namespace:Avalonia.Diagnostics.ViewModels"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Avalonia.Diagnostics.Views.TreePageView">
|
||||
<Grid ColumnDefinitions="*,4,3*">
|
||||
<Grid ColumnDefinitions="*,4,3*">
|
||||
<TreeView Name="tree" Items="{Binding Nodes}" SelectedItem="{Binding SelectedNode, Mode=TwoWay}">
|
||||
<TreeView.DataTemplates>
|
||||
<TreeDataTemplate DataType="vm:TreeNode"
|
||||
ItemsSource="{Binding Children}">
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock Text="{Binding Type}"/>
|
||||
<TextBlock Text="{Binding Classes}"/>
|
||||
<TextBlock Text="{Binding Type}" />
|
||||
<TextBlock Text="{Binding Classes}" />
|
||||
</StackPanel>
|
||||
</TreeDataTemplate>
|
||||
</TreeView.DataTemplates>
|
||||
<TreeView.Styles>
|
||||
<Style Selector="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
||||
</Style>
|
||||
</TreeView.Styles>
|
||||
</TreeView>
|
||||
|
||||
<GridSplitter Width="4" Grid.Column="1"/>
|
||||
<ContentControl Content="{Binding Details}" Grid.Column="2"/>
|
||||
<GridSplitter Width="4" Grid.Column="1" />
|
||||
<ContentControl Content="{Binding Details}" Grid.Column="2" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
|
||||
public TreePageView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
InitializeComponent();
|
||||
_tree.ItemContainerGenerator.Index.Materialized += TreeViewItemMaterialized;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Avalonia.Diagnostics.Views
|
||||
_adorner = new Rectangle
|
||||
{
|
||||
Fill = new SolidColorBrush(0x80a0c5e8),
|
||||
[AdornerLayer.AdornedElementProperty] = node.Visual,
|
||||
[AdornerLayer.AdornedElementProperty] = node.Visual
|
||||
};
|
||||
|
||||
layer.Children.Add(_adorner);
|
||||
|
||||
Reference in New Issue
Block a user