//--------------------------------------------------------------------------------------------------------------------------------------------------- //Showing product information. private void ListForChoosingProducts_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e) { //Creating a new layout for showing information about product. AlertDialog.Builder Object = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.From(this); LinearLayout layout = new LinearLayout(this); View product_Info = inflater.Inflate(Resource.Layout.product_Info, layout); Object.SetView(product_Info); //Elements from the layout. TextView NameText = product_Info.FindViewById <TextView>(Resource.Id.NameText); TextView ProteinsText = product_Info.FindViewById <TextView>(Resource.Id.ProteinsText); TextView FatsText = product_Info.FindViewById <TextView>(Resource.Id.FatsText); TextView CarbsText = product_Info.FindViewById <TextView>(Resource.Id.CarbsText); TextView WaterText = product_Info.FindViewById <TextView>(Resource.Id.WaterText); TextView CcalsText = product_Info.FindViewById <TextView>(Resource.Id.CcalsText); //Temporary product for getting information about choosed product. Product TempProduct = DatabaseProducts.GetProduct(ListForProducts.ElementAt(e.Position)); //Showing information. NameText.Text = TempProduct.Name; ProteinsText.Text = TempProduct.Protein.ToString(); FatsText.Text = TempProduct.Fats.ToString(); CarbsText.Text = TempProduct.Carbohydrates.ToString(); WaterText.Text = TempProduct.Water.ToString(); CcalsText.Text = TempProduct.Ccal.ToString(); //Action on positive button. Object.SetPositiveButton(Resource.String.OK, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) {})); //Showing the form. Object.Show(); }
//--------------------------------------------------------------------------------------------------------------------------------------------------- //Adding a new product. private void ListForChoosingProducts_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { //Creating a new layout for entering a number of grams. AlertDialog.Builder Object = new AlertDialog.Builder(this); LayoutInflater inflater = LayoutInflater.From(this); LinearLayout layout = new LinearLayout(this); View product_Quantity = inflater.Inflate(Resource.Layout.product_Quantity, layout); Object.SetView(product_Quantity); //Elements from the layout. NumberPicker ProductAmount = product_Quantity.FindViewById <NumberPicker>(Resource.Id.AmountPicker); ProductAmount.MinValue = 1; ProductAmount.MaxValue = 1000; ProductAmount.SetFormatter(new HelpclassNumberPickerFormatter()); //Action on pressing positive button. Object.SetPositiveButton(Resource.String.OK, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1) { //Creating a new product and adding it to the user's list of products. Product TempProduct = DatabaseProducts.GetProduct(ListForProducts.ElementAt(e.Position)); TempProduct.Setter(ProductAmount.Value * 10, DateTime.Now); User TempUser = DatabaseUser.GetUser(User.CurrentUser); TempUser.Products.Add(TempProduct); DatabaseUser.SQConnection.UpdateWithChildren(TempUser); })); //Action on pressing negative button. Object.SetNegativeButton(Resource.String.Cancel, new EventHandler <DialogClickEventArgs>(delegate(object Sender, DialogClickEventArgs e1){})); //Showing the form. Object.Show(); }