コード例 #1
0
        // Token: 0x06007C33 RID: 31795 RVA: 0x0022EB24 File Offset: 0x0022CD24
        public static IList <DependencyObject> GetSelectedNodes(object selection)
        {
            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }
            ITextPointer        textPointer = null;
            ITextPointer        position    = null;
            IList <TextSegment> list;

            TextSelectionHelper.CheckSelection(selection, out textPointer, out position, out list);
            IList <DependencyObject> list2 = new List <DependencyObject>();

            if (textPointer.CompareTo(position) == 0)
            {
                list2.Add(((TextPointer)textPointer).Parent);
                return(list2);
            }
            TextPointer textPointer2 = (TextPointer)textPointer.CreatePointer();

            while (((ITextPointer)textPointer2).CompareTo(position) < 0)
            {
                DependencyObject parent = textPointer2.Parent;
                if (!list2.Contains(parent))
                {
                    list2.Add(parent);
                }
                textPointer2.MoveToNextContextPosition(LogicalDirection.Forward);
            }
            return(list2);
        }
コード例 #2
0
        // Token: 0x06007C34 RID: 31796 RVA: 0x0022EBB0 File Offset: 0x0022CDB0
        public static UIElement GetParent(object selection)
        {
            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }
            ITextPointer        pointer     = null;
            ITextPointer        textPointer = null;
            IList <TextSegment> list;

            TextSelectionHelper.CheckSelection(selection, out pointer, out textPointer, out list);
            return(TextSelectionHelper.GetParent(pointer));
        }
コード例 #3
0
        // Token: 0x06007C45 RID: 31813 RVA: 0x0022F240 File Offset: 0x0022D440
        public override IList <ContentLocatorPart> GenerateLocatorParts(object selection, DependencyObject startNode)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }
            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }
            IList <TextSegment> list = null;
            ITextPointer        textPointer;
            ITextPointer        position;

            TextSelectionHelper.CheckSelection(selection, out textPointer, out position, out list);
            if (!(textPointer is TextPointer))
            {
                throw new ArgumentException(SR.Get("WrongSelectionType"), "selection");
            }
            ITextPointer textPointer2;
            ITextPointer textPointer3;

            if (!this.GetNodesStartAndEnd(startNode, out textPointer2, out textPointer3))
            {
                return(null);
            }
            if (textPointer2.CompareTo(position) > 0)
            {
                throw new ArgumentException(SR.Get("InvalidStartNodeForTextSelection"), "startNode");
            }
            if (textPointer3.CompareTo(textPointer) < 0)
            {
                throw new ArgumentException(SR.Get("InvalidStartNodeForTextSelection"), "startNode");
            }
            ContentLocatorPart contentLocatorPart = new ContentLocatorPart(TextSelectionProcessor.CharacterRangeElementName);
            int num  = 0;
            int num2 = 0;

            for (int i = 0; i < list.Count; i++)
            {
                this.GetTextSegmentValues(list[i], textPointer2, textPointer3, out num, out num2);
                contentLocatorPart.NameValuePairs.Add("Segment" + i.ToString(NumberFormatInfo.InvariantInfo), num.ToString(NumberFormatInfo.InvariantInfo) + TextSelectionProcessor.Separator[0].ToString() + num2.ToString(NumberFormatInfo.InvariantInfo));
            }
            contentLocatorPart.NameValuePairs.Add("Count", list.Count.ToString(NumberFormatInfo.InvariantInfo));
            return(new List <ContentLocatorPart>(1)
            {
                contentLocatorPart
            });
        }
コード例 #4
0
        GenerateLocatorParts(Object selection, DependencyObject startNode)
        {
            if (startNode == null)
            {
                throw new ArgumentNullException("startNode");
            }

            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }

            ITextPointer        start;
            ITextPointer        end;
            IList <TextSegment> textSegments = null;

            TextSelectionHelper.CheckSelection(selection, out start, out end, out textSegments);
            if (!(start is TextPointer))
            {
                throw new ArgumentException(SR.Get(SRID.WrongSelectionType), "selection");
            }

            ITextPointer elementStart;
            ITextPointer elementEnd;

            // If we can't get the start/end of the node then we can't generate a locator part
            if (!GetNodesStartAndEnd(startNode, out elementStart, out elementEnd))
            {
                return(null);
            }

            if (elementStart.CompareTo(end) > 0)
            {
                throw new ArgumentException(SR.Get(SRID.InvalidStartNodeForTextSelection), "startNode");
            }

            if (elementEnd.CompareTo(start) < 0)
            {
                throw new ArgumentException(SR.Get(SRID.InvalidStartNodeForTextSelection), "startNode");
            }

            ContentLocatorPart part = new ContentLocatorPart(CharacterRangeElementName);

            int startOffset = 0;
            int endOffset   = 0;

            for (int i = 0; i < textSegments.Count; i++)
            {
                GetTextSegmentValues(textSegments[i], elementStart, elementEnd, out startOffset, out endOffset);

                part.NameValuePairs.Add(SegmentAttribute + i.ToString(NumberFormatInfo.InvariantInfo), startOffset.ToString(NumberFormatInfo.InvariantInfo) + TextSelectionProcessor.Separator[0] + endOffset.ToString(NumberFormatInfo.InvariantInfo));
            }

            part.NameValuePairs.Add(CountAttribute, textSegments.Count.ToString(NumberFormatInfo.InvariantInfo));

            List <ContentLocatorPart> res = new List <ContentLocatorPart>(1);

            res.Add(part);

            return(res);
        }