Exemplo n.º 1
0
        /// <summary>
        /// todo bzw. nachfrage: geht die methode findall nicht alleine alle elemente der collection durch? wird in der foreach-schleife dadurch nicht doppelt gearbeitet?
        /// Sucht rekusiv alle Kindelemente eines Knotens und ermittelt dessen Eingenschaften
        /// </summary>
        /// <param name="top">teh current tree object</param>
        /// <param name="collection">gibt die AutomationElement-Collection an</param>
        /// <param name="depth">gibt an wie tief der Suche ausgehend vom Root-Element an.</param>
        private void findChildrenOfNode(Object top, AutomationElementCollection collection, int depth)
        {
            #region set grantFilterStrategiesChildren
            if (collection != null && collection.Count > 0 && !strategyMgr.getSpecifiedTree().IsRoot(top))
            {
                OSMElements.OSMElement osmTop = strategyMgr.getSpecifiedTree().GetData(top);
                if (osmTop.properties.grantFilterStrategiesChildren == null)
                {
                    osmTop.properties.grantFilterStrategiesChildren = new List <string>();
                }
                if (!osmTop.properties.grantFilterStrategiesChildren.Contains(Settings.filterStrategyTypeToUserName(this.GetType())))
                {
                    osmTop.properties.grantFilterStrategiesChildren.Add(Settings.filterStrategyTypeToUserName(this.GetType()));
                }
            }
            #endregion
            foreach (AutomationElement element in collection)
            {
                if (strategyMgr.getSpecifiedTree().Depth(top) < depth || depth <= -1)
                {
                    OSMElements.OSMElement osmElement = new OSMElements.OSMElement();
                    osmElement.properties = setProperties(element);
                    Object node = strategyMgr.getSpecifiedTree().AddChild(top, osmElement);

                    AutomationElementCollection c = element.FindAll(TreeScope.Children, Condition.TrueCondition);
                    findChildrenOfNode(node, c, depth);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Seeks to an <see cref="OSMElements.OSMElement"/> the appropriate <see cref="AutomationElement"/>
        /// </summary>
        /// <param name="osmElement">OSM element</param>
        /// <returns>the appropriate <see cref="AutomationElement"</returns>
        private AutomationElement getAutomationelementOfOsmElement(OSMElements.OSMElement osmElement)
        {
            AutomationElement au;
            Condition         cond = setPropertiesCondition(osmElement.properties);

            if (osmElement.properties.hWndFiltered != IntPtr.Zero)
            {
                //ist der Weg wirklich schneller?
                IntPtr            pointer           = strategyMgr.getSpecifiedOperationSystem().getProcessHwndFromHwnd(deliverElementID(osmElement.properties.hWndFiltered));
                AutomationElement mainWindowElement = deliverAutomationElementFromHWND(pointer);
                //au = mainWindowElement.FindFirst(TreeScope.Children, cond);
                if (mainWindowElement == null)
                {
                    return(null);
                }
                au = mainWindowElement.FindFirst(TreeScope.Subtree, cond);
            }
            else
            {
                if (grantTrees.filteredTree != null && strategyMgr.getSpecifiedTree().HasChild(grantTrees.filteredTree) && strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(grantTrees.filteredTree)).properties.hWndFiltered != IntPtr.Zero)
                {
                    IntPtr hwnd = strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(grantTrees.filteredTree)).properties.hWndFiltered;
                    //IntPtr pointer = strategyMgr.getSpecifiedOperationSystem().getProcessHwndFromHwnd(deliverElementID(strategyMgr.filteredTree.Child.Data.properties.hWndFiltered));
                    AutomationElement element = AutomationElement.FromHandle(hwnd);
                    au = element.FindFirst(TreeScope.Descendants, cond);
                }
                else
                {
                    au = AutomationElement.RootElement.FindFirst(TreeScope.Descendants, cond); //Attention: it is possible that another element will be found
                }
            }
            return(au);
        }
Exemplo n.º 3
0
        private OSMElements.OSMElement addElementInBrailleTree(object filteredNode, TextviewElement tve, int width, ref int startXPosition, int startYPosition)
        {
            OSMElements.OSMElement osmFiltered = strategyMgr.getSpecifiedTree().GetData(filteredNode);
            int            depth = strategyMgr.getSpecifiedTree().Depth(filteredNode) * shiftingPerDepth;
            TextviewObject tvo   = grantTrees.TextviewObject;

            OSMElements.OSMElement osmBraille  = new OSMElements.OSMElement();
            GeneralProperties      propBraille = new GeneralProperties();
            BrailleRepresentation  braille     = new BrailleRepresentation();

            braille.isVisible = true;
            propBraille.controlTypeFiltered = "Text";
            braille.isGroupChild            = true;
            braille.typeOfView = tvo.typeOfView;
            braille.screenName = tvo.screenName;
            braille.displayedGuiElementType = tve.property;
            braille.viewName = osmFiltered.properties.IdGenerated + "_" + tve.order;

            propBraille.boundingRectangleFiltered = new Rect(startXPosition, startYPosition, width, 5);//TODO: richtig machen

            osmBraille.properties            = propBraille;
            osmBraille.brailleRepresentation = braille;
            propBraille.IdGenerated          = treeOperation.generatedIds.generatedIdBrailleNode(osmBraille);
            osmBraille.properties            = propBraille;
            treeOperation.osmTreeConnector.addOsmConnection(osmFiltered.properties.IdGenerated, propBraille.IdGenerated);
            treeOperation.updateNodes.updateNodeOfBrailleUi(ref osmBraille);
            return(osmBraille);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generates an id for one node of the braille (output) tree.
        /// </summary>
        /// <param name="node">one node of the braille tree</param>
        /// <returns>the generated id</returns>
        public String generatedIdBrailleNode(OSMElements.OSMElement osmElement)
        {
            /* https://blogs.msdn.microsoft.com/csharpfaq/2006/10/09/how-do-i-calculate-a-md5-hash-from-a-string/
             * http://stackoverflow.com/questions/12979212/md5-hash-from-string
             * http://stackoverflow.com/questions/10520048/calculate-md5-checksum-for-a-file
             */
            GeneralProperties     properties = osmElement.properties;
            BrailleRepresentation braille    = osmElement.brailleRepresentation;
            String result = properties.controlTypeFiltered +
                            braille.displayedGuiElementType +
                            braille.screenName +
                            braille.viewName +
                            properties.boundingRectangleFiltered.ToString() +
                            properties.controlTypeFiltered +
                            (braille.typeOfView == null? "":braille.typeOfView) +
                            (braille.uiElementSpecialContent == null? "": braille.uiElementSpecialContent.ToString());

            byte[] hash;
            using (var md5 = MD5.Create())
            {
                hash = md5.ComputeHash(Encoding.UTF8.GetBytes(result));
            }
            StringBuilder sb = new StringBuilder();

            foreach (byte b in hash)
            {
                sb.Append(b.ToString("X2"));
            }
            return(sb.ToString());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds all elements (of the subtree) as Sysmbols to the braille tree
        /// </summary>
        /// <param name="subtree">subtree to add as Symbols</param>
        /// <param name="lastRect">position of the last UI element which was added</param>
        /// <param name="idToIgnore">a list of all (ids of) elements which should NOT be added as symbol</param>
        public void addsAllElementsAsSymbols(object subtree, ref Rect lastRect, string[] idToIgnore = null)
        {
            ATemplateUi generalUiInstance = new TemplateNode(strategyMgr, grantTrees, treeOperation);
            RendererUiElementConnector defaultRendererUiConnector = new RendererUiElementConnector("Text", "Text", new RendererUiElementConnector.SizeUiElement(5, 21));

            foreach (Object node in strategyMgr.getSpecifiedTree().DirectChildrenNodes(subtree))
            {
                /* Prüfen, ob der Knoten Ignoriert werden soll
                 *    nicht ignorieren -> Kinder
                 * nur Kinder Zeichnen -> ControllType der Eltern beachten --> evtl. werden mehrere Kinder mit einmal dargestellt
                 */
                OSMElements.OSMElement osmNode = strategyMgr.getSpecifiedTree().GetData(node);
                if (idToIgnore == null || !idToIgnore.Contains(osmNode.properties.IdGenerated))
                {
                    RendererUiElementConnector connector = rendererUiElementConnectorContainsControltype(osmNode.properties.controlTypeFiltered);
                    if (connector == null && strategyMgr.getSpecifiedTree().HasChild(node))
                    {
                        //consider the children
                        addsAllElementsAsSymbols(node, ref lastRect, idToIgnore);
                    }
                    else
                    {
                        if (connector == null)
                        {
                            connector = defaultRendererUiConnector;
                        }
                        //TODO: use a diffenent template for every element type?
                        generalUiInstance.createUiElementFromTemplate(node, createTemplateObjectFromNode(node, connector, ref lastRect));//new type of view
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds a parent element in the tree.
        /// </summary>
        /// <param name="parentElement">the parent Automation element</param>
        /// <param name="tree">the tree</param>
        private void addParentOfNode(AutomationElement parentElement, ref Object tree)
        {
            Object tree2 = getStrategyMgr().getSpecifiedTree().NewTree();

            OSMElements.OSMElement osmElement = new OSMElements.OSMElement();
            osmElement.properties = setProperties(parentElement);
            #region set grantFilterStrategiesChildren
            if (tree != null)
            {
                OSMElements.OSMElement osmChild = strategyMgr.getSpecifiedTree().GetData(tree);
                if (osmChild != null && !osmChild.Equals(new OSMElements.OSMElement()))
                {
                    if (osmChild.properties.grantFilterStrategiesChildren != null)
                    {
                        osmElement.properties.grantFilterStrategiesChildren = osmChild.properties.grantFilterStrategiesChildren;
                    }
                    else
                    {
                        osmElement.properties.grantFilterStrategiesChildren = new List <string>();
                        osmElement.properties.grantFilterStrategiesChildren.Add(osmChild.properties.grantFilterStrategy);
                    }
                }
            }
            #endregion
            Object node = strategyMgr.getSpecifiedTree().AddChild(tree2, osmElement);
            strategyMgr.getSpecifiedTree().AddChild(node, tree);
            strategyMgr.getSpecifiedTree().Clear(tree);
            strategyMgr.getSpecifiedTree().AddChild(tree, tree2);
        }
Exemplo n.º 7
0
        public void getScreenshotPointInApplicationTest()
        {
            initilaizeFilteredTree();
            strategyMgr.getSpecifiedGeneralTemplateUi().generatedUiFromTemplate(pathToTemplate);
            strategyMgr.getSpecifiedBrailleDisplay().setActiveAdapter();
            strategyMgr.getSpecifiedBrailleDisplay().generatedBrailleUi();
            //in dem genutzten Template ist bei der View 'lv' der Screenshot
            strategyMgr.getSpecifiedBrailleDisplay().setVisibleScreen("lv");
            int    pointX      = 6;
            int    pointY      = 42;
            Object nodeAtPoint = guiFuctions.getBrailleNodeAtPoint(pointX, pointY);
            int    clickX;
            int    clickY;

            guiFuctions.getScreenshotPointInApplication(nodeAtPoint, pointX, pointY, out clickX, out clickY);
            //nun folgt der Abgleich, ob die richtige Position ermittelt wurde => es sollte der Button '7' auf dem Taschenrechner sein
            OSMElements.OSMElement dataOfPoint = strategyMgr.getSpecifiedFilter().getOSMElement(clickX, clickY);
            Assert.AreEqual("Button", dataOfPoint.properties.controlTypeFiltered, "Es hätte der Button sein sollen!");
            Assert.AreEqual("7", dataOfPoint.properties.nameFiltered, "auf dem Button hätte die Zahl '7' stehen müssen!");
            List <Object> searchresult = treeOperation.searchNodes.getNodesByProperties(grantTrees.filteredTree, dataOfPoint.properties);

            Assert.AreNotEqual(null, searchresult, "Es hätte ein Knoten im gefilterten Baum gefunden werden müssen!");
            Assert.AreNotEqual(new List <Object>(), searchresult, "Es hätte ein Knoten im gefilterten Baum gefunden werden müssen!");
            Assert.AreEqual(1, searchresult.Count, "Es hätte genau ein Knoten gefunden werden müssen!");
            strategyMgr.getSpecifiedBrailleDisplay().removeActiveAdapter();
            guiFuctions.deleteGrantTrees();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Adds a navigatiobar for the screen
        /// </summary>
        /// <param name="pathToXml">path of the used template (XML)</param>
        /// <param name="screenName">name of the screen on wich the navigation bar should be added</param>
        /// <param name="typeOfView">name of the type of view in which the navigation bar should be added</param>
        public void addNavigationbarForScreen(string pathToXml, String screenName, String typeOfView)
        {
            TemplateUiObject templateObject = getTemplateUiObjectOfNavigationbarScreen(pathToXml);

            if (templateObject.Equals(new TemplateUiObject()))
            {
                return;
            }
            List <String> screens    = treeOperation.searchNodes.getPosibleScreenNames(typeOfView);
            List <String> screenNavi = new List <string>();

            //screenNavi.Add(strategyMgr.getSpecifiedTree().GetData(subtree).brailleRepresentation.screenName);
            screenNavi.Add(screenName);
            templateObject.Screens = screenNavi;
            List <OSMElements.OSMElement> groupElementsStatic = calculatePositionOfScreenTab(screens, templateObject);

            if (groupElementsStatic == null || groupElementsStatic.Equals(new List <OSMElements.OSMElement>()))
            {
                return;
            }
            templateObject.groupElements = groupElementsStatic;
            Object tree = grantTrees.filteredTree;
            BrailleRepresentation br = templateObject.osm.brailleRepresentation;

            br.groupelementsOfSameType = new GroupelementsOfSameType();
            OSMElements.OSMElement osm = templateObject.osm;
            osm.brailleRepresentation = br;
            templateObject.osm        = osm;
            ATemplateUi generalUiInstance = new TemplateGroupStatic(strategyMgr, grantTrees, treeOperation);

            generalUiInstance.createUiElementFromTemplate(tree, templateObject);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Erstellt einen Braille-Tree, welcher zum Testen der suchen genutzt werden kann
        /// </summary>
        private void initilaizeBrailleTree2Screens()
        {
            #region 1. node
            OSMElements.OSMElement osm = new OSMElements.OSMElement();

            osm.brailleRepresentation.isVisible  = true;
            osm.brailleRepresentation.screenName = "TestScreen";
            osm.brailleRepresentation.viewName   = "TestView";
            osm.brailleRepresentation.typeOfView = VIEWCATEGORYSYMBOLVIEW;

            osm.properties.boundingRectangleFiltered = new Rect(0, 0, 20, 10);
            osm.properties.controlTypeFiltered       = "Text";
            osm.properties.valueFiltered             = "Test";

            treeOperation.updateNodes.addNodeInBrailleTree(osm);
            #endregion

            #region 2. node
            OSMElements.OSMElement osm2 = new OSMElements.OSMElement();

            osm2.brailleRepresentation.isVisible  = true;
            osm2.brailleRepresentation.screenName = "TestScreen -2";
            osm2.brailleRepresentation.viewName   = "TestView";
            osm2.brailleRepresentation.typeOfView = VIEWCATEGORYSYMBOLVIEW;

            osm2.properties.boundingRectangleFiltered = new Rect(0, 0, 20, 10);
            osm2.properties.controlTypeFiltered       = "Text";
            osm2.properties.valueFiltered             = "Test";
            treeOperation.updateNodes.addNodeInBrailleTree(osm2);
            #endregion
        }
Exemplo n.º 10
0
        public void updateImg()
        {
            if (grantTrees.filteredTree == null)
            {
                Console.WriteLine("Die Anwendung wurde noch nicht gefiltert - bitte 'F5' drücken");
                return;
            }
            String            brailleId           = "";
            GeneralProperties propertiesForSearch = new GeneralProperties();

            propertiesForSearch.controlTypeFiltered = "Screenshot";
            List <Object> treeElement = treeOperation.searchNodes.getNodesByProperties(grantTrees.brailleTree, propertiesForSearch, OperatorEnum.and);

            if (treeElement.Count > 0)
            {
                brailleId = strategyMgr.getSpecifiedTree().GetData(treeElement[0]).properties.IdGenerated;
            }
            if (brailleId.Equals(""))
            {
                return;
            }
            OsmTreeConnectorTuple osmRelationships = grantTrees.osmTreeConnections.Find(r => r.BrailleTreeId.Equals(brailleId) || r.FilteredTreeId.Equals(brailleId));

            if (osmRelationships != null)
            {
                //strategyMgr.getSpecifiedFilter().updateNodeOfFilteredTree(osmRelationships.FilteredTree);
                treeOperation.updateNodes.filteredNodeElementOfApplication(osmRelationships.FilteredTreeId);

                OSMElements.OSMElement relatedBrailleTreeObject = treeOperation.searchNodes.getBrailleTreeOsmElementById(osmRelationships.BrailleTreeId);
                if (!relatedBrailleTreeObject.Equals(new OSMElements.OSMElement()))
                {
                    strategyMgr.getSpecifiedBrailleDisplay().updateViewContent(ref relatedBrailleTreeObject);
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Wechselt zwischen screen1 und screen2
        /// </summary>
        public void changeScreen(String name)
        {
            if (name.Equals(""))
            {
                return;
            }
            if (strategyMgr.getSpecifiedBrailleDisplay() == null)
            {
                return;
            }
            if (getPosibleScreens().Contains(name))
            {
                strategyMgr.getSpecifiedBrailleDisplay().setVisibleScreen(name);
            }
            // ITreeStrategy<OSMElement.OSMElement> subtreeFiltered = strategyMgr.getSpecifiedTreeOperations().getSubtreeOfScreen(visibleScreen);
            //Screenshots aktualisieren beim Screen-Wechsel
            Object            subnodesOfScreen = treeOperation.searchNodes.getSubtreeOfScreen(name);
            GeneralProperties prop             = new GeneralProperties();

            prop.controlTypeFiltered = "Screenshot";
            List <Object> screenshotNodes = treeOperation.searchNodes.getNodesByProperties(subnodesOfScreen, prop);

            foreach (Object node in screenshotNodes)
            {
                OSMElements.OSMElement osmScreenshot = strategyMgr.getSpecifiedTree().GetData(node);
                strategyMgr.getSpecifiedBrailleDisplay().updateViewContent(ref osmScreenshot);
                strategyMgr.getSpecifiedTree().SetData(node, osmScreenshot);
                grantTrees.brailleTree = strategyMgr.getSpecifiedTree().Root(node);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// filters the siblings of the AutomationElement
        /// </summary>
        /// <param name="automationElement">the AutomationElementn</param>
        /// <param name="tree">the tree object</param>
        private void filterSibling(AutomationElement automationElement, ref Object tree)
        {
            //TreeWalker walker = TreeWalker.ControlViewWalker;
            TreeWalker        walker        = TreeWalker.ContentViewWalker;
            AutomationElement elementParent = walker.GetParent(automationElement);
            int depth = 0;
            //      filterChildren(elementParent, 0, ref tree); // depth is null  ==> all siblings will be "top nodes" (see https://www.codeproject.com/Articles/12476/A-Generic-Tree-Collection )
            //oder             walker.GetPreviousSibling(mainElement);             walker.GetNextSibling(mainElement);

            AutomationElementCollection collection = elementParent.FindAll(TreeScope.Children, Condition.TrueCondition);

            //findChildrenOfNode(tree, collection, depth);

            foreach (AutomationElement element in collection)
            {
                if (!element.Equals(automationElement) && (strategyMgr.getSpecifiedTree().Depth(tree) < depth || depth <= -1))
                {
                    OSMElements.OSMElement osmElement = new OSMElements.OSMElement();
                    osmElement.properties = setProperties(element);
                    Object node = strategyMgr.getSpecifiedTree().AddChild(tree, osmElement);

                    AutomationElementCollection c = element.FindAll(TreeScope.Children, Condition.TrueCondition);
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Setzt die Beziehung von dem "realen" GUI Element zu dem UI-Element auf der Stiftplatte umd die Darstellung eines Screenshots zu testen
        /// falls noch kein Baum gefiltert wurde, so wird die Anwendung gefiltert
        /// </summary>
        public void setOSMRelationshipImg()
        {
            if (strategyMgr.getSpecifiedOperationSystem().deliverCursorPosition())
            {
                try
                {
                    IFilterStrategy filterStrategy = strategyMgr.getSpecifiedFilter();

                    if (grantTree.filteredTree == null)
                    {
                        filterTreeOfApplication();
                    }
                    if (strategyMgr.getSpecifiedOperationSystem().deliverCursorPosition())
                    {
                        int pointX;
                        int pointY;

                        strategyMgr.getSpecifiedOperationSystem().getCursorPoint(out pointX, out pointY);
                        OSMElements.OSMElement osmElement          = filterStrategy.getOSMElement(pointX, pointY);
                        GeneralProperties      propertiesForSearch = new GeneralProperties();
                        propertiesForSearch.controlTypeFiltered = "Screenshot";
                        List <Object> treeElement = treeOperation.searchNodes.getNodesByProperties(grantTree.brailleTree, propertiesForSearch, OperatorEnum.and);
                        if (treeElement.Count > 0)
                        {
                            treeOperation.osmTreeConnector.addOsmConnection(osmElement.properties.IdGenerated, strategyMgr.getSpecifiedTree().GetData(treeElement[0]).properties.IdGenerated);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("An error occurred: '{0}'", ex);
                }
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// filters a subtree
        /// </summary>
        /// <param name="element">the AutomationElement of the filtered element</param>
        /// <param name="tree">the tree object</param>
        private void filterSubtree(AutomationElement element, ref Object tree)
        {
            OSMElements.OSMElement osmElement = new OSMElements.OSMElement();
            osmElement.properties = setProperties(element);

            Object treeTop = strategyMgr.getSpecifiedTree().AddChild(tree, osmElement);

            filterChildren(element, -1, ref treeTop);
            tree = strategyMgr.getSpecifiedTree().Root(treeTop);
        }
Exemplo n.º 15
0
        /// <summary>
        /// filters an application depending on a given OSM element
        /// </summary>
        /// <param name="osmElementOfFirstNodeOfSubtree">osm element of the to filtered application</param>
        /// <param name="treeScope">kind of filtering</param>
        /// <returns>the filtered (sub-)tree</returns>
        public Object filtering(OSMElements.OSMElement osmElementOfFirstNodeOfSubtree, TreeScopeEnum treeScope)
        {
            AutomationElement au = getAutomationelementOfOsmElement(osmElementOfFirstNodeOfSubtree);

            if (au != null)
            {
                return(filtering(au, treeScope, -1));
            }
            return(null);
        }
Exemplo n.º 16
0
        /// <summary>
        /// searches a filtered node ID (in <c>grantTrees.filteredTree</c> ) by a given HWND
        /// </summary>
        /// <param name="hwnd">a hwnd of a node</param>
        /// <returns>the node ID OR <c>null</c></returns>
        public String getIdFilteredNodeByHwnd(IntPtr hwnd)
        {
            Object node = getFilteredNodeByHwnd(hwnd);

            if (node == null)
            {
                return(null);
            }
            OSMElements.OSMElement osmData = strategyMgr.getSpecifiedTree().GetData(node);
            return(osmData.properties.IdGenerated);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Generates ids for the whole filtered tree.
 /// </summary>
 /// <param name="parentNode">reference to the filtered tree object</param>
 public void generatedIdsOfFilteredTree(ref Object tree)
 {
     foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(tree))
     {
         if (strategyMgr.getSpecifiedTree().GetData(node).properties.IdGenerated == null)
         {
             OSMElements.OSMElement osm = strategyMgr.getSpecifiedTree().GetData(node);
             osm.properties.IdGenerated = generatedIdFilteredNode(node);
             strategyMgr.getSpecifiedTree().SetData(node, osm);
         }
     }
 }
Exemplo n.º 18
0
        /// <summary>
        /// Seeks new data for a node
        /// </summary>
        /// <param name="osmElementFilteredNode">OSM element to update</param>
        /// <returns>new properties for a node</returns>
        public GeneralProperties updateNodeContent(OSMElements.OSMElement osmElementFilteredNode)
        {
            GeneralProperties propertiesUpdated = new GeneralProperties();
            AutomationElement au = getAutomationelementOfOsmElement(osmElementFilteredNode);

            if (au != null)
            {
                propertiesUpdated             = setProperties(au);
                propertiesUpdated.IdGenerated = osmElementFilteredNode.properties.IdGenerated;
            }
            return(propertiesUpdated);
        }
Exemplo n.º 19
0
        /// <summary>
        /// filters an application deppending on a given AutomationElement (to the specified depth)
        /// </summary>
        /// <param name="element">the AutomationElement of the filtered element</param>
        /// <param name="depth">depth of filtering for the <paramref name="treeScope"/> of 'Parent', 'Children' and 'Application';  <code>-1</code> means the whole depth</param>
        /// <param name="tree">the tree object</param>
        private void filterApplication(AutomationElement element, int depth, ref Object tree)
        {
            IntPtr            mainAppHwdn = strategyMgr.getSpecifiedOperationSystem().getProcessHwndFromHwnd(element.Current.ProcessId);
            AutomationElement mainAppAutomationelement = deliverAutomationElementFromHWND(mainAppHwdn);

            OSMElements.OSMElement osmElement = new OSMElements.OSMElement();
            osmElement.properties = setProperties(mainAppAutomationelement);

            Object top = strategyMgr.getSpecifiedTree().AddChild(tree, osmElement);

            filterChildren(mainAppAutomationelement, -1, ref top);
        }
Exemplo n.º 20
0
        /// <summary>
        /// depending on the given properties, all nodes with these properties are searched (depth-first search).
        /// Properties which are null or the default value is set are ignore
        /// </summary>
        /// <param name="tree">tree object for search </param>
        /// <param name="properties">properties for the search</param>
        /// <param name="oper">Operator for combining the properties (and, or) </param>
        /// <returns>A list of the found tree objects</returns>
        public List <Object> getNodesByProperties(Object tree, OSMElements.OSMElement properties, OperatorEnum oper = OperatorEnum.and)
        {
            List <Object> result = new List <Object>();

            if (tree == null)
            {
                return(result);
            }
            List <String> listOfUsedProperties = OSMElements.OSMElement.getAllTypes();

            listOfUsedProperties = trimListOfProperties(listOfUsedProperties, properties);
            foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(tree))
            {
                OSMElements.OSMElement nodeData = strategyMgr.getSpecifiedTree().GetData(node);
                Boolean isToAdd = true;
                foreach (String s in listOfUsedProperties)
                {
                    Boolean resultEquals = false;
                    var     data_1       = OSMElements.OSMElement.getElement(s, nodeData);
                    var     data_2       = OSMElements.OSMElement.getElement(s, properties);
                    if ((data_1 != null && data_1.Equals(data_2)) || (data_1 == null && data_2 == null))
                    {
                        resultEquals = true;
                    }
                    else
                    {
                        resultEquals = false;
                    }

                    if (OperatorEnum.Equals(oper, OperatorEnum.and))
                    {
                        isToAdd = isToAdd && resultEquals;
                        if (!isToAdd)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (OperatorEnum.Equals(oper, OperatorEnum.or))
                        {
                            isToAdd = isToAdd || resultEquals;
                        }
                    }
                }
                if (isToAdd)
                {
                    result.Add(node);
                }
            }
            return(result);
        }
Exemplo n.º 21
0
        private OSMElements.OSMElement createChildBrailleNode(Object filteredSubtree, TemplateUiObject templateObject, String viewName)
        {
            //TODO: falls eine Beziehung im Baum erstellt werden soll muss diese hier? noch gesetzt werden => geht nicht ID ist noch nicht vorhanden
            OSMElements.OSMElement brailleNode = templateObject.osm;
            GeneralProperties      prop        = templateObject.osm.properties;
            BrailleRepresentation  braille     = templateObject.osm.brailleRepresentation;

            prop.isEnabledFiltered = false;
            braille.isVisible      = true;
            if (templateObject.osm.properties.controlTypeFiltered.Equals("DropDownMenuItem"))
            {
                OSMElements.UiElements.DropDownMenuItem dropDownMenu = new OSMElements.UiElements.DropDownMenuItem();
                if (strategyMgr.getSpecifiedTree().HasChild(filteredSubtree) && strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(filteredSubtree)).properties.controlTypeFiltered.Contains("Item"))
                {
                    dropDownMenu.hasChild = true;
                }
                if (strategyMgr.getSpecifiedTree().HasNext(filteredSubtree) && strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Next(filteredSubtree)).properties.controlTypeFiltered.Contains("Item"))
                {
                    dropDownMenu.hasNext = true;
                }
                if (strategyMgr.getSpecifiedTree().HasPrevious(filteredSubtree) && strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Previous(filteredSubtree)).properties.controlTypeFiltered.Contains("Item"))
                {
                    dropDownMenu.hasPrevious = true;
                }
                if (strategyMgr.getSpecifiedTree().HasParent(filteredSubtree) && strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Parent(filteredSubtree)).properties.controlTypeFiltered.Contains("Item"))
                {
                    dropDownMenu.isChild = true;
                }
                dropDownMenu.isOpen             = false;
                dropDownMenu.isVertical         = false;
                braille.uiElementSpecialContent = dropDownMenu;
            }
            if (templateObject.osm.properties.controlTypeFiltered.Equals("TabItem"))
            {
                OSMElements.UiElements.TabItem tabView = new OSMElements.UiElements.TabItem();
                //tabView.orientation = templateObject.orientation;
                //braille.uiElementSpecialContent = tabView;
                braille.uiElementSpecialContent = templateObject.osm.brailleRepresentation.uiElementSpecialContent;
            }
            if (templateObject.Screens == null)
            {
                Debug.WriteLine("Achtung, hier wurde kein Screen angegeben!"); return(new OSMElements.OSMElement());
            }
            braille.screenName                = templateObject.Screens[0]; // hier wird immer nur ein Screen-Name übergeben
            braille.viewName                  = viewName;
            brailleNode.properties            = prop;
            brailleNode.brailleRepresentation = braille;
            prop.IdGenerated                  = treeOperation.generatedIds.generatedIdBrailleNode(brailleNode);
            brailleNode.properties            = prop;

            return(brailleNode);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Determinates the screen name to a given screen id
 /// </summary>
 /// <param name="screenId">the id of the screen</param>
 /// <returns>Returns the screen name OR <c>null</c></returns>
 public String getScreenIdToScreenName(String screenId)
 {
     if (screenId == null)
     {
         return(null);
     }
     OSMElements.OSMElement osm = getBrailleTreeOsmElementById(screenId);
     if (osm == null || osm.Equals(new OSMElements.OSMElement()) || osm.brailleRepresentation == null)
     {
         return(null);
     }
     return(osm.brailleRepresentation.screenName);
 }
Exemplo n.º 23
0
        public void getBrailleNodeAtPointTest()
        {
            initilaizeBrailleTree2Nodes();
            strategyMgr.getSpecifiedBrailleDisplay().setActiveAdapter();
            strategyMgr.getSpecifiedBrailleDisplay().generatedBrailleUi();
            strategyMgr.getSpecifiedBrailleDisplay().setVisibleScreen("TestScreen");
            Object nodeAtPoint = guiFuctions.getBrailleNodeAtPoint(5, 35);

            Assert.AreNotEqual(null, nodeAtPoint, "Es hätte ein Knoten gefunden werden sollen!");
            OSMElements.OSMElement data = strategyMgr.getSpecifiedTree().GetData(nodeAtPoint);
            Assert.AreEqual("TestView - 2", data.brailleRepresentation.viewName, "An der Position (5,35) hätte die 'TestView - 2' sein sollen!");
            strategyMgr.getSpecifiedBrailleDisplay().removeActiveAdapter();
            guiFuctions.deleteGrantTrees();
        }
Exemplo n.º 24
0
 /// <summary>
 /// Sets some "special" properties for the first node
 /// </summary>
 /// <param name="tree">the tree object</param>
 private void setSpecialPropertiesOfFirstNode(ref Object tree)
 {
     if (strategyMgr.getSpecifiedTree().HasChild(tree))
     {
         //  Settings settings = new Settings();
         OSMElements.OSMElement osm = new OSMElements.OSMElement();
         osm.brailleRepresentation = strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(tree)).brailleRepresentation;
         osm.properties            = strategyMgr.getSpecifiedTree().GetData(strategyMgr.getSpecifiedTree().Child(tree)).properties;
         //   osm.properties.grantFilterStrategy = settings.filterStrategyTypeToUserName(this.GetType());
         osm.properties.processName = strategyMgr.getSpecifiedOperationSystem().getProcessNameOfApplication(osm.properties.processIdFiltered);
         osm.properties.appPath     = strategyMgr.getSpecifiedOperationSystem().getFileNameOfApplicationByMainWindowTitle(osm.properties.processIdFiltered);
         strategyMgr.getSpecifiedTree().SetData(strategyMgr.getSpecifiedTree().Child(tree), osm);
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// depending on the given properties, all nodes with these properties are searched (depth-first search).
        /// Only properties that have been specified are taken into account.
        /// </summary>
        /// <param name="tree">tree object for search </param>
        /// <param name="generalProperties">properties for the search</param>
        /// <param name="oper">Operator for combining the properties (and, or) </param>
        /// <returns>A list of the found tree objects</returns>
        public List <Object> getNodesByProperties(Object tree, OSMElements.GeneralProperties generalProperties, OperatorEnum oper = OperatorEnum.and)
        {//TODO: many properties are still missing
            List <Object> result = new List <Object>();

            if (tree == null)
            {
                return(result);
            }
            foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(tree))
            {
                OSMElements.OSMElement nodeData       = strategyMgr.getSpecifiedTree().GetData(node);
                Boolean propertieLocalizedControlType = generalProperties.localizedControlTypeFiltered == null || nodeData.properties.localizedControlTypeFiltered.Equals(generalProperties.localizedControlTypeFiltered);
                Boolean propertieName              = generalProperties.nameFiltered == null || nodeData.properties.nameFiltered.Equals(generalProperties.nameFiltered);
                Boolean propertieIsEnabled         = generalProperties.isEnabledFiltered == null || nodeData.properties.isEnabledFiltered == generalProperties.isEnabledFiltered;
                Boolean propertieBoundingRectangle = generalProperties.boundingRectangleFiltered == new System.Windows.Rect() || nodeData.properties.boundingRectangleFiltered.Equals(generalProperties.boundingRectangleFiltered);
                Boolean propertieIdGenerated       = generalProperties.IdGenerated == null || generalProperties.IdGenerated.Equals(nodeData.properties.IdGenerated);
                Boolean propertieAccessKey         = generalProperties.accessKeyFiltered == null || generalProperties.accessKeyFiltered.Equals(nodeData.properties.accessKeyFiltered);
                Boolean acceleratorKey             = generalProperties.acceleratorKeyFiltered == null || generalProperties.acceleratorKeyFiltered.Equals(nodeData.properties.acceleratorKeyFiltered);
                Boolean runtimeId    = generalProperties.runtimeIDFiltered == null || Enumerable.SequenceEqual(generalProperties.runtimeIDFiltered, nodeData.properties.runtimeIDFiltered);
                Boolean automationId = generalProperties.autoamtionIdFiltered == null || generalProperties.autoamtionIdFiltered.Equals(nodeData.properties.autoamtionIdFiltered); //ist zumindest bei Skype für ein UI-Element nicht immer gleich
                Boolean controlType  = generalProperties.controlTypeFiltered == null || generalProperties.controlTypeFiltered.Equals(nodeData.properties.controlTypeFiltered);
                if (OperatorEnum.Equals(oper, OperatorEnum.and))
                {
                    if (propertieBoundingRectangle && propertieLocalizedControlType && propertieIdGenerated && propertieAccessKey && acceleratorKey &&
                        runtimeId && controlType && propertieName && propertieIsEnabled)
                    {
                        result.Add(node);
                    }
                }
                if (OperatorEnum.Equals(oper, OperatorEnum.or))
                {//TODO: add properties
                    if ((generalProperties.localizedControlTypeFiltered != null && propertieLocalizedControlType) ||
                        (generalProperties.nameFiltered != null && propertieName) ||
                        (generalProperties.isEnabledFiltered != null && propertieIsEnabled) ||
                        (generalProperties.boundingRectangleFiltered != new System.Windows.Rect() && propertieBoundingRectangle) ||
                        (generalProperties.IdGenerated != null && propertieIdGenerated) ||
                        (generalProperties.accessKeyFiltered != null && propertieAccessKey) ||
                        (generalProperties.acceleratorKeyFiltered != null && acceleratorKey) ||
                        (generalProperties.runtimeIDFiltered != null && runtimeId) ||
                        (generalProperties.controlTypeFiltered != null && controlType)
                        )
                    {
                        result.Add(node);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 26
0
        private OSMElements.OSMElement createParentBrailleNode(Object filteredSubtree, TemplateUiObject templateObject)
        {
            OSMElements.OSMElement brailleNode = new OSMElements.OSMElement();
            brailleNode.brailleRepresentation = templateObject.osm.brailleRepresentation;
            brailleNode.properties            = templateObject.osm.properties;

            brailleNode.properties.isEnabledFiltered        = false;
            brailleNode.properties.controlTypeFiltered      = "GroupElement";
            brailleNode.properties.isContentElementFiltered = false; //-> es ist Elternteil einer Gruppe
            brailleNode.brailleRepresentation.isVisible     = true;
            if (templateObject.Screens == null)
            {
                Debug.WriteLine("Achtung, hier wurde kein Screen angegeben!"); return(new OSMElements.OSMElement());
            }
            brailleNode.brailleRepresentation.screenName       = templateObject.Screens[0]; // hier wird immer nur ein Screen-Name übergeben
            brailleNode.brailleRepresentation.viewName         = "_" + templateObject.viewName + "_groupElementsStatic_Count_" + templateObject.groupElements.Count();
            brailleNode.brailleRepresentation.templateFullName = templateObject.groupImplementedClassTypeFullName;
            brailleNode.brailleRepresentation.templateNamspace = templateObject.groupImplementedClassTypeDllName;

            if (templateObject.osm.brailleRepresentation.boarder != null)
            {
                brailleNode.brailleRepresentation.boarder = templateObject.osm.brailleRepresentation.boarder;
            }
            if (templateObject.osm.brailleRepresentation.padding != null)
            {
                brailleNode.brailleRepresentation.padding = templateObject.osm.brailleRepresentation.padding;
            }
            if (templateObject.osm.brailleRepresentation.margin != null)
            {
                brailleNode.brailleRepresentation.margin = templateObject.osm.brailleRepresentation.margin;
            }

            String idGenerated = treeOperation.updateNodes.addNodeInBrailleTree(brailleNode);

            if (idGenerated == null)
            {
                Debug.WriteLine("Es konnte keine Id erstellt werden."); return(new OSMElements.OSMElement());
            }
            brailleNode.properties.IdGenerated = idGenerated;

            if (filteredSubtree != null && strategyMgr.getSpecifiedTree().GetData(filteredSubtree) != null)
            {
                treeOperation.osmTreeConnector.addOsmConnection(strategyMgr.getSpecifiedTree().GetData(filteredSubtree).properties.IdGenerated, idGenerated);
            }
            treeOperation.updateNodes.updateNodeOfBrailleUi(ref brailleNode);

            return(brailleNode);
        }
Exemplo n.º 27
0
 /// <summary>
 /// searches a filtered node (in <c>grantTrees.filteredTree</c> ) by a given HWND
 /// </summary>
 /// <param name="hwnd">a hwnd of a node</param>
 /// <returns>the node object OR <c>null</c></returns>
 public Object getFilteredNodeByHwnd(IntPtr hwnd)
 {
     if (IntPtr.Zero.Equals(hwnd) || grantTrees.filteredTree == null)
     {
         return(null);
     }
     foreach (Object node in strategyMgr.getSpecifiedTree().AllNodes(grantTrees.filteredTree))
     {
         OSMElements.OSMElement osmData = strategyMgr.getSpecifiedTree().GetData(node);
         if (hwnd.Equals(osmData.properties.hWndFiltered))
         {
             return(node);
         }
     }
     return(null);
 }
Exemplo n.º 28
0
 internal bool existViewInTree(Object subtree, String viewName)
 {
     if (viewName == null || viewName.Equals(""))
     {
         return(false);
     }
     foreach (Object o in strategyMgr.getSpecifiedTree().AllChildrenNodes(subtree))
     {
         OSMElements.OSMElement data = strategyMgr.getSpecifiedTree().GetData(o);
         if (viewName.Equals(data.brailleRepresentation.viewName))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 29
0
        public void getBrailleNodeInGroupAtPointTest()
        {
            initilaizeFilteredTree();
            strategyMgr.getSpecifiedGeneralTemplateUi().generatedUiFromTemplate(pathToTemplate);
            strategyMgr.getSpecifiedBrailleDisplay().setActiveAdapter();
            strategyMgr.getSpecifiedBrailleDisplay().generatedBrailleUi();
            // auf dem Screen 'a1' befindet sich der gesuchte Knoten
            strategyMgr.getSpecifiedBrailleDisplay().setVisibleScreen("a1");
            Object nodeAtPoint = guiFuctions.getBrailleNodeAtPoint(25, 25);

            Assert.AreNotEqual(null, nodeAtPoint, "Es hätte ein Knoten gefunden werden sollen!");
            OSMElements.OSMElement data = strategyMgr.getSpecifiedTree().GetData(nodeAtPoint);
            Assert.AreEqual("0", data.properties.valueFiltered, "An der Position (25,25) hätte der Button mit der Ziffer '0' sein sollen. Somit hätte der Value auch '0' sein sollen!");
            strategyMgr.getSpecifiedBrailleDisplay().removeActiveAdapter();
            guiFuctions.deleteGrantTrees();
        }
Exemplo n.º 30
0
        private OSMElements.OSMElement addSeparatorElementInBrailleTree(String separator, ref int startX, int startY)
        {
            OSMElements.OSMElement osmBraille = new OSMElements.OSMElement();

            osmBraille.brailleRepresentation.isVisible      = true;
            osmBraille.properties.controlTypeFiltered       = "Text";
            osmBraille.brailleRepresentation.isGroupChild   = true;
            osmBraille.brailleRepresentation.typeOfView     = grantTrees.TextviewObject.typeOfView;
            osmBraille.brailleRepresentation.screenName     = grantTrees.TextviewObject.screenName;
            osmBraille.brailleRepresentation.viewName       = "separator";
            osmBraille.properties.valueFiltered             = separator;
            osmBraille.properties.boundingRectangleFiltered = new Rect(startX, startY, separator.Length * 3, 5);//TODO: richtig machen

            osmBraille.properties.IdGenerated = treeOperation.generatedIds.generatedIdBrailleNode(osmBraille);
            return(osmBraille);
        }