/// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Private Functions private void CellcoreOnDrag(object sender, View.DragEventArgs args) { try { Items = AppData.PropertyModel.SelectedAction.Action.Paragraphs; switch (args.Event.Action) { case DragAction.Started: args.Handled = true; break; case DragAction.Entered: args.Handled = true; if (FirstIndex == -1) { FirstIndex = VisitActionDetailsPage.TblSection.IndexOf(Cell); } break; case DragAction.Exited: args.Handled = true; break; case DragAction.Drop: args.Handled = true; if (SecondIndex == -1) { SecondIndex = VisitActionDetailsPage.TblSection.IndexOf(Cell); } break; case DragAction.Ended: args.Handled = true; if (FirstIndex != -1) { var firstType = Items[FirstIndex].ParagraphType; var secondType = Items[SecondIndex].ParagraphType; if (firstType == secondType) { var firstItem = Items[FirstIndex]; if (firstItem != null) { Items.RemoveAt(FirstIndex); Items.Insert(SecondIndex, firstItem); VisitActionDetailsPage.CurrentInstance.RefreshList(); } } } FirstIndex = -1; SecondIndex = -1; break; } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
private void CellcoreOnDrag(object sender, View.DragEventArgs args) { ViewGroup = sender as ViewGroup; if (ViewGroup != null) { ListView = ViewGroup.Parent.Parent as Android.Widget.ListView; } switch (args.Event.Action) { case DragAction.Started: args.Handled = true; break; case DragAction.Entered: args.Handled = true; if (ListView != null) { if (FirstIndex == -1) { FirstIndex = ListView.IndexOfChild(ViewGroup.Parent as View); } } break; case DragAction.Exited: args.Handled = true; break; case DragAction.Drop: args.Handled = true; if (SecondIndex == -1) { SecondIndex = ListView.IndexOfChild(ViewGroup.Parent as View); } if (FirstIndex != -1) { var firstItem = Items[FirstIndex - 1]; if (firstItem != null) { Items.RemoveAt(FirstIndex - 1); Items.Insert(SecondIndex - 1, firstItem); ParentListView.ItemsSource = null; ParentListView.ItemsSource = Items; } } FirstIndex = -1; SecondIndex = -1; break; case DragAction.Ended: args.Handled = true; break; } }