コード例 #1
0
 public void RedrawItem()
 {
     // redraw on every diagram
     foreach (ShapeElement shapeElement in
              PresentationViewsSubject.GetPresentation(ParentModelElement as ModelElement).OfType <ShapeElement>().Distinct())
     {
         shapeElement.Invalidate();
     }
 }
コード例 #2
0
        public void RedrawItem()
        {
            List <ShapeElement> shapeElements = PresentationViewsSubject.GetPresentation(this).OfType <ShapeElement>().ToList();

            foreach (ShapeElement shapeElement in shapeElements)
            {
                shapeElement.Invalidate();
            }
        }
コード例 #3
0
ファイル: ModelAttribute.cs プロジェクト: suprcodr/EFDesigner
 /// <summary>Redraws the presentation element on any diagram rendering this model element</summary>
 public void RedrawItem()
 {
    if (ParentModelElement != null)
    {
       List<ShapeElement> shapeElements = PresentationViewsSubject.GetPresentation(ParentModelElement as ModelElement).OfType<ShapeElement>().ToList();
       foreach (ShapeElement shapeElement in shapeElements)
          shapeElement.Invalidate();
    }
 }
コード例 #4
0
 /// <summary>Redraws the presentation element on any diagram rendering this model element</summary>
 public void RedrawItem()
 {
    if (ParentModelElement != null)
    {
       foreach (ShapeElement shapeElement in
             PresentationViewsSubject.GetPresentation(ParentModelElement as ModelElement).OfType<ShapeElement>().Distinct())
          shapeElement.Invalidate();
    }
 }
コード例 #5
0
 /// <summary>
 /// Redraws the association on every open diagram
 /// </summary>
 /// <param name="element"></param>
 /// <param name="sourceDeleteAction"></param>
 /// <param name="targetDeleteAction"></param>
 /// <param name="sourceMultiplicity"></param>
 /// <param name="targetMultiplicity"></param>
 public static void UpdateAssociationDisplay(Association element
                                             , DeleteAction?sourceDeleteAction = null
                                             , DeleteAction?targetDeleteAction = null)
 {
     // redraw on every diagram
     foreach (AssociationConnector connector in PresentationViewsSubject.GetPresentation(element).OfType <AssociationConnector>().Distinct())
     {
         UpdateAssociationDisplay(connector, sourceDeleteAction, targetDeleteAction);
     }
 }
コード例 #6
0
        public static void UpdateClassDisplay(ModelClass element)
        {
            if (element == null)
            {
                return;
            }

            // update on every diagram
            foreach (ClassShape classShape in PresentationViewsSubject
                     .GetPresentation(element)
                     .OfType <ClassShape>())
            {
                if (element.IsAbstract)
                {
                    classShape.OutlineColor     = Color.OrangeRed;
                    classShape.OutlineThickness = 0.03f;
                    classShape.OutlineDashStyle = DashStyle.Dot;
                }
                else if (element.IsDependentType)
                {
                    classShape.OutlineColor     = Color.ForestGreen;
                    classShape.OutlineThickness = 0.03f;
                    classShape.OutlineDashStyle = DashStyle.Dot;
                }
                else if (element.ImplementNotify)
                {
                    classShape.OutlineColor     = Color.CornflowerBlue;
                    classShape.OutlineThickness = 0.03f;
                    classShape.OutlineDashStyle = DashStyle.Dot;
                }
                else
                {
                    classShape.OutlineColor     = Color.Black;
                    classShape.OutlineThickness = 0.01f;
                    classShape.OutlineDashStyle = DashStyle.Solid;
                }
            }

            // ensure foreign key attributes have the proper setting to surface the right glyph
            foreach (ModelAttribute modelAttribute in element.Attributes)
            {
                modelAttribute.IsForeignKey = false;
            }

            foreach (ModelAttribute modelAttribute in element.Store.ElementDirectory.AllElements
                     .OfType <Association>()
                     .Where(a => a.Dependent == element &&
                            !string.IsNullOrEmpty(a.FKPropertyName))
                     .SelectMany(association => association.FKPropertyName.Split(',')
                                 .Select(propertyName => element.Attributes.FirstOrDefault(attr => attr.Name == propertyName))
                                 .Where(modelAttribute => modelAttribute != null)))
            {
                modelAttribute.IsForeignKey = true;
            }
        }
コード例 #7
0
 /// <summary>
 /// Invalidate all presentation elements associated with a given <see cref="ModelElement"/>
 /// </summary>
 private static void InvalidateAssociatedDisplay(ModelElement element)
 {
     foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element))
     {
         IInvalidateDisplay updateDisplay;
         if (null != (updateDisplay = pel as IInvalidateDisplay))
         {
             updateDisplay.InvalidateRequired(true);
         }
     }
 }
コード例 #8
0
        private static void ShapeDeletedEvent(object sender, ElementDeletedEventArgs e)
        {
            PresentationViewsSubject link = e.ModelElement as PresentationViewsSubject;
            ModelElement             backingElement;

            if (!(backingElement = link.Subject).IsDeleted &&
                link.Presentation is IDisplayMultiplePresentations)
            {
                InvalidateRemainingShapes(backingElement, null);
            }
        }
コード例 #9
0
 public static void UpdateAssociationDisplay(Association element
                                             , DeleteAction?sourceDeleteAction = null
                                             , DeleteAction?targetDeleteAction = null
                                             , Multiplicity?sourceMultiplicity = null
                                             , Multiplicity?targetMultiplicity = null)
 {
     foreach (AssociationConnector connector in PresentationViewsSubject.GetPresentation(element).OfType <AssociationConnector>().Distinct())
     {
         UpdateAssociationDisplay(connector, sourceDeleteAction, targetDeleteAction);
     }
 }
コード例 #10
0
ファイル: SelectExtension.cs プロジェクト: gaelgael5/galileo
        public static void Select(IEnumerable <DslModeling::ModelElement> items)
        {
            List <NodeShape> shapes = new List <NodeShape>(items.Count());

            foreach (var item in items)
            {
                NodeShape shape = (NodeShape)PresentationViewsSubject.GetPresentation(item).FirstOrDefault();
                shapes.Add(shape);
            }

            Select(shapes);
        }
コード例 #11
0
 public static void UpdatePresentationElement <T>(this ModelElement modelElement, Action <T> updateAction) where T : PresentationElement
 {
     if (PresentationViewsSubject.GetPresentation(modelElement).Count == 1)
     {
         PresentationElement presentationElement = PresentationViewsSubject.GetPresentation(modelElement)[0];
         T pe = presentationElement as T;
         if (pe != null)
         {
             updateAction(pe);
         }
     }
 }
コード例 #12
0
        public void RedrawItem()
        {
            ModelElement[] modelElements = { this, Source, Target };

            // redraw on every diagram
            foreach (ShapeElement shapeElement in
                     modelElements.SelectMany(modelElement => PresentationViewsSubject.GetPresentation(modelElement)
                                              .OfType <ShapeElement>()
                                              .Distinct()))
            {
                shapeElement.Invalidate();
            }
        }
コード例 #13
0
ファイル: RoleNameShape.cs プロジェクト: kevinmiles/NORMA
 /// <summary>
 /// Adjust the role name display for all shapes corresponding a given fact type
 /// </summary>
 public static void UpdateRoleNameDisplay(FactType factType)
 {
     foreach (PresentationElement element in PresentationViewsSubject.GetPresentation(factType))
     {
         FactTypeShape factTypeShape;
         ORMDiagram    diagram;
         if (null != (factTypeShape = element as FactTypeShape) &&
             null != (diagram = factTypeShape.Diagram as ORMDiagram))
         {
             UpdateRoleNameDisplay(factType, factTypeShape, diagram, false);
         }
     }
 }
コード例 #14
0
        /// <summary>
        /// Repaints the compartment shape for the given element.
        /// </summary>
        private static void RepaintCompartmentShape(CustomizableElementSchema element)
        {
            Guard.NotNull(() => element, element);

            foreach (var shape in PresentationViewsSubject.GetPresentation(element))
            {
                CompartmentShape compartment = shape as CompartmentShape;
                if (compartment != null)
                {
                    compartment.Invalidate();
                }
            }
        }
コード例 #15
0
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            base.ElementPropertyChanged(e);

            var changedProperty = e.ModelElement as ScalarProperty;

            Debug.Assert(changedProperty != null);

            // this rule will fire if a PropertyRef gets deleted (this happens if a keyed property that has a sibling keyed property is deleted),
            // in which case we ignore this change.
            if (changedProperty.IsDeleted)
            {
                return;
            }

            Debug.Assert(changedProperty.EntityType != null && changedProperty.EntityType.EntityDesignerViewModel != null);

            if (changedProperty != null &&
                changedProperty.EntityType != null &&
                changedProperty.EntityType.EntityDesignerViewModel != null)
            {
                var diagram = changedProperty.EntityType.EntityDesignerViewModel.GetDiagram();
                Debug.Assert(diagram != null, "EntityDesignerDiagram is null");

                // if EntityKey property changed, we need to invalidate properties compartment for this property to refresh the icon
                if (e.DomainProperty.Id == ScalarProperty.EntityKeyDomainPropertyId)
                {
                    foreach (var pe in PresentationViewsSubject.GetPresentation(changedProperty.EntityType))
                    {
                        var entityShape = pe as EntityTypeShape;
                        if (entityShape != null)
                        {
                            entityShape.PropertiesCompartment.Invalidate(true);
                        }
                    }
                }

                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null);
                // don't do the auto update stuff if we are in the middle of deserialization
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    if (e.DomainProperty.Id == ScalarProperty.EntityKeyDomainPropertyId)
                    {
                        ViewModelChangeContext.GetNewOrExistingContext(tx)
                        .ViewModelChanges.Add(new ScalarPropertyKeyChange(changedProperty));
                    }
                }
            }
        }
コード例 #16
0
        public static void AjustarAoPadrao(Simbolo simbolo)
        {
            var compartimento = PresentationViewsSubject.GetPresentation(simbolo)
                                .FirstOrDefault() as SimboloCompartment;

            if (compartimento == null)
            {
                return;
            }

            var novoSize = new SizeD(2, compartimento.Size.Height);

            compartimento.Size = novoSize;
        }
コード例 #17
0
ファイル: Association.cs プロジェクト: tdabek/EFDesigner
        public void RedrawItem()
        {
            ModelElement[] modelElements = { this, Source, Target };

            List <ShapeElement> shapeElements =
                modelElements.SelectMany(modelElement => PresentationViewsSubject.GetPresentation(modelElement)
                                         .OfType <ShapeElement>())
                .ToList();

            foreach (ShapeElement shapeElement in shapeElements)
            {
                shapeElement.Invalidate();
            }
        }
コード例 #18
0
        /// <summary>
        /// Force a redraw of the associated presentation elements on a given diagram.
        /// This is used when a transaction is not active to update for a temporary
        /// display change.
        /// </summary>
        private static void RedrawPelsOnDiagram(ModelElement element, Diagram diagram)
        {
            LinkedElementCollection <PresentationElement> pels = PresentationViewsSubject.GetPresentation(element);
            int pelsCount = pels.Count;

            for (int i = 0; i < pelsCount; ++i)
            {
                ShapeElement shape = pels[i] as ShapeElement;
                if (shape != null && shape.Diagram == diagram)
                {
                    shape.Invalidate(true);
                }
            }
        }
コード例 #19
0
ファイル: RoleNameShape.cs プロジェクト: kevinmiles/NORMA
        /// <summary>
        /// Removes the RoleNameShape from the associated Role
        /// </summary>
        public static void RemoveRoleNameShapeFromRole(Role role)
        {
            LinkedElementCollection <PresentationElement> pels = PresentationViewsSubject.GetPresentation(role);
            int pelCount = pels.Count;

            for (int i = pelCount - 1; i >= 0; --i)
            {
                RoleNameShape pel = pels[i] as RoleNameShape;
                if (pel != null)
                {
                    pel.Delete();
                }
            }
        }
コード例 #20
0
        /// <summary>
        ///     Do the following when a new Inheritance is created:
        ///     - Display a warning and proceed per user choice
        ///     - Remove any keys defined in the derived entity (and their derived entities down the hierarchy)
        /// </summary>
        /// <param name="e"></param>
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            base.ElementAdded(e);

            var addedInheritance = e.ModelElement as Inheritance;

            Debug.Assert(addedInheritance != null);
            Debug.Assert(addedInheritance.SourceEntityType != null);
            Debug.Assert(addedInheritance.SourceEntityType.EntityDesignerViewModel != null);
            Debug.Assert(addedInheritance.TargetEntityType != null);

            if (addedInheritance != null &&
                addedInheritance.SourceEntityType != null &&
                addedInheritance.SourceEntityType.EntityDesignerViewModel != null &&
                addedInheritance.TargetEntityType != null)
            {
                // We need to invalidate the target entitytypeshape element; so base type name will be updated correctly.
                foreach (var pe in  PresentationViewsSubject.GetPresentation(addedInheritance.TargetEntityType))
                {
                    var entityShape = pe as EntityTypeShape;
                    if (entityShape != null)
                    {
                        entityShape.Invalidate();
                    }
                }

                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null);
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    var source    = addedInheritance.SourceEntityType;
                    var viewModel = source.EntityDesignerViewModel;

                    var b = viewModel.ModelXRef.GetExisting(addedInheritance.SourceEntityType) as EntityType;
                    var d = viewModel.ModelXRef.GetExisting(addedInheritance.TargetEntityType) as EntityType;

                    var baseEntity    = b as ConceptualEntityType;
                    var derivedEntity = d as ConceptualEntityType;

                    Debug.Assert(b != null ? baseEntity != null : true, "EntityType is not ConceptualEntityType");
                    Debug.Assert(d != null ? derivedEntity != null : true, "EntityType is not ConceptualEntityType");

                    Debug.Assert(baseEntity != null && derivedEntity != null);

                    ViewModelChangeContext.GetNewOrExistingContext(tx)
                    .ViewModelChanges.Add(new InheritanceAdd(addedInheritance, baseEntity, derivedEntity));
                }
            }
        }
コード例 #21
0
        public static DslModeling::ElementLink Connect(DslModeling::ModelElement source, DslModeling::ModelElement target)
        {
            if (source == null)
            {
                throw new global::System.ArgumentNullException("source");
            }
            if (target == null)
            {
                throw new global::System.ArgumentNullException("target");
            }

            if (CanAcceptSourceAndTarget(source, target))
            {
                if (target is ExternalComponent)
                {
                    if (source is DataLayer)
                    {
                        return(new DataLayerReferencesExternalComponent((DataLayer)source, (ExternalComponent)target));
                    }
                }

                // Enregistrement de la position initiale de l'élément initial pour aligner
                // les élements verticalement dans le cas d'une référence multicouches.
                IList <PresentationElement> shapes = null;
                // On privilégie la source
                if (source is ClassImplementation || source is ServiceContract)
                {
                    shapes = PresentationViewsSubject.GetPresentation(source);
                }
                else if (target is ClassImplementation || target is ServiceContract)
                {
                    shapes = PresentationViewsSubject.GetPresentation(target);
                }

                if (shapes != null && shapes.Count > 0)
                {
                    UnplacedModelHelper.RegisterInitialPosition(source.Store, ((NodeShape)shapes[0]).AbsoluteBoundingBox.X);
                }

                ElementLink link = CreateLink(source, target);
                if (link != null)
                {
                    return(link);
                }
            }

            global::System.Diagnostics.Debug.Fail("Having agreed that the connection can be accepted we should never fail to make one.");
            throw new global::System.InvalidOperationException();
        }
コード例 #22
0
        protected override void OnSelectionChanged(System.EventArgs e)
        {
            base.OnSelectionChanged(e);

            // restore cached settings
            highlightCache?.ResetShapeColors();
            highlightCache = null;

            if (PrimarySelection is ModelElement modelElement &&
                PresentationViewsSubject.GetPresentation(modelElement).FirstOrDefault() is IHighlightFromModelExplorer selectedShape)
            {
                highlightCache = new HighlightCache(selectedShape);
                highlightCache.SetShapeColors();
            }
        }
コード例 #23
0
        /// <summary>
        /// Looks for a shape that represents a model element
        /// </summary>
        /// <param name="modelElement">a model element that is represented by a compartment shape</param>
        /// <returns>the shape</returns>
        private static ICompartmentMouseActionTrackable GetFirstCompartmentShapeForModelElement(ModelElement modelElement)
        {
            LinkedElementCollection <PresentationElement> presentations = PresentationViewsSubject.GetPresentation(modelElement);

            foreach (PresentationElement element in presentations)
            {
                ICompartmentMouseActionTrackable shape = element as ICompartmentMouseActionTrackable;
                if (shape != null)
                {
                    return(shape);
                }
            }

            return(null);
        }
コード例 #24
0
 /// <summary>
 /// Helper function for preferred identifier validation
 /// </summary>
 private static void InvalidateForPreferredIdentifier(UniquenessConstraint constraint)
 {
     if (!constraint.IsInternal &&
         !constraint.IsDeleted)
     {
         foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(constraint))
         {
             ExternalConstraintShape constraintShape = pel as ExternalConstraintShape;
             if (constraintShape != null)
             {
                 constraintShape.Invalidate(true);
             }
         }
     }
 }
コード例 #25
0
        internal static void UpdateDisplayForCascadeDelete(Association element,
                                                           DeleteAction?sourceDeleteAction = null,
                                                           DeleteAction?targetDeleteAction = null,
                                                           Multiplicity?sourceMultiplicity = null,
                                                           Multiplicity?targetMultiplicity = null)
        {
            ModelRoot modelRoot = element.Store.ElementDirectory.FindElements <ModelRoot>().FirstOrDefault();

            sourceDeleteAction = sourceDeleteAction ?? element.SourceDeleteAction;
            targetDeleteAction = targetDeleteAction ?? element.TargetDeleteAction;
            sourceMultiplicity = sourceMultiplicity ?? element.SourceMultiplicity;
            targetMultiplicity = targetMultiplicity ?? element.TargetMultiplicity;

            bool cascade = modelRoot.ShowCascadeDeletes &&
                           element.Persistent &&
                           (sourceMultiplicity == Multiplicity.One ||
                            targetMultiplicity == Multiplicity.One ||
                            targetDeleteAction == DeleteAction.Cascade ||
                            sourceDeleteAction == DeleteAction.Cascade);

            List <AssociationConnector> changeColor =
                PresentationViewsSubject.GetPresentation(element)
                .OfType <AssociationConnector>()
                .Where(connector => (cascade && connector.Color != Color.Red) ||
                       (!cascade && connector.Color != Color.Black))
                .ToList();

            List <AssociationConnector> changeStyle =
                PresentationViewsSubject.GetPresentation(element)
                .OfType <AssociationConnector>()
                .Where(connector => (cascade && connector.DashStyle != DashStyle.Dash) ||
                       (!cascade && connector.DashStyle != DashStyle.Solid))
                .ToList();

            foreach (AssociationConnector connector in changeColor)
            {
                connector.Color = cascade
                                 ? Color.Red
                                 : Color.Black;
            }

            foreach (AssociationConnector connector in changeStyle)
            {
                connector.DashStyle = cascade
                                     ? DashStyle.Dash
                                     : DashStyle.Solid;
            }
        }
コード例 #26
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);
             }
         }
     }
 }
コード例 #27
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();
                    }
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Create an EGP to add to the clipboard.
        /// Called when the elements to be copied or dragged have been
        /// collected into an ElementGroup and after the roots have been marked.
        /// This override ensures that the shapes and connectors of each element and relationship are included.
        /// </summary>
        /// <param name="elementGroup">Group of elements and maybe shapes</param>
        /// <param name="elements">The original set of elements to be added, not including children, relationships, etc. Typically, the current selection.</param>
        /// <param name="closureType">Copy or Delete - specifies which propagation scheme to follow</param>
        /// <returns>EGP </returns>
        protected override ElementGroupPrototype CreateElementGroupPrototype(ElementGroup elementGroup, ICollection <ModelElement> elements, ClosureType closureType)
        {
            // Get the elements already in the group:
            ModelElement[] mels = elementGroup.ModelElements
                                  .Concat(elementGroup.ElementLinks) // Omit if the paste target is not the diagram.
                                  .ToArray();

            // Get their shapes and connectors:
            IEnumerable <PresentationElement> shapes =
                mels.SelectMany(mel =>
                                PresentationViewsSubject.GetPresentation(mel));

            elementGroup.AddRange(shapes, true);

            return(base.CreateElementGroupPrototype(elementGroup, elements, closureType));
        }
コード例 #29
0
ファイル: DiagramUtil.cs プロジェクト: psulek/doemd
        public static ShapeElement GetModelElementFirstShape(ModelElement modelElement)
        {
            LinkedElementCollection <PresentationElement> presentations =
                PresentationViewsSubject.GetPresentation(modelElement);

            foreach (ModelElement element in presentations)
            {
                ShapeElement shapeElement = (element as ShapeElement);

                if (shapeElement != null)
                {
                    return(shapeElement);
                }
            }
            return(null);
        }
コード例 #30
0
        /// <summary>
        /// Repaints the connector shapes for given links.
        /// </summary>
        private static void RepaintRelationshipConnectors <T>(ModelElement element) where T : ElementLink
        {
            var link = element as T;

            if (link != null)
            {
                foreach (var shape in PresentationViewsSubject.GetPresentation(link))
                {
                    BinaryLinkShape connector = shape as BinaryLinkShape;
                    if (connector != null)
                    {
                        connector.Invalidate();
                    }
                }
            }
        }