public void Push(VObjectHostState state) { if (_disposed) { throw new System.ObjectDisposedException("StatesStack"); } if (state == null) { throw new System.ArgumentNullException("state"); } if (state.IsEmpty) { throw new System.ArgumentException(StringResources.GetString("ExStrObjectCannotBeEmpty"), "state"); } if (_count < _array.Length) { _count++; } if (++_index >= _array.Length) { _index = 0; } if (_array[_index] != null) { _array[_index].Dispose(); _array[_index] = null; } _array[_index] = state; }
private void UpdateCurrentState() { if (!_undoRedoEnabled) { throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUndoRedoShouldBeEnabled")); } _currentState = new VObjectHostState(); _vObjectHost.Layers.Serialize(_currentState.Stream); _currentState.LayerIndex = _vObjectHost.CurrentLayerIndex; }
private void RestoreState(VObjectHostState state) { if (!_undoRedoEnabled) { throw new Aurigma.GraphicsMill.UnexpectedException(StringResources.GetString("ExStrUndoRedoShouldBeEnabled")); } _restoringState = true; try { _vObjectHost.Layers.Deserialize(state.Stream); _vObjectHost.CurrentLayerIndex = state.LayerIndex; } finally { _restoringState = false; } }
public VObjectHostState Pop() { if (_disposed) { throw new System.ObjectDisposedException("StatesStack"); } if (_count < 1) { throw new Aurigma.GraphicsMill.ObjectEmptyException(); } VObjectHostState result = _array[_index]; System.Diagnostics.Debug.Assert(result != null, "State stack cannot contain null elements!"); _array[_index] = null; if (--_index < 0) { _index = _array.Length - 1; } _count--; return(result); }
public StateStack(int capacity) { _index = -1; _array = new VObjectHostState[capacity]; }