예제 #1
0
        protected virtual void UpdateNodes(IDictionary <string, IValue> update)
        {
            if (update == null || !update.ContainsKey("nodes"))
            {
                return;
            }

            var nodes = update["nodes"].GetList();

            foreach (var node in nodes)
            {
                var nodeDictionary = node.GetDictionary();
                if (nodeDictionary == null)
                {
                    continue;
                }

                int nodeId            = nodeDictionary["id"].GetInt();
                var accessibilityNode = GetNode(nodeId);

                // Create if it is a new one
                if (accessibilityNode != null)
                {
                    accessibilityNode.Update(nodeDictionary);
                }
                else
                {
                    accessibilityNode            = new AccessibilityNode((FrameworkElement)Owner, nodeDictionary, this);
                    accessibilityNodeMap[nodeId] = accessibilityNode;
                }
            }
        }
예제 #2
0
        protected virtual void RemoveNode(AccessibilityNode node)
        {
            if (node == null)
            {
                return;
            }

            foreach (var child in node.GetChildAccessibilityNodes())
            {
                RemoveNode(child);
            }

            accessibilityNodeMap.Remove(node.Id);
        }
예제 #3
0
        protected virtual void UpdateLayout(IDictionary <string, IValue> eventDictionary, List <IDictionary <string, IValue> > updateDictionaries)
        {
            foreach (var updateDictionary in updateDictionaries)
            {
                bool rootNodeChanged = false;

                // If a node is to be cleared
                if (updateDictionary.ContainsKey("node_id_to_clear"))
                {
                    // Reset root node if that is to be cleared
                    int nodeIdToClear = updateDictionary["node_id_to_clear"].GetInt();
                    if (nodeIdToClear == RootNodeId)
                    {
                        RootNodeId = -1;
                    }

                    AccessibilityNode node = GetNode(nodeIdToClear);
                    RemoveNode(node);
                }

                if (updateDictionary.ContainsKey("root_id"))
                {
                    int newRootNodeId = updateDictionary["root_id"].GetInt();
                    if (newRootNodeId != RootNodeId)
                    {
                        RootNodeId      = newRootNodeId;
                        rootNodeChanged = true;
                    }
                }

                UpdateNodes(updateDictionary);

                if (rootNodeChanged)
                {
                    RaiseAutomationEvent(AutomationEvents.StructureChanged);
                }
            }
        }