Exemplo n.º 1
0
        public static bool RemoveChild(this AnchoredBlock parent, TextElement child)
        {
            var block = child as Block;

            if (block == null)
            {
                return(false);
            }

            return(parent.Blocks.Remove(block));
        }
Exemplo n.º 2
0
        public static void AddChild(this AnchoredBlock parent, TextElement child)
        {
            var block = child as Block;

            if (block == null)
            {
                return;
            }

            parent.Blocks.Add(block);
        }
Exemplo n.º 3
0
        public static void InsertAfter(this AnchoredBlock parent, TextElement previousSibling, TextElement child)
        {
            var block = child as Block;

            if (block == null)
            {
                return;
            }

            var previousBlock = previousSibling as Block;

            if (previousBlock == null || !parent.Blocks.Contains(previousBlock))
            {
                parent.Blocks.Add(block);
            }

            parent.Blocks.InsertAfter(previousBlock, block);
        }
Exemplo n.º 4
0
        public static void InsertBefore(this AnchoredBlock parent, TextElement nextSibling, TextElement child)
        {
            var block = child as Block;

            if (block == null)
            {
                return;
            }

            var nextBlock = nextSibling as Block;

            if (nextBlock == null || !parent.Blocks.Contains(nextBlock))
            {
                parent.Blocks.Add(block);
            }

            parent.Blocks.InsertBefore(nextBlock, block);
        }
Exemplo n.º 5
0
        private static int GetCharOffsetToPosition(Inline currentInline, TextPointer position, out TextPointer result)
        {
            Run run = currentInline as Run;

            if (run != null)
            {
                return(GetCharOffsetToPosition(run, position, out result));
            }

            LineBreak lineBreak = currentInline as LineBreak;

            if (lineBreak != null)
            {
                return(GetCharOffsetToPosition(lineBreak, position, out result));
            }

            Span span = currentInline as Span;

            if (span != null)
            {
                return(GetCharOffsetToPosition(span, position, out result));
            }

            InlineUIContainer inlineUIContainer = currentInline as InlineUIContainer;

            if (inlineUIContainer != null)
            {
                return(GetCharOffsetToPosition(inlineUIContainer, position, out result));
            }

            AnchoredBlock anchoredBlock = currentInline as AnchoredBlock;

            if (anchoredBlock != null)
            {
                return(GetCharOffsetToPosition(anchoredBlock, position, out result));
            }

            throw new ArgumentException();
        }
Exemplo n.º 6
0
        private static TextPointer GetPointerFromCharOffset(Inline currentInline, ref int charOffset)
        {
            Run run = currentInline as Run;

            if (run != null)
            {
                return(GetPointerFromCharOffset(run, ref charOffset));
            }

            LineBreak lineBreak = currentInline as LineBreak;

            if (lineBreak != null)
            {
                return(GetPointerFromCharOffset(lineBreak, ref charOffset));
            }

            Span span = currentInline as Span;

            if (span != null)
            {
                return(GetPointerFromCharOffset(span, ref charOffset));
            }

            InlineUIContainer inlineUIContainer = currentInline as InlineUIContainer;

            if (inlineUIContainer != null)
            {
                return(GetPointerFromCharOffset(inlineUIContainer, ref charOffset));
            }

            AnchoredBlock anchoredBlock = currentInline as AnchoredBlock;

            if (anchoredBlock != null)
            {
                return(GetPointerFromCharOffset(anchoredBlock, ref charOffset));
            }

            throw new ArgumentException();
        }
Exemplo n.º 7
0
        // Token: 0x06006B36 RID: 27446 RVA: 0x001EF6F4 File Offset: 0x001ED8F4
        internal override bool InvalidateStructure(int startPosition)
        {
            Invariant.Assert(base.ParagraphEndCharacterPosition >= startPosition);
            bool result = false;

            if (base.ParagraphStartCharacterPosition == startPosition)
            {
                result = true;
                AnchoredBlock anchoredBlock = null;
                if (this._attachedObjects != null && this._attachedObjects.Count > 0)
                {
                    anchoredBlock = (AnchoredBlock)this._attachedObjects[0].Element;
                }
                if (anchoredBlock != null && startPosition == anchoredBlock.ElementStartOffset)
                {
                    StaticTextPointer staticTextPointerFromCP = TextContainerHelper.GetStaticTextPointerFromCP(base.StructuralCache.TextContainer, startPosition);
                    if (staticTextPointerFromCP.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
                    {
                        result = (anchoredBlock != staticTextPointerFromCP.GetAdjacentElement(LogicalDirection.Forward));
                    }
                }
            }
            this.InvalidateTextFormatCache();
            if (this._attachedObjects != null)
            {
                for (int i = 0; i < this._attachedObjects.Count; i++)
                {
                    BaseParagraph para = this._attachedObjects[i].Para;
                    if (para.ParagraphEndCharacterPosition >= startPosition)
                    {
                        para.InvalidateStructure(startPosition);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 8
0
 public static IEnumerable <TextElement> GetChildren(this AnchoredBlock parent)
 {
     return(parent.Blocks);
 }
Exemplo n.º 9
0
 private static int GetCharOffsetToPosition(AnchoredBlock anchoredBlock, TextPointer position, out TextPointer result)
 {
     return(GetCharOffsetToPosition(anchoredBlock.Blocks, position, out result));
 }
Exemplo n.º 10
0
 private static TextPointer GetPointerFromCharOffset(AnchoredBlock anchoredBlock, ref int charOffset)
 {
     return(GetPointerFromCharOffset(anchoredBlock.ElementEnd, anchoredBlock.Blocks, ref charOffset));
 }