コード例 #1
0
ファイル: TransactionHelper.cs プロジェクト: malain/candle
        /// <summary>
        /// Liste des shapes à positionner
        /// </summary>
        /// <param name="store">The store.</param>
        /// <returns></returns>
        public static List <NodeShape> GetUnplacedShapes(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>;
            List <NodeShape>    shapes   = new List <NodeShape>();

            foreach (ModelElement element in elements)
            {
                foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element))
                {
                    if (pel is NodeShape)
                    {
                        NodeShape shape = pel as NodeShape;
                        shapes.Add(shape);
                    }
                }
            }
            return(shapes);
        }
コード例 #2
0
        // traverse according to layout positions
        public IEnumerator <VDWidget> GetEnumerator()
        {
            List <NodeShape> childShapeList = new List <NodeShape>();
            var shapes = PresentationViewsSubject.GetPresentation(m_rootWidget);

            if (shapes != null && shapes.Count > 0)
            {
                NodeShape parentShape = shapes[0] as NodeShape;
                if (parentShape != null)
                {
                    foreach (var shape in parentShape.NestedChildShapes)
                    {
                        NodeShape childShape = shape as NodeShape;
                        if (childShape != null)
                        {
                            childShapeList.Add(childShape);
                        }
                    }
                }
            }

            // traverse according to position, row first
            childShapeList.Sort((a, b) =>
            {
                if (a.Location.Y - b.Location.Y > Utility.NumberHelper.DOUBLE_DIFFERENCE)
                {
                    return(1);
                }
                else if (b.Location.Y - a.Location.Y > Utility.NumberHelper.DOUBLE_DIFFERENCE)
                {
                    return(-1);
                }
                else if (a.Location.X - b.Location.X > Utility.NumberHelper.DOUBLE_DIFFERENCE)
                {
                    return(1);
                }
                else if (b.Location.X - a.Location.X > Utility.NumberHelper.DOUBLE_DIFFERENCE)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            });

            //
            List <VDWidget> childWidgets = new List <VDWidget>();

            foreach (NodeShape shape in childShapeList)
            {
                VDWidget widget = shape.ModelElement as VDWidget;
                if (widget != null)
                {
                    childWidgets.Add(widget);
                }
            }

            return(childWidgets.GetEnumerator());
        }
コード例 #3
0
 /// <summary>
 /// ChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ValueComparisonConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority;
 /// </summary>
 private static void ValueComparisonConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e)
 {
     if (e.DomainProperty.Id == ValueComparisonConstraint.OperatorDomainPropertyId)
     {
         ModelElement element = e.ModelElement;
         if (!element.IsDeleted)
         {
             // Redraw the ring constraint wherever it is displayed.
             foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element))
             {
                 ValueComparisonConstraintShape constraintShape;
                 if (null != (constraintShape = pel as ValueComparisonConstraintShape))
                 {
                     ((IInvalidateDisplay)constraintShape).InvalidateRequired(true);
                     if (ValueComparisonConstraint.IsDirectionalOperator((ValueComparisonOperator)e.OldValue) ^
                         ValueComparisonConstraint.IsDirectionalOperator((ValueComparisonOperator)e.NewValue))
                     {
                         foreach (LinkShape linkShape in LinkConnectsToNode.GetLink(constraintShape))
                         {
                             ExternalConstraintLink constraintLink;
                             if (null != (constraintLink = linkShape as ExternalConstraintLink))
                             {
                                 ((IInvalidateDisplay)constraintLink).InvalidateRequired(true);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #4
0
            /// <summary>
            /// Code that handles retrieval of the text to display in ValueConstraintShape.
            /// </summary>
            public sealed override string GetDisplayText(ShapeElement parentShape)
            {
                string retval = null;
                ValueConstraintShape parentValueConstraintShape = parentShape as ValueConstraintShape;

                if (parentShape is ObjectTypeShape)
                {
                    LinkedElementCollection <PresentationElement> pelList = PresentationViewsSubject.GetPresentation(parentShape);
                    foreach (ShapeElement pel in pelList)
                    {
                        ValueConstraintShape valueConstraintShape = pel as ValueConstraintShape;
                        if (valueConstraintShape != null)
                        {
                            parentValueConstraintShape = valueConstraintShape;
                            break;
                        }
                    }
                }
                if (parentValueConstraintShape == null)
                {
                    retval = base.GetDisplayText(parentShape);
                }
                else
                {
                    retval = parentValueConstraintShape.DisplayText;
                }
                return(retval);
            }
コード例 #5
0
        /// <summary>
        /// Creates a new view digram for the pattern model.
        /// </summary>
        /// <param name="patternModel">The pattern model</param>
        /// <param name="docData">The document window data</param>
        /// <returns></returns>
        public static Guid CreateNewViewDiagram(PatternModelSchema patternModel, ModelingDocData docData)
        {
            Guard.NotNull(() => patternModel, patternModel);
            Guard.NotNull(() => docData, docData);

            // Create a new diagram file
            var docView = docData.DocViews.FirstOrDefault() as SingleDiagramDocView;
            PatternModelSchemaDiagram diagram = null;

            patternModel.Store.TransactionManager.DoWithinTransaction(() =>
            {
                diagram = PatternModelSerializationHelper.CreatePatternModelSchemaDiagram(
                    new SerializationResult(),
                    patternModel.Store.DefaultPartition,
                    patternModel.Store.GetRootElement(),
                    string.Empty);
            });
            if (diagram != null)
            {
                SetCurrentDiagram(docView, diagram, patternModel.Pattern);

                FixUpDiagram(patternModel, patternModel.Pattern, diagram.Id.ToString(),
                             PresentationViewsSubject.GetPresentation(patternModel.Pattern).OfType <ShapeElement>());

                return(diagram.Id);
            }

            return(Guid.Empty);
        }
コード例 #6
0
        /// <summary>
        /// Handles property change events for the listed classes of this rule.
        /// </summary>
        /// <param name="e">The event args.</param>
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            Guard.NotNull(() => e, e);

            if (e.DomainProperty.Id == PropertySchema.TypeDomainPropertyId)
            {
                if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                {
                    var property = (PropertySchema)e.ModelElement;

                    // Clear any previous DefaultValue of the property.
                    var defaultValueName = Reflector <PropertySchema> .GetPropertyName(x => x.RawDefaultValue);

                    var descriptor = TypeDescriptor.GetProperties(property)[defaultValueName];
                    descriptor.ResetValue(property);

                    // Repaint the owners compartment shape (to update the custom displayed text value)
                    if (property.Owner != null)
                    {
                        foreach (var shape in PresentationViewsSubject.GetPresentation(property.Owner))
                        {
                            CompartmentShape compartment = shape as CompartmentShape;
                            if (compartment != null)
                            {
                                compartment.Invalidate();
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
        public static void AjustarAoConteudo(Simbolo simbolo)
        {
            var compartimento = PresentationViewsSubject.GetPresentation(simbolo)
                                .FirstOrDefault() as SimboloCompartment;

            if (compartimento == null)
            {
                return;
            }

            var tamanhos = new List <SizeD>();

            foreach (var nocao in simbolo.Nocoes)
            {
                tamanhos.Add(DisplayText.ObterTamanho(compartimento, nocao));
            }

            foreach (var impacto in simbolo.Impactos)
            {
                tamanhos.Add(DisplayText.ObterTamanho(compartimento, impacto));
            }

            var maiorLargura = tamanhos.Max(s => s.Width);
            var novoSize     = new SizeD(maiorLargura, compartimento.Size.Height);

            compartimento.Size = novoSize;
        }
コード例 #8
0
        /// <summary>
        /// Quand on commence à éditer une cellule, on supprime la sélection dans le diagramme pour être sur de capturer
        /// tous les événements
        /// (Pour corriger le BUG: Quand on appuie sur la touche DEL lors de l'édition d'une cellule, c'est le shape sélectionné qui disparait)
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.DataGridViewCellCancelEventArgs"></see> that contains the event data.</param>
        /// <exception cref="T:System.ArgumentOutOfRangeException">The value of the <see cref="P:System.Windows.Forms.DataGridViewCellCancelEventArgs.ColumnIndex"></see> property of e is greater than the number of columns in the control minus one.-or-The value of the <see cref="P:System.Windows.Forms.DataGridViewCellCancelEventArgs.RowIndex"></see> property of e is greater than the number of rows in the control minus one.</exception>
        protected override void OnCellBeginEdit(DataGridViewCellCancelEventArgs e)
        {
            base.OnCellBeginEdit(e);

            ModelElement elem = _root as ModelElement;

            // On enlève la sélection sur le shape
            if (elem != null)
            {
                IList <PresentationElement> shapes = PresentationViewsSubject.GetPresentation(elem);
                if (shapes.Count > 0)
                {
                    NodeShape ns = shapes[0] as NodeShape;
                    if (ns != null && ns.Diagram != null && ns.Diagram.ClientViews.Count > 0)
                    {
                        DiagramClientView clientView = ns.Diagram.ClientViews[0] as DiagramClientView;
                        if (clientView != null)
                        {
                            clientView.Selection.Clear();
                        }
                    }
                }
            }

            // L'entete n'est pas éditable ou une catégorie
            VirtualTreeGridItem item = GetRowValue(e.RowIndex);

            if (item == null || item.Kind == ModelKind.Root || item.Kind == ModelKind.Category)
            {
                e.Cancel = true;
            }

            _inPlaceEditMode = true;
        }
コード例 #9
0
        /// <summary>
        /// Execute the command
        /// </summary>
        public void Exec()
        {
            CandleModel system = _shape.ModelElement as CandleModel;

            // Si la commande a été lancé sur le composant, on référence le modèle
            if (system == null)
            {
                BinaryComponent component = _shape.ModelElement as BinaryComponent;
                if (component != null)
                {
                    system = component.Model;
                }
            }

            // Peut etre à null si le composant n'est pas de type Binary
            if (system != null)
            {
                // Affiche la fenetre de dialogue permettant de choisir les assemblies
                IAssemblySelectorDialog selector = ServiceLocator.Instance.GetService <IAssemblySelectorDialog>();
                if (selector.ShowDialog(0))
                {
                    ImportAssemblies(system, selector.SelectedAssemblies);

                    // On arrange les shapes du composant
                    IList <PresentationElement> componentShapes = PresentationViewsSubject.GetPresentation(system.Component);
                    ArrangeShapesCommand        cmd             = new ArrangeShapesCommand((NodeShape)componentShapes[0]);
                    cmd.Exec();
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// TIPS Affectation d'un parent graphique diffèrent que le parent du modèle à un enfant
        /// </summary>
        /// <param name="childShape">The child shape.</param>
        /// <returns>The parent shape for the child shape.</returns>
        public override ShapeElement ChooseParentShape(ShapeElement childShape)
        {
            // Les layers apparaissent graphiquement dans un PackageLayer mais leur père reste
            // le composant
            if (childShape.ModelElement is Layer)
            {
                // Recherche du shape du layerPackage
                LayerPackage package = ((Layer)childShape.ModelElement).LayerPackage;
                if (package != null)
                {
                    IList <PresentationElement> shapes = PresentationViewsSubject.GetPresentation(package);
                    if (shapes.Count > 0)
                    {
                        NodeShape parentShape = (NodeShape)shapes[0];
                        return(parentShape);
                    }
                }
            }

            if (childShape.ModelElement is DataLayer)
            {
                CandleModel model = ((DataLayer)childShape.ModelElement).Component.Model;
                if (model != null)
                {
                    IList <PresentationElement> shapes = PresentationViewsSubject.GetPresentation(model);
                    if (shapes.Count > 0)
                    {
                        NodeShape parentShape = (NodeShape)shapes[0];
                        return(parentShape);
                    }
                }
            }

            return(base.ChooseParentShape(childShape));
        }
コード例 #11
0
        /// <summary>
        /// DeleteRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ExclusiveOrConstraintCoupler), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddShapeRulePriority;
        /// Split a single shape into two shapes when a exclusion constraint
        /// is decoupled from a mandatory constraint
        /// </summary>
        private static void ExclusiveOrCouplerDeletedRule(ElementDeletedEventArgs e)
        {
            ExclusiveOrConstraintCoupler link      = e.ModelElement as ExclusiveOrConstraintCoupler;
            MandatoryConstraint          mandatory = link.MandatoryConstraint;
            ExclusionConstraint          exclusion = link.ExclusionConstraint;

            if (!mandatory.IsDeleted && !exclusion.IsDeleted)
            {
                LinkedElementCollection <PresentationElement> pels = PresentationViewsSubject.GetPresentation(mandatory);
                int pelCount = pels.Count;
                for (int i = 0; i < pelCount; ++i)
                {
                    ExternalConstraintShape shape = pels[i] as ExternalConstraintShape;
                    if (shape != null)
                    {
                        ORMDiagram diagram = (ORMDiagram)shape.Diagram;
                        RectangleD bounds  = shape.AbsoluteBounds;
                        double     width   = bounds.Width;
                        bounds.Offset(-width / 2, 0);
                        bounds = diagram.BoundsRules.GetCompliantBounds(shape, bounds);
                        shape.AbsoluteBounds = bounds;
                        bounds.Offset(width, 0);
                        diagram.PlaceORMElementOnDiagram(null, exclusion, bounds.Location, ORMPlacementOption.None, null, null);
                    }
                }
            }
        }
コード例 #12
0
        /// <summary>
        ///     This method will return a DSL ShapeElement for the given efobject.  If the given efobject doesn't map to a designer shape,
        ///     then this will look for a designer shape for the object's parent.
        ///     If no designer shape can be found, this will return null.
        /// </summary>
        /// <param name="efobject"></param>
        /// <returns></returns>
        private static ShapeElement GetDesignerShapeElementForEFObject(EntityDesignerDiagram diagram, EFObject efobject)
        {
            ShapeElement shapeElement = null;

            while (shapeElement == null &&
                   efobject != null &&
                   ((efobject is ConceptualEntityModel) == false))
            {
                var dslElement = diagram.ModelElement.ModelXRef.GetExisting(efobject);
                shapeElement = dslElement as ShapeElement;

                if (shapeElement == null &&
                    dslElement != null)
                {
                    var shapes = PresentationViewsSubject.GetPresentation(dslElement);

                    // just select the first shape for this item
                    if (shapes != null &&
                        shapes.Count > 0)
                    {
                        shapeElement = shapes[0] as ShapeElement;
                    }
                }

                // walk up the EFObject tree until we find a node that has a ShapeElement.
                if (shapeElement == null)
                {
                    efobject = efobject.Parent;
                }
            }
            return(shapeElement);
        }
コード例 #13
0
        public override void ElementDeleted(ElementDeletedEventArgs e)
        {
            base.ElementDeleted(e);

            var inheritance = e.ModelElement as Inheritance;

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

                var tx = ModelUtils.GetCurrentTx(inheritance.Store);
                Debug.Assert(tx != null);
                if (tx != null &&
                    !tx.IsSerializing)
                {
                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new InheritanceDelete(inheritance));
                }
            }
        }
コード例 #14
0
ファイル: TableShape.cs プロジェクト: ozialien/NORMA
        /// <summary>
        /// Reorder compartment items when a column is renamed.
        /// </summary>
        private static void ColumnRenamedEvent(object sender, ElementPropertyChangedEventArgs e)
        {
            Column column = (Column)e.ModelElement;
            Table  table;

            if (!column.IsDeleted &&
                null != (table = column.Table))
            {
                foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(table))
                {
                    TableShape shape = pel as TableShape;
                    if (shape != null)
                    {
                        foreach (ShapeElement childShape in shape.NestedChildShapes)
                        {
                            ColumnElementListCompartment compartment;
                            OrderedElementList <Column, ColumnElementListCompartment> columnList;
                            int oldIndex;
                            int newIndex;
                            if (null != (compartment = childShape as ColumnElementListCompartment) &&
                                null != (columnList = compartment.Items as OrderedElementList <Column, ColumnElementListCompartment>))

                            {
                                if (columnList.OnElementReorder(column, out oldIndex, out newIndex))
                                {
                                    MoveSubFieldSelectionOnOrderChange(tableShape, compartment, oldIndex, newIndex);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #15
0
 public static void Redraw(this ModelElement element)
 {
     foreach (ShapeElement shapeElement in PresentationViewsSubject.GetPresentation(element).OfType <ShapeElement>().Distinct().ToList())
     {
         shapeElement.Invalidate();
     }
 }
コード例 #16
0
        /// <summary>
        /// Highlight all potential connections for this shape. We do this with generics because it needs to work
        /// for both SocketShapes and SocketUseShapes. Examples:
        ///
        /// HighlightPossibleConnections<SocketUse, Socket>();
        /// HighlightPossibleConnections<Socket, SocketUse>();
        /// </summary>
        /// <typeparam name="S">The type of source of the mouse down</typeparam>
        /// <typeparam name="T">The target type of the potential connection</typeparam>
        protected void HighlightPossibleConnections <S, T>()
            where S : SocketBase
            where T : SocketBase
        {
            //Hightlight all compatible sockets
            S source = this.ModelElement as S;

            if (source == null)
            {
                return;
            }

            var targets = Store.ElementDirectory.FindElements <T>(false);

            foreach (var target in targets)
            {
                if (!source.CanConnectTo(target))
                {
                    continue;
                }

                var targetShape = PresentationViewsSubject.GetPresentation(target).FirstOrDefault() as SocketShapeBase;
                if (targetShape != null)
                {
                    targetShape.Highlight = true;
                }
            }
        }
コード例 #17
0
        internal static void UpdateDisplayForPersistence(Association element)
        {
            // don't change unless necessary so as to not set the model's dirty flag without need
            bool persistent = element.Persistent;

            List <AssociationConnector> changeColors =
                PresentationViewsSubject.GetPresentation(element)
                .OfType <AssociationConnector>()
                .Where(connector => (persistent && connector.Color != Color.Black) ||
                       (!persistent && connector.Color != Color.DarkGray))
                .ToList();

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

            foreach (AssociationConnector connector in changeColors)
            {
                connector.Color = persistent
                                 ? Color.Black
                                 : Color.DarkGray;
            }

            foreach (AssociationConnector connector in changeStyle)
            {
                connector.DashStyle = persistent
                                     ? DashStyle.Solid
                                     : DashStyle.Dash;
            }
        }
コード例 #18
0
 /// <summary>
 /// ChangeRule: typeof(RingConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority;
 /// </summary>
 private static void RingConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e)
 {
     if (e.DomainProperty.Id == RingConstraint.RingTypeDomainPropertyId)
     {
         RingConstraint ringConstraint = (RingConstraint)e.ModelElement;
         if (!ringConstraint.IsDeleted)
         {
             foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(ringConstraint))
             {
                 RingConstraintShape ringConstraintShape = pel as RingConstraintShape;
                 if (ringConstraintShape != null)
                 {
                     foreach (LinkConnectsToNode connection in DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(ringConstraintShape, LinkConnectsToNode.NodesDomainRoleId))
                     {
                         BinaryLinkShape binaryLink = connection.Link as BinaryLinkShape;
                         if (binaryLink != null)
                         {
                             binaryLink.RecalculateRoute();
                         }
                     }
                     SizeD oldSize = ringConstraintShape.Size;
                     ringConstraintShape.AutoResize();
                     if (oldSize == ringConstraintShape.Size)
                     {
                         ringConstraintShape.InvalidateRequired(true);
                     }
                 }
             }
         }
     }
 }
コード例 #19
0
 public static void ColorShapeOutline(ModelClass element)
 {
     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;
         }
     }
 }
コード例 #20
0
ファイル: TableShape.cs プロジェクト: ozialien/NORMA
        private static void ColumnOrderChanged(object sender, RolePlayerOrderChangedEventArgs e)
        {
            // If a row is selected in the changed table, then adjust its row
            ModelElement element = e.SourceElement;

            if (!element.IsDeleted)
            {
                Table table = (Table)element;
                foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element))
                {
                    TableShape shape;
                    if (null != (shape = pel as TableShape))
                    {
                        foreach (ShapeElement childShape in shape.NestedChildShapes)
                        {
                            ColumnElementListCompartment compartment;
                            if (null != (compartment = childShape as ColumnElementListCompartment))
                            {
                                MoveSubFieldSelectionOnOrderChange(shape, compartment, e.OldOrdinal, e.NewOrdinal);
                            }
                        }
                    }
                }
            }
        }
コード例 #21
0
ファイル: AssociationLink.cs プロジェクト: malain/candle
        /// <summary>
        /// Sélection des propriétes dans la compartiment list
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="association">The association.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="properties">The properties.</param>
        private static void SelectProperties(DiagramClientView view, Association association, Entity entity,
                                             IList <Property> properties)
        {
            IList <PresentationElement> presentations = PresentationViewsSubject.GetPresentation(entity);

            Debug.Assert(presentations.Count > 0);
            Compartment compartment = ((CompartmentShape)presentations[0]).FindCompartment("Properties");

            Debug.Assert(compartment != null);
            foreach (ShapeField field in compartment.ShapeFields)
            {
                if (field is ListField)
                {
                    foreach (Property property in properties)
                    {
                        if (property != null)
                        {
                            int         index = entity.Properties.IndexOf(property);
                            DiagramItem item  = new DiagramItem(compartment, field, new ListItemSubField(index));
                            if (!view.Selection.Contains(item))
                            {
                                view.Selection.Add(item);
                            }
                        }
                    }
                    break;
                }
            }
        }
コード例 #22
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();
    }
 }
コード例 #23
0
ファイル: ModelEnum.cs プロジェクト: slamj1/EFDesigner
        /// <summary>
        /// Redraws this enum.
        /// </summary>
        public void RedrawItem()
        {
            List <ShapeElement> shapeElements = PresentationViewsSubject.GetPresentation(this).OfType <ShapeElement>().Distinct().ToList();

            foreach (ShapeElement shapeElement in shapeElements)
            {
                shapeElement.Invalidate();
            }
        }
コード例 #24
0
        /// <summary>
        /// Gets the (first) shape representing the given element, in the given diagram
        /// </summary>
        public static NodeShape GetShape(this ModelElement element, Diagram diagram)
        {
            Guard.NotNull(() => element, element);
            Guard.NotNull(() => diagram, diagram);

            return(PresentationViewsSubject.GetPresentation(element)
                   .OfType <NodeShape>()
                   .FirstOrDefault(s => s.Diagram == diagram));
        }
コード例 #25
0
 /// <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();
    }
 }
コード例 #26
0
 /// <summary>
 /// Redraws this enum.
 /// </summary>
 public void RedrawItem()
 {
     // redraw on every diagram
     foreach (ShapeElement shapeElement in
              PresentationViewsSubject.GetPresentation(this).OfType <ShapeElement>().Distinct())
     {
         shapeElement.Invalidate();
     }
 }
コード例 #27
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);
     }
 }
コード例 #28
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;
            }
        }
コード例 #29
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);
     }
 }
コード例 #30
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);
         }
     }
 }