Exemple #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;
        }
        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));
        }