Beispiel #1
0
        /// <summary>
        /// Returns an <c>OSMElement</c> with the last received content from NVDA
        /// </summary>
        /// <returns></returns>
        public OSMElement getScreenreaderContent()
        {
            //throw new NotImplementedException();

            /*
             * TCP/IP connection to MVBD is necessary
             *
             *
             */
            if (!strategyMgr.getSpecifiedOperationSystem().isApplicationRunning("NVDA"))
            {
                return(null);
            }
            // Das hier ist erstmal nur zum Testen
            Settings        settings             = new Settings();
            List <Strategy> externalSRStrategies = settings.getPossibleExternalScreenreaders();

            if (externalSRStrategies.Exists(p => p.className.Equals(this.GetType().FullName + ", " + this.GetType().Namespace)))
            {
                OSMElement osm = new OSMElement();
                osm.properties.valueFiltered       = lastContent;
                osm.properties.controlTypeFiltered = "external screenreader";
                osm.properties.grantFilterStrategy = externalSRStrategies.Find(p => p.className.Equals(this.GetType().FullName + ", " + this.GetType().Namespace)).userName;

                osm.properties.IdGenerated = generatedIdforOsmNode();
                return(osm);
            }
            return(null);
        }
Beispiel #2
0
        public void TestGetPinsAsStringInFilteredTree()
        {
            guiFuctions.loadGrantProject(treePath);
            Assert.AreNotEqual(grantTrees, null);
            Assert.AreNotEqual(grantTrees.filteredTree, null);
            Assert.AreNotEqual(grantTrees.brailleTree, null);

            System.Windows.Forms.SendKeys.SendWait("{ESC}"); // set focus back to Visual Studio
            System.Threading.Thread.Sleep(2000);             // Wait of connection to MVBD & first conntent sets
            if (!strategyMgr.getSpecifiedOperationSystem().isApplicationRunning("MVBD"))
            {
                Assert.Fail("MVBD isn't running!");
            }
            if (!strategyMgr.getSpecifiedOperationSystem().isApplicationRunning("NVDA"))
            {
                Assert.Fail("NVDA isn't running!");
            }
            System.Threading.Thread.Sleep(2000);
            OSMElement content = strategyMgr.getSpecifiedExternalScreenreader().getScreenreaderContent();

            Assert.AreNotEqual(null, content);
            Debug.WriteLine(content);
            int treeNodeOld = strategyMgr.getSpecifiedTree().Count(grantTrees.filteredTree);

            // add node to filtered tree
            treeOperation.updateNodes.addNodeExternalScreenreaderInFilteredTree(content);
            Assert.AreEqual(treeNodeOld + 1, strategyMgr.getSpecifiedTree().Count(grantTrees.filteredTree));
            Debug.WriteLine("Tree with external screenreader node:\n" + strategyMgr.getSpecifiedTree().ToStringRecursive(grantTrees.filteredTree));
        }
Beispiel #3
0
        /// <summary>
        /// Ermittelt aus einem <c>OSMElement.OSMElement</c> die zugehörige Position
        /// </summary>
        /// <param name="osmElement">gibt das <c>OSMElement an</c></param>
        /// <returns><c>Rectangle</c> mit der Position des Objektes</returns>
        public Rectangle getRect(OSMElement osmElement)
        {
            int x      = (int)osmElement.properties.boundingRectangleFiltered.TopLeft.X;
            int y      = (int)osmElement.properties.boundingRectangleFiltered.TopLeft.Y;
            int x2     = (int)osmElement.properties.boundingRectangleFiltered.TopRight.X;
            int y2     = (int)osmElement.properties.boundingRectangleFiltered.BottomLeft.Y;
            int height = y2 - y;
            int width  = x2 - x;

            // Create rectangle.
            return(new Rectangle(x, y, width, height));
        }
Beispiel #4
0
        private void ParseTagsData(
            byte[] data,
            OSMElement element,
            ref int bufferOffset
#if DEBUG
            , ElementDebugInfos debugInfos
#endif
            )
        {
            var unreadBytes = data.Length - bufferOffset;

            while (unreadBytes > 0)
            {
                if (data[bufferOffset] != 0)
                {
#if DEBUG
                    var keyValuePosition = (uint)bufferOffset + 1;
#endif
                    var storedPosition = VarInt.ParseUInt32(data, ref bufferOffset);
#if DEBUG
                    debugInfos.Add(keyValuePosition, "start of stored 'key/value'-pair (" + storedPosition + ").");
#endif
                    var tag = this._storedStringPairs[(int)storedPosition - 1];
                    element.Tags.Add(Encoding.UTF8.GetString(tag.Key), Encoding.UTF8.GetString(tag.Value));
                }
                else
                {
#if DEBUG
                    var keyValuePosition = (uint)bufferOffset + 1;
#endif
                    var tag = StringPair.ParseToByteArrayPair(data, ref bufferOffset);
#if DEBUG
                    debugInfos.Add(keyValuePosition, "start of raw 'key/value'-pair.");
#endif
                    if (tag.HasValue)
                    {
                        var tagValue = tag.Value;
                        element.Tags.Add(Encoding.UTF8.GetString(tagValue.Key), Encoding.UTF8.GetString(tagValue.Value));
                        if (tagValue.Key.Length + tagValue.Value.Length <= 250)
                        {
                            this._storedStringPairs.Insert(0, tagValue);
                        }
                    }
                }
                unreadBytes = data.Length - bufferOffset;
            }
        }
Beispiel #5
0
        public void TestGetPinsAsString()
        {
            System.Windows.Forms.SendKeys.SendWait("{ESC}"); // set focus back to Visual Studio
            System.Threading.Thread.Sleep(2000);             // Wait of connection to MVBD & first conntent sets
            if (!strategyMgr.getSpecifiedOperationSystem().isApplicationRunning("MVBD"))
            {
                Assert.Fail("MVBD isn't running!");
            }
            if (!strategyMgr.getSpecifiedOperationSystem().isApplicationRunning("NVDA"))
            {
                Assert.Fail("NVDA isn't running!");
            }
            System.Threading.Thread.Sleep(2000);
            OSMElement content = strategyMgr.getSpecifiedExternalScreenreader().getScreenreaderContent();

            Assert.AreNotEqual(null, content);
            Debug.WriteLine("Braillezeile NVDA: " + content);
        }
Beispiel #6
0
        private void ParseVersionData(
            byte[] data,
            OSMElement element,
            ref int bufferOffset
#if DEBUG
            , ElementDebugInfos debugInfos
#endif
            )
        {
#if DEBUG
            var versionPosition = (uint)bufferOffset + 1;
#endif
            element.Version = VarInt.ParseUInt64(data, ref bufferOffset);
#if DEBUG
            debugInfos.Add(versionPosition, "start of 'version' (" + element.Version + ").");
#endif
            if (element.Version == 0)
            {
                return;
            }

#if DEBUG
            var timestampOffset = (uint)bufferOffset + 1;
#endif
            var timestampDiff = VarInt.ParseInt64(data, ref bufferOffset);
#if DEBUG
            debugInfos.Add(timestampOffset, "start of 'timestamp' (diff: " + timestampDiff + ").");
#endif
            var unixTimestamp = timestampDiff + this._lastTimestamp;
            this._lastTimestamp = unixTimestamp;
            element.Timestamp   = UNIX_START.AddSeconds(unixTimestamp);
            if (unixTimestamp == 0)
            {
                return;
            }

#if DEBUG
            var changesetPosition = (uint)bufferOffset + 1;
#endif
            element.Changeset = (ulong)(VarInt.ParseInt64(data, ref bufferOffset) + this._lastChangeset);
#if DEBUG
            debugInfos.Add(changesetPosition, "start of 'changeset' (" + element.Changeset + ").");
#endif
            this._lastChangeset = (long)element.Changeset;

            KeyValuePair <byte[], byte[]>?keyValuePair;
            if (data[bufferOffset] == 0)
            {
#if DEBUG
                debugInfos.Add((uint)bufferOffset + 1, "start of 'uid/user'-pair (raw).");
#endif
                keyValuePair = StringPair.ParseToByteArrayPair(data, ref bufferOffset);
                if (keyValuePair.HasValue)
                {
                    var keyValuePairValue = keyValuePair.Value;
                    element.UserId   = VarInt.ParseUInt64(keyValuePairValue.Key);
                    element.UserName = Encoding.UTF8.GetString(keyValuePairValue.Value);
                    if (element.UserId != 0)
                    {
                        if (keyValuePairValue.Key.Length + keyValuePairValue.Value.Length <= 250)
                        {
                            this._storedStringPairs.Insert(0, keyValuePairValue);
                        }
                    }
                }
                else
                {
                    this._storedStringPairs.Insert(0, new KeyValuePair <byte[], byte[]>(new byte[0], new byte[0]));
                }
            }
            else
            {
#if DEBUG
                debugInfos.Add((uint)bufferOffset + 1, "start of 'uid/user'-pair (stored).");
#endif
                var storedPosition = VarInt.ParseUInt32(data, ref bufferOffset);
                if (this._storedStringPairs.ElementExistsAtPosition((int)storedPosition))
                {
                    keyValuePair     = this._storedStringPairs[(int)storedPosition - 1];
                    element.UserId   = VarInt.ParseUInt64(keyValuePair?.Key);
                    element.UserName = Encoding.UTF8.GetString(keyValuePair?.Value);
                }
            }
        }