コード例 #1
0
        protected virtual void SelectLassoComponents(Rectangle lasso)//TODO: make hit test strategy pluggable
        {
            double left   = lasso.GetValue <double>(Canvas.LeftProperty);
            double top    = lasso.GetValue <double>(Canvas.TopProperty);
            double width  = lasso.Width;
            double height = lasso.Height;
            Rect   r      = new Rect(left, top, width, height);
            List <IDesignableControl> selection = new List <IDesignableControl>();

            foreach (var u in LayoutRoot.Children)
            {
                if (u is IDesignableControl)
                {
                    IDesignableControl test    = (IDesignableControl)u;
                    Point[]            corners = test.Visual.GetCanvasCorners();
                    for (int i = 0; i < corners.Length; ++i)
                    {
                        if (r.Contains(corners[i]))
                        {
                            selection.Add(test);
                            break;
                        }
                    }
                }
            }

            SelectionSvc.Select(selection);
        }
コード例 #2
0
 private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     SelectionSvc.Select(null);
     _isSelecting          = true;
     SelectDrawingBehavior = new RectangleDrawingBehavior(LayoutRoot);
     LayoutRoot.CaptureMouse();
     _localMousePos = e.GetPosition(this);
     _selectingRect = (Rectangle)SelectDrawingBehavior.StartDrawing(_localMousePos);
 }