예제 #1
0
        internal static void BindToDescriptionPropertiesIfUnset(
            XamlUICommand uiCommand,
            FrameworkElement target)
        {
            string localHelpText = AutomationProperties.GetHelpText(target);

            if (localHelpText == null || string.IsNullOrEmpty(localHelpText))
            {
                target.SetBinding(AutomationProperties.HelpTextProperty, new Binding {
                    Path = "Description", Source = uiCommand
                });
            }

            object localToolTipAsI;

            localToolTipAsI = ToolTipService.GetToolTip(target);

            string  localToolTipAsString = null;
            ToolTip localToolTip         = null;

            if (localToolTipAsI != null)
            {
                localToolTipAsString = localToolTipAsI.ToString();
                localToolTip         = localToolTipAsI as ToolTip;
            }

            if ((localToolTipAsString == null || string.IsNullOrEmpty(localToolTipAsString)) && localToolTip == null)
            {
                target.SetBinding(ToolTipService.ToolTipProperty, new Binding {
                    Path = "Description", Source = uiCommand
                });
            }
        }
예제 #2
0
        private void ToggleHelp(DependencyObject dependObj)
        {
            // Continue recursive toggle. Using the VisualTreeHelper works nicely.
            for (int x = 0; x < VisualTreeHelper.GetChildrenCount(dependObj); x++)
            {
                DependencyObject child = VisualTreeHelper.GetChild(dependObj, x);
                ToggleHelp(child);
            }

            // BitmapEffect is defined on UIElement so our DependencyObject
            // must be a UIElement also
            if (dependObj is UIElement)
            {
                UIElement element = (UIElement)dependObj;

                if (HelpActive)
                {
                    string helpText = AutomationProperties.GetHelpText(element);

                    if (!String.IsNullOrEmpty(helpText))
                    {
                    }
                }
            }
        }
예제 #3
0
        private void winMain_MouseMove(object sender, MouseEventArgs e)
        {
            // You can check the HelpActive property if desired, however
            // the listener should not be hooked up so this should not be firing
            HitTestResult hitTestResult = VisualTreeHelper.HitTest(((Visual)sender), e.GetPosition(this));

            if (hitTestResult.VisualHit != null && CurrentHelpDO != hitTestResult.VisualHit)
            {
                // Walk up the tree in case a parent element has help defined
                DependencyObject checkHelpDO = hitTestResult.VisualHit;
                string           helpText    = AutomationProperties.GetHelpText(checkHelpDO);

                while (String.IsNullOrEmpty(helpText) && checkHelpDO != null && checkHelpDO != mainWindow)
                {
                    checkHelpDO = VisualTreeHelper.GetParent(checkHelpDO);
                    helpText    = AutomationProperties.GetHelpText(checkHelpDO);
                }

                if (String.IsNullOrEmpty(helpText) && CurrentHelpPopup != null)
                {
                    CurrentHelpPopup.IsOpen = false;
                    CurrentHelpDO           = null;
                }
                else if (!String.IsNullOrEmpty(helpText) && CurrentHelpDO != checkHelpDO)
                {
                    CurrentHelpDO = checkHelpDO;
                    // New visual "stack" hit, close old popup, if any
                    if (CurrentHelpPopup != null)
                    {
                        CurrentHelpPopup.IsOpen = false;
                    }

                    // Obviously you can make the popup look anyway you want it to look
                    // with any number of options. I chose a simple tooltip look-and-feel.
                    CurrentHelpPopup = new Popup()
                    {
                        //AllowsTransparency = true,
                        PopupAnimation  = PopupAnimation.Scroll,
                        PlacementTarget = (UIElement)hitTestResult.VisualHit,
                        IsOpen          = true,
                        Child           = new System.Windows.Controls.Border()
                        {
                            CornerRadius    = new CornerRadius(10),
                            BorderBrush     = new SolidColorBrush(Colors.Goldenrod),
                            BorderThickness = new Thickness(2),
                            Background      = new SolidColorBrush(Colors.LightYellow),
                            Child           = new TextBlock()
                            {
                                Margin     = new Thickness(10),
                                Text       = helpText.Replace("\\r\\n", "\r\n"),
                                FontSize   = 14,
                                FontWeight = FontWeights.Normal
                            }
                        }
                    };
                    CurrentHelpPopup.IsOpen = true;
                }
            }
        }
예제 #4
0
        //--------------------------------------------------------------------
        //
        // Constructors
        //
        //---------------------------------------------------------------------

        #region Constructors
        private FixedSOMImage(Rect imageRect, GeneralTransform trans, Uri sourceUri, FixedNode node, DependencyObject o) : base(node, trans)
        {
            _boundingRect = trans.TransformBounds(imageRect);
            _source       = sourceUri;
            _startIndex   = 0;
            _endIndex     = 1;
            _name         = AutomationProperties.GetName(o);
            _helpText     = AutomationProperties.GetHelpText(o);
        }
        protected void UpdateAutomationHelpText()
        {
            var helpText = AutomationProperties.GetHelpText(Element);

            if (!string.IsNullOrEmpty(helpText))
            {
                WAutomationProperties.SetHelpText(Control, helpText);
            }
        }
예제 #6
0
        private void UpdateHeaderAutomationProperties(GridViewColumnHeader columnHeader)
        {
            var    sortDir     = SortableColumnHeaderAttachedProperties.GetSortDirectionProperty(columnHeader);
            string oldHelpText = AutomationProperties.GetHelpText(columnHeader);
            string newHelpText;

            if (sortDir == ListSortDirection.Ascending)
            {
                newHelpText = Resx.Resources.Accessibility_ColumnSortedAscendingHelpText;
            }
            else if (sortDir == ListSortDirection.Descending)
            {
                newHelpText = Resx.Resources.Accessibility_ColumnSortedDescendingHelpText;
            }
            else
            {
                newHelpText = Resx.Resources.Accessibility_ColumnNotSortedHelpText;
            }

            AutomationProperties.SetHelpText(columnHeader, newHelpText);
            var peer = UIElementAutomationPeer.FromElement(columnHeader);

            peer?.RaisePropertyChangedEvent(AutomationElementIdentifiers.HelpTextProperty, oldHelpText, newHelpText);
        }
예제 #7
0
 ///
 protected override string GetHelpTextCore()
 {
     return(AutomationProperties.GetHelpText(_owner));
 }
예제 #8
0
        public void GetTabIndexesOnParentPage_CompositeControls()
        {
            var label = new Label()
            {
                TabIndex = 1
            };

            var composite = new CustomGrid();

            var label2 = new Label()
            {
                TabIndex = 10
            };

            var timePicker = new TimePicker()
            {
                TabIndex = 11
            };

            var label3 = new Label()
            {
                TabIndex = 12
            };

            var timePicker2 = new TimePicker()
            {
                TabIndex = 13
            };

            var stack = new StackLayout
            {
                Children =
                {
                    label,
                    composite,
                    label2,
                    timePicker,
                    label3,
                    timePicker2
                }
            };

            var scroll = new ScrollView()
            {
                Content = stack
            };

            var page = new ContentPage {
                Content = scroll
            };

            SortedDictionary <int, List <ITabStopElement> > tabIndexes = null;

            foreach (var child in page.LogicalChildren)
            {
                if (!(child is VisualElement ve))
                {
                    continue;
                }

                tabIndexes = ve.GetSortedTabIndexesOnParentPage();
                break;
            }

            Assert.That(tabIndexes.Any());

            Assert.AreEqual(3, tabIndexes[0].Count, "Too many items in group 0");
            Assert.AreEqual(tabIndexes[0][0], scroll);
            Assert.AreEqual(tabIndexes[0][1], stack);
            Assert.AreEqual(tabIndexes[0][2], composite);

            Assert.AreEqual(2, tabIndexes[1].Count, "Too many items in group 1");
            Assert.AreEqual(tabIndexes[1][0], label);
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[1][1]);
            Assert.AreEqual("1", AutomationProperties.GetHelpText(((Frame)tabIndexes[1][1])));

            Assert.AreEqual(1, tabIndexes[2].Count, "Too many items in group 2");
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[2][0]);
            Assert.AreEqual("2", AutomationProperties.GetHelpText(((Frame)tabIndexes[2][0])));

            Assert.AreEqual(1, tabIndexes[3].Count, "Too many items in group 3");
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[3][0]);
            Assert.AreEqual("3", AutomationProperties.GetHelpText(((Frame)tabIndexes[3][0])));

            Assert.AreEqual(1, tabIndexes[4].Count, "Too many items in group 4");
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[4][0]);
            Assert.AreEqual("4", AutomationProperties.GetHelpText(((Frame)tabIndexes[4][0])));

            Assert.AreEqual(1, tabIndexes[5].Count, "Too many items in group 5");
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[5][0]);
            Assert.AreEqual("5", AutomationProperties.GetHelpText(((Frame)tabIndexes[5][0])));

            Assert.AreEqual(1, tabIndexes[6].Count, "Too many items in group 6");
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[6][0]);
            Assert.AreEqual("6", AutomationProperties.GetHelpText(((Frame)tabIndexes[6][0])));

            Assert.AreEqual(1, tabIndexes[7].Count, "Too many items in group 7");
            Assert.IsAssignableFrom(typeof(Frame), tabIndexes[7][0]);
            Assert.AreEqual("7", AutomationProperties.GetHelpText(((Frame)tabIndexes[7][0])));

            Assert.IsFalse(tabIndexes.ContainsKey(8), "Something unexpected in group 8");
            Assert.IsFalse(tabIndexes.ContainsKey(9), "Something unexpected in group 9");

            Assert.AreEqual(1, tabIndexes[10].Count, "Too many items in group 10");
            Assert.AreEqual(tabIndexes[10][0], label2);
            Assert.AreEqual(1, tabIndexes[11].Count, "Too many items in group 11");
            Assert.AreEqual(tabIndexes[11][0], timePicker);
            Assert.AreEqual(1, tabIndexes[12].Count, "Too many items in group 12");
            Assert.AreEqual(tabIndexes[12][0], label3);
            Assert.AreEqual(1, tabIndexes[13].Count, "Too many items in group 13");
            Assert.AreEqual(tabIndexes[13][0], timePicker2);
        }
예제 #9
0
		protected string GetSemanticHint(IViewHandler viewHandler) =>
			AutomationProperties.GetHelpText((FrameworkElement)viewHandler.NativeView);
 private void CopyAutopmationProperties(FrameworkElement sourceFrameworkElement, FrameworkElement targetFrameworkElement)
 {
     AutomationProperties.SetName(targetFrameworkElement, AutomationProperties.GetName(sourceFrameworkElement));
     AutomationProperties.SetHelpText(targetFrameworkElement, AutomationProperties.GetHelpText(sourceFrameworkElement));
 }