diff --git a/Ooui/UI.cs b/Ooui/UI.cs index d351b1f..50bf1a8 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -193,7 +193,7 @@ namespace Ooui public static string GetUrl (string path) { var localhost = host == "*" ? "localhost" : host; - var url = Path.Combine($"http://{localhost}:{port}{path}"); + var url = $"http://{localhost}:{port}{path}"; return url; } diff --git a/Samples/WeatherApp/Core.cs b/Samples/WeatherApp/Core.cs index 1d61701..be0ee02 100644 --- a/Samples/WeatherApp/Core.cs +++ b/Samples/WeatherApp/Core.cs @@ -16,11 +16,13 @@ namespace WeatherApp if (results["weather"] != null) { + string tempUnit = GetTempUnit(units); + string speedUnit = GetSpeedUnit(units); Weather weather = new Weather { Title = (string)results["name"], - Temperature = (string)results["main"]["temp"] + " F", - Wind = (string)results["wind"]["speed"] + " mph", + Temperature = (string)results["main"]["temp"] + tempUnit, + Wind = (string)results["wind"]["speed"] + speedUnit, Humidity = (string)results["main"]["humidity"] + " %", Visibility = (string)results["weather"][0]["main"] }; @@ -37,5 +39,29 @@ namespace WeatherApp return null; } } + + private static string GetSpeedUnit(string units) + { + switch (units) + { + case "imperial": + return " mph"; + default: + return " kph"; + } + } + + private static string GetTempUnit(string units) + { + switch (units) + { + case "metric": + return " °C"; + case "imperial": + return " °F"; + default: + return " °K"; + } + } } } diff --git a/Samples/WeatherApp/Weather.cs b/Samples/WeatherApp/Weather.cs index e6e30f4..a97b39f 100644 --- a/Samples/WeatherApp/Weather.cs +++ b/Samples/WeatherApp/Weather.cs @@ -1,4 +1,6 @@ -namespace WeatherApp +using System.Collections.Generic; + +namespace WeatherApp { public class Weather { @@ -9,6 +11,7 @@ public string Visibility { get; set; } public string Sunrise { get; set; } public string Sunset { get; set; } + public List UnitOfMeasures { get; set; } public Weather() { @@ -21,6 +24,7 @@ this.Visibility = " "; this.Sunrise = " "; this.Sunset = " "; + this.UnitOfMeasures = new List{"kelvin", "metric", "imperial"}; } } -} \ No newline at end of file +} diff --git a/Samples/WeatherApp/WeatherPage.xaml b/Samples/WeatherApp/WeatherPage.xaml index 5de42b2..e6cfe03 100644 --- a/Samples/WeatherApp/WeatherPage.xaml +++ b/Samples/WeatherApp/WeatherPage.xaml @@ -35,7 +35,7 @@