public void Remove(DraggableView view) { view.OnDragEvent -= this.OnDrag; view.DragEndEvent -= this.DragEnded; this.OriginalViewList.Remove(view); this.SwitchedViewList.Remove(view); this.Children.Remove(view); }
public void Insert(int index, DraggableView view) { this.OriginalViewList.Insert(index, view); this.SwitchedViewList.Insert(index, view); this.Children.Insert(index, view); view.DragStartEvent += this.DragStarted; view.OnDragEvent += this.OnDrag; view.DragEndEvent += this.DragEnded; }
public void Move(DraggableView view, int toIndex) { this.OriginalViewList.Remove(view); this.SwitchedViewList.Remove(view); this.Children.Remove(view); this.OriginalViewList.Insert(toIndex, view); this.SwitchedViewList.Insert(toIndex, view); this.Children.Insert(toIndex, view); }
public void AddView(DraggableView view) { this.OriginalViewList.Add(view); this.SwitchedViewList.Add(view); this.Children.Add(view); view.DragStartEvent += this.DragStarted; view.OnDragEvent += this.OnDrag; view.DragEndEvent += this.DragEnded; }
private void OnDrag(object sender, OnDragEventArgs e) { DraggableView view = sender as DraggableView; double yDelta = e.YDelta; var indexOfViewNow = IndexOfViewInSwitchedList(view); var indexOfViewbyRatio = IndexOfViewbyYDelta(view, yDelta); if (indexOfViewNow == indexOfViewbyRatio) { return; } if (indexOfViewbyRatio < 0 || indexOfViewbyRatio >= SwitchedViewList.Count) { return; } var switchingView = SwitchedViewList[indexOfViewbyRatio]; var originalIndexOfSwitchinCell = OriginalIndexOfSwitchinCell(switchingView); switchingView.TranslateTo(0, (indexOfViewNow - originalIndexOfSwitchinCell) * (switchingView.Height + Spacing)); SwitchedViewList[indexOfViewbyRatio] = view; SwitchedViewList[indexOfViewNow] = switchingView; }
private int OriginalIndexOfSwitchinCell(DraggableView switchingView) { return(OriginalViewList.FindIndex(v => v == switchingView)); }