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 Profile : ContentPage
{
public Profile()
{
InitializeComponent();
txtUsername1.Text = Constant.loggedUser.Firstname + " " + Constant.loggedUser.Lastname;
txtusername2.Text = "Name : " + Constant.loggedUser.Firstname + " " + Constant.loggedUser.Lastname;
txtpostalcode.Text = "Post Code : " + Constant.loggedUser.Postcode;
//txtReportcount.Text = "Reports Subitted : " + "0";
getReportCount();
profilepic.Source = ImageSource.FromFile(Constant.loggedUser.profileimage);
}
private async void getReportCount()
{
var report = await App.Database.GetReportsAsync();
txtReportcount.Text = "Reports Subitted: " + report.Count().ToString();
}
private async void btnlogout_Clicked(object sender, EventArgs e)
{
busyIndi.IsVisible = true;
await Task.Delay(1000);
busyIndi.IsVisible = false;
Xamarin.Essentials.Preferences.Set("log", false);
Application.Current.MainPage = new Login();
}
private void btnChangeprofileimage_Clicked(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;
User_ user = App.Database.GetUserAsync(Constant.loggedUser.Username).Result;
user.profileimage = file.Path;
await App.Database.SaveUserAsync(user);
busyIndi.IsVisible = true;
await Task.Delay(1000);
busyIndi.IsVisible = false;
await DisplayAlert("", "Profile image updated", "Ok");
profilepic.Source = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
return stream;
});
}
}
}