private async void SetGeolocation(TcpConnectionInfo connection) { MainWindowModel model = DataContext as MainWindowModel; GeolocationResponse geolocation = await GetLocationFromIp(connection.RemoteIp); if (geolocation != null) { if (model.HighlightedConnection == connection)//check if highlighted con. is still the same one { model.HighlightedGeolocation = $"{geolocation.country}({geolocation.countryCode}), {geolocation.regionName}"; } } }
private void Refresh() { MainWindowModel model = DataContext as MainWindowModel; atc.RefreshList(model.Filter); if (model.SelectedConnection != null) { //change highlighted conn model.HighlightedConnection = model.SelectedConnection; scene.Values.Clear(); model.HighlightedGeolocation = string.Empty; SetGeolocation(model.HighlightedConnection); } model.Connections.Clear(); foreach (TcpConnectionInfo tci in atc.Connections) { model.Connections.Add(tci); } if (model.HighlightedConnection != null) { Win32Error result = atc.Update(model.HighlightedConnection); if (result.Failed) { model.HighlightedConnection = null; scene.Values.Clear(); model.HighlightedGeolocation = string.Empty; } else { model.HighlightedConnection = model.HighlightedConnection;//force bindings update scene.Values.Add(model.HighlightedConnection.RTT); if (scene.Values.Count > 60) { scene.Values.RemoveAt(0); } uint maxVal = scene.Values.Max(); maxVal = Math.Max(maxVal, 100); scene.Height = maxVal; model.GraphHeight = maxVal; } } }