Пример #1
0
        /// <summary>
        /// Add element and highlight
        /// </summary>
        /// <param name="el"></param>
        /// <param name="txt"></param>
        public void AddElement(A11yElement el, string txt = "!")
        {
            if (el != null)
            {
                if (!Items.Keys.Contains(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();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Add element and highlight
        /// </summary>
        /// <param name="el"></param>
        /// <param name="txt"></param>
        public void AddElementRoundBorder(A11yElement el, string txt = "!")
        {
            if (el != null)
            {
                if (!Items.Keys.Contains(el))
                {
                    if (this.IsVisible && !el.BoundingRectangle.IsEmpty && this.Dimensions.IntersectsWith(el.BoundingRectangle))
                    {
                        var l = (el.BoundingRectangle.Left - Dimensions.Left) / DPI;
                        var t = (el.BoundingRectangle.Top - Dimensions.Top) / DPI;

                        var bord = new Border()
                        {
                            BorderBrush     = Application.Current.Resources["DarkGreyTextBrush"] as SolidColorBrush,
                            BorderThickness = new Thickness(2),
                            Background      = Application.Current.Resources["LightBackgroundBrush"] as SolidColorBrush,
                            Width           = 28,
                            Height          = 28,
                            CornerRadius    = new CornerRadius(28),
                        };

                        TextBlock tb = null;
                        if (txt != null)
                        {
                            tb = new TextBlock()
                            {
                                Text = txt,
                                Tag  = el,
                                HorizontalAlignment = HorizontalAlignment.Center,
                                VerticalAlignment   = VerticalAlignment.Center,
                            };
                            if (TBCallback != null)
                            {
                                tb.MouseDown += TBCallback;
                            }

                            bord.Child = tb;
                        }
                        canvas.Children.Add(bord);
                        bord.SetValue(Canvas.LeftProperty, GetMidPoint(l, el.BoundingRectangle.Width, bord.Width));
                        bord.SetValue(Canvas.TopProperty, GetMidPoint(t, el.BoundingRectangle.Height, bord.Height));
                        bord.SetValue(Canvas.ZIndexProperty, 0);
                        Items[el] = new GroupHighlighterItem(bord, tb);
                    }
                }
                else
                {
                    Items[el].AddRef();
                }
            }
        }