コード例 #1
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 });
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// A mouse click event has occurred on this ExternalConstraintShape
 /// </summary>
 /// <param name="e">DiagramPointEventArgs</param>
 public override void OnDoubleClick(DiagramPointEventArgs e)
 {
     if (!ORMBaseShape.AttemptErrorActivation(e))
     {
         ActivateNewRoleSequenceConnectAction(e.DiagramClientView);
     }
     base.OnDoubleClick(e);
 }
コード例 #3
0
        private static void UpdateRequiredEvent(object sender, ElementPropertyChangedEventArgs e)
        {
            ORMBaseShape shape = (ORMBaseShape)e.ModelElement;

            if (!shape.IsDeleted)
            {
                shape.BeforeInvalidate();
                shape.Invalidate(Math.Abs(unchecked ((long)e.OldValue - (long)e.NewValue)) != 1L);
            }
        }
コード例 #4
0
        private static void ShapeAddedEvent(object sender, ElementAddedEventArgs e)
        {
            ORMBaseShape shape = e.ModelElement as ORMBaseShape;
            ModelElement backingElement;

            if (shape is IDisplayMultiplePresentations &&
                null != (backingElement = shape.ModelElement))
            {
                InvalidateRemainingShapes(backingElement, shape);
            }
        }
コード例 #5
0
 private static void InvalidateErrorOwnerDisplay(ModelElement element)
 {
     if (!element.IsDeleting)
     {
         LinkedElementCollection <PresentationElement> pels = PresentationViewsSubject.GetPresentation(element);
         int pelCount = pels.Count;
         for (int i = 0; i < pelCount; ++i)
         {
             ORMBaseShape shape = pels[i] as ORMBaseShape;
             if (shape != null && !shape.IsDeleting)
             {
                 shape.InvalidateRequired(true);
             }
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// ChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.Note), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority;
        /// </summary>
        private static void NoteChangeRule(ElementPropertyChangedEventArgs e)
        {
            Guid attributeGuid = e.DomainProperty.Id;

            if (attributeGuid == Note.TextDomainPropertyId)
            {
                foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(e.ModelElement))
                {
                    ORMBaseShape shape = pel as ORMBaseShape;
                    if (shape != null)
                    {
                        shape.AutoResize();
                    }
                }
            }
        }
コード例 #7
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);
     }
 }
コード例 #8
0
 /// <summary>
 /// Attempt model error activation
 /// </summary>
 public override void OnDoubleClick(DiagramPointEventArgs e)
 {
     ORMBaseShape.AttemptErrorActivation(e);
     base.OnDoubleClick(e);
 }
コード例 #9
0
ファイル: DomainRelationships.cs プロジェクト: ozialien/NORMA
 public static DslModeling::LinkedElementCollection <global::Microsoft.VisualStudio.Modeling.ModelElement> GetExtensionCollection(ORMBaseShape element)
 {
     return(new DslModeling::LinkedElementCollection <global::Microsoft.VisualStudio.Modeling.ModelElement>(element, ExtendedElementDomainRoleId));
 }
コード例 #10
0
ファイル: DomainRelationships.cs プロジェクト: ozialien/NORMA
 public static void SetExtendedElement(global::Microsoft.VisualStudio.Modeling.ModelElement element, ORMBaseShape newExtendedElement)
 {
     DslModeling::DomainRoleInfo.SetLinkedElement(element, ExtensionDomainRoleId, newExtendedElement);
 }
コード例 #11
0
ファイル: DomainRelationships.cs プロジェクト: ozialien/NORMA
 /// <summary>
 /// Constructor
 /// Creates a ORMBaseShapeHasExtensionElement link in the same Partition as the given ORMBaseShape
 /// </summary>
 /// <param name="source">ORMBaseShape to use as the source of the relationship.</param>
 /// <param name="target">ModelElement to use as the target of the relationship.</param>
 public ORMBaseShapeHasExtensionElement(ORMBaseShape source, global::Microsoft.VisualStudio.Modeling.ModelElement target)
     : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[] { new DslModeling::RoleAssignment(ORMBaseShapeHasExtensionElement.ExtendedElementDomainRoleId, source), new DslModeling::RoleAssignment(ORMBaseShapeHasExtensionElement.ExtensionDomainRoleId, target) }, null)
 {
 }
コード例 #12
0
        /// <summary>
        /// Helper function to keep all relative shapes equidistant from
        /// a shape when the shape bounds change.
        /// </summary>
        /// <param name="e">ElementPropertyChangedEventArgs</param>
        protected static void MaintainRelativeShapeOffsetsForBoundsChange(ElementPropertyChangedEventArgs e)
        {
            Guid attributeId = e.DomainProperty.Id;

            if (attributeId == ORMBaseShape.AbsoluteBoundsDomainPropertyId)
            {
                ORMBaseShape parentShape = e.ModelElement as ORMBaseShape;
                RectangleD   oldBounds   = (RectangleD)e.OldValue;
                if (oldBounds.IsEmpty ||
                    oldBounds.Size == parentShape.DefaultSize ||
                    e.ModelElement.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.ContainsKey(ORMBaseShape.PlaceAllChildShapes))
                {
                    // Initializing, let normal placement win
                    return;
                }
                RectangleD newBounds = (RectangleD)e.NewValue;
                SizeD      oldSize   = oldBounds.Size;
                SizeD      newSize   = newBounds.Size;
                double     xChange   = newSize.Width - oldSize.Width;
                double     yChange   = newSize.Height - oldSize.Height;
                bool       checkX    = !VGConstants.FuzzZero(xChange, VGConstants.FuzzDistance);
                bool       checkY    = !VGConstants.FuzzZero(yChange, VGConstants.FuzzDistance);
                if (checkX || checkY)
                {
                    LinkedElementCollection <ShapeElement> childShapes = parentShape.RelativeChildShapes;
                    int childCount = childShapes.Count;
                    if (childCount != 0)
                    {
                        for (int i = 0; i < childCount; ++i)
                        {
                            bool      changeBounds = false;
                            PointD    change       = default(PointD);
                            NodeShape childShape   = childShapes[i] as NodeShape;
                            if (childShape != null)
                            {
                                RectangleD childBounds = childShape.AbsoluteBounds;
                                if (checkX)
                                {
                                    double newRight  = newBounds.Right - xChange;
                                    double childLeft = childBounds.Left;
                                    if (childLeft > newRight ||                                       // Completely to the right
                                        (childBounds.Right > newRight && childLeft > newBounds.Left)) // Straddles right edge
                                    {
                                        change.X     = xChange;
                                        changeBounds = true;
                                    }
                                }
                                if (checkY)
                                {
                                    double newBottom = newBounds.Bottom - yChange;
                                    double childTop  = childBounds.Top;
                                    if (childTop > newBottom ||                                       // Completely below
                                        (childBounds.Bottom > newBottom && childTop > newBounds.Top)) // Straddles bottom edge
                                    {
                                        change.Y     = yChange;
                                        changeBounds = true;
                                    }
                                }
                                if (changeBounds)
                                {
                                    childBounds.Offset(change);
                                    childShape.AbsoluteBounds = childBounds;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #13
0
ファイル: ORMBaseShape.cs プロジェクト: cjheath/NORMA
		private static void InvalidateRemainingShapes(ModelElement backingElement, ORMBaseShape ignoreShape)
		{
			LinkedElementCollection<PresentationElement> pels = PresentationViewsSubject.GetPresentation(backingElement);
			int pelCount = pels.Count;
			if (ignoreShape == null || pelCount > 1)
			{
				for (int i = 0; i < pelCount; ++i)
				{
					PresentationElement pel = pels[i];
					ORMBaseShape updateShape;
					if (pel != ignoreShape &&
						null != (updateShape = pel as ORMBaseShape))
					{
						updateShape.Invalidate();
					}
				}
			}
		}