66 lines
No EOL
1.7 KiB
C#
66 lines
No EOL
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using DT2;
|
|
|
|
namespace DT3 {
|
|
|
|
public class UrlTesterModel : INotifyPropertyChanged {
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
int size;
|
|
int time;
|
|
string url;
|
|
DT2.UrlTester urlTester;
|
|
|
|
public UrlTesterModel() {
|
|
urlTester = new DT2.UrlTester();
|
|
IDictionary<string, Stopwatch> sw = new Dictionary<string, Stopwatch>();
|
|
urlTester.PageStart += url => { sw.Add(url, Stopwatch.StartNew()); };
|
|
urlTester.PageLoaded += (url, size) => {
|
|
sw[url].Stop();
|
|
int time = (int)sw[url].Elapsed.TotalMilliseconds;
|
|
Size = size;
|
|
Time = time;
|
|
sw.Remove(url);
|
|
};
|
|
}
|
|
|
|
public int Size {
|
|
get { return size; }
|
|
set
|
|
{
|
|
NotifyPropertyChanged();
|
|
size = value;
|
|
}
|
|
}
|
|
|
|
public int Time {
|
|
get { return time; }
|
|
set
|
|
{
|
|
NotifyPropertyChanged();
|
|
time = value;
|
|
}
|
|
}
|
|
|
|
public string Url {
|
|
get { return url; }
|
|
set
|
|
{
|
|
NotifyPropertyChanged();
|
|
url = value;
|
|
}
|
|
}
|
|
|
|
protected void NotifyPropertyChanged([CallerMemberName] string memberName = null)
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(memberName));
|
|
}
|
|
}
|
|
|
|
} |