public void Update() { state = station.GetState(); SetImageDate(); Temperature = state.Temperature + "°C"; WheatherType = state.WheatherType; }
public WheatherState GetState() { WheatherState state = new WheatherState(); Random rand = new Random(); int index = rand.Next(0, (states.Length - 1)); states[index].Temperature = rand.Next(-30, 30); return(states[index]); }
protected void SetImageDate() { if (state == null) { state = station.GetState(); } BitmapImage img = new BitmapImage(); img.BeginInit(); img.CacheOption = BitmapCacheOption.OnLoad; img.UriSource = new Uri("pack://*****:*****@"/ObserverPattern;component/res/" + state.Path, UriKind.Relative); img.EndInit(); img.Freeze(); WheatherImage = img; }