async Task ExecuteStreamCommand() { if (!IsBusy) { try { IsBusy = true; Servico = new CVService(key, urlStream); if (_imagemStream == null) { await DisplayAlert("Erro", "Nenhuma imagem selecionada", "Ok"); } Model = await Servico.CVSStreamAsync(_imagemStream); ExibirLista(Model); } catch (System.Exception ex) { await DisplayAlert("Erro!", $"Erro:{ex.Message}", "Ok"); } finally { IsBusy = false; } } return; }
async void ExecuteServicoCommand() { if (!IsBusy) { try { IsBusy = true; Servico = new CVService(key, url); Model = await Servico.CVSUrlAsync(Url); ExibirLista(Model); } catch (System.Exception ex) { await DisplayAlert("Erro!", $"Erro:{ex.Message}", "Ok"); } finally { IsBusy = false; } } return; }
public PrincipalViewModel() { ServicoCommand = new Command(ExecuteServicoCommand, () => !IsBusy); StreamCommand = new Command(async() => await ExecuteStreamCommand(), () => !IsBusy); TirarCommand = new Command(async() => await ExecuteTirarCommand(), () => !IsBusy); AbrirCommand = new Command(async() => await ExecuteAbrirCommand(), () => !IsBusy); Model = new CVSModel(); MyPrediction = new ObservableCollection <Prediction>(); }
private void ExibirLista(CVSModel Model) { MyPrediction.Clear(); foreach (var item in Model.Predictions) { MyPrediction.Add(new Prediction { Tag = item.Tag, TagId = item.TagId, Probability = item.Probability }); } }