//This function should be async and should be called asyncronously private void DrawDamageCircle(VehicleMarkDamageDetails objVehicleMarkDamage) { try { TextView lblMarkDamageNumber = new TextView(this); lblMarkDamageNumber.Id = objVehicleMarkDamage.DamageNumber; lblMarkDamageNumber.Text = objVehicleMarkDamage.DamageNumber.ToString(); lblMarkDamageNumber.SetTextColor(Color.White); lblMarkDamageNumber.SetWidth(60); lblMarkDamageNumber.SetHeight(60); lblMarkDamageNumber.Gravity = GravityFlags.Center; if (rentRunningTrans.TransType.Equals("PRE")) { lblMarkDamageNumber.SetBackgroundResource(Resource.Drawable.rounded_corner_black); } else if (rentRunningTrans.TransType.Equals("OUT")) { lblMarkDamageNumber.SetTextColor(Color.White); if (objVehicleMarkDamage.ID > 0) { lblMarkDamageNumber.SetBackgroundResource(Resource.Drawable.rounded_corner_black); } else { lblMarkDamageNumber.SetBackgroundResource(Resource.Drawable.rounded_corner_green); } } else if (rentRunningTrans.TransType.Equals("IN")) { lblMarkDamageNumber.SetTextColor(Color.White); if (objVehicleMarkDamage.ID > 0) { lblMarkDamageNumber.SetBackgroundResource(Resource.Drawable.rounded_corner_black); } else { lblMarkDamageNumber.SetBackgroundResource(Resource.Drawable.rounded_corner_red); } } lblMarkDamageNumber.Click += MarkDamageNumber_Click; //lblMarkDamageNumber.SetOnTouchListener(this); lblMarkDamageNumber.SetOnLongClickListener(this); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WrapContent, FrameLayout.LayoutParams.WrapContent); layoutParams.TopMargin = objVehicleMarkDamage.DamageLocationY - 30; // margin in pixels, not dps layoutParams.LeftMargin = objVehicleMarkDamage.DamageLocationX - 30; // margin in pixels, not dps // add into my parent view _markdamage.AddView(lblMarkDamageNumber, layoutParams); } catch (Exception ex) { //Do nothing } }
public bool OnDrag(View view, DragEvent e) { switch (e.Action) { case DragAction.Started: return(true); case DragAction.Entered: return(true); case DragAction.Exited: return(true); case DragAction.Drop: objVehicleMarkDamageDetails = rentRunningTrans.RentVehicleDamage.Where(x => x.DamageNumber == Convert.ToInt32(e.ClipData.GetItemAt(0).Text)).First(); objVehicleMarkDamageDetails.DamageLocationX = (int)e.GetX(); objVehicleMarkDamageDetails.DamageLocationY = (int)e.GetY(); this.DrawDamageCircle(objVehicleMarkDamageDetails); //view.Visibility = (ViewStates.Invisible); //droppedIndex = Convert.ToInt16(view.GetTag(Resource.String.keyval)); ; return(true); case DragAction.Ended: return(true); } return(false); }
private void MarkDamageNumber_Click(object sender, EventArgs e) { //View view = (View)sender; var intent_CaptureDamageImage = new Intent(this, typeof(RentFlowCaptureDamageImageActivity)); objVehicleMarkDamageDetails = rentRunningTrans.RentVehicleDamage.Where(x => x.DamageNumber == Convert.ToInt32(((TextView)sender).Text)).First(); intent_CaptureDamageImage.PutExtra("objMarkDamageDetail", JsonConvert.SerializeObject(objVehicleMarkDamageDetails)); // intent_CaptureDamageImage.PutExtra("VehicleTransId", rentRunningTrans.VehicleTransID.ToString()); //intent_CaptureDamageImage.PutExtra("TapImageLocationX", ((int)e.GetX()).ToString()); //intent_CaptureDamageImage.PutExtra("TapImageLocationY", ((int)e.GetY()).ToString()); //intent_CaptureDamageImage.PutExtra("DamageCounter", ((TextView)sender).Text); StartActivityForResult(intent_CaptureDamageImage, 1); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { if (data.GetStringExtra("MarkDamage") != null) { objVehicleMarkDamageDetails = JsonConvert.DeserializeObject <VehicleMarkDamageDetails>(data.GetStringExtra("MarkDamage")); this.DrawDamageCircle(objVehicleMarkDamageDetails); if (rentRunningTrans.RentVehicleDamage == null) { rentRunningTrans.RentVehicleDamage = new List <VehicleMarkDamageDetails>(); } if (rentRunningTrans.RentVehicleDamage.Where(x => x.DamageNumber == objVehicleMarkDamageDetails.DamageNumber).ToList().Count > 0) { rentRunningTrans.RentVehicleDamage.Where(x => x.DamageNumber == objVehicleMarkDamageDetails.DamageNumber).Any(c => { c.DamageType = objVehicleMarkDamageDetails.DamageType; c.ImagePath = objVehicleMarkDamageDetails.ImagePath; return(true); }); } else { rentRunningTrans.RentVehicleDamage.Add(objVehicleMarkDamageDetails); iLastDamageNumber = objVehicleMarkDamageDetails.DamageNumber; } } } //for deleting mark if (resultCode == Result.FirstUser) { if (data.GetStringExtra("MarkDamage") != null) { objVehicleMarkDamageDetails = JsonConvert.DeserializeObject <VehicleMarkDamageDetails>(data.GetStringExtra("MarkDamage")); if (rentRunningTrans.RentVehicleDamage.Remove(objVehicleMarkDamageDetails)) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetMessage("damage is deleted."); alert.SetNeutralButton("OK", delegate { }); alert.Create().Show(); // Toast.MakeText(this, "damage is deleted.", ToastLength.Short).Show(); } } } }
public override bool OnOptionsItemSelected(IMenuItem item) { var intent_MarkDamage = new Intent(this, typeof(RentFlowMarkDamageActivity)); switch (item.ItemId) { case Resource.Id.menu_done: Regex regxDamageType = new Regex("(Select damage type)"); if (!regxDamageType.Match(lstDamageType.SelectedItem.ToString()).Success) { if (_ImagePath != null) { if (objMarkDamageDetail == null) { objMarkDamageDetail = new VehicleMarkDamageDetails(); objMarkDamageDetail.VehicleTransID = Convert.ToInt32(Intent.GetStringExtra("VehicleTransId")); objMarkDamageDetail.DamageLocationX = Convert.ToInt32(strLocationX); objMarkDamageDetail.DamageLocationY = Convert.ToInt32(strLocationY); objMarkDamageDetail.DamageNumber = iLastDamageNumber + 1; objMarkDamageDetail.DamageType = lstDamageType.SelectedItemId.ToString(); objMarkDamageDetail.ImagePath = _ImagePath.ToString(); objMarkDamageDetail.DamageImageId = iDamageImageId; //objMarkDamageDetail.DamageImageId = imgVehicle.Id = 102; // objMarkDamageDetail.DamageImageId = imgVehicle.Id = 102; } else { objMarkDamageDetail.DamageType = lstDamageType.SelectedItemId.ToString(); objMarkDamageDetail.ImagePath = _ImagePath.ToString(); } // intent_MarkDamage.PutExtra("MarkDamage", JsonConvert.SerializeObject(objMarkDamageDetail)); // SetResult(Result.Ok, intent_MarkDamage); //Finish(); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetMessage("Please select image from gallery or take from camera."); alert.SetNeutralButton("OK", delegate { }); alert.Create().Show(); } } else { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetMessage("Please select damage type."); alert.SetNeutralButton("OK", delegate { }); alert.Create().Show(); lstDamageType.RequestFocus(); } break; case Resource.Id.menu_cancel: SetResult(Result.Canceled, intent_MarkDamage); Finish(); break; case Resource.Id.menu_delete: // intent_MarkDamage.PutExtra("MarkDamage", JsonConvert.SerializeObject(objMarkDamageDetail)); // SetResult(Result.FirstUser, intent_MarkDamage); // Finish(); break; } //Toast.MakeText(this, "Top ActionBar pressed: " + item.TitleFormatted, ToastLength.Short).Show(); return(base.OnOptionsItemSelected(item)); }