示例#1
0
        private void SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox lb = sender as ListBox;

            if (lb == null)
            {
                return;
            }

            AccessElement element = lb.SelectedItem as AccessElement;
            int           id      = element.Id;

            txtIn.Text = id.ToString();
            myapp.Overlay.ColorRect(id);
        }
示例#2
0
        public new void Show()
        {
            AccessHelper helper = myapp.Helper;

            Width  = helper.Target.Current.BoundingRectangle.Width;
            Height = helper.Target.Current.BoundingRectangle.Height;
            Top    = helper.Target.Current.BoundingRectangle.Top;
            Left   = helper.Target.Current.BoundingRectangle.Left;

            foreach (KeyValuePair <int, AccessElement> entry in helper.AccessElements)
            {
                AccessElement element = entry.Value;
                if ((element.Width > 0) && (element.Height > 0))
                {
                    System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
                    rect.Width   = element.Width;
                    rect.Height  = element.Height;
                    rect.Fill    = Brushes.Black;
                    rect.Opacity = .5;
                    rect.Name    = "rect_" + element.Id.ToString();

                    TextBlock number = new TextBlock();
                    number.Background          = Brushes.White;
                    number.Foreground          = Brushes.Black;
                    number.VerticalAlignment   = VerticalAlignment.Center;
                    number.HorizontalAlignment = HorizontalAlignment.Center;
                    number.TextAlignment       = TextAlignment.Center;
                    number.Width  = 20;
                    number.Height = 16;
                    number.Text   = element.Id.ToString();
                    number.Name   = "number_" + element.Id.ToString();

                    Canvas.SetLeft(rect, element.Left - Left);
                    Canvas.SetTop(rect, element.Top - Top);
                    canvas.Children.Add(rect);
                    Canvas.SetLeft(number, Canvas.GetLeft(rect));
                    Canvas.SetTop(number, Canvas.GetTop(rect));
                    canvas.Children.Add(number);
                }
            }
            base.Show();
        }