コード例 #1
0
        /// <summary>
        /// ChangeRule: typeof(ORMBaseBinaryLinkShape), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AutoLayoutShapesRulePriority;
        /// Keep relative child elements a fixed distance away from the fact
        /// when the shape changes.
        /// </summary>
        private static void LinkChangeRule(ElementPropertyChangedEventArgs e)
        {
            Guid attributeId = e.DomainProperty.Id;

            if (attributeId == ORMBaseBinaryLinkShape.EdgePointsDomainPropertyId)
            {
                ORMBaseBinaryLinkShape parentShape = e.ModelElement as ORMBaseBinaryLinkShape;
                LinkedElementCollection <ShapeElement> childShapes = parentShape.RelativeChildShapes;
                int childCount = childShapes.Count;
                for (int i = 0; i < childCount; ++i)
                {
                    LinkConnectorShape linkConnector = childShapes[i] as LinkConnectorShape;
                    if (linkConnector != null)
                    {
                        RectangleD bounds = parentShape.AbsoluteBoundingBox;
                        linkConnector.Location = new PointD(bounds.Width / 2, bounds.Height / 2);
                        ReadOnlyCollection <LinkConnectsToNode> links = DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(linkConnector, LinkConnectsToNode.NodesDomainRoleId);
                        int linksCount = links.Count;
                        for (int j = 0; j < linksCount; ++j)
                        {
                            LinkConnectsToNode link      = links[j];
                            BinaryLinkShape    linkShape = link.Link as BinaryLinkShape;
                            if (linkShape != null)
                            {
                                // Changing the location is not reliably reconnecting all shapes, especially
                                // during load. Force the link to reconnect with a RecalculateRoute call
                                linkShape.RecalculateRoute();
                            }
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>.
        /// </summary>
        protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action)
        {
            // UNDONE: If we delay attach user interface events (possible in the future for
            // external model scenarios), then we need to check ModelStateEvents here and
            // be more precise in which events are attached that affect model state such as
            // calculated shape size. Currently, this is only called without 'UserInterfaceEvents'
            // for unit-testing.
            if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents)))
            {
                Store store = Store;
                ORMDiagram.ManageEventHandlers(store, eventManager, action);
                ORMBaseShape.ManageEventHandlers(store, eventManager, action);
                ReadingShape.ManageEventHandlers(store, eventManager, action);
                ExternalConstraintShape.ManageEventHandlers(store, eventManager, action);
                RolePlayerLink.ManageEventHandlers(store, eventManager, action);
                ObjectTypeShape.ManageEventHandlers(store, eventManager, action);
                ORMBaseBinaryLinkShape.ManageEventHandlers(store, eventManager, action);
                FactTypeShape.ManageEventHandlers(store, eventManager, action);
                SubtypeLink.ManageEventHandlers(store, eventManager, action);
            }

            if (0 != (reasons & EventSubscriberReasons.DocumentLoaded))
            {
                IORMToolServices             services;
                IORMExtendableElementService extendableElementService;
                if (null != (services = Store as IORMToolServices) &&
                    null != (extendableElementService = services.ExtendableElementService))
                {
                    extendableElementService.RegisterExtensionRoles(new Guid[] { ORMDiagramHasExtensionElement.ExtensionDomainRoleId, ORMBaseShapeHasExtensionElement.ExtensionDomainRoleId });
                }
            }
        }
コード例 #3
0
        private static void UpdateRequiredEvent(object sender, ElementPropertyChangedEventArgs e)
        {
            ORMBaseBinaryLinkShape shape = (ORMBaseBinaryLinkShape)e.ModelElement;

            if (!shape.IsDeleted)
            {
                shape.BeforeInvalidate();
                shape.Invalidate(Math.Abs(unchecked ((long)e.OldValue - (long)e.NewValue)) != 1L);
            }
        }
コード例 #4
0
 /// <summary>
 /// Implements <see cref="IModelingEventSubscriber.ManageModelingEventHandlers"/>.
 /// </summary>
 protected void ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action)
 {
     // UNDONE: If we delay attach user interface events (possible in the future for
     // external model scenarios), then we need to check ModelStateEvents here and
     // be more precise in which events are attached that affect model state such as
     // calculated shape size. Currently, this is only called without 'UserInterfaceEvents'
     // for unit-testing.
     if ((EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents) == (reasons & (EventSubscriberReasons.DocumentLoaded | EventSubscriberReasons.UserInterfaceEvents)))
     {
         Store store = Store;
         ORMBaseShape.ManageEventHandlers(store, eventManager, action);
         ReadingShape.ManageEventHandlers(store, eventManager, action);
         ExternalConstraintShape.ManageEventHandlers(store, eventManager, action);
         RolePlayerLink.ManageEventHandlers(store, eventManager, action);
         ObjectTypeShape.ManageEventHandlers(store, eventManager, action);
         ORMBaseBinaryLinkShape.ManageEventHandlers(store, eventManager, action);
         FactTypeShape.ManageEventHandlers(store, eventManager, action);
         SubtypeLink.ManageEventHandlers(store, eventManager, action);
     }
 }