コード例 #1
0
        private void SetSelectedRectangle(Point beginPoint, Point endPoint)
        {
            // Make sure x/y are top-left, and width/height is bottom-right
            Point a = Utils.Min(beginPoint, endPoint);
            Point b = Utils.Max(beginPoint, endPoint);

            var newRect = Rectangle.FromLTRB(a.X, a.Y, b.X, b.Y);

            // Determine if there is a need to update shapes
            if (selectedRectangle == newRect)
            {
                return;
            }

            // Update selected rectangle
            selectedRectangle = newRect;

            // Update selected shapes
            var shapes = Canvas.Instance.GetShapesByRectangle(selectedRectangle);

            ClickData.Clear(true);
            ClickData.Set(shapes);

            // Update borders of selected shapes
            // This may be needed
            Canvas.Instance.Invalidate();
        }