Example #1
0
        protected void DidUpdateWeaherEventHandler(WeatherObject weatherObj)
        {
            if (DidEndUpadateWeather != null)
            {
                DidEndUpadateWeather();
            }

            float temperature = ConverterValueContext.convertTemperature(WeatherModel.CurrentWeather.MainInfo.Temp, this.TemperatureFormat);

            Temperature = string.Format("{0:0.#}", temperature);
            Main        = WeatherModel.CurrentWeather.Main;
            WindSpeed   = WeatherModel.CurrentWeather.MainInfo.Wind.Speed.ToString();
            Humidity    = WeatherModel.CurrentWeather.MainInfo.Humidity.ToString();
            City        = WeatherModel.CurrentWeather.City.Name;
        }
        private string convertTemperature(float value, ConverterValueContext context)
        {
            if (context.TempFormat == TemperatureFormat.Celsius)
            {
                return(String.Format("{0:0.#} °C", value));
            }

            else if (context.TempFormat == TemperatureFormat.Fahrenheit)
            {
                return(String.Format("{0:0.#} °F", value));
            }

            else if (context.TempFormat == TemperatureFormat.Kelvin)
            {
                return(String.Format("{0:0.#} K", value));
            }

            return(value.ToString());
        }
Example #3
0
        private static string convertTemperature(string value, ConverterValueContext context)
        {
            if (context.TempFormat == TemperatureFormat.Celsius)
            {
                return(String.Format("{0} °C", value));
            }

            else if (context.TempFormat == TemperatureFormat.Fahrenheit)
            {
                return(String.Format("{0} °F", value));
            }

            else if (context.TempFormat == TemperatureFormat.Kelvin)
            {
                return(String.Format("{0} K", value));
            }

            return(value);
        }
        protected override string Convert(float value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (parameter != null)
            {
                ConverterValueContext context = parameter as ConverterValueContext;

                if (context.Property == PropertyName.Temperature)
                {
                    return(convertTemperature(ConverterValueContext.convertTemperature(value, context.TempFormat), context));
                }

                else if (context.Property == PropertyName.WindSpeed)
                {
                    return(convertWindSpeed(value, context));
                }

                else if (context.Property == PropertyName.Humidity)
                {
                    return(convertHumidity(value, context));
                }
            }

            return(base.Convert(value, targetType, parameter, culture));
        }
 private string convertHumidity(float value, ConverterValueContext context)
 {
     return(String.Format("Humidity: {0} %", value));
 }
 private string convertWindSpeed(float value, ConverterValueContext context)
 {
     return(String.Format("Wind: {0} mps", value));
 }
Example #7
0
 private string convertWindSpeed(string value, ConverterValueContext context)
 {
     return(String.Format("Wind: {0} meter/sec", value));
 }