Beispiel #1
0
        private void Image_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var mousePos = e.GetPosition(OuterGrid);
            var l        = RenderImage.TranslatePoint(new Point(0, 0), OuterGrid);

            if (mousePos.X < l.X)
            {
                return;
            }
            // Capture and track the mouse.
            DrawSelectionBox = true;
            MouseDownPos     = e.GetPosition(OuterGrid);
            OuterGrid.CaptureMouse();

            // Initial placement of the drag selection box.
            Canvas.SetLeft(SelectionBox, MouseDownPos.X);
            Canvas.SetTop(SelectionBox, MouseDownPos.Y);
            SelectionBox.Width  = 0;
            SelectionBox.Height = 0;

            // Make the drag selection box visible.
            SelectionBox.Visibility = Visibility.Visible;
        }