private void ResetViews() { using (new SourceAccess(this)) { int currentIndex = Zoombox.ViewStackIndex; IsResettingViews = true; try { Clear(); foreach (object item in _source) { ZoomboxView view = ZoomboxViewStack.GetViewFromSourceItem(item); Add(view); } currentIndex = Math.Min(Math.Max(0, currentIndex), Count - 1); Zoombox.ViewStackIndex = currentIndex; Zoombox.SetCurrentViewIndex(currentIndex); Zoombox.RefocusView(); } finally { IsResettingViews = false; } } }
private void MoveViews(int oldIndex, int newIndex, IList movedItems) { using (new SourceAccess(this)) { int currentIndex = Zoombox.ViewStackIndex; int indexAfterMove = currentIndex; // adjust the current index, if it was affected by the move if (!((oldIndex < currentIndex && newIndex < currentIndex) || (oldIndex > currentIndex && newIndex > currentIndex))) { if (currentIndex >= oldIndex && currentIndex < oldIndex + movedItems.Count) { indexAfterMove += newIndex - oldIndex; } else if (currentIndex >= newIndex) { indexAfterMove += movedItems.Count; } } IsMovingViews = true; try { for (int i = 0; i < movedItems.Count; i++) { RemoveAt(oldIndex); } for (int i = 0; i < movedItems.Count; i++) { Insert(newIndex + i, ZoomboxViewStack.GetViewFromSourceItem(movedItems[i])); } if (indexAfterMove != currentIndex) { Zoombox.ViewStackIndex = indexAfterMove; Zoombox.SetCurrentViewIndex(indexAfterMove); } } finally { IsMovingViews = false; } } }
private void InsertViews(int index, IList newItems) { using (new SourceAccess(this)) { foreach (object item in newItems) { ZoomboxView view = ZoomboxViewStack.GetViewFromSourceItem(item); if (index >= Count) { Add(view); } else { Insert(index, view); } index++; } } }
public void Dispose() { _viewStack.IsChangeFromSource = false; _viewStack = null; GC.SuppressFinalize(this); }
public SourceAccess(ZoomboxViewStack viewStack) { _viewStack = viewStack; _viewStack.IsChangeFromSource = true; }