Split logic and design

This commit is contained in:
Manuel Thalmann 2024-03-22 02:23:46 +01:00
parent 7241a265e6
commit bedbe2ea84
3 changed files with 5 additions and 35 deletions

View file

@ -54,6 +54,7 @@ namespace DT3 {
{
url = value;
NotifyPropertyChanged();
_ = urlTester.GetUrlAsync(Url);
}
}

View file

@ -5,7 +5,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DT3"
mc:Ignorable="d"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="MainWindow"
Height="450"
Width="800">
@ -33,10 +32,9 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Content="GetUrl"
IsDefault="true"
Click="GetUrl" />
IsDefault="true" />
<TextBox Grid.Column="2"
x:Name="urlBox" />
Text="{Binding Url, Mode=OneWayToSource}" />
</Grid>
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>

View file

@ -10,6 +10,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DT2;
using DT3;
namespace UrlTester;
@ -18,39 +19,9 @@ namespace UrlTester;
/// </summary>
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()
{
InitializeComponent();
}
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);
DataContext = new UrlTesterModel();
}
}