//Click Button Register
        private async void Btn_Register_OnClicked(object sender, EventArgs e)
        {
            try
            {
                if (!CrossConnectivity.Current.IsConnected)
                {
                    await DisplayAlert(AppResources.Label_Error, AppResources.Label_Check_Your_Internet, AppResources.Label_OK);
                }
                else
                {
                    UserDialogs.Instance.ShowLoading(AppResources.Label_Please_wait, MaskType.None);

                    //API_Request.Session = Functions.RandomString(40);

                    string Gender = "male";
                    using (var client = new HttpClient())
                    {
                        var formContent = new FormUrlEncodedContent(new[]
                        {
                            new KeyValuePair <string, string>("username", Txt_Username.Text),
                            new KeyValuePair <string, string>("password", Txt_password.Text),
                            new KeyValuePair <string, string>("confirm_password", Txt_passwordConfirm.Text),
                            new KeyValuePair <string, string>("email", Txt_Email.Text),
                            new KeyValuePair <string, string>("gender", Gender),
                            //new KeyValuePair<string, string>("s", API_Request.Session)
                        });

                        var response = await client.PostAsync(API_Request.API_Register, formContent);

                        response.EnsureSuccessStatusCode();
                        var Response_json = await response.Content.ReadAsStringAsync();

                        var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(Response_json);
                        string ApiStatus = data["api_status"].ToString();

                        if (ApiStatus == "200")
                        {
                            var successtype = data["success_type"].ToString();

                            if (successtype.Contains("registered"))
                            {
                                UserDialogs.Instance.HideLoading();

                                try
                                {
                                    API_Request.User_id = data["user_id"].ToString();
                                    API_Request.Session = data["session_id"].ToString();

                                    //Insert user data to database
                                    DataTables.LoginTB user = new DataTables.LoginTB();
                                    user.UserID   = API_Request.User_id;
                                    user.Session  = API_Request.Session;
                                    user.Username = Txt_Username.Text;
                                    user.Password = Txt_password.Text;
                                    user.Status   = "Active";

                                    Classes.DataUserLoginList.Add(user);
                                    SQL_Commander.Insert_Login_Credentials(user);

                                    //Messeges is login user
                                    Hamburg_Page.IsLogin = true;

                                    //Check User Status and Get data
                                    SQL_Commander.Get_data_Login_Credentials();
                                    var s = Classes.SeconderyListPage.FirstOrDefault(a => a.Name_page == AppResources.Label_Login);
                                    if (s != null)
                                    {
                                        s.Name_page = AppResources.Label_Logout;
                                        s.Icon_page = IoniciconsFont.LogOut;
                                    }

                                    UserDialogs.Instance.HideLoading();
                                    await Navigation.PopModalAsync(true);
                                }
                                catch (Exception exception)
                                {
                                    exception.ToString();
                                    await Navigation.PopAsync();
                                }
                            }
                            else if (successtype.Contains("verification"))
                            {
                                successtype = data["message"].ToString();

                                //await DisplayAlert("Error registered", successtype, "OK");
                                UserDialogs.Instance.ShowError(successtype);
                            }
                        }
                        else if (ApiStatus == "400")
                        {
                            JObject errors     = JObject.FromObject(data["errors"]);
                            var     error_id   = errors["error_id"].ToString();
                            var     error_text = errors["error_text"].ToString();

                            UserDialogs.Instance.HideLoading();
                            await DisplayAlert("Error", error_text, "OK");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var exception = ex.ToString();
                await DisplayAlert(AppResources.Label_Error, AppResources.Label_Session_Dead, AppResources.Label_OK);

                UserDialogs.Instance.HideLoading();
            }
        }
        //Click Button Login
        private async void Btn_Login_OnClicked(object sender, EventArgs e)
        {
            try
            {
                if (!CrossConnectivity.Current.IsConnected)
                {
                    await DisplayAlert(AppResources.Label_Error, AppResources.Label_Check_Your_Internet, AppResources.Label_OK);
                }
                else
                {
                    UserDialogs.Instance.ShowLoading(AppResources.Label_Please_wait, MaskType.None);

                    //API_Request.Session = Functions.RandomString(30);

                    using (var client = new HttpClient())
                    {
                        var formContent = new FormUrlEncodedContent(new[]
                        {
                            new KeyValuePair <string, string>("username", Txt_Username.Text),
                            new KeyValuePair <string, string>("password", Txt_password.Text),
                            //new KeyValuePair<string, string>("s", API_Request.Session),
                        });

                        var response = await client.PostAsync(API_Request.API_Login, formContent);

                        response.EnsureSuccessStatusCode();
                        var Response_json = await response.Content.ReadAsStringAsync();

                        var    data      = JsonConvert.DeserializeObject <Dictionary <string, object> >(Response_json);
                        string ApiStatus = data["api_status"].ToString();

                        if (ApiStatus == "200")
                        {
                            JObject Login_data = JObject.FromObject(data["data"]);

                            API_Request.User_id = Login_data["user_id"].ToString();
                            API_Request.Session = Login_data["session_id"].ToString();
                            API_Request.Cookie  = Login_data["cookie"].ToString();

                            //Insert user data to database
                            DataTables.LoginTB user = new DataTables.LoginTB();
                            user.UserID   = API_Request.User_id;
                            user.Session  = API_Request.Session;
                            user.Cookie   = API_Request.Cookie;
                            user.Username = Txt_Username.Text;
                            user.Password = Txt_password.Text;
                            user.Status   = "Active";

                            Classes.DataUserLoginList.Add(user);
                            SQL_Commander.Insert_Login_Credentials(user);

                            //Messeges is login user
                            Hamburg_Page.IsLogin = true;
                            var Status_user = Classes.SeconderyListPage.FirstOrDefault(a => a.Name_page == AppResources.Label_Login);
                            if (Status_user != null)
                            {
                                Status_user.Name_page = AppResources.Label_Logout;
                                Status_user.Icon_page = IoniciconsFont.LogOut;

                                var query = Classes.ListPage.FirstOrDefault(a => a.Name_page == AppResources.Label_My_Channel);
                                if (query == null)
                                {
                                    Classes.ListPage.Insert(0, new Classes.PageItems()
                                    {
                                        Name_page       = AppResources.Label_My_Channel,
                                        Icon_page       = IoniciconsFont.Person,
                                        BackgroundColor = "#696969",
                                        TextColor       = "#444"
                                    });
                                    Classes.ListPage.Insert(2, new Classes.PageItems()
                                    {
                                        Name_page       = AppResources.Label_PlayLists,
                                        Icon_page       = IoniciconsFont.Play,
                                        BackgroundColor = "#696969",
                                        TextColor       = "#444"
                                    });
                                    Classes.ListPage.Insert(3, new Classes.PageItems()
                                    {
                                        Name_page       = AppResources.Label_Liked_Videos,
                                        Icon_page       = IoniciconsFont.Thumbsup,
                                        BackgroundColor = "#696969",
                                        TextColor       = "#444"
                                    });
                                    Classes.ListPage.Add(new Classes.PageItems()
                                    {
                                        Name_page       = AppResources.Label_Upload,
                                        Icon_page       = IoniciconsFont.IosCloudUpload,
                                        BackgroundColor = "#696969",
                                        TextColor       = "#444"
                                    });
                                    if (Settings.DarkTheme)
                                    {
                                        foreach (var Item in Classes.ListPage)
                                        {
                                            Item.BackgroundColor = "#bcbcbc";
                                            Item.TextColor       = "#ffff";
                                        }
                                    }
                                }
                            }
                            //Check User Status and Get data
                            SQL_Commander.Get_data_Login_Credentials();

                            UserDialogs.Instance.HideLoading();
                            await Navigation.PopModalAsync(true);
                        }
                        else if (ApiStatus == "304")
                        {
                            JObject errors    = JObject.FromObject(data["errors"]);
                            string  errorID   = errors["error_id"].ToString();
                            var     errortext = errors["error_text"].ToString();

                            UserDialogs.Instance.ShowError(errortext);
                        }
                        else
                        {
                            UserDialogs.Instance.HideLoading();
                            await DisplayAlert(AppResources.Label_Login, AppResources.Label_Login_Not_Correct, AppResources.Label_OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var exception = ex.ToString();
                await DisplayAlert(AppResources.Label_Error, AppResources.Label_Session_Dead, AppResources.Label_OK);

                UserDialogs.Instance.HideLoading();
            }
        }