void img_Click(ImageData idata) { idata.Selected = !idata.Selected; foreach (ImageData item in images) { if (item != idata && item.Selected) item.Selected = false; } SetButtonsEnabled(); }
private void AddImage(string path) { LinearLayout llNewImage = new LinearLayout(this); llNewImage.LayoutParameters = new ViewGroup.LayoutParams( LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent); var p = Constants.PreviewCard.BorderSize; llNewImage.SetPadding(p, p, p, p); var img = new ImageView(this); img.LayoutParameters = new LinearLayout.LayoutParams( Constants.PreviewCard.ImageWidth, Constants.PreviewCard.ImageHeight); try { img.SetImageURI(Android.Net.Uri.Parse(path)); } catch(Exception ex) { Toast.MakeText(this, ex.Message, ToastLength.Short).Show(); img.SetImageResource(Resource.Drawable.ErrorImage); } llNewImage.AddView(img); llImages.AddView(llNewImage); ImageData id = new ImageData(); id.ImageFile = path; id.layoutWithImage = llNewImage; id.Selected = false; images.Add(id); CheckShowNoImage(); SetButtonsEnabled(); img.Click += (o, s) => img_Click(id); /*switch (num) { case 0: ivFore.SetImageURI(uri); return; case 1: ivBack.SetImageURI(uri); return; default: break; }*/ }