protected sealed override void OpenEdit(RowManager rowManager) { Debug.Assert(rowManager == RowManager); KeepInitialInputElement(rowManager); if (rowManager.VirtualRow != null) { _insertingRow = rowManager.VirtualRow; _insertingRow.DataRow = DataSet.BeginAdd(); } else { _insertingRow = new RowPresenter(rowManager, DataSet.BeginAdd()); } _insertingRow.RawIndex = InsertingRowRawIndex; if (rowManager.VirtualRowPlacement == VirtualRowPlacement.Head) { rowManager.VirtualRow = new RowPresenter(rowManager, 0); } else if (rowManager.VirtualRowPlacement == VirtualRowPlacement.Tail) { rowManager.VirtualRow = new RowPresenter(rowManager, -1); } else if (rowManager.VirtualRow != null) { rowManager.VirtualRow = null; } rowManager.Editing = this; rowManager.OnRowsChanged(); rowManager.SetCurrentRow(_insertingRow, false); }
protected sealed override RowPresenter CommitEdit(RowManager rowManager, bool staysOnInserting) { Debug.Assert(!rowManager.IsEditing); Debug.Assert(rowManager == RowManager); DisposeInsertingRow(false); var newDataRow = DataSet.EndAdd(CommitEditIndex); var newCurrentRow = rowManager[newDataRow]; if (!rowManager.CurrentRowChangeSuspended) { if (newCurrentRow != null) { rowManager.CurrentRow = newCurrentRow; } } if (staysOnInserting) { StayOnInserting(rowManager, newCurrentRow); var currentView = rowManager.CurrentRow?.View; if (currentView != null && currentView.ContainsKeyboardFocus() && InitialInputElement != null && InitialInputElement != currentView.ActiveInputElement && (InitialInputElement as DependencyObject).FindVisaulAncestor <RowView>() == currentView) { InitialInputElement.Focus(); } } return(newCurrentRow); }
public override void OnRowsChanged(RowManager rowManager) { if (rowManager.CurrentRow.IsDisposed) { CancelEdit(rowManager); } }
protected InsertHandler(RowManager rowManager, RowPresenter reference) { Debug.Assert(rowManager != null); Debug.Assert(reference == null || reference.RowManager == rowManager); RowManager = rowManager; Reference = reference; }
protected override RowPresenter CommitEdit(RowManager rowManager, bool staysOnInserting) { var currentRow = rowManager.CurrentRow; currentRow.DataRow.EndEdit(); return(currentRow); }
protected sealed override void RollbackEdit(RowManager rowManager) { Debug.Assert(!rowManager.IsEditing); Debug.Assert(rowManager == RowManager); DataSet.CancelAdd(); DisposeInsertingRow(true); }
private void KeepInitialInputElement(RowManager rowManager) { var currentView = rowManager.CurrentRow?.View; if (currentView != null) { InitialInputElement = currentView.ActiveInputElement; } }
private void DisposeInsertingRow(bool isRollback) { _insertingRow.DataRow = null; _insertingRow.Dispose(); if (isRollback) { RowManager._suggestedCurrentRow = CurrentRowAfterRollback; RowManager.OnRowsChanged(); } }
public override void OnRowsChanged(RowManager rowManager) { if (Reference != null) { if (Reference.IsDisposed) { Reference = ReferenceForDisposed; } else { RefreshReferenceRawIndex(); } } if (rowManager.VirtualRowPlacement == VirtualRowPlacement.Tail) { rowManager.VirtualRow.RawIndex = rowManager.Rows.Count - 1; } if (InsertingRow != null) { InsertingRow.RawIndex = InsertingRowRawIndex; } }
private static EditHandler GetCurrentRowEditHandler(RowManager rowManager) { var currentRow = rowManager.CurrentRow; if (currentRow.IsVirtual) { var virtualRowPlacement = rowManager.VirtualRowPlacement; if (virtualRowPlacement == VirtualRowPlacement.Head) { return(InsertHandler.EditVirtualHead(rowManager)); } else { Debug.Assert(virtualRowPlacement == VirtualRowPlacement.Tail); return(InsertHandler.EditVirtualTail(rowManager)); } } else { return(EditCurrentHandler.Singleton); } }
public InsertAfterHandler(RowManager rowManager, RowPresenter reference) : base(rowManager, reference) { }
protected override void StayOnInserting(RowManager rowManager, RowPresenter rowInserted) { rowManager.BeginInsertBefore(null, rowInserted); }
public static InsertHandler After(RowManager rowManager, RowPresenter reference) { return(new InsertAfterHandler(rowManager, reference)); }
public static InsertHandler Before(RowManager rowManager, RowPresenter reference) { return(new InsertBeforeHandler(rowManager, reference)); }
public EditVirtualTailHandler(RowManager rowManager) : base(rowManager, null) { }
protected override void StayOnInserting(RowManager rowManager, RowPresenter rowInserted) { Debug.Assert(rowManager.VirtualRow != null); rowManager.CurrentRow = rowManager.VirtualRow; }
protected abstract void StayOnInserting(RowManager rowManager, RowPresenter rowInserted);