public MainModel() { Device.StartTimer(TimeSpan.FromSeconds(1), () => { UpdatedData?.Invoke(this, new DataEventArgs() { Count = _count }); _count++; return(true); }); }
public void StartCounter() { Device.StartTimer(TimeSpan.FromSeconds(1), () => { UpdatedData?.Invoke(this, new DataEventArgs() { Count = count }); count++; return(true); }); }
public SignupPage(User existing) { InitializeComponent(); UernameTextSignup.ReturnCommand = new Command(() => EmailTextSignup.Focus()); EmailTextSignup.ReturnCommand = new Command(() => PasswordText1Signup.Focus()); PasswordText1Signup.ReturnCommand = new Command(() => PasswordText2Signup.Focus()); Title = "Update profile data"; UernameTextSignup.Text = existing.Username; EmailTextSignup.Text = existing.Email; SignupBtn.Text = "Update data"; SignupBtn.Clicked -= Signup_Btn_Clicked; SignupBtn.Clicked += async(s, e) => { switch (EntryTests()) { case 1: await DisplayAlert("Empty data", "Please fill all fields.", "OK"); return; case 2: await DisplayAlert("Incorrect password", "Passwords do not match. Please try again.", "OK"); return; case 3: await DisplayAlert("Incorrect username", "Username too short or contains special characters. Please try again.", "OK"); return; case 4: await DisplayAlert("Incorrect password", "Password must be at least 6 characters long. Please try again.", "OK"); return; case 5: await DisplayAlert("Incorrect email", "Email address invalid. Please try again.", "OK"); return; case 0: break; default: await DisplayAlert("Something went wrong", "An unknown error occured.", "OK"); return; } if (EntityLoader.LookForExistingUser(EmailTextSignup.Text, UernameTextSignup.Text)) { await DisplayAlert("Error", "A user with this email or username already exists.", "OK"); return; } else { Encryption enc = new Encryption(); string prevRole = ConstVars.currentUser.Role; int prevId = ConstVars.currentUser.Id; ConstVars.currentUser = new User { Id = prevId, Username = UernameTextSignup.Text, Password = enc.Encrypt(PasswordText1Signup.Text), Email = EmailTextSignup.Text, Role = prevRole }; EntityLoader.UpdateUserData(); await DisplayAlert("Success", "Data change sucessful.", "Great!"); updated?.Invoke(); await Navigation.PopAsync(); } }; }