This commit is contained in:
Florian Rappl 2015-04-16 12:06:56 +02:00
Родитель 0a97febcf9
Коммит 86a66d4af1
5 изменённых файлов: 108 добавлений и 12 удалений

Просмотреть файл

@ -55,6 +55,9 @@
<TabItem Header="Profiler">
<Pages:Profiler DataContext="{Binding Profiler}" />
</TabItem>
<TabItem Header="Errors">
<Pages:Errors DataContext="{Binding Errors}" />
</TabItem>
</TabControl>
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
Text="{Binding Status}"

Просмотреть файл

@ -4,8 +4,85 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<Style TargetType="ListBox"
x:Key="ListStyle"
BasedOn="{StaticResource {x:Type ListBox}}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}"
Value="0">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<TextBlock TextAlignment="Center"
Text="Yippie, no errors!" />
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
</Grid>
<ScrollViewer>
<StackPanel Orientation="Vertical">
<TextBlock Text="HTML"
Foreground="DarkOrange"
FontSize="32" />
<ListBox ItemsSource="{Binding Html}"
Style="{StaticResource ListStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0 4">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Position}"
Grid.Row="0"
Foreground="DarkGray"
TextAlignment="Left"/>
<TextBlock Text="{Binding Code, StringFormat=Code {0}}"
FontWeight="Bold"
Foreground="DarkGray"
Grid.Row="0"
TextAlignment="Right" />
<TextBlock Text="{Binding Message}"
Grid.Row="1" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock Text="CSS"
Foreground="CornflowerBlue"
FontSize="32" />
<ListBox ItemsSource="{Binding Css}"
Style="{StaticResource ListStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0 4">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Text="{Binding Position}"
Grid.Row="0"
Foreground="DarkGray"
TextAlignment="Left"/>
<TextBlock Text="{Binding Code, StringFormat=Code {0}}"
FontWeight="Bold"
Foreground="DarkGray"
Grid.Row="0"
TextAlignment="Right" />
<TextBlock Text="{Binding Message}"
Grid.Row="1" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
</UserControl>

Просмотреть файл

@ -2,22 +2,32 @@
{
using AngleSharp.Events;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
class ErrorsViewModel : BaseViewModel, IEventViewModel
{
readonly IEventAggregator _events;
readonly ObservableCollection<CssParseErrorEvent> _cssErrors;
readonly ObservableCollection<HtmlParseErrorEvent> _htmlErrors;
public ErrorsViewModel(IEventAggregator events)
{
_events = events;
Register<CssParseErrorEvent>(m =>
{
});
Register<HtmlParseErrorEvent>(m =>
{
_cssErrors = new ObservableCollection<CssParseErrorEvent>();
_htmlErrors = new ObservableCollection<HtmlParseErrorEvent>();
Register<CssParseErrorEvent>(m => App.Current.Dispatcher.Invoke(() => _cssErrors.Add(m)));
Register<HtmlParseErrorEvent>(m => App.Current.Dispatcher.Invoke(() => _htmlErrors.Add(m)));
}
});
public IEnumerable<CssParseErrorEvent> Css
{
get { return _cssErrors; }
}
public IEnumerable<HtmlParseErrorEvent> Html
{
get { return _htmlErrors; }
}
void Register<T>(Action<T> listener)
@ -28,7 +38,8 @@
public void Reset()
{
//throw new NotImplementedException();
_cssErrors.Clear();
_htmlErrors.Clear();
}
}
}

Просмотреть файл

@ -80,6 +80,11 @@
get { return dom; }
}
public ErrorsViewModel Errors
{
get { return errors; }
}
public ProfilerViewModel Profiler
{
get { return profiler; }

Просмотреть файл

@ -31,7 +31,7 @@
Register<RequestStartEvent>(m =>
{
var start = _time.Elapsed;
m.Ended += _ => AddItem("Response " + _.Address, OxyColors.Red, start, _time.Elapsed);
m.Ended += _ => AddItem((_ != null ? "Response " + _.Address.Href : "No response"), OxyColors.Red, start, _time.Elapsed);
});
}