Split logic and design
This commit is contained in:
parent
7241a265e6
commit
bedbe2ea84
3 changed files with 5 additions and 35 deletions
|
@ -54,6 +54,7 @@ namespace DT3 {
|
||||||
{
|
{
|
||||||
url = value;
|
url = value;
|
||||||
NotifyPropertyChanged();
|
NotifyPropertyChanged();
|
||||||
|
_ = urlTester.GetUrlAsync(Url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:DT3"
|
xmlns:local="clr-namespace:DT3"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
|
||||||
Title="MainWindow"
|
Title="MainWindow"
|
||||||
Height="450"
|
Height="450"
|
||||||
Width="800">
|
Width="800">
|
||||||
|
@ -33,10 +32,9 @@
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Button Content="GetUrl"
|
<Button Content="GetUrl"
|
||||||
IsDefault="true"
|
IsDefault="true" />
|
||||||
Click="GetUrl" />
|
|
||||||
<TextBox Grid.Column="2"
|
<TextBox Grid.Column="2"
|
||||||
x:Name="urlBox" />
|
Text="{Binding Url, Mode=OneWayToSource}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<StackPanel.Resources>
|
<StackPanel.Resources>
|
||||||
|
|
|
@ -10,6 +10,7 @@ using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using DT2;
|
using DT2;
|
||||||
|
using DT3;
|
||||||
|
|
||||||
namespace UrlTester;
|
namespace UrlTester;
|
||||||
|
|
||||||
|
@ -18,39 +19,9 @@ namespace UrlTester;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
public static readonly DependencyProperty SizeProperty = DependencyProperty.Register(
|
|
||||||
"Size",
|
|
||||||
typeof(int),
|
|
||||||
typeof(MainWindow));
|
|
||||||
|
|
||||||
public static readonly DependencyProperty TimeProperty = DependencyProperty.Register(
|
|
||||||
"Time",
|
|
||||||
typeof(long),
|
|
||||||
typeof(MainWindow));
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
DataContext = new UrlTesterModel();
|
||||||
|
|
||||||
public void GetUrl(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
var tester = new DT2.UrlTester();
|
|
||||||
var stopWatch = new Stopwatch();
|
|
||||||
|
|
||||||
tester.PageStart += (_) =>
|
|
||||||
{
|
|
||||||
stopWatch.Start();
|
|
||||||
};
|
|
||||||
|
|
||||||
tester.PageLoaded += (_, size) =>
|
|
||||||
{
|
|
||||||
stopWatch.Stop();
|
|
||||||
SetValue(SizeProperty, size);
|
|
||||||
SetValue(TimeProperty, stopWatch.ElapsedMilliseconds);
|
|
||||||
Debug.WriteLine("");
|
|
||||||
};
|
|
||||||
|
|
||||||
_ = tester.GetUrlAsync(urlBox.Text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue