public void AddElement()

in src/AccessibilityInsights.SharedUx/Highlighting/WindowHighlighterBase.cs [140:193]


        public void AddElement(A11yElement el, string txt = "!")
        {
            if (el != null)
            {
                if (!Items.ContainsKey(el))
                {
                    if (this.IsVisible && !el.BoundingRectangle.IsEmpty && this.Dimensions.IntersectsWith(el.BoundingRectangle))
                    {
                        var l = (el.BoundingRectangle.Left - Dimensions.Left) / DPI - GapWidth;
                        var t = (el.BoundingRectangle.Top - Dimensions.Top) / DPI - GapWidth;

                        var bord = new Border()
                        {
                            BorderBrush = Brush,
                            BorderThickness = new Thickness(4),
                            Width = el.BoundingRectangle.Width / DPI + GapWidth * 2,
                            Height = el.BoundingRectangle.Height / DPI + GapWidth * 2,
                        };
                        TextBlock tb = null;
                        if (txt != null)
                        {
                            tb = new TextBlock()
                            {
                                Text = txt,
                                Background = Brush,
                                Foreground = new SolidColorBrush(Colors.White),
                                Tag = el,
                                Width = 28,
                                TextAlignment = TextAlignment.Center,
                                Height = 28
                            };
                            if (TBCallback != null)
                            {
                                tb.MouseDown += TBCallback;
                            }

                            canvas.Children.Add(tb);
                            tb.SetValue(Canvas.LeftProperty, l + el.BoundingRectangle.Width / DPI - tb.Width + GapWidth * 2);
                            tb.SetValue(Canvas.TopProperty, t);
                            tb.SetValue(Canvas.ZIndexProperty, 1);
                        }
                        canvas.Children.Add(bord);
                        bord.SetValue(Canvas.LeftProperty, l);
                        bord.SetValue(Canvas.TopProperty, t);
                        bord.SetValue(Canvas.ZIndexProperty, 0);
                        Items[el] = new GroupHighlighterItem(bord, tb);
                    }
                }
                else
                {
                    Items[el].AddRef();
                }
            }
        }