예제 #1
0
 public void Location_LocationPingChanged(object sender, LocationPingChangedEventArgs e)
 {
     if (CurrentBestLocation == null)
     {
         CurrentBestLocation = e.NewLocationPing;
     }
     else if ((CurrentBestLocation.Server == e.NewLocationPing.Server) && (e.NewLocationPing.Ping == 0))
     {
         CurrentBestLocation = null;
         Debug.WriteLine($"{e.NewLocationPing.LocationName}-{e.NewLocationPing.Server}-{e.NewLocationPing.Ping}");
     }
     else
     {
         if (e.NewLocationPing.Server == CurrentBestLocation.Server)
         {
             CurrentBestLocation.Ping = e.NewLocationPing.Ping;
             Debug.WriteLine($"{e.NewLocationPing.LocationName}-{e.NewLocationPing.Server}-{e.NewLocationPing.Ping}");
         }
         else if ((e.NewLocationPing.Ping > 0) && (e.NewLocationPing.Ping < CurrentBestLocation.Ping))
         {
             CurrentBestLocation = e.NewLocationPing;
             Debug.WriteLine($"{e.NewLocationPing.LocationName}-{e.NewLocationPing.Server}-{e.NewLocationPing.Ping}");
         }
     }
 }
예제 #2
0
        private void PingExecuter_PingChanged(object sender, PingChangedEventArgs e)
        {
            var location = new LocationPingChanged();

            location.Icon         = Icon;
            location.LocationName = Name;
            location.Server       = e.NewPing.Server;
            location.Ping         = e.NewPing.Ping;

            var args = new LocationPingChangedEventArgs();

            args.NewLocationPing = location;

            LocationPingChanged?.Invoke(this, args);
        }