Beispiel #1
0
 private void Add(IDrawOperation node)
 {
     using (var refCounted = RefCountable.Create(node))
     {
         Add(refCounted);
     }
 }
Beispiel #2
0
        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);
                }
            }
        }
Beispiel #3
0
        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;
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
 /// <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;
 }
Beispiel #9
0
 /// <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);
 }
Beispiel #10
0
        public bool Equals(IDrawOperation other)
        {
            IDrawOperation oThis = (IDrawOperation)this;

            return(oThis.Compare(other) == DrawResult.Equal);
        }
Beispiel #11
0
 public void CopyFrom(IDrawOperation other)
 {
     frameworkElements.Clear();
     frameworkElements.AddRange(other.UIElements);
 }
Beispiel #12
0
 public void ReplaceDrawOperation(int index, IDrawOperation node)
 {
     MakeWritable(index);
     DrawOperations !.Add(RefCountable.Create(node));
 }
Beispiel #13
0
 public void AddDrawOperation(IDrawOperation node)
 {
     MakeWritable(Count);
     DrawOperations !.Add(RefCountable.Create(node));
 }