Exemplo n.º 1
0
        // Token: 0x06007C12 RID: 31762 RVA: 0x0022E560 File Offset: 0x0022C760
        private bool ResolveLocatorPart(DependencyObject dependencyObject, LocatorManager.ResolvingLocatorState data, bool visitedViaVisualTree)
        {
            if (data.Finished)
            {
                return(false);
            }
            ContentLocator     contentLocatorBase = data.ContentLocatorBase;
            bool               result             = true;
            ContentLocatorPart contentLocatorPart = contentLocatorBase.Parts[data.LocatorPartIndex];

            if (contentLocatorPart == null)
            {
                result = false;
            }
            SubTreeProcessor subTreeProcessorForLocatorPart = this.GetSubTreeProcessorForLocatorPart(contentLocatorPart);

            if (subTreeProcessorForLocatorPart == null)
            {
                result = false;
            }
            if (contentLocatorPart != null && subTreeProcessorForLocatorPart != null)
            {
                DependencyObject dependencyObject2 = subTreeProcessorForLocatorPart.ResolveLocatorPart(contentLocatorPart, dependencyObject, out result);
                if (dependencyObject2 != null)
                {
                    data.AttachmentLevel = AttachmentLevel.Incomplete;
                    data.AttachedAnchor  = dependencyObject2;
                    result = true;
                    data.LastNodeMatched = dependencyObject2;
                    data.LocatorPartIndex++;
                    if (data.LocatorPartIndex == contentLocatorBase.Parts.Count)
                    {
                        data.AttachmentLevel = AttachmentLevel.Full;
                        data.AttachedAnchor  = dependencyObject2;
                        result = false;
                    }
                    else if (data.LocatorPartIndex == contentLocatorBase.Parts.Count - 1)
                    {
                        contentLocatorPart = contentLocatorBase.Parts[data.LocatorPartIndex];
                        SelectionProcessor selectionProcessorForLocatorPart = this.GetSelectionProcessorForLocatorPart(contentLocatorPart);
                        if (selectionProcessorForLocatorPart != null)
                        {
                            AttachmentLevel attachmentLevel;
                            object          obj = selectionProcessorForLocatorPart.ResolveLocatorPart(contentLocatorPart, dependencyObject2, out attachmentLevel);
                            if (obj != null)
                            {
                                data.AttachmentLevel = attachmentLevel;
                                data.AttachedAnchor  = obj;
                                result = false;
                            }
                            else
                            {
                                result = false;
                            }
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        // Token: 0x06007C05 RID: 31749 RVA: 0x0022DD80 File Offset: 0x0022BF80
        public IList <ContentLocatorBase> GenerateLocators(object selection)
        {
            base.VerifyAccess();
            if (selection == null)
            {
                throw new ArgumentNullException("selection");
            }
            SelectionProcessor selectionProcessor = this.GetSelectionProcessor(selection.GetType());

            if (selectionProcessor != null)
            {
                ICollection nodes = (ICollection)selectionProcessor.GetSelectedNodes(selection);
                IList <ContentLocatorBase> list = null;
                PathNode pathNode = PathNode.BuildPathForElements(nodes);
                if (pathNode != null)
                {
                    SubTreeProcessor subTreeProcessor = this.GetSubTreeProcessor(pathNode.Node);
                    list = this.GenerateLocators(subTreeProcessor, pathNode, selection);
                }
                if (list == null)
                {
                    list = new List <ContentLocatorBase>(0);
                }
                return(list);
            }
            throw new ArgumentException("Unsupported Selection", "selection");
        }
Exemplo n.º 3
0
        // Token: 0x06007C11 RID: 31761 RVA: 0x0022E4B0 File Offset: 0x0022C6B0
        private LocatorManager.ResolvingLocatorState ResolveSingleLocator(ref object selection, ref AttachmentLevel attachmentLevel, AttachmentLevel attemptedLevel, ContentLocator locator, int offset, DependencyObject startNode, bool skipStartNode)
        {
            LocatorManager.ResolvingLocatorState resolvingLocatorState = new LocatorManager.ResolvingLocatorState();
            resolvingLocatorState.LocatorPartIndex   = offset;
            resolvingLocatorState.ContentLocatorBase = locator;
            PrePostDescendentsWalker <LocatorManager.ResolvingLocatorState> prePostDescendentsWalker = new PrePostDescendentsWalker <LocatorManager.ResolvingLocatorState>(TreeWalkPriority.VisualTree, new VisitedCallback <LocatorManager.ResolvingLocatorState>(this.ResolveLocatorPart), new VisitedCallback <LocatorManager.ResolvingLocatorState>(this.TerminateResolve), resolvingLocatorState);

            prePostDescendentsWalker.StartWalk(startNode, skipStartNode);
            if (resolvingLocatorState.AttachmentLevel == AttachmentLevel.Full && resolvingLocatorState.AttachedAnchor != null)
            {
                if (selection != null)
                {
                    SelectionProcessor selectionProcessor = this.GetSelectionProcessor(selection.GetType());
                    if (selectionProcessor != null)
                    {
                        object obj;
                        if (selectionProcessor.MergeSelections(selection, resolvingLocatorState.AttachedAnchor, out obj))
                        {
                            selection = obj;
                        }
                        else
                        {
                            attachmentLevel &= ~attemptedLevel;
                        }
                    }
                    else
                    {
                        attachmentLevel &= ~attemptedLevel;
                    }
                }
                else
                {
                    selection = resolvingLocatorState.AttachedAnchor;
                }
            }
            else
            {
                attachmentLevel &= ~attemptedLevel;
            }
            return(resolvingLocatorState);
        }
Exemplo n.º 4
0
 // Token: 0x06007C01 RID: 31745 RVA: 0x0022DA98 File Offset: 0x0022BC98
 public void RegisterSelectionProcessor(SelectionProcessor processor, Type selectionType)
 {
     base.VerifyAccess();
     if (processor == null)
     {
         throw new ArgumentNullException("processor");
     }
     if (selectionType == null)
     {
         throw new ArgumentNullException("selectionType");
     }
     XmlQualifiedName[] locatorPartTypes = processor.GetLocatorPartTypes();
     this._selectionProcessors[selectionType] = processor;
     if (locatorPartTypes != null)
     {
         foreach (XmlQualifiedName key in locatorPartTypes)
         {
             this._locatorPartHandlers[key] = processor;
         }
     }
 }
        /// <summary>
        ///     Registers a selection processor for a selection Type.
        ///     This call overrides any previous registrations for the Type.
        ///     The processor also provides an array of locator part types it knows how
        ///     to handle.  If a processor provides a locator part type that has been
        ///     provided by a previously registered processor, the last processor to be
        ///     registered overrides all others.
        /// </summary>
        /// <remark>
        ///     GetSelectionProcessor(Type) looks for a processor registered for
        ///     the Type or any of its base Types.  Interfaces are not taken into
        ///     account.  Do not register a selection processor for an interface
        ///     Type.
        /// </remark>
        /// <param name="processor">instance to be registered</param>
        /// <param name="selectionType">Type of selection processed by this processor</param>
        /// <exception cref="ArgumentNullException">processor or selectionType is null</exception>
        public void RegisterSelectionProcessor(SelectionProcessor processor, Type selectionType)
        {
            VerifyAccess();
            if (processor == null)
                throw new ArgumentNullException("processor");

            if (selectionType == null)
                throw new ArgumentNullException("selectionType");

            XmlQualifiedName[] locatorPartTypes = processor.GetLocatorPartTypes();
            _selectionProcessors[selectionType] = processor;

            if (locatorPartTypes != null)
            {
                foreach (XmlQualifiedName type in locatorPartTypes)
                {
                    _locatorPartHandlers[type] = processor;
                }
            }            
        }
Exemplo n.º 6
0
        // Token: 0x06007C10 RID: 31760 RVA: 0x0022E31C File Offset: 0x0022C51C
        private object InternalResolveLocator(ContentLocatorBase locator, int offset, DependencyObject startNode, bool skipStartNode, out AttachmentLevel attachmentLevel)
        {
            attachmentLevel = AttachmentLevel.Full;
            object result = null;
            ContentLocatorGroup contentLocatorGroup = locator as ContentLocatorGroup;
            ContentLocator      contentLocator      = locator as ContentLocator;
            AttachmentLevel     attachmentLevel2    = AttachmentLevel.Unresolved;

            if (contentLocator != null && offset == contentLocator.Parts.Count - 1)
            {
                ContentLocatorPart locatorPart = contentLocator.Parts[offset];
                SelectionProcessor selectionProcessorForLocatorPart = this.GetSelectionProcessorForLocatorPart(locatorPart);
                if (selectionProcessorForLocatorPart != null)
                {
                    result          = selectionProcessorForLocatorPart.ResolveLocatorPart(locatorPart, startNode, out attachmentLevel2);
                    attachmentLevel = attachmentLevel2;
                    return(result);
                }
            }
            IList <ContentLocator> list;

            if (contentLocatorGroup == null)
            {
                list = new List <ContentLocator>(1);
                list.Add(contentLocator);
            }
            else
            {
                AnnotationService service = AnnotationService.GetService(startNode);
                if (service != null)
                {
                    startNode = service.Root;
                }
                list          = contentLocatorGroup.Locators;
                offset        = 0;
                skipStartNode = false;
            }
            bool flag = true;

            if (list.Count > 0)
            {
                LocatorManager.ResolvingLocatorState resolvingLocatorState = this.ResolveSingleLocator(ref result, ref attachmentLevel, AttachmentLevel.StartPortion, list[0], offset, startNode, skipStartNode);
                if (list.Count == 1)
                {
                    result          = resolvingLocatorState.AttachedAnchor;
                    attachmentLevel = resolvingLocatorState.AttachmentLevel;
                }
                else
                {
                    if (list.Count > 2)
                    {
                        AttachmentLevel attachmentLevel3 = AttachmentLevel.Unresolved;
                        AttachmentLevel attachmentLevel4 = attachmentLevel;
                        for (int i = 1; i < list.Count - 1; i++)
                        {
                            resolvingLocatorState = this.ResolveSingleLocator(ref result, ref attachmentLevel, AttachmentLevel.MiddlePortion, list[i], offset, startNode, skipStartNode);
                            if (attachmentLevel3 == AttachmentLevel.Unresolved || (attachmentLevel & AttachmentLevel.MiddlePortion) != AttachmentLevel.Unresolved)
                            {
                                attachmentLevel3 = attachmentLevel;
                            }
                            attachmentLevel = attachmentLevel4;
                        }
                        attachmentLevel = attachmentLevel3;
                    }
                    else
                    {
                        flag = false;
                    }
                    resolvingLocatorState = this.ResolveSingleLocator(ref result, ref attachmentLevel, AttachmentLevel.EndPortion, list[list.Count - 1], offset, startNode, skipStartNode);
                    if (!flag && attachmentLevel == AttachmentLevel.MiddlePortion)
                    {
                        attachmentLevel &= ~AttachmentLevel.MiddlePortion;
                    }
                    if (attachmentLevel == (AttachmentLevel.StartPortion | AttachmentLevel.EndPortion))
                    {
                        attachmentLevel = AttachmentLevel.Full;
                    }
                }
            }
            else
            {
                attachmentLevel = AttachmentLevel.Unresolved;
            }
            return(result);
        }
Exemplo n.º 7
0
        // Token: 0x06007C0C RID: 31756 RVA: 0x0022DFEC File Offset: 0x0022C1EC
        private IList <ContentLocatorBase> GenerateLocators(SubTreeProcessor processor, PathNode startNode, object selection)
        {
            List <ContentLocatorBase> list = new List <ContentLocatorBase>();
            bool           flag            = true;
            ContentLocator contentLocator  = processor.GenerateLocator(startNode, out flag);
            bool           flag2           = contentLocator != null;

            if (flag)
            {
                int count = startNode.Children.Count;
                if (count != 0)
                {
                    if (count != 1)
                    {
                        ContentLocatorBase contentLocatorBase = this.GenerateLocatorGroup(startNode, selection);
                        if (contentLocatorBase != null)
                        {
                            flag2 = false;
                        }
                        if (contentLocator != null)
                        {
                            list.Add(contentLocator.Merge(contentLocatorBase));
                        }
                        else if (contentLocatorBase != null)
                        {
                            list.Add(contentLocatorBase);
                        }
                    }
                    else
                    {
                        SubTreeProcessor           subTreeProcessor = this.GetSubTreeProcessor(startNode.Node);
                        IList <ContentLocatorBase> list2            = this.GenerateLocators(subTreeProcessor, (PathNode)startNode.Children[0], selection);
                        if (list2 != null && list2.Count > 0)
                        {
                            flag2 = false;
                        }
                        if (contentLocator != null)
                        {
                            list.AddRange(this.Merge(contentLocator, list2));
                        }
                        else
                        {
                            list.AddRange(list2);
                        }
                    }
                }
                else if (contentLocator != null)
                {
                    list.Add(contentLocator);
                }
            }
            else if (contentLocator != null)
            {
                list.Add(contentLocator);
            }
            if (flag2 && selection != null)
            {
                SelectionProcessor selectionProcessor = this.GetSelectionProcessor(selection.GetType());
                if (selectionProcessor != null)
                {
                    IList <ContentLocatorPart> list3 = selectionProcessor.GenerateLocatorParts(selection, startNode.Node);
                    if (list3 != null && list3.Count > 0)
                    {
                        List <ContentLocatorBase> list4 = new List <ContentLocatorBase>(list.Count * list3.Count);
                        foreach (ContentLocatorBase contentLocatorBase2 in list)
                        {
                            list4.AddRange(((ContentLocator)contentLocatorBase2).DotProduct(list3));
                        }
                        list = list4;
                    }
                }
            }
            return(list);
        }