Beispiel #1
0
        /// <summary>
        /// Handle the mouse left button up event.  Here we actually process the selected rectangle
        /// if any by first raising an event for client to receive then also zooming to that rectangle
        /// if ZoomSelection is true
        /// </summary>
        /// <param name="sender">Mouse</param>
        /// <param name="e">Mouse button information</param>
        void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            _watching = false;
            if (_selectionRectVisual != null)
            {
                Mouse.Capture(_target, CaptureMode.None);
                Point  pos = e.GetPosition(_container);
                double f   = Math.Min(Math.Abs(pos.X - _mouseDownPoint.X), Math.Abs(pos.Y - _mouseDownPoint.Y));
                Rect   r   = GetSelectionRect(pos);
                _selectionRect = r;
                if (Selected != null)
                {
                    Selected(this, EventArgs.Empty);
                }

                if (_zoomSelection && f > _zoomSizeThreshold)
                {
                    _zoom.ZoomToRect(r);
                }

                _container.Children.Remove(_selectionRectVisual);
                _selectionRectVisual = null;
            }
        }