/// <summary> /// If a new child shape was not placed, then defer to /// PlaceAsChildOf on the child. Note that AutoResize /// has not been called on the child prior to this call. /// </summary> /// <param name="child">A new child shape element</param> /// <param name="childWasPlaced">false if the child element was not previously placed.</param> /// <param name="createdDuringViewFixup">Whether this shape was created as part of a view fixup</param> protected override void OnChildConfigured(ShapeElement child, bool childWasPlaced, bool createdDuringViewFixup) { // Don't check childWasPlaced here during drag-drop. In this case, // childWasPlace will be true if the parent shape was placed, so is // only relevant for our code base for the top-level shapes, in which // case the OnChildConfigured for the dropped shape is called on the // diagram, not a base shape. Any derived shape that allows placed // drag from the toolbox (etc) onto child shapes (which none of // the shapes in ORMShapeDomainModel allow), then childWasPlaced should // be tested. if (childWasPlaced) { Transaction transaction = Store.TransactionManager.CurrentTransaction.TopLevelTransaction; if (transaction != null && (DropTargetContext.HasDropTargetContext(transaction) || transaction.Context.ContextInfo.ContainsKey(ORMBaseShape.PlaceAllChildShapes))) { childWasPlaced = false; } } if (!childWasPlaced) { ORMBaseShape baseShape; if (null != (baseShape = child as ORMBaseShape)) { baseShape.PlaceAsChildOf(this, createdDuringViewFixup); } } }
/// <summary> /// Stop all auto shape selection on transaction commit except when /// the item is being dropped. /// </summary> public override IList FixUpDiagramSelection(ShapeElement newChildShape) { if (DropTargetContext.HasDropTargetContext(Store.TransactionManager.CurrentTransaction)) { return(base.FixUpDiagramSelection(newChildShape)); } return(null); }
/// <summary> /// Gets the unplaced shapes for auto layout. /// </summary> /// <param name="store">The store.</param> /// <returns></returns> public static Dictionary <NodeShape, Dictionary <ShapeElement, bool> > GetUnplacedShapesForAutoLayout(Store store) { object obj; store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.TryGetValue( "{FED4CA6E-2FFC-4751-A799-9B3808C384EA}", out obj); if (obj == null) { return(null); } List <ModelElement> elements = obj as List <ModelElement>; Dictionary <NodeShape, Dictionary <ShapeElement, bool> > unplacedShapesMap = new Dictionary <NodeShape, Dictionary <ShapeElement, bool> >(); foreach (ModelElement element in elements) { foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element)) { if (pel is NodeShape) { NodeShape shape = pel as NodeShape; PointD dropLocation = DropTargetContext.GetDropLocation( store.TransactionManager.CurrentTransaction.TopLevelTransaction); shape.AbsoluteBounds = new RectangleD(dropLocation.X, shape.AbsoluteBounds.Y, shape.AbsoluteBounds.Width, shape.AbsoluteBounds.Height); NodeShape parentShape = shape.ParentShape as NodeShape; if (parentShape != null) { Dictionary <ShapeElement, bool> shapeElementMap; if (!unplacedShapesMap.TryGetValue(parentShape, out shapeElementMap)) { shapeElementMap = new Dictionary <ShapeElement, bool>(); unplacedShapesMap.Add(parentShape, shapeElementMap); } shapeElementMap.Add(shape, true); } } } } return(unplacedShapesMap); }
/// <summary> /// Construct a <code>DropTargetEvent</code> object with /// the specified <code>DropTargetContext</code>. /// <P> </summary> /// <param name="dtc"> The <code>DropTargetContext</code> </param> /// <exception cref="NullPointerException"> if {@code dtc} equals {@code null}. </exception> /// <seealso cref= #getSource() </seealso> /// <seealso cref= #getDropTargetContext() </seealso> public DropTargetEvent(DropTargetContext dtc) : base(dtc.DropTarget) { Context = dtc; }