public MainPageViewModel(INavigationService navigationService) : base(navigationService) { Title = "Scan Page"; ScanCommand = new DelegateCommand(Scan); EnableFilteringCommand = new DelegateCommand(EnableFiltering); EnableFavoriteCommand = new DelegateCommand(EnableFavorite); SetFilteringParamCommand = new DelegateCommand(SetFilteringParam); ScanedDevices = new ObservableCollection <DeviceViewModel>(); filteringParam = new DeviceViewModel(); this.Scan(); }
private void AddDevice(IScanResult result) { bool isExited = false; int index = 0; foreach (var device in ScanedDevices) { if (device.Uuid.Equals(result.Device.Uuid.ToString())) { isExited = true; device.Update(result); break; } index++; } if (isExited == false) { if (IsFavorite) { return; } if (IsFiltering == false) { var d = new DeviceViewModel(result); ScanedDevices.Add(d); } else { var d = new DeviceViewModel(result); if (this.IsMeetFilteringCondition(d, filteringParam)) { ScanedDevices.Add(d); } } } }
private bool IsMeetFilteringCondition(DeviceViewModel device, DeviceViewModel filter) { bool isFiltering = false; if (filter.IsEmptyData()) { return(true); } var empty = new DeviceViewModel(); if (device.Name.IndexOf(filter.Name, StringComparison.OrdinalIgnoreCase) >= 0) { if (device.Uuid.IndexOf(filter.Uuid, StringComparison.OrdinalIgnoreCase) >= 0) { if (device.Rssi > filter.Rssi) { isFiltering = true; } } } return(isFiltering); }
public override void OnNavigatedTo(NavigationParameters parameters) { Device = (DeviceViewModel)parameters["device"]; }