Пример #1
0
 /// <summary>
 /// Selects all shapes.
 /// </summary>
 /// <param name="shapes">Shapes to select.</param>
 public static void SelectAll(ShapeCollection shapes)
 {
     foreach (IShape shape in shapes)
     {
         shape.Selected = true;
     }
 }
Пример #2
0
 /// <summary>
 /// Add a ShapeCollection in the current collection.
 /// </summary>
 /// <param name="shapes">ShapeCollection to add.</param>
 public void AddRange(ShapeCollection shapes)
 {
     foreach (IShape shape in shapes)
     {
         Add(shape);
     }
 }
Пример #3
0
        /// <summary>
        /// Selects the shape contains point.
        /// </summary>
        /// <param name="shapes">Shape collection.</param>
        /// <param name="point">Point to check.</param>
        /// <returns>Hit position of the selected shape.</returns>
        protected HitPositions SelectShape(ShapeCollection shapes, Point point)
        {
            if (Control.ModifierKeys != Keys.Control)
            {
                Select.UnselectAll(shapes);
            }

            HitPositions hitPosition = HitPositions.None;

            for (int i = shapes.Count - 1; i >= 0; i--)
            {
                IShape shape = shapes[i];

                hitPosition = shape.HitTest(point);
                if (hitPosition != HitPositions.None)
                {
                    shapes.BringToFront(shape);
                    shape.Selected     = true;
                    _lastSelectedShape = shape;

                    return(hitPosition);
                }
            }

            return(HitPositions.None);
        }
Пример #4
0
 /// <summary>
 /// Unselects all shapes.
 /// </summary>
 /// <param name="shapes">Shapes to unselect.</param>
 public static void UnselectAll(ShapeCollection shapes)
 {
     foreach (IShape shape in shapes)
     {
         shape.Selected = false;
     }
 }
Пример #5
0
        /// <summary>
        /// Clones the collection and its content.
        /// </summary>
        /// <returns>Cloned object.</returns>
        virtual public object Clone()
        {
            ShapeCollection clonedCollection = new ShapeCollection();

            foreach (IShape shape in this)
            {
                clonedCollection.Add(shape.Clone() as IShape);
            }

            return(clonedCollection);
        }
Пример #6
0
        /// <summary>
        /// Gets selected shapes in the collection.
        /// </summary>
        /// <param name="shapes">Shape collection.</param>
        /// <returns>Selected shapes.</returns>
        public static ShapeCollection GetSelectedShapes(ShapeCollection shapes)
        {
            ShapeCollection selectedShapes = new ShapeCollection();

            foreach (IShape shape in shapes)
            {
                if (shape.Selected)
                {
                    selectedShapes.Add(shape);
                }
            }

            return(selectedShapes);
        }
Пример #7
0
        /// <summary>
        /// Transforms all internal shapes into an array of objects.
        /// </summary>
        /// <param name="shapes">Collection to transform.</param>
        /// <returns>Array of object.</returns>
        public static object[] ToObjects(ShapeCollection shapes)
        {
            if (shapes.Count == 0)
            {
                return(null);
            }

            object[] objectShapes = new object[shapes.Count];
            for (int i = 0; i < shapes.Count; i++)
            {
                objectShapes[i] = shapes[i];
            }

            return(objectShapes);
        }
Пример #8
0
        /// <summary>
        /// Updates shapes location and size relative to grid resolution.
        /// </summary>
        /// <param name="shapes">Shapes to update.</param>
        public void SnapToGrid(ShapeCollection shapes)
        {
            foreach (IShape shape in shapes)
            {
                bool selected = shape.Selected;
                bool locked   = shape.Locked;

                shape.Selected = true;
                shape.Locked   = false;

                shape.Location  = GetRoundedPoint(shape.Location);
                shape.Dimension = GetRoundedSize(shape.Dimension);

                shape.Selected = selected;
                shape.Locked   = locked;
            }
        }
Пример #9
0
 /// <summary>
 /// Updates the cursor during the tool actions
 /// </summary>
 /// <param name="document">Informations transferred from DrawingPanel</param>
 /// <param name="shapes">Shapes to manage</param>
 /// <param name="point">Mouse point</param>
 /// <returns></returns>
 virtual public bool UpdateCursor(IDocument document, ShapeCollection shapes, Point point)
 {
     return(false);
 }