Exemple #1
0
        //---------------------------------------------------------------------------------------------------------------------------------------------------

        //Action on long click on the item in choosing the use list.
        private void ListOfUsers_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            //Creating a new layout for deleting one user.
            AlertDialog.Builder Object   = new AlertDialog.Builder(this);
            LayoutInflater      inflater = LayoutInflater.From(this);
            LinearLayout        layout   = new LinearLayout(this);
            View FormViewDelete          = inflater.Inflate(Resource.Layout.DeleteUserForm, layout);

            Object.SetView(FormViewDelete);

            TextView DeleteUserTextView = FormViewDelete.FindViewById <TextView>(Resource.Id.DeleteUserText);

            DeleteUserTextView.Text = Resources.GetString(Resource.String.DeleteUser) + Classes.WorkWithDatabase.SQConnection.Table <Classes.User>().ElementAt(e.Position).Name + " ?";

            //Action on pressing posititve button.
            Object.SetPositiveButton(Resource.String.OK, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1)
            {
                //If current user is deleted, then the current user isn't choosed.
                if (Classes.User.CurrentUser == e.Position)
                {
                    Classes.User.CurrentUser = -1;
                }

                //Deleting fromm the DB.
                WorkWithDatabase.DeleteUser(TempList.ElementAt(e.Position));

                //Deleting from the list.
                TempList.RemoveAt(e.Position);
                var adapter         = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, TempList);
                ListOfUsers.Adapter = adapter;
            }));

            //Action on pressing negative button.
            Object.SetNegativeButton(Resource.String.Cancel, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) { }));

            //Showing the new form for deleting a user.
            Object.Show();
        }