/// <summary> /// When URL changes stops and restarts everything. /// </summary> private void UrlSelector_URLChanged(object sender, string e) { Pinger.Stop().ContinueWith((previousTask) => { _dispatcher.Invoke(new Action(() => { PingManipulator.Reset(); Graph.Reset(); Display.Reset(); Pinger.Start(e); })); }); }
/// <summary> /// When new ping is calculated notifies other components /// </summary> private void Pinger_NewPing(object sender, PingerData e) { try { _dispatcher.Invoke(new Action(() => { PingManipulatorResult pingManipulatorResult = PingManipulator.Calculate(e); Graph.Draw(pingManipulatorResult); Display.Update(pingManipulatorResult); //_scrollViewerTrainer.ScrollCenter(); })); } catch { } }
/// <summary> /// Creates a new instance of the <see cref="PingTrackerViewModel"/> class. /// </summary> public PingTrackerViewModel(System.Windows.Threading.Dispatcher dispatcher, IScrollViewerTrainer scrollViewerTrainer) { _dispatcher = dispatcher; _scrollViewerTrainer = scrollViewerTrainer; Graph = new Graph(); Pinger = new Pinger(); PingManipulator = new PingManipulator(); Display = new Library.DataDisplay.Display(); Pinger.NewPing += Pinger_NewPing; Pinger.Start(Display.UrlSelector.URL); Display.UrlSelector.URLChanged += UrlSelector_URLChanged; }