コード例 #1
0
ファイル: Glimpse.cs プロジェクト: sillsdev/WorldPad
        // When used in a do-once instruction, this call is repeated.
        // Note the code that keeps m_select from being appended to m_path more than once.
        public override void Execute()
        {
            base.Execute();
            PassFailInContext(m_onPass, m_onFail, out m_onPass, out m_onFail);
            Context con = (Context)Ancestor(typeof(Context));

            isNotNull(con, "Glimpse must occur in some context");
            AccessibilityHelper ah = con.Accessibility;

            isNotNull(ah, "Glimpse context not accessible");
            m_path   = Utilities.evalExpr(m_path);
            m_expect = Utilities.evalExpr(m_expect);

            /// Use the path or GUI Model or both
            if (m_select != null && m_select != "" && !m_doneOnce)
            {
                m_path     = SelectToPath(con, m_select) + m_path;             // process m_select
                m_doneOnce = true;
            }

            if (m_path != null && m_path != "")
            {
                GuiPath gpath = new GuiPath(m_path);
                isNotNull(gpath, "attribute path='" + m_path + "' not parsed");
                GlimpsePath(ah, gpath, m_expect);
            }
            else
            {
                fail("attribute 'path' or 'select' must be set.");
            }
            Logger.getOnly().result(this);
        }
コード例 #2
0
ファイル: Click.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// Execute a click, creating and executing more for @select and
        /// creating and executing child instructions.
        /// When used in a do-once instruction, this call is repeated.
        /// </summary>
        public override void Execute()
        {
            // Increase the wait time if the rest time is greater
            // This gives the script writer some control over how
            // long to try the click.
            base.Execute();
            Context con = (Context)Ancestor(typeof(Context));

            isNotNull(con, makeNameTag() + " must occur in some context");
            AccessibilityHelper ah = con.Accessibility;

            isNotNull(ah, makeNameTag() + " context is not accessible");
            m_path = Utilities.evalExpr(m_path);

            /// Use the path or GUI Model or both
            if (m_select != null && m_select != "" && !m_doneOnce)
            {
                m_path     = SelectToPath(con, m_select) + m_path;             // process m_select
                m_doneOnce = true;
            }

            if (m_path != null && m_path != "")
            {
                GuiPath gpath = new GuiPath(m_path);
                isNotNull(gpath, makeNameTag() + " path='" + m_path + "' not parsed");
                ClickPathUntilFound(ah, gpath);
            }
            else
            {
                fail(makeNameTag() + "attribute 'path' or 'select' must be set or evaluate properly.");
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a view with the given tag and class name.
        /// </summary>
        /// <param name="themedContext">The context.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="className">The class name.</param>
        /// <param name="initialProps">The initial props.</param>
        public void CreateView(ThemedReactContext themedContext, int tag, string className, JObject initialProps)
        {
            AssertOnCorrectDispatcher();
            using (Tracer.Trace(Tracer.TRACE_TAG_REACT_VIEW, "NativeViewHierarcyManager.CreateView")
                   .With("tag", tag)
                   .With("className", className)
                   .Start())
            {
                var viewManager = _viewManagers.Get(className);
                var view        = viewManager.CreateView(themedContext);
                _tagsToViews.Add(tag, view);
                _tagsToViewManagers.Add(tag, viewManager);

                ViewExtensions.SetTag(view, tag);
                ViewExtensions.SetReactContext(view, themedContext);

#if WINDOWS_UWP
                if (view is UIElement element)
                {
                    AccessibilityHelper.OnViewInstanceCreated(element);
                }
#endif

                if (initialProps != null)
                {
                    viewManager.UpdateProps(view, initialProps);
                }
            }
        }
コード例 #4
0
        public void SetImportantForAccessibility(BorderedCanvas view, string importantForAccessibilityValue)
        {
            var importantForAccessibility = EnumHelpers.ParseNullable <ImportantForAccessibility>(importantForAccessibilityValue)
                                            ?? ImportantForAccessibility.Auto;

            AccessibilityHelper.SetImportantForAccessibility(view, importantForAccessibility);
        }
コード例 #5
0
        public override void Init()
        {
            base.Init();

            Thread.Sleep(500);

            // Select "File/Import/Standard Format" to bring up the import dialog
            m_app.SendKeys("%F");
            m_app.SendKeys("{DOWN 8}");
            m_app.SendKeys("{ENTER}");
            m_app.SendKeys("{ENTER}");
            Application.DoEvents();

            AccessibilityHelper importDlg =
                m_app.MainAccessibilityHelper.Parent.FindDirectChild("Import Standard Format",
                                                                     AccessibleRole.None);

            // select the "Import" button which is the default button
            if (importDlg != null)
            {
                m_app.SendKeys("{ENTER}");
            }

            Application.DoEvents();

            m_dialog = m_app.MainAccessibilityHelper.Parent.FindDirectChild(
                "Import Standard Format", AccessibleRole.None);

            m_saveRegistryData = Unpacker.PrepareRegistryForPTData();
        }
コード例 #6
0
ファイル: Glimpse.cs プロジェクト: sillsdev/WorldPad
        /// <summary>
        /// Glimpse one gui-path and return the result. If the expected value is not found,
        /// an assertion is raised.
        /// </summary>
        /// <param name="ah">Context accessibility helper, taken as the starting place for gpath.</param>
        /// <param name="gpath">The path through the GUI to the control.</param>
        /// <param name="expect">The expected value of the property for the control.</param>
        /// <returns></returns>
        bool GlimpsePath(AccessibilityHelper ah, GuiPath gpath, string expect)
        {
            m_Result = true;
            m_got    = null;
            IPathVisitor visitor = null;

            ah       = gpath.FindInGui(ah, visitor);
            m_Result = GlimpseGUI(ah, expect);
            if (m_Result)
            {
                base.Finished = true;                       // teminates do-once
            }
            if ((m_onPass == "assert" && m_Result == true) ||
                (m_onFail == "assert" && m_Result == false))
            {
                if (m_message != null && m_message.HasContent())
                {
                    fail(m_message.Read());
                }
                else
                {
                    string image = "Property [" + m_prop + "] was [" + m_got + "] expecting [" + m_expect + "] Result = '" + m_Result + "', on-pass='******', on-fail='" + m_onFail + "'";
                    if (gpath != null)
                    {
                        fail(image + " on gPath = " + gpath.toString());
                    }
                    else
                    {
                        fail(image);
                    }
                }
            }
            return(m_Result);
        }
コード例 #7
0
        public override void Execute()
        {
            base.Execute();
            Context con = (Context)Ancestor(typeof(Context));

            m_log.isNotNull(con, makeNameTag() + "Hover-over must occur in some context");
            AccessibilityHelper ah = con.Accessibility;

            m_log.isNotNull(ah, makeNameTag() + "The hover-over context is not accessible");
            m_path = Utilities.evalExpr(m_path);

            // Use the path
            if (m_path != null && m_path != "")
            {
                GuiPath gpath = new GuiPath(m_path);
                m_log.isNotNull(gpath, makeNameTag() + "attribute path='" + m_path + "' not parsed");
                string BadPath = HoverPath(ah, gpath);
                if (BadPath != "")
                {
                    m_log.fail(BadPath);
                }
            }
            else
            {
                m_log.fail(makeNameTag() + "attribute 'path' must be set.");
            }
            Finished = true;             // tell do-once it's done
        }
コード例 #8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Check the controls on the step and see if there are non-excaptable controls on it,
        /// i.e. for the overview page return false if there are any check boxes.
        /// </summary>
        /// <param name="parent">The element to start with</param>
        /// <param name="acceptableRoles">Sorted array of acceptable controls</param>
        /// <returns><c>true</c> if all visible controls are acceptable, otherwise
        /// <c>false</c>.</returns>
        /// ------------------------------------------------------------------------------------
        protected bool CheckControls(AccessibilityHelper parent, AccessibleRole[] acceptableRoles)
        {
            bool fRet = true;

            foreach (AccessibilityHelper child in parent)
            {
                if ((child.States & AccessibleStates.Invisible) == AccessibleStates.Invisible)
                {
                    continue;
                }

                if (Array.BinarySearch(acceptableRoles, child.Role) < 0)
                {
                    return(false);
                }

                if (child.IsRealAccessibleObject)
                {
                    fRet = CheckControls(child, acceptableRoles);
                }

                if (!fRet)
                {
                    return(fRet);
                }
            }

            return(fRet);
        }
コード例 #9
0
ファイル: Context.cs プロジェクト: cambell-prince/FieldWorks
 public Context() : base()
 {
     m_ah     = null;
     m_onFail = null;
     m_onPass = null;
     m_tag    = "on-context";
 }
コード例 #10
0
        public void FindChild()
        {
            // Not enough accessibility to get to the menu reliably - too many NAMELESS

            /*AccessibilityHelper child = m_ah.FindChild("~MainMenu~", AccessibleRole.Window);
             * Assert.IsNotNull(child,"null child");
             * Assert.AreEqual("~MainMenu~", child.Name);
             * Assert.AreEqual(AccessibleRole.Window, child.Role);
             *
             * child = child.FindChild("mnuFormat", AccessibleRole.MenuItem);
             * Assert.IsNotNull(child,"null child");
             * Assert.AreEqual("mnuFormat", child.Name);
             * Assert.AreEqual(AccessibleRole.MenuItem, child.Role);*/

            AccessibilityHelper child = m_ah.FindChild(null, AccessibleRole.Client);

            Assert.IsNotNull(child, "null child");
            Assert.AreEqual("Kalaba (TestLangProj) - Translation Editor", child.Name);
            Assert.AreEqual(AccessibleRole.Client, child.Role);

            child = m_ah.FindChild("System", AccessibleRole.MenuBar);
            Assert.IsNotNull(child, "null child");
            Assert.AreEqual("System", child.Name);
            Assert.AreEqual(AccessibleRole.MenuBar, child.Role);

            child = m_ah.FindChild("NotExistantChild", AccessibleRole.None);
            Assert.IsNull(child, "non-null child");

            child = m_ah.FindChild(null, AccessibleRole.None);
            Assert.IsNull(child, "non-null child");
        }
コード例 #11
0
        public void DataFormatPage()
        {
            Assert.IsNotNull(m_dialog, "Didn't get an Import dialog");

            m_app.SendKeys("%N");
            Application.DoEvents();

            AccessibilityHelper step2 = m_dialog.FindChild("Step 2", AccessibleRole.None);

            Assert.IsNotNull(step2, "Can't find Step 2");

            // first test with Paratext "installed"
            int nRequiredRbs = 0;

            CheckRadioButtons(step2, ref nRequiredRbs);
            Assert.AreEqual(2, nRequiredRbs, "Unexpected number of radio buttons");

            // then without
            //TODO DavidO: Unsure of these changes; need to fix and reenable this test
            //PrepareParatextProjectTestData.RestoreRegistry();
            //PrepareParatextProjectTestData.TestFolder = null;
            //PrepareParatextProjectTestData.PrepareRegistryForTestData();
            m_saveRegistryData.RestoreRegistryData();
            //Unpacker.TEStyleFileTestFolder = null;
            m_saveRegistryData = Unpacker.PrepareRegistryForPTData();

            // go back to overview page and then go again to second step
            m_app.SendKeys("%B");
            m_app.SendKeys("%N");
            Application.DoEvents();

            nRequiredRbs = 0;
            CheckRadioButtons(step2, ref nRequiredRbs);
            Assert.AreEqual(2, nRequiredRbs, "Unexpected number of radio buttons");
        }
コード例 #12
0
        /// <summary>
        /// Click on an appPath via the gui model and/or a guiPath via
        /// Active Accessibility.
        /// If only the context is not null, it's value is used.
        /// If the context is null, the model root is used with appPath.
        /// The appPath is applied first, if any, then the guiPath.
        /// If there is no context or appPath, the guiPath is used.
        /// </summary>
        /// <param name="context">Model node to start appPath from or null</param>
        /// <param name="appPath">the appPath to a control or null</param>
        /// <param name="guiPath">the guiPath to click or null</param>
        /// <param name="leftClick">true if left-click, false on right-click</param>
        /// <returns>true if the path was valid and a click attempted</returns>
        private bool click(XmlNode context, string appPath, string guiPath, bool leftClick)
        {
            // if only a context, select it to click on.
            XmlPath xp = m_GuiModel.selectToXmlPath(context, appPath);

            if (xp == null || !xp.isValid())
            {
                return(false);
            }
            AccessibilityHelper ah = findInGui(xp, guiPath);

            if (ah == null)
            {
                return(false);
            }
            if (leftClick)
            {
                ah.SimulateClickRelative(10, 10);
            }
            else
            {
                ah.SimulateRightClickRelative(10, 10);
            }
            return(true);
        }
コード例 #13
0
        /// <summary>
        /// method to apply when a non-terminal node has been found
        /// </summary>
        /// <param name="ah"></param>
        public void visitNode(AccessibilityHelper ah)
        {         // does this ah need to be clicked or something to get to its children?
            if (1 == m_logLevel)
            {
                m_log.paragraph(makeNameTag() + "Click found &quot;" + ah.Role + ":" + ah.Name + "&quot;");
            }

            if ((ah.Role == AccessibleRole.MenuItem) || (m_for != null && "all" == (string)m_for))
            {
                if (1 == m_logLevel)
                {
                    m_log.paragraph(makeNameTag() + "Click determining what to do with this intermediate step");
                }
                bool isFocused = (ah.States & AccessibleStates.Focused) == AccessibleStates.Focused;
                if (!isFocused)
                {
                    if (1 == m_logLevel)
                    {
                        m_log.paragraph(makeNameTag() + "Clicking relative to &quot;" + ah.Role + ":" + ah.Name + "&quot; by (" + m_dx + ", " + m_dy + ") since it does not have focus");
                    }
                    ah.SimulateClickRelative(m_dx, m_dy);
                }
                else
                {
                    if (1 == m_logLevel)
                    {
                        m_log.paragraph(makeNameTag() + "Click hovering on &quot;" + ah.Role + ":" + ah.Name + "&quot; since it has focus");
                    }
                    ah.MoveMouseOverMe();                     // hover
                }
            }
        }
コード例 #14
0
        public MappingContext(SyntaxNode contextExpression, SemanticModel semanticModel)
        {
            var typeDeclaration = contextExpression.FindContainer <TypeDeclarationSyntax>();

            ContextSymbol       = semanticModel.GetDeclaredSymbol(typeDeclaration) as INamedTypeSymbol;
            AccessibilityHelper = new AccessibilityHelper(ContextSymbol);
        }
コード例 #15
0
        /// <summary>
        /// Tries to find the target ah repeatedly for the "Wait" period
        /// </summary>
        /// <param name="ah"></param>
        /// <param name="gpath"></param>
        private void ClickPathUntilFound(AccessibilityHelper ah, GuiPath gpath)
        {
            string badPath = "";

            if (DoingOnce())
            {
                badPath = ClickPath(ah, gpath);
            }
            else
            {             // act as if it's being done once
                //IntPtr handle = (IntPtr)ah.HWnd; // get an updated ah based on its window handle
                bool done = false;
                while (!done && !m_finished)
                {
                    //ah = new AccessibilityHelper((handle)); // refresh the context ah
                    ah = new AccessibilityHelper(ah);                     // refresh the context ah
                    if (ah == null)
                    {
                        m_log.paragraph(makeNameTag() + "ClickPathUntilFound on " + gpath + " handled a null context");
                    }
                    if (ah != null)
                    {
                        badPath = ClickPath(ah, gpath);
                    }
                    done = Utilities.NumTicks(m_ExecuteTickCount, System.Environment.TickCount) > m_until;
                    System.Threading.Thread.Sleep(500);                     // try every half second
                }
                // if not clicked, it waited a long time on a bad path
                if (!m_finished)
                {
                    m_log.fail(makeNameTag() + badPath);
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Adds a child at the given index.
        /// </summary>
        /// <param name="parent">The parent view.</param>
        /// <param name="child">The child view.</param>
        /// <param name="index">The index.</param>
        public void AddView(DependencyObject parent, DependencyObject child, int index)
        {
            var span = (Span)parent;

            var inlineChild = child as Inline;

            if (inlineChild == null)
            {
                inlineChild = new InlineUIContainer
                {
                    Child = (UIElement)child,
                };
            }

#if WINDOWS_UWP
            span.Inlines.Insert(index, inlineChild);

            var parentUIElement = AccessibilityHelper.GetParentElementFromTextElement(span);
            if (parentUIElement != null)
            {
                AccessibilityHelper.OnChildAdded(parentUIElement, child);
            }
#else
            ((IList)span.Inlines).Insert(index, inlineChild);
#endif
        }
コード例 #17
0
        /// <summary>
        /// Look at a window control using Active Accessibility via an appPath
        /// and the gui model and/or a guiPath.
        /// The property of the control is matched against the expected value.
        /// If only the context is not null, it's value is used as a path to the control.
        /// If the context is null, the model root is used with appPath to find the path.
        /// The appPath is applied first, if any, then the guiPath to create a path.
        /// If there is no context or appPath, the guiPath is used for the path.
        /// </summary>
        /// <param name="context">Model node to start appPath from or null</param>
        /// <param name="appPath">the appPath to a control or null</param>
        /// <param name="guiPath">the guiPath to glimpse or null</param>
        /// <param name="property">names the property to look at - "present" is default</param>
        /// <param name="expect">text to match against the property value</param>
        /// <returns>true if the expected value matched what was found.</returns>
        private bool glimpse(XmlNode context, string appPath, string guiPath, string property, string expect)
        {
            // if only a context, select it to glimpse.
            if (appPath == null && guiPath == null)
            {
                property = "value";
            }
            XmlPath xp = m_GuiModel.selectToXmlPath(context, appPath);

            if (xp == null || !xp.isValid())
            {
                return(false);
            }
            AccessibilityHelper ah = findInGui(xp, guiPath);

            if (ah == null)
            {
                return(false);
            }
            if (!Utilities.isGoodStr(expect) && xp != null)
            {
                if (xp.ModelNode is XmlAttribute || xp.ModelNode is XmlText)
                {
                    expect = xp.ModelNode.Value;
                    if (Utilities.isGoodStr(expect) && !Utilities.isGoodStr(property))
                    {
                        property = "value";
                    }
                }
            }
            return(GlimpseGUI(ah, property, expect));
        }
コード例 #18
0
ファイル: Desktop.cs プロジェクト: vkarthim/FieldWorks
        public override void Execute()
        {           // first, see if the last test left an error window open
            //m_memory = System.  //Application.Process
            CheckForErrorDialogs(false);
            // find any window then switch to its parent until it doesn't have one
            //IntPtr foundHwndPtr = FindWindow(null, null); // Random Window
            IntPtr foundHwndPtr = FindWindow(null, "Program Manager");             // 9:Program Manager/9:$NL;/33:OnDesktop?

            if ((int)foundHwndPtr != 0)
            {
                m_ah = new AccessibilityHelper(foundHwndPtr);
                m_log.isNotNull(m_ah, makeNameTag() + "window " + (int)foundHwndPtr + "isn't accessible");
                m_log.areEqual(m_ah.Name, "Program Manager", makeNameTag() + "window " + m_ah.Name + " found insteadof Program Manager");
                //	while (m_ah.Name != "OnDesktop" && m_ah.Role != AccessibleRole.Window && m_ah.Parent != null)
                //		m_ah = m_ah.Parent;
            }
            m_log.isNotNull(m_ah, @"Program Manager object not found");
            m_log.isTrue(m_ah.Name == "Program Manager" && m_ah.Role == AccessibleRole.Window, @"Program Manager not found! Got """ + m_ah.Role + ":" + m_ah.Name + @""" instead");
            if (1 == m_logLevel)
            {
                m_log.paragraph(makeNameTag() + "OnDesktop is &quot;" + m_ah.Role + ":" + m_ah.Name + "&quot;");
            }

            base.Execute();
            Finished = true;             // tell do-once it's done
        }
コード例 #19
0
        /// <summary>
        /// Update the properties on the inline instance.
        /// </summary>
        /// <param name="inline">The instance.</param>
        public override void UpdateInline(Inline inline)
        {
            ((Run)inline).Text = _text;

#if WINDOWS_UWP
            AccessibilityHelper.OnTextChanged(inline);
#endif
        }
コード例 #20
0
ファイル: HoverOver.cs プロジェクト: sillsdev/WorldPad
 /// <summary>
 /// method to apply when a non-terminal node has been found
 /// </summary>
 /// <param name="ah"></param>
 public void visitNode(AccessibilityHelper ah)
 {                         // does this ah need to be clicked or something to get to its children?
     ah.MoveMouseOverMe(); // hover
     if (1 == m_logLevel)
     {
         m_log.paragraph("HoverOver hovering over &quot;" + ah.Role + ":" + ah.Name + "&quot;");
     }
 }
コード例 #21
0
        /// <summary>
        /// Clears out the <see cref="LayoutAnimationController"/> and processes accessibility changes
        /// </summary>
        public void OnBatchComplete()
        {
            _layoutAnimator.Reset();

#if WINDOWS_UWP
            AccessibilityHelper.OnBatchComplete();
#endif
        }
コード例 #22
0
        void IViewParentManager.RemoveChildAt(object parent, int index)
        {
            var element = (TFrameworkElement)parent;

            RemoveChildAt((TFrameworkElement)parent, index);
#if WINDOWS_UWP
            AccessibilityHelper.OnChildRemoved(element);
#endif
        }
コード例 #23
0
        public static Task <Document> RefactorAsync(
            Document document,
            ConstructorDeclarationSyntax constructorDeclaration,
            CancellationToken cancellationToken)
        {
            ConstructorDeclarationSyntax newNode = AccessibilityHelper.ChangeAccessibility(constructorDeclaration, Accessibility.Protected, ModifierComparer.Instance);

            return(document.ReplaceNodeAsync(constructorDeclaration, newNode, cancellationToken));
        }
コード例 #24
0
        void IViewParentManager.AddView(DependencyObject parent, DependencyObject child, int index)
        {
            var element = (TFrameworkElement)parent;

            AddView(element, child, index);
#if WINDOWS_UWP
            AccessibilityHelper.OnChildAdded(element, child);
#endif
        }
コード例 #25
0
        void IViewParentManager.RemoveAllChildren(DependencyObject parent)
        {
            var element = (TFrameworkElement)parent;

            RemoveAllChildren(element);
#if WINDOWS_UWP
            AccessibilityHelper.OnChildRemoved(element);
#endif
        }
コード例 #26
0
        public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
        {
            if (!Settings.IsCodeFixEnabled(CodeFixIdentifiers.ChangeAccessibility))
            {
                return;
            }

            SyntaxNode root = await context.GetSyntaxRootAsync().ConfigureAwait(false);

            if (!TryFindFirstAncestorOrSelf(
                    root,
                    context.Span,
                    out SyntaxNode node,
                    predicate: f => OverrideInfo.CanCreate(f)))
            {
                return;
            }

            foreach (Diagnostic diagnostic in context.Diagnostics)
            {
                switch (diagnostic.Id)
                {
                case CompilerDiagnosticIdentifiers.CannotChangeAccessModifiersWhenOverridingInheritedMember:
                {
                    SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);

                    OverrideInfo overrideInfo = OverrideInfo.Create(node, semanticModel, context.CancellationToken);

                    if (!overrideInfo.Success)
                    {
                        break;
                    }

                    Accessibility newAccessibility = overrideInfo.OverriddenSymbol.DeclaredAccessibility;

                    CodeAction codeAction = CodeAction.Create(
                        $"Change accessibility to '{AccessibilityHelper.GetAccessibilityName(newAccessibility)}'",
                        cancellationToken =>
                        {
                            if (node.Kind() == SyntaxKind.VariableDeclarator)
                            {
                                node = node.Parent.Parent;
                            }

                            SyntaxNode newNode = AccessibilityHelper.ChangeAccessibility(node, newAccessibility, ModifierComparer.Instance);

                            return(context.Document.ReplaceNodeAsync(node, newNode, cancellationToken));
                        },
                        GetEquivalenceKey(diagnostic));

                    context.RegisterCodeFix(codeAction, diagnostic);
                    break;
                }
                }
            }
        }
コード例 #27
0
        public static Task <Document> RefactorAsync(
            Document document,
            SyntaxNode node,
            Accessibility newAccessibility,
            CancellationToken cancellationToken)
        {
            SyntaxNode newNode = AccessibilityHelper.ChangeAccessibility(node, newAccessibility, ModifierComparer.Instance);

            return(document.ReplaceNodeAsync(node, newNode, cancellationToken));
        }
コード例 #28
0
        void IViewParentManager.AddView(object parent, object child, int index)
        {
            var element          = (TFrameworkElement)parent;
            var dependencyObject = ViewConversion.GetDependencyObject(child);

            AddView(element, dependencyObject, index);
#if WINDOWS_UWP
            AccessibilityHelper.OnChildAdded(element, dependencyObject);
#endif
        }
コード例 #29
0
        public static Task <Document> RefactorAsync(
            Document document,
            MemberDeclarationSyntax member,
            Accessibility accessibility,
            CancellationToken cancellationToken)
        {
            MemberDeclarationSyntax newNode = AccessibilityHelper.ChangeAccessibility(member, accessibility, ModifierComparer.Instance);

            return(document.ReplaceNodeAsync(member, newNode, cancellationToken));
        }
コード例 #30
0
        /// <summary>
        /// Creates a view and installs event emitters on it.
        /// </summary>
        /// <param name="reactContext">The context.</param>
        /// <returns>The view.</returns>
        public TFrameworkElement CreateView(ThemedReactContext reactContext)
        {
            var view = CreateViewInstance(reactContext);

#if WINDOWS_UWP
            AccessibilityHelper.OnViewInstanceCreated(view);
#endif
            AddEventEmitters(reactContext, view);
            // TODO: enable touch intercepting view parents
            return(view);
        }
コード例 #31
0
		/// <summary>
		/// Matches legal name and role combinations to their ah counterparts.
		/// They can match on both.
		/// Match NAMELESS to a null ah.name.
		/// Match name to ah.value when role is Alert and ah.role is anything.
		/// Match anything when name is null or #ANY.
		/// Match any ah.role when role is None.
		/// One name match and one role match must be true.
		/// </summary>
		/// <param name="name">The text to match, can be null</param>
		/// <param name="role">The Accessible role - some like Alert are special</param>
		/// <param name="ah">The accessible object</param>
		/// <returns>true if a name and a role matched</returns>
		private bool MatchNameAndRole(string name, AccessibleRole role, AccessibilityHelper ah)
		{
			bool result = false;
			bool NameResult = false;
			// check if the name is a regular expression
			if (name != null && name.StartsWith("rexp#"))
			{
				Regex rx = new Regex(name.Substring(5));
				string MatchItem = "";
				if (ah.Role == AccessibleRole.Alert) MatchItem = ah.Value;
				else                                 MatchItem = ah.Name;
				NameResult = rx.IsMatch(MatchItem);
				Log log = Log.getOnly();
				log.writeElt("match-reg-exp");
				log.writeAttr("pattern", name.Substring(5));
				log.writeAttr("to", MatchItem);
				log.writeAttr("result", result.ToString());
				log.endElt();
			}
			else if (ah.Role == AccessibleRole.Alert)
				NameResult = name == ah.Value;

			result =
				(
					NameResult
					|| name == ah.Name
					|| (name == "NAMELESS" && ah.Name == null) // should never be null, but "" instead
					|| (name == "NAMELESS" && ah.Name == "")
					|| name == null
					|| name == "#ANY"
				)
				&& (role == ah.Role || role == AccessibleRole.None
					|| role == AccessibleRole.Alert);
			return result;
		}
コード例 #32
0
 /// <summary>
 /// Creates a child node list, putting parent's client first.
 /// </summary>
 /// <param name="parent">An ah with children</param>
 /// <returns>An ArrayList of the children</returns>
 private ArrayList MakeChildList(AccessibilityHelper parent)
 {
     ArrayList nodes = new ArrayList(parent.ChildCount);
     //AccessibilityHelper ah = parent.FindClient();
     //if (ah != null) {nodes.Add(ah);} // client first
     foreach(AccessibilityHelper child in parent)
         //if (child != ah)
         if (child != null) nodes.Add(child);
     return nodes;
 }
コード例 #33
0
        /// <summary>
        /// Matches legal name and role combinations to their ah counterparts.
        /// They can match on both.
        /// Match NAMELESS to a null ah.name.
        /// Match name to ah.value when role is Alert and ah.role is anything.
        /// Match anything when name is null or #ANY.
        /// Match any ah.role when role is None.
        /// One name match and one role match must be true.
        /// </summary>
        /// <param name="name">The text to match, can be null</param>
        /// <param name="role">The Accessible role - some like Alert are special</param>
        /// <param name="ah">The accessible object</param>
        /// <returns>true if a name and a role matched</returns>
        private bool MatchNameAndRole(string name, AccessibleRole role, AccessibilityHelper ah)
        {
            bool result = false;
            bool NameResult = false;
            // check if the name is a regular expression
            if (name != null && name.StartsWith("rexp#"))
            {
                Regex rx = null;
                try { rx = new Regex(name.Substring(5)); }
                catch (ArgumentException e)
                {
                    Logger.getOnly().paragraph("Path name reg exp [" + name.Substring(5)
                          + "] " + e.Message);
                }
                if (rx != null)
                {
                    string MatchItem = "";
                    if (ah.Role == AccessibleRole.Alert) MatchItem = ah.Value;
                    else MatchItem = ah.Name;
                    NameResult = rx.IsMatch(MatchItem);
                    Logger.getOnly().paragraph("Path name reg exp [" + name.Substring(5)
                        + "] on [" + MatchItem + "] was " + NameResult.ToString());
                }
            }
            else if (ah.Role == AccessibleRole.Alert)
                NameResult = name == ah.Value;

            result =
                (
                    NameResult
                    || name == ah.Name
                    || (name == "NAMELESS" && ah.Name == null) // should never be null, but "" instead
                    || (name == "NAMELESS" && ah.Name.Length == 0) // "" empty doesn't always match
                    || name == null
                    || name == "#ANY"
                )
                && (role == ah.Role || role == AccessibleRole.None
                    || role == AccessibleRole.Alert);
            return result;
        }
コード例 #34
0
 /// <summary>
 /// ValueOrChild determines if the ah's value should be macthed or
 /// if a child should be matched.
 /// </summary>
 /// <param name="nextGP">The next path step beyond this ah</param>
 /// <param name="ah">The accessibility object currently considered</param>
 /// <param name="visitor">null or the object providing methods that are called when steps are found.</param>
 /// <returns>An AccessibilityHelper if checking for a value, otherwise null</returns>
 public AccessibilityHelper ValueOrChild(GuiPath nextGP, AccessibilityHelper ah, IPathVisitor visitor)
 {
     bool result = false;
     if (nextGP.Role == AccessibleRole.Alert)
     { // check if the name is a regular expression
         if (nextGP.Name != null && nextGP.Name.StartsWith("rexp#"))
         {
             Regex rx = new Regex(nextGP.Name.Substring(5));
             result = rx.IsMatch(ah.Value);
             Logger.getOnly().paragraph("Path name reg exp " + nextGP.Name.Substring(5)
                 + " on " + ah.Value + " was " + result.ToString());
         }
         else result = nextGP.Name == ah.Value; // match the value to the next path's name
         if (!result)
         { // it didn't match, so the search failed
             if (visitor != null) visitor.notFound(nextGP);
             return null;
         }
     }
     if (result) return ah;
     return ah.SearchPath(nextGP, visitor); // continue on the path
 }
コード例 #35
0
        public override void Init()
        {
            base.Init();

            Thread.Sleep(500);

            // Select "File/Import/Standard Format" to bring up the import dialog
            m_app.SendKeys("%F");
            m_app.SendKeys("{DOWN 8}");
            m_app.SendKeys("{ENTER}");
            m_app.SendKeys("{ENTER}");
            Application.DoEvents();

            AccessibilityHelper importDlg =
                m_app.MainAccessibilityHelper.Parent.FindDirectChild("Import Standard Format",
                AccessibleRole.None);

            // select the "Import" button which is the default button
            if (importDlg != null)
                m_app.SendKeys("{ENTER}");

            Application.DoEvents();

            m_dialog = m_app.MainAccessibilityHelper.Parent.FindDirectChild(
                "Import Standard Format", AccessibleRole.None);

            m_saveRegistryData = Unpacker.PrepareRegistryForPTData();
        }
コード例 #36
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Check the controls on the step and see if there are non-excaptable controls on it,
        /// i.e. for the overview page return false if there are any check boxes.
        /// </summary>
        /// <param name="parent">The element to start with</param>
        /// <param name="acceptableRoles">Sorted array of acceptable controls</param>
        /// <returns><c>true</c> if all visible controls are acceptable, otherwise
        /// <c>false</c>.</returns>
        /// ------------------------------------------------------------------------------------
        protected bool CheckControls(AccessibilityHelper parent, AccessibleRole[] acceptableRoles)
        {
            bool fRet = true;
            foreach (AccessibilityHelper child in parent)
            {
                if ((child.States & AccessibleStates.Invisible) == AccessibleStates.Invisible)
                    continue;

                if (Array.BinarySearch(acceptableRoles, child.Role) < 0)
                    return false;

                if (child.IsRealAccessibleObject)
                    fRet = CheckControls(child, acceptableRoles);

                if (!fRet)
                    return fRet;
            }

            return fRet;
        }
コード例 #37
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Check the radio buttons. We should have exactly two: Paratext and Other
        /// </summary>
        /// <param name="parent">The element to start with</param>
        /// <param name="nRbsFound">Number of radio buttons found.</param>
        /// <remarks>On return <paramref name="nRbsFound"/> should be 2. If there are additional
        /// radio buttons on the dialog, <paramref name="nRbsFound"/> will return a negative
        /// number.</remarks>
        /// ------------------------------------------------------------------------------------
        protected void CheckRadioButtons(AccessibilityHelper parent, ref int nRbsFound)
        {
            foreach (AccessibilityHelper child in parent)
            {
                if ((child.States & AccessibleStates.Invisible) == AccessibleStates.Invisible)
                    continue;

                if (child.Role == AccessibleRole.RadioButton)
                {
                    if (child.Name == "Paratext")
                    {
                        // paratext radio button has to be default if paratext is installed
                        RegistryKey regKey = Registry.LocalMachine.OpenSubKey(kPTSettingsRegKey);
                        if (regKey != null)
                            Assert.AreEqual(AccessibleStates.Checked, (child.States & AccessibleStates.Checked),
                                "Paratext is installed, but Paratext radio button "
                                + "is not the default.");

                        nRbsFound++;
                    }
                    else if (child.Name == "Other")
                    {
                        // Other radio button has to be default if Paratext isn't installed
                        RegistryKey regKey = Registry.LocalMachine.OpenSubKey(kPTSettingsRegKey);
                        if (regKey == null)
                            Assert.AreEqual(AccessibleStates.Checked, (child.States & AccessibleStates.Checked),
                                "Paratext is not installed, but Other radio button is not the default.");

                        nRbsFound++;
                    }
                    else
                        nRbsFound = -99;
                }

                if (child.IsRealAccessibleObject)
                    CheckRadioButtons(child, ref nRbsFound);
            }
        }
コード例 #38
0
		/// <summary>
		/// ValueOrChild determines if the ah's value should be macthed or
		/// if a child should be matched.
		/// </summary>
		/// <param name="nextGP">The next path step beyond this ah</param>
		/// <param name="ah">The accessibility object currently considered</param>
		/// <param name="visitor">null or the object providing methods that are called when steps are found.</param>
		/// <returns>An AccessibilityHelper if checking for a value, otherwise null</returns>
		public AccessibilityHelper ValueOrChild(GuiPath nextGP, AccessibilityHelper ah, IPathVisitor visitor)
		{
			bool result = false;
			if (nextGP.Role == AccessibleRole.Alert)
			{ // check if the name is a regular expression
				if (nextGP.Name != null && nextGP.Name.StartsWith("rexp#"))
				{
					Regex rx = new Regex(nextGP.Name.Substring(5));
					result = rx.IsMatch(ah.Value);
					Log log = Log.getOnly();
					log.writeElt("ValueOrChild");
					log.writeAttr("pattern", nextGP.Name.Substring(5));
					log.writeAttr("to", ah.Value);
					log.writeAttr("result", result.ToString());
					log.endElt();
				}
				else result = nextGP.Name == ah.Value; // match the value to the next path's name
				if (!result)
				{ // it didn't match, so the search failed
					if (visitor != null) visitor.notFound(nextGP);
					return null;
				}
			}
			if (result) return ah;
			return ah.SearchPath(nextGP, visitor); // continue on the path
		}