Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
using Plugin.Media;
using Plugin.Media.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UEngage.Models;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace UEngage
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Signup : ContentPage
{
public string imageLocation = "";
public Signup()
{
InitializeComponent();
}
private async void btnsignup_Clicked(object sender, EventArgs e)
{
if (txtpassword.Text != txtConfirm.Text)
{
DisplayAlert("", "Password does not match with confirm password", "Ok");
return;
}
if(string.IsNullOrEmpty(txtUsername.Text)|| string.IsNullOrEmpty(txtpostal.Text) ||
string.IsNullOrEmpty(txtpassword.Text) || string.IsNullOrEmpty(txtlastname.Text)||
string.IsNullOrEmpty(txtfirstname.Text) || string.IsNullOrEmpty(txtConfirm.Text))
{
await DisplayAlert("", "Fill all the fields before save", "Ok");
return;
}
else
{
User_ user = new User_()
{
Firstname = txtfirstname.Text,
Password = txtpassword.Text,
Lastname = txtlastname.Text,
Postcode = txtpostal.Text,
Username = txtUsername.Text,
profileimage = imageLocation
};
await App.Database.SaveUserAsync(user);
busyIndi.IsVisible = true;
await Task.Delay(1000);
busyIndi.IsVisible = false;
await DisplayAlert("", "Signup successful. please proceed with login to continue", "Ok");
Xamarin.Essentials.Preferences.Set("log", true);
await Navigation.PopModalAsync();
}
}
private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
{
_ = TakePhotoAsync();
}
async Task TakePhotoAsync()
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}
string imagename = DateTime.Now.ToString("ddMMyyyHHmmss") + ".jpg";
MediaFile file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
Directory = "SampleImages",
Name = imagename
});
if (file == null)
return;
//lblfilelocation.Text = "Image saved Location : " + file.Path;
imageLocation = file.Path;
profimage.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
}
}
}