private async void NextIconButton_OnClick(object sender, EventArgs e) { if (!String.IsNullOrEmpty(FullNameTextBox.Text) || !String.IsNullOrEmpty(EmailTextBox.Text) || !String.IsNullOrEmpty(AddressTextBox.Text) || !String.IsNullOrEmpty(PhoneNumberTextBox.Text)) { StaticData.CurrentUser.Name = FullNameTextBox.Text; StaticData.CurrentUser.Email = EmailTextBox.Text; StaticData.CurrentUser.Address = AddressTextBox.Text; StaticData.CurrentUser.PhoneNumber = PhoneNumberTextBox.Text; StaticMethod.ShowProgress(this, "Registering...", 0, true, true); string temp = await UserAPI.Register(StaticData.CurrentUser); StaticMethod.ShowProgress(this, "Registering...", 0, true, false); NavigationService.Navigate( new Uri("/PageGroups/LoginGroup/LoginPage.xaml?username="******"&password="******"Please fill in all box", "Warning", MessageBoxButton.OK); } }
private async Task Login(string username, string password) { StaticMethod.ShowProgress(this, "Logging in...", 0, true, true); string temp = await UserAPI.LoginTask(username, password); JObject jArray = JObject.Parse(temp); StaticData.CurrentUser = jArray.ToObject <User>(); NavigationService.Navigate(new Uri("/PageGroups/MainGroup/MainPage.xaml", UriKind.Relative)); StaticMethod.ShowProgress(this, "Logging in...", 0, true, false); }
/// <summary> /// Toggle Offline mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SingleCloudIcon_OnTap(object sender, GestureEventArgs e) { if (!StaticData.isOfflineMode) { StaticMethod.ShowProgress(this, "Offline mode ON", 2000, false, true); StaticData.isOfflineMode = true; } else { StaticMethod.ShowProgress(this, "Offline mode OFF", 2000, false, true); StaticData.isOfflineMode = false; } }
private async Task Authenticate() { string message = String.Empty; try { session = await StaticData.FacebookSessionClient.LoginAsync("user_about_me,read_stream,email"); StaticData.AccessToken = session.AccessToken; StaticData.FacebookId = session.FacebookId; FacebookClient fb = new FacebookClient(StaticData.AccessToken); var temp = await fb.GetTaskAsync("me"); string jsonTemp = temp.ToString(); JObject jObject = JObject.Parse(jsonTemp); FacebookUser newFacebookUser = jObject.ToObject <FacebookUser>(); StaticData.CurrentUser.Name = newFacebookUser.name; StaticData.CurrentUser.UserName = newFacebookUser.username; StaticData.CurrentUser.Password = newFacebookUser.id; StaticData.CurrentUser.Email = newFacebookUser.email; StaticData.CurrentUser.IsFacebookUser = true; StaticMethod.ShowProgress(this, "Registering...", 0, true, true); try { string tempRegister = await UserAPI.Register(StaticData.CurrentUser); //Save that logged in facebook FacebookLoginSettingHelper newHelper = new FacebookLoginSettingHelper(); newHelper.SetLanguage(true); StaticMethod.ShowProgress(this, "Registering...", 0, true, false); } catch (Exception e) { //Username conflict Console.WriteLine(e); } await Login(StaticData.CurrentUser.UserName, StaticData.CurrentUser.Password); } catch (InvalidOperationException e) { message = "Login failed! Exception details: " + e.Message; MessageBox.Show(message); } }
void geolocator_StatusChanged(Geolocator sender, StatusChangedEventArgs args) { string status = ""; bool isShowLoading = false; int time = 0; switch (args.Status) { case PositionStatus.Disabled: // the application does not have the right capability or the location master switch is off status = "location is disabled in phone settings"; time = 2000; break; case PositionStatus.Initializing: // the geolocator started the tracking operation status = "initializing..."; isShowLoading = true; break; case PositionStatus.NoData: // the location service was not able to acquire the location status = "no data"; time = 2000; break; case PositionStatus.Ready: // the location service is generating geopositions as specified by the tracking parameters status = "ready"; time = 2000; break; case PositionStatus.NotAvailable: status = "not available"; time = 2000; // not used in WindowsPhone, Windows desktop uses this value to signal that there is no hardware capable to acquire location information break; case PositionStatus.NotInitialized: // the initial state of the geolocator, once the tracking operation is stopped by the user the geolocator moves back to this state status = "Geo Locator not initialized"; time = 2000; break; } Dispatcher.BeginInvoke(() => { //StatusTextBlock.Text = status; StaticMethod.ShowProgress(this, status, time, isShowLoading, true); }); }
private async Task Login(string username, string password) { StaticMethod.ShowProgress(this, "Logging in...", 0, true, true); string temp; if (!StaticData.isOfflineMode) { temp = await UserAPI.LoginTask(username, password); } else { temp = "{\"IsFacebookUser\":false,\"Point\":0,\"Enrollments\":[],\"Answers\":[],\"Id\":8,\"Name\":\"Tu\u1ea5n Tr\u1ea7n V\u0103n\",\"UserName\":\"tuantv\",\"Password\":\"123123\",\"UserType\":3,\"Email\":\"[email protected]\",\"Address\":\"Th\u1ee7 \u0110\u1ee9c, HCMC\",\"PhoneNumber\":\"0866771508\",\"RegistrationDate\":\"2014-03-27T21:52:16.737Z\",\"ObjectState\":0}"; } JObject jArray = JObject.Parse(temp); StaticData.CurrentUser = jArray.ToObject <User>(); NavigationService.Navigate(new Uri("/PageGroups/MainGroup/MainPage.xaml", UriKind.Relative)); StaticMethod.ShowProgress(this, "Logging in...", 0, true, false); }