private void RemoveListViewItemsMissingFromViewModel(MainFormViewModel viewModelToView) { for (int i = deviceListView.Items.Count - 1; i >= 0; i--) { DeviceViewModel listModel = (DeviceViewModel)deviceListView.Items[i].Tag; DeviceViewModel viewModel = viewModelToView.Devices.SingleOrDefault(d => d.Equals(listModel)); if ((viewModel == null) || (!viewModel.Visible)) deviceListView.Items.RemoveAt(i); } }
private void GetRemoteApplicationModels(Instance instance) { PerformRemoteCommand(instance, (service) => { IEnumerable<Remoting.Server.Data.Transfer.Device> devices; IEnumerable<CryptoCoin> configurations; bool mining, hasChanges, dynamicIntensity; //set some safe defaults in case the call fails this.remoteViewModel = new MainFormViewModel(); service.GetApplicationModels(GetSendingSignature(instance), out devices, out configurations, out mining, out hasChanges, out dynamicIntensity); this.remoteInstanceMining = mining; this.remoteViewModel.HasChanges = hasChanges; this.remoteViewModel.DynamicIntensity = dynamicIntensity; SaveDeviceTransferObjects(devices); SaveCoinTransferObjects(configurations); }); }