public void ClearAll() { foreach (ZoneViewModel zvm in ZoneViewModels) { zvm.DisposeModel(); } ZoneViewModels.Clear(); }
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; }