Example #1
0
 public LoginPage()
 {
     InitializeComponent();
     BindingContext = new LoginDBModel();
     UserNameEntry.SetBinding(Entry.TextProperty, "Username");
     PasswordEntry.SetBinding(Entry.TextProperty, "Passdata");
 }
Example #2
0
        void Handle_Tapped(object sender, EventArgs e)
        {
            var name = ((Image)sender).ClassId;

            switch (name)
            {
            case "UserName":
                if (!UserNameEntry.IsFocused)
                {
                    UserNameEntry.Focus();
                }
                break;

            case "Email":
                if (!EmailEntry.IsFocused)
                {
                    EmailEntry.Focus();
                }
                break;

            case "DisplayName":
                //  if (!DisplayNameEntry.IsFocused)
                // DisplayNameEntry.Focus();
                break;

            default:
                break;
            }
        }
 protected override void OnAppearing()
 {
     base.OnAppearing();
     // Do this to work around https://bugzilla.xamarin.com/show_bug.cgi?id=44774
     Resolver.Resolve <IDeviceService>().RunOnMainThread(() =>
     {
         ForceLayout();
         UserNameEntry.Focus();
     });
 }
        public EnterUserPage()
        {
            InitializeComponent();

            NavigationPage.SetHasBackButton(this, false);

            UserNameEntry.SetBinding(Entry.ReturnCommandProperty, nameof(EnterUserViewModel.NavigateToPlaylistPageCommand));

            NextButton.SetBinding(Button.CommandProperty, nameof(EnterUserViewModel.NavigateToPlaylistPageCommand));
        }
Example #5
0
 public MainWindow() : base(Gtk.WindowType.Toplevel)
 {
     Build();
     //
     // Color changes
     //
     ModifyBg(StateType.Normal, new Gdk.Color(38, 31, 31));
     label1.ModifyFg(StateType.Normal, new Gdk.Color(237, 227, 227));
     DatabaseEntry.ModifyBase(StateType.Normal, new Gdk.Color(89, 82, 82));
     DatabaseEntry.ModifyText(StateType.Normal, new Gdk.Color(237, 227, 227));
     label2.ModifyFg(StateType.Normal, new Gdk.Color(237, 227, 227));
     UserNameEntry.ModifyBase(StateType.Normal, new Gdk.Color(89, 82, 82));
     UserNameEntry.ModifyText(StateType.Normal, new Gdk.Color(237, 227, 227));
     label3.ModifyFg(StateType.Normal, new Gdk.Color(237, 227, 227));
     PasswordEntry.ModifyBase(StateType.Normal, new Gdk.Color(89, 82, 82));
     PasswordEntry.ModifyText(StateType.Normal, new Gdk.Color(237, 227, 227));
     label4.ModifyFg(StateType.Normal, new Gdk.Color(237, 227, 227));
     combobox1.ModifyBase(StateType.Normal, new Gdk.Color(89, 82, 82));
     label5.ModifyFg(StateType.Normal, new Gdk.Color(237, 227, 227));
     SearchEntry.ModifyBase(StateType.Normal, new Gdk.Color(155, 149, 149));
 }
        private async void StartMiningButton_Clicked(object sender, EventArgs e)
        {
            LoadingOverlay.IsVisible = true;
            var FullName        = FullNameEntry.Text;
            var Username        = UserNameEntry.Text;
            var EmailID         = EmailIDEntry.Text;
            var Password        = PasswordEntry.Text;
            var ConfirmPassword = ConfirmPasswordEntry.Text;

            if (String.IsNullOrWhiteSpace(FullName) || String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(EmailID) || String.IsNullOrWhiteSpace(Password) || String.IsNullOrWhiteSpace(ConfirmPassword))
            {
                var Message = "Fill out every entry";
                await DisplayAlert("Error", Message, "OK");

                LoadingOverlay.IsVisible = false;
                return;
            }
            if (Username.Contains(" "))
            {
                var Message = "Username can't contain whitespace";
                await DisplayAlert("Error", Message, "OK");

                UserNameEntry.Focus();
                LoadingOverlay.IsVisible = false;
                return;
            }
            if (Username.Length < 6)
            {
                var Message = "Username length should be atleast 6";
                await DisplayAlert("Error", Message, "OK");

                UserNameEntry.Focus();
                LoadingOverlay.IsVisible = false;
                return;
            }
            if (Password.Length < 6)
            {
                var Message = "Password length should be atleast 6";
                await DisplayAlert("Error", Message, "OK");

                PasswordEntry.Focus();
                LoadingOverlay.IsVisible = false;
                return;
            }
            if (Password != ConfirmPassword)
            {
                var Message = "Passwords don't match";
                await DisplayAlert("Error", Message, "OK");

                PasswordEntry.Focus();
                LoadingOverlay.IsVisible = false;
                return;
            }
            List <string> AccessRights = new List <string>();

            if (AdminCheck.Checked)
            {
                AccessRights.Add("Admin");
            }
            if (CreateAccountCheck.Checked)
            {
                AccessRights.Add("CreateAccount");
            }
            if (CreateTransactionCheck.Checked)
            {
                AccessRights.Add("CreateTransaction");
            }
            var newUser = new User()
            {
                FullName               = FullName,
                UserName               = Username.ToLower(),
                EmailID                = EmailID.ToLower(),
                Password               = Password,
                ConfirmPassword        = ConfirmPassword,
                AccessRights           = JsonConvert.SerializeObject(AccessRights),
                AssociatedProductTypes = JsonConvert.SerializeObject(new List <string>())
            };

            MainLayout.IsVisible = false;
            await Task.Run(async() =>
            {
                string url     = "http://PureMedblockchain.acashmkj.me/UserAccount/CreateAccount";
                HttpContent q1 = new FormUrlEncodedContent(new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("userName", Application.Current.Properties["UserName"].ToString()), new KeyValuePair <string, string>("password", Application.Current.Properties["Password"].ToString()), new KeyValuePair <string, string>("user", JsonConvert.SerializeObject(newUser))
                });
                using (var httpClient = new HttpClient())
                {
                    try
                    {
                        Task <HttpResponseMessage> getResponse = httpClient.PostAsync(url, q1);
                        HttpResponseMessage response           = await getResponse;
                        if (response.IsSuccessStatusCode)
                        {
                            var myContent = await response.Content.ReadAsStringAsync();

                            if (myContent == "True")
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    MainScrollView.Content = new Label()
                                    {
                                        Text           = $"Account Successfully Created.\n\n UserName : {newUser.UserName} \n Password : {newUser.Password}",
                                        TextColor      = Color.Green,
                                        FontSize       = 18,
                                        FontAttributes = FontAttributes.Bold
                                    };
                                    CreateAccountButton.IsVisible = false;
                                    BackButton.IsVisible          = true;
                                    MainScrollView.IsVisible      = true;
                                    LoadingOverlay.IsVisible      = false;
                                    return;
                                });
                            }
                            else if (myContent == "UserName")
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    var Message = "Username already exists!";
                                    DisplayAlert("Error", Message, "OK");
                                    UserNameEntry.Focus();
                                    MainLayout.IsVisible     = true;
                                    LoadingOverlay.IsVisible = false;
                                    return;
                                });
                            }
                            else
                            {
                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    MainScrollView.Content = new Label()
                                    {
                                        Text           = "Account Creation Failed!!",
                                        TextColor      = Color.Red,
                                        FontSize       = 18,
                                        FontAttributes = FontAttributes.Bold
                                    };
                                    MainScrollView.IsVisible = true;
                                    LoadingOverlay.IsVisible = false;
                                    return;
                                });
                            }
                        }
                        else
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                var Message = "Server Is Down. Try Again After Some Time";
                                DisplayAlert("Error", Message, "OK");
                                MainLayout.IsVisible     = true;
                                LoadingOverlay.IsVisible = false;
                                return;
                            });
                        }
                    }
                    catch (Exception)
                    {
                        Device.BeginInvokeOnMainThread(() =>
                        {
                            var Message = "Check Your Internet Connection and Try Again";
                            DisplayAlert("Error", Message, "OK");
                            MainLayout.IsVisible     = true;
                            LoadingOverlay.IsVisible = false;
                            return;
                        });
                    }
                }
            });
        }
 private void FullNameEntry_Completed(object sender, EventArgs e)
 {
     UserNameEntry.Focus();
 }