public async void OnZonesFound(object sender, EventArgs <ObservableCollection <ZoneViewModel> > e) { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { if ((ZoneViewModels?.Count() ?? 0) > 0) { ZoneViewModels.Clear(); } //Get saved settings ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; string udn = localSettings.Values["ACTIVEZONE"] as string; //Check is there were settings //If not, get UDN from active Renderer if (string.IsNullOrEmpty(udn)) { udn = PivotItemViewModel.ActiveRenderer?.UDN ?? string.Empty; } bool notChecked = true; ZoneViewModel zone = null; if ((e?.Value?.Count() ?? 0) > 0) { foreach (var vm in e.Value) { vm.IsActive = false; //Save pointer to previous selected zone if (notChecked) { zone = vm; if (udn == vm.Udn) { notChecked = false; } } ZoneViewModels.Add(vm); } if (zone.MediaRenderer != null) { zone.IsActive = true; } await Task.Delay(TimeSpan.FromMilliseconds(500)); foreach (var vm in ZoneViewModels) { await vm.InitVolumes(); } } }); }
public async Task InitViewModel() { await DispatcherHelper.ExecuteOnUIThreadAsync(async() => { ZoneViewModels.Clear(); foreach (var vm in Shell.Instance.ViewModel.ZoneViewModels) { ZoneViewModels.Add(vm); await vm.InitVolumes(); } }); App.UpnpBaseUnit.ZoneLoaded += OnZonesFound; }
private void FillModel(List <Zone> zones) { if (zones.Count > 0) { ClearAll(); foreach (Zone zone in zones) { ZoneViewModel zvm = new ZoneViewModel(Navigation, zone); ZoneViewModels.Add(zvm); } State = ModelState.Normal; } else { State = ModelState.NoData; } }
private void FillModel(List <Zone> zones) { if (zones.Count > 0) { ClearAll(); foreach (Zone zone in zones) { SetDefaultSizes(zone); ZoneViewModel zvm = new ZoneViewModel(Navigation, zone); zvm.OnTap += Zvm_OnTap; ZoneViewModels.Add(zvm); } State = ModelState.Normal; UpdateMinSizes(); Rebuild(true); } else { State = ModelState.NoData; } }