zhaw-dnet2/Tasks/UrlTester/MainWindow.xaml.cs

56 lines
1.3 KiB
C#
Raw Normal View History

2024-03-21 23:25:00 +00:00
using System.Diagnostics;
using System.Text;
2024-03-21 22:24:29 +00:00
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
2024-03-21 23:25:00 +00:00
using DT2;
2024-03-21 22:24:29 +00:00
2024-03-21 22:43:09 +00:00
namespace UrlTester;
2024-03-21 22:24:29 +00:00
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </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));
2024-03-21 22:24:29 +00:00
public MainWindow()
{
InitializeComponent();
}
2024-03-21 23:25:00 +00:00
public void GetUrl(object sender, RoutedEventArgs e)
{
2024-03-21 23:56:40 +00:00
var tester = new DT2.UrlTester();
2024-03-21 23:25:00 +00:00
var stopWatch = new Stopwatch();
2024-03-21 23:56:40 +00:00
tester.PageStart += (_) =>
{
stopWatch.Start();
};
tester.PageLoaded += (_, size) =>
{
stopWatch.Stop();
SetValue(SizeProperty, size);
SetValue(TimeProperty, stopWatch.ElapsedMilliseconds);
Debug.WriteLine("");
2024-03-21 23:56:40 +00:00
};
_ = tester.GetUrlAsync(urlBox.Text);
2024-03-21 23:25:00 +00:00
}
2024-03-21 22:24:29 +00:00
}