public void UpdateWeather() { Dispatcher.UIThread.InvokeAsync(() => { Rectangle dim = this.FindControl <Rectangle>("WeatherDim"); Image gif = this.FindControl <Image>("WeatherGif"); string resource = "MISC.WEATHER_" + battleView.Client.Battle.Weather + ".gif"; switch (battleView.Client.Battle.Weather) { case PBEWeather.Hailstorm: { dim.Fill = hailstormDim; dim.IsVisible = true; GifImage.SetSourceStream(gif, Utils.GetResourceStream(resource)); gif.IsVisible = true; break; } case PBEWeather.HarshSunlight: { dim.Fill = harshSunlightDim; dim.IsVisible = true; gif.IsVisible = false; break; } case PBEWeather.Rain: { dim.Fill = rainDim; dim.IsVisible = true; GifImage.SetSourceStream(gif, Utils.GetResourceStream(resource)); gif.IsVisible = true; break; } case PBEWeather.Sandstorm: { dim.Fill = sandstormDim; dim.IsVisible = true; gif.IsVisible = false; break; } default: { dim.IsVisible = false; gif.IsVisible = false; break; } } }); }