/// <summary> /// Called when the user or program code tries to move or resize the shape, and when the shape is initially created. /// In this case, we restrict the ComponentTerminal to be at a fixed position on the shape, with a fixed size. /// </summary> /// <param name="shape">The shape that is being moved or created.</param> /// <param name="proposedBounds">What the user or code would like.</param> /// <returns>The permitted bounds that are closest to the proposedBounds.</returns> public override RectangleD GetCompliantBounds(ShapeElement shape, RectangleD proposedBounds) { ComponentTerminal terminal = shape.ModelElement as ComponentTerminal; if (terminal == null) { return(proposedBounds); } ComponentTerminalShape terminalShape = shape as ComponentTerminalShape; ComponentShape componentShape = terminalShape.ParentShape as ComponentShape; if (componentShape == null) { return(proposedBounds); } // Location depends on which terminal it is, of which type of shape. PointD relativeLocation = componentShape.GetTerminalLocation(terminal); if (relativeLocation.X > 0 || relativeLocation.Y > 0) { return(new RectangleD(relativeLocation.X - 0.025, relativeLocation.Y - 0.025, proposedBounds.Width, proposedBounds.Height)); } else { return(proposedBounds); } }
public override void OnDoubleClick(DiagramPointEventArgs e) { base.OnDoubleClick(e); ComponentShape shape = e.HitDiagramItem.Shape as ComponentShape; if (ClickReceiverEvent != null && shape != null) { ClickReceiverEvent(shape); e.Handled = true; // else it will be passed to parent shape too. } }
/// <summary> /// Called when the decorator is to be displayed on a particular shape instance. /// Called whenever the diagram is refreshed. /// </summary> /// <param name="parentShape">The shape on which the image is to be displayed.</param> /// <returns></returns> public override Image GetDisplayImage(ShapeElement parentShape) { ComponentShape componentShape = parentShape as ComponentShape; RotateFlipType rotateFlip = rotateFlips[componentShape.RotateFlip]; if (cachedImage[componentShape.RotateFlip] == null) { Image image = base.GetDisplayImage(parentShape).Clone() as Image; if (image != null) { image.RotateFlip(rotateFlip); cachedImage[componentShape.RotateFlip] = image; } } return(cachedImage[componentShape.RotateFlip]); }