-
-
Save icebeam7/53e2c976b0edc9626528a3bef63b341e to your computer and use it in GitHub Desktop.
ViewModels/AnalisisImagenViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Windows.Input; | |
using System.Threading.Tasks; | |
using System.Collections.ObjectModel; | |
using Xamarin.Forms; | |
using ICTalkMobileApp.Models; | |
using ICTalkMobileApp.Services; | |
namespace ICTalkMobileApp.ViewModels | |
{ | |
public class AnalisisImagenViewModel : BaseViewModel | |
{ | |
private ObservableCollection<Analisis> imagenesSimilares; | |
public ObservableCollection<Analisis> ImagenesSimilares | |
{ | |
get => imagenesSimilares; | |
set { imagenesSimilares = value; OnPropertyChanged(); } | |
} | |
private Analisis imagenActual; | |
public Analisis ImagenActual | |
{ | |
get => imagenActual; | |
set { imagenActual = value; OnPropertyChanged(); } | |
} | |
private string rutaImagen; | |
public string RutaImagen | |
{ | |
get { return rutaImagen; } | |
set { rutaImagen = value; OnPropertyChanged(); } | |
} | |
public ICommand ComandoTomarFoto { get; private set; } | |
public ICommand ComandoSeleccionarFoto { get; private set; } | |
public ICommand ComandoSubirImagen { get; private set; } | |
public ICommand ComandoObtenerSimilares { get; private set; } | |
private ServicioStorage servicioStorage; | |
public AnalisisImagenViewModel() | |
{ | |
servicioStorage = new ServicioStorage(); | |
ComandoTomarFoto = new Command(async () => await TomarFoto()); | |
ComandoSeleccionarFoto = new Command(async () => await SeleccionarFoto()); | |
ComandoSubirImagen = new Command(async () => await SubirImagen()); | |
ComandoObtenerSimilares = new Command(async () => await ObtenerSimilares()); | |
} | |
private async Task TomarFoto() | |
{ | |
RutaImagen = await ServicioImagen.TomarFoto(); | |
} | |
private async Task SeleccionarFoto() | |
{ | |
RutaImagen = await ServicioImagen.SeleccionarFoto(); | |
} | |
private async Task SubirImagen() | |
{ | |
await servicioStorage.SubirImagen(RutaImagen); | |
} | |
private async Task ObtenerSimilares() | |
{ | |
var lista = await servicioStorage.ObtenerImagenesSimilares(RutaImagen); | |
ImagenesSimilares = new ObservableCollection<Analisis>(lista); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment