private void Add(IDrawOperation node) { using (var refCounted = RefCountable.Create(node)) { Add(refCounted); } }
private void Render(IDrawingContextImpl context, VisualNode node, IVisual layer, Rect clipBounds) { if (layer == null || node.LayerRoot == layer) { clipBounds = node.ClipBounds.Intersect(clipBounds); if (!clipBounds.IsEmpty) { node.BeginRender(context); foreach (var operation in node.DrawOperations) { _currentDraw = operation; operation.Render(context); _currentDraw = null; } foreach (var child in node.Children) { Render(context, (VisualNode)child, layer, clipBounds); } node.EndRender(context); } } }
private void EndConsume() { IDrawOperation drawOperation = operations[currentOperationIndex]; currentElementIndex++; for (int i = drawOperation.UIElements.Count - 1; i >= currentElementIndex; i--) { drawOperation.UIElements.RemoveAt(i); } currentElementIndex = int.MaxValue / 2; }
private void Add(IDrawOperation node) { if (_drawOperationindex < _node.DrawOperations.Count) { _node.ReplaceDrawOperation(_drawOperationindex, node); } else { _node.AddDrawOperation(node); } ++_drawOperationindex; }
private FrameworkElement TryConsume() { FrameworkElement result = null; if (currentOperationIndex >= 0 && currentOperationIndex < operations.Count) { IDrawOperation drawOperation = operations[currentOperationIndex]; currentElementIndex++; if (currentElementIndex >= 0 && currentElementIndex < drawOperation.UIElements.Count) { result = drawOperation.UIElements[currentElementIndex]; } } return(result); }
DrawResult IDrawOperation.Compare(IDrawOperation obj) { DrawResult result = DrawResult.Different; if (ReferenceEquals(obj, this)) { result = DrawResult.Equal; } else if (obj is T) { if (Transposed((T)obj)) { result = DrawResult.Moved; } else { result = DrawResult.Equal; } } return(result); }
protected DrawResult Draw(IDrawOperation operation) { while (TryConsume() != null) { //throw new InvalidOperationException(); } currentElementIndex = -1; currentOperationIndex++; DrawResult result = DrawResult.Different; bool add = true; if (currentOperationIndex >= 0 && currentOperationIndex < operations.Count) { result = operation.Compare(operations[currentOperationIndex]); if (result == DrawResult.Different) { // Clear the operations after the current index ClearAfterCurrent(); } else { // Copy the elements from the cached operation. operation.CopyFrom(operations[currentOperationIndex]); operations[currentOperationIndex] = operation; add = false; } } if (add) { operations.Add(operation); } currentDrawState = result; return(result); }
/// <summary> /// Replaces an item in the <see cref="DrawOperations"/> collection. /// </summary> /// <param name="index">The opeation to be replaced.</param> /// <param name="operation">The operation to add.</param> public void ReplaceDrawOperation(int index, IDrawOperation operation) { EnsureDrawOperationsCreated(); _drawOperations[index] = operation; }
/// <summary> /// Adds an operation to the <see cref="DrawOperations"/> collection. /// </summary> /// <param name="operation">The operation to add.</param> public void AddDrawOperation(IDrawOperation operation) { EnsureDrawOperationsCreated(); _drawOperations.Add(operation); }
public bool Equals(IDrawOperation other) { IDrawOperation oThis = (IDrawOperation)this; return(oThis.Compare(other) == DrawResult.Equal); }
public void CopyFrom(IDrawOperation other) { frameworkElements.Clear(); frameworkElements.AddRange(other.UIElements); }
public void ReplaceDrawOperation(int index, IDrawOperation node) { MakeWritable(index); DrawOperations !.Add(RefCountable.Create(node)); }
public void AddDrawOperation(IDrawOperation node) { MakeWritable(Count); DrawOperations !.Add(RefCountable.Create(node)); }