/// <summary> /// Performs validation based on provided rules and populates <see cref="Errors"/> if any errors occured /// </summary> /// <returns><c>true</c> if validation successful, <c>false</c> otherwise.</returns> public bool Validate() { var errors = _validations.Where(v => !v.Validate(Value)) .Select(v => v.ValidationMessage); _errors.Clear(); _errors.AddRange(errors); IsValid = !_errors.Any(); return(IsValid); }
public async Task InitializeComponents() { try { Components = new ObservableRangeCollection <Component>(); ComponentKeeper componentKeeper = new ComponentKeeper(); await componentKeeper.Reload($"PlaceId={_thisProcess.PlaceId}"); Device.BeginInvokeOnMainThread(() => { Components = new ObservableRangeCollection <Component>(); Components.AddRange(componentKeeper.Items); if (Components.Any()) { if (_thisProcess.ComponentId != null) { Component = Components.Where(c => c.ComponentId == _thisProcess.ComponentId).FirstOrDefault(); } HasComponents = true; } else { HasComponents = false; } }); } catch (Exception ex) { throw; } }
protected override void ViewIsAppearing(object sender, EventArgs e) { base.ViewIsAppearing(sender, e); if (!Teams.Any()) { this.LoadTeamsCommand.Execute(true); } }
protected override void ViewIsAppearing(object sender, EventArgs e) { base.ViewIsAppearing(sender, e); if (!Games.Any()) { LoadGamesCommand.Execute(true); } }
private void InitializeData(ObservableRangeCollection <Transaction> initialObservableCollection) { _groupingItemViews = new ObservableCollection <TransactionItemView>(); initialObservableCollection.CollectionChanged += Items_CollectionChanged; if (initialObservableCollection.Any()) { resumeDashboardGrid.Children.AddVertical(Transform(initialObservableCollection)); } }
private void UpdateSyncLogCollection(IList <SyncLog> syncLogs, bool undoFilteEnabled) { Device.BeginInvokeOnMainThread(() => { if (syncLogs.Any()) { _syncLogsInternal.AddRange(syncLogs.OrderByDescending(_ => _.SyncDate).ToList()); } DeleteHistoryCommand.IsEnabled = _syncLogsInternal.Any(); UndoFilterCommand.IsEnabled = undoFilteEnabled; DeleteHistoryButtonText = undoFilteEnabled ? DeleteHistoryButtonTextFiltered : DeleteHistoryButtonTextStandard; }); }
private bool CanVote() { if (Voting || Loading) { return(false); } if (!Questions.Any()) { return(false); } return(Questions.All(q => q.HasAnswer)); }
public void Add(string ip) { if (!banks.Any(r => r.Ip == ip)) { var newBank = new Bqms { Ip = ip }; banks.Add(newBank); if (banks.Count == 1) { Bank = newBank; } } }
async Task ListarPersonasFiltradas(int skipIndex, int takeIndex) { if (!NoHayNadaMasParaCargar) { GruposEventosAsistentesDTO grupoEventoParaListar = new GruposEventosAsistentesDTO { CodigoEvento = _grupoEvento.Consecutivo, SkipIndexBase = skipIndex, TakeIndexBase = takeIndex, IdiomaBase = App.IdiomaPersona, IdentificadorParaBuscar = TextoBuscador, ZonaHorariaGMTBase = _dateTimeHelper.DifferenceBetweenGMTAndLocalTimeZone }; if (IsNotConnected) { return; } List <GruposEventosAsistentesDTO> listaPersonas = await _grupoService.ListarEventosAsistentesDeUnEvento(grupoEventoParaListar) ?? new List <GruposEventosAsistentesDTO>(); if (listaPersonas != null) { if (listaPersonas.Count > 0) { if (_personas == null) { _personas = new ObservableRangeCollection <GruposEventosAsistentesDTO>(listaPersonas); } else { listaPersonas = listaPersonas.Where(x => !_personas.Any(y => y.Personas.Consecutivo == x.Personas.Consecutivo)).ToList(); _personas.AddRange(listaPersonas); } RaisePropertyChanged(nameof(Personas)); } else { NoHayNadaMasParaCargar = listaPersonas.Count <= 0; } } } }
public async void LoadNavigationGraph() { _locations = new ObservableRangeCollection <Location>(); var ci = CrossMultilingual.Current.CurrentCultureInfo; if (!Application.Current.Properties.ContainsKey("FirstUse")) { string NTUH_YunLin = _resourceManager.GetString("HOSPITAL_NAME_STRING", ci).ToString(); string Taipei_City_Hall = _resourceManager.GetString("TAIPEI_CITY_HALL_STRING", ci).ToString(); NavigraphStorage.GenerateFileRoute(NTUH_YunLin, "NTUH_YunLin"); NavigraphStorage.GenerateFileRoute(Taipei_City_Hall, "Taipei_City_Hall"); Application.Current.Properties["FirstUse"] = false; } foreach (string naviGraphName in NavigraphStorage.GetAllNavigationGraphs()) { _locations.Add(new Location { UserNaming = naviGraphName }); } if (_locations.Any()) { NavigationGraphFiles = _locations; } else { var currentLanguage = CrossMultilingual.Current.CurrentCultureInfo; Page mainPage = Application.Current.MainPage; await mainPage.DisplayAlert( _resourceManager.GetString("GO_SETTING_PAGE_STRING", currentLanguage), _resourceManager.GetString("DOWNLOAD_NAVIGATION_GRAPH_STRING", currentLanguage), _resourceManager.GetString("OK_STRING", currentLanguage)); await mainPage.Navigation.PushAsync(new SettingTableViewPage()); } }
/// <summary> /// Initializes a new instance of the ApplicationSettingsViewModel class. /// </summary> /// <param name="userService">User service</param> /// <param name="subtitlesService">Subtitles service</param> public ApplicationSettingsViewModel(IUserService userService, ISubtitlesService subtitlesService) { _userService = userService; Version = Constants.AppVersion; RefreshCacheSize(); RegisterCommands(); SubtitlesColor = Color.FromRgb(255, 255, 255); Task.Run(async() => { DownloadLimit = await _userService.GetDownloadLimit(); UploadLimit = await _userService.GetUploadLimit(); var defaultSubtitleLanguage = await _userService.GetDefaultSubtitleLanguage(); DefaultHdQuality = await _userService.GetDefaultHdQuality(); try { AvailableSubtitlesLanguages = new ObservableRangeCollection <string>(); var languages = (await subtitlesService.GetSubLanguages()).Select(a => a.LanguageName) .OrderBy(a => a) .ToList(); DispatcherHelper.CheckBeginInvokeOnUI(() => { languages.Insert(0, LocalizationProviderHelper.GetLocalizedValue <string>("NoneLabel")); AvailableSubtitlesLanguages.AddRange( new ObservableRangeCollection <string>(languages)); DefaultSubtitleLanguage = AvailableSubtitlesLanguages.Any(a => a == defaultSubtitleLanguage) ? defaultSubtitleLanguage : LocalizationProviderHelper.GetLocalizedValue <string>("NoneLabel"); }); } catch (Exception ex) { Logger.Error(ex); } }); }
public async void LoadNavigationGraph() { locations = new ObservableRangeCollection <Location>(); foreach (string naviGraphName in NavigraphStorage.GetAllNavigraphs()) { locations.Add(new Location { UserNaming = naviGraphName }); } if (locations.Any()) { NavigationGraphFiles = locations; } else { Page mainPage = Application.Current.MainPage; await mainPage.DisplayAlert("Go to the Setting page", "You should download the navigation graph first", "OK"); await mainPage.Navigation.PushAsync(new SettingTableViewPage()); } }
async Task ListarPersonasFiltradas(int skipIndex, int takeIndex) { List <BuscadorModel> listaBuscadorModel = new List <BuscadorModel>(); if (!NoHayNadaMasParaCargar) { BuscadorDTO buscadorDTO = new BuscadorDTO { CategoriasParaBuscar = new List <int> { _categoriaSeleccionada.CodigoCategoria }, EstaturaInicial = MinimaAltura, EstaturaFinal = MaximaAltura, PesoInicial = MinimoPeso, PesoFinal = MaximoPeso, EdadInicio = MinimaEdad, EdadFinal = MaximaEdad, SkipIndexBase = skipIndex, TakeIndexBase = takeIndex, IdiomaBase = App.IdiomaPersona, IdentificadorParaBuscar = TextoBuscador, FechaInicio = FechaInicio, FechaFinal = FechaFinal, ZonaHorariaGMTBase = _dateTimeHelper.DifferenceBetweenGMTAndLocalTimeZone }; if (PaisSeleccionado != null && PaisSeleccionado.Consecutivo > 0) { buscadorDTO.PaisesParaBuscar = new List <int> { PaisSeleccionado.Consecutivo }; } if (TipoBusqueda == TipoBusqueda.Candidato) { if (IsNotConnected) { return; } List <CandidatosDTO> listaCandidatos = await _candidatoServices.ListarCandidatos(buscadorDTO) ?? new List <CandidatosDTO>(); listaBuscadorModel = (BuscadorModel.CrearListaBuscadorModel(listaCandidatos)); } else if (TipoBusqueda == TipoBusqueda.Grupo) { if (IsNotConnected) { return; } List <GruposDTO> listaGrupos = await _gruposServices.ListarGrupos(buscadorDTO) ?? new List <GruposDTO>(); listaBuscadorModel = BuscadorModel.CrearListaBuscadorModel(listaGrupos); } else if (TipoBusqueda == TipoBusqueda.Evento) { if (IsNotConnected) { return; } List <GruposEventosDTO> listaEventos = await _gruposServices.ListarEventos(buscadorDTO); listaBuscadorModel = BuscadorModel.CrearListaBuscadorModel(listaEventos); } if (listaBuscadorModel != null) { if (listaBuscadorModel.Count > 0) { if (_busqueda == null) { _busqueda = new ObservableRangeCollection <BuscadorModel>(listaBuscadorModel); } else { listaBuscadorModel = listaBuscadorModel.Where(x => !_busqueda.Any(y => y.CodigoPrincipal == x.CodigoPrincipal && y.TipoBusqueda == x.TipoBusqueda)).ToList(); _busqueda.AddRange(listaBuscadorModel); } RaisePropertyChanged("Busqueda"); } else { NoHayNadaMasParaCargar = listaBuscadorModel.Count <= 0; } } } }
private bool IsCheckAllEnabled() { return(_textures.Any(node => !node.IsPicked)); }
async Task CargarItemsEnTimeLineSegunPerfil(int skipIndex, int takeIndex, bool isRefresh = false) { if (Persona != null && !NoHayNadaMasParaCargarPublicacion) { List <BiografiaTimeLineModel> listaTimeLine = new List <BiografiaTimeLineModel>(); if (Persona.TipoPerfil == TipoPerfil.Candidato && Persona.CandidatoDeLaPersona != null) { CandidatosVideosDTO candidatoVideo = new CandidatosVideosDTO { CodigoCandidato = Persona.CandidatoDeLaPersona.Consecutivo, SkipIndexBase = skipIndex, TakeIndexBase = takeIndex, ZonaHorariaGMTBase = _dateTimeHelper.DifferenceBetweenGMTAndLocalTimeZone }; if (isRefresh && LastRefresh != DateTime.MinValue) { candidatoVideo.FechaFiltroBase = LastRefresh; LastRefresh = DateTime.Now; } if (IsNotConnected) { return; } listaTimeLine = BiografiaTimeLineModel.CrearListaBiografiaTimeLine(await _candidatosServices.ListarCandidatosVideosDeUnCandidato(candidatoVideo)); } else if (Persona.TipoPerfil == TipoPerfil.Grupo && Persona.GrupoDeLaPersona != null) { BuscadorDTO grupoEvento = new BuscadorDTO { ConsecutivoPerfil = Persona.GrupoDeLaPersona.Consecutivo, SkipIndexBase = skipIndex, TakeIndexBase = takeIndex, ZonaHorariaGMTBase = _dateTimeHelper.DifferenceBetweenGMTAndLocalTimeZone }; if (isRefresh && LastRefresh != DateTime.MinValue) { grupoEvento.FechaFiltroBase = LastRefresh; LastRefresh = DateTime.Now; } if (IsNotConnected) { return; } listaTimeLine = BiografiaTimeLineModel.CrearListaBiografiaTimeLine(await _gruposServices.ListarEventosDeUnGrupo(grupoEvento)); } if (listaTimeLine != null) { if (listaTimeLine.Count > 0) { if (_timeLine == null) { _timeLine = new ObservableRangeCollection <BiografiaTimeLineModel>(listaTimeLine); } else { // Filtro para evitar tener publicaciones repetidas listaTimeLine = listaTimeLine.Where(x => !_timeLine.Any(y => y.CodigoPublicacion == x.CodigoPublicacion && y.TipoTimeLine == TipoItemTimeLine.Publicacion)).ToList(); if (isRefresh) { // Reverso la lista para mantener el orden listaTimeLine.Reverse(); foreach (var timeLine in listaTimeLine) { _timeLine.Insert(0, timeLine); } } else { _timeLine.AddRange(listaTimeLine); } } RaisePropertyChanged(nameof(TimeLine)); } else { NoHayNadaMasParaCargarPublicacion = listaTimeLine.Count <= 0 && !isRefresh; } } } }
/// <summary> /// Initializes a new instance of the ApplicationSettingsViewModel class. /// </summary> /// <param name="userService">User service</param> /// <param name="subtitlesService">Subtitles service</param> public ApplicationSettingsViewModel(IUserService userService, ISubtitlesService subtitlesService) { _userService = userService; Version = Constants.AppVersion; RefreshCacheSize(); RegisterCommands(); SubtitlesColor = Color.FromRgb(255, 255, 255); ShowTraktDialogCommand = new RelayCommand(async() => { await Messenger.Default.SendAsync(new ShowTraktDialogMessage()); }); Task.Run(async() => { try { SubtitleSizes = new ObservableCollection <SubtitleSize> { new SubtitleSize { Label = LocalizationProviderHelper.GetLocalizedValue <string>("Bigger"), Size = 6 }, new SubtitleSize { Label = LocalizationProviderHelper.GetLocalizedValue <string>("Big"), Size = 12 }, new SubtitleSize { Label = LocalizationProviderHelper.GetLocalizedValue <string>("Normal"), Size = 16 }, new SubtitleSize { Label = LocalizationProviderHelper.GetLocalizedValue <string>("Small"), Size = 18 }, new SubtitleSize { Label = LocalizationProviderHelper.GetLocalizedValue <string>("Smaller"), Size = 20 } }; SelectedSubtitleSize = SubtitleSizes.FirstOrDefault(a => a.Size == 16); DownloadLimit = await _userService.GetDownloadLimit(); UploadLimit = await _userService.GetUploadLimit(); var defaultSubtitleLanguage = await _userService.GetDefaultSubtitleLanguage(); DefaultHdQuality = await _userService.GetDefaultHdQuality(); LoadingSubtitles = true; AvailableSubtitlesLanguages = new ObservableRangeCollection <string>(); var languages = (await subtitlesService.GetSubLanguages()).Select(a => a.LanguageName) .OrderBy(a => a) .ToList(); DispatcherHelper.CheckBeginInvokeOnUI(() => { languages.Insert(0, LocalizationProviderHelper.GetLocalizedValue <string>("NoneLabel")); AvailableSubtitlesLanguages.AddRange( new ObservableRangeCollection <string>(languages)); DefaultSubtitleLanguage = AvailableSubtitlesLanguages.Any(a => a == defaultSubtitleLanguage) ? defaultSubtitleLanguage : LocalizationProviderHelper.GetLocalizedValue <string>("NoneLabel"); LoadingSubtitles = false; }); } catch (Exception ex) { Logger.Error(ex); DispatcherHelper.CheckBeginInvokeOnUI(() => { LoadingSubtitles = false; AvailableSubtitlesLanguages.Insert(0, LocalizationProviderHelper.GetLocalizedValue <string>("NoneLabel")); DefaultSubtitleLanguage = AvailableSubtitlesLanguages.FirstOrDefault(); }); } }); }