Beispiel #1
0
 public void selectInputUserText()
 {
     RunOnUiThread(() =>
     {
         inputUser.SelectAll();
     });
 }
        private void AddAutocompleteToLayout(string [] autocomplete, int resource, string title)
        {
            var lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.WrapContent);

            lp.SetMargins(50, 5, 50, 5);
            _linearLayout.LayoutParameters = lp;
            _linearLayout.AddView(new TextView(_activity)
            {
                Text = title
            }, lp);
            var adapter = new ArrayAdapter(_activity, resource, autocomplete);

            _autoCompleteText.Adapter = adapter;
            if (_win != null)
            {
                _autoCompleteText.Text = _win;
                _autoCompleteText.SelectAll();
            }

            if (_note != null)
            {
                _noteText.Text = _note;
                _noteText.SelectAll();
            }
            _linearLayout.AddView(_autoCompleteText, lp);
        }
        private void BtnLogin_Click(object sender, System.EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            res.AddReturnedValue(CheckValidation());
            if (res.HasError)
            {
                Toast.MakeText(this, res.ErrorMessage, ToastLength.Short).Show();
                return;
            }

            var user = UserBussines.Get(txtUserName.Text.Trim());

            if (user == null)
            {
                Toast.MakeText(this, $"کاربر با نام کاربری {txtUserName.Text} یافت نشد", ToastLength.Long).Show();
                txtUserName.SelectAll();
                return;
            }

            var ue        = new UTF8Encoding();
            var bytes     = ue.GetBytes(txtPassword.Text.Trim());
            var md5       = new MD5CryptoServiceProvider();
            var hashBytes = md5.ComputeHash(bytes);
            var password  = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "")
                            .ToLower();

            if (password != user.Password)
            {
                Toast.MakeText(this, "رمز عبور اشتباه است", ToastLength.Long).Show();
                txtPassword.SelectAll();
                return;
            }

            if (user.IsBlock)
            {
                Toast.MakeText(this, "دسترسی شما به برنامه، از طریق پنل مدیریت محدود شده است", ToastLength.Long).Show();
                txtPassword.SelectAll();
                return;
            }

            CurrentUser.User       = user;
            CurrentUser.LastVorrod = DateTime.Now;

            StartActivity(typeof(MainActivity));
        }
Beispiel #4
0
        private void FromButton_Click(object sender, EventArgs e)
        {
            PopupMenu menu = new PopupMenu(this, sender as View);

            menu.MenuItemClick += (s, a) =>
            {
                if (a.Item.ItemId == 0)
                {
                    UpdateAutoFrom();
                }
                else if (a.Item.ItemId == 1)
                {
                    fromTextView.RequestFocus();
                    fromTextView.ShowDropDown();
                    fromTextView.SelectAll();

                    fromTextView.PostDelayed(() =>
                    {
                        InputMethodManager inputMethodManager = GetSystemService(Context.InputMethodService) as InputMethodManager;
                        inputMethodManager.ShowSoftInput(fromTextView, ShowFlags.Forced);
                    }, 250);
                }
                else
                {
                    Stop stop = TramUrWayApplication.GetStop(a.Item.ItemId);
                    fromTextView.Text = stop.Name;
                }
            };

            // Auto: based on current location and favorites
            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                menu.Menu.Add(1, 0, 1, "Automatique").SetIcon(Resource.Drawable.ic_place);
            }

            // Favorite stops
            foreach (Stop stop in TramUrWayApplication.Config.FavoriteStops.GroupBy(s => s.Name).Select(g => g.First()))
            {
                menu.Menu.Add(1, stop.Id, 2, stop.Name);
            }

            // Other: focus the search box and trigger autocomplete
            menu.Menu.Add(1, 1, 3, "Autre ...");

            menu.Show();
        }