Beispiel #1
0
        /// <summary>
        /// Update a dependency part.
        /// </summary>
        /// <param name="domainClassId"></param>
        /// <param name="parts"></param>
        /// <param name="bSource"></param>
        /// <param name="link"></param>
        /// <param name="info"></param>
        protected virtual void UpdatePart(Guid domainClassId, Dictionary <Guid, GraphicalDependencyShape> parts, bool bSource, ElementLink link, DomainRelationshipInfo info)
        {
            GraphicalDependencyShape shape;

            parts.TryGetValue(info.Id, out shape);

            if (shape == null)
            {
                GraphicalDependenciesFilterItem filterItem = new GraphicalDependenciesFilterItem(this.ViewModelStore, this, info.Id);
                filterItem.Title = info.DisplayName;
                this.FilterItemVMs.Add(filterItem);

                shape = CreateHostShape(link, info);

                parts.Add(info.Id, shape);
                if (!bSource)
                {
                    this.Diagram.SourceDependencyShapes.Add(shape);
                }
                else
                {
                    this.Diagram.TargetDependencyShapes.Add(shape);
                }
            }

            shape.AddNestedChild(CreateChildShape(link, bSource));
        }
Beispiel #2
0
        /// <summary>
        /// Updates the displayed dependencies based on filter information.
        /// </summary>
        public virtual void UpdateBasedOnFilter(GraphicalDependenciesFilterItem filterItem)
        {
            this.Store.UndoManager.UndoState = UndoState.DisabledNoFlush;
            using (Transaction t = this.Store.TransactionManager.BeginTransaction("", true))
            {
                if (filterItem.IsFiltered)
                {
                    // remove elements
                    for (int i = 0; i < this.Diagram.SourceDependencyShapes.Count; i++)
                    {
                        if (this.Diagram.SourceDependencyShapes[i].RelationshipTypeId == filterItem.RelationshipType &&
                            this.Diagram.SourceDependencyShapes[i].RelationshipTypeId != Guid.Empty)
                        {
                            RemoveHostShape(this.Diagram.SourceDependencyShapes[i]);
                            break;
                        }

                        if (this.Diagram.SourceDependencyShapes[i].CustomInfo == filterItem.CustomFilterInformation &&
                            !String.IsNullOrEmpty(this.Diagram.SourceDependencyShapes[i].CustomInfo))
                        {
                            RemoveHostShape(this.Diagram.SourceDependencyShapes[i]);
                            break;
                        }
                    }

                    for (int i = 0; i < this.Diagram.TargetDependencyShapes.Count; i++)
                    {
                        if (this.Diagram.TargetDependencyShapes[i].RelationshipTypeId == filterItem.RelationshipType &&
                            this.Diagram.TargetDependencyShapes[i].RelationshipTypeId != Guid.Empty)
                        {
                            RemoveHostShape(this.Diagram.TargetDependencyShapes[i]);
                            break;
                        }

                        if (this.Diagram.TargetDependencyShapes[i].CustomInfo == filterItem.CustomFilterInformation &&
                            !String.IsNullOrEmpty(this.Diagram.TargetDependencyShapes[i].CustomInfo))
                        {
                            RemoveHostShape(this.Diagram.TargetDependencyShapes[i]);
                            break;
                        }
                    }
                    UpdateLayout();
                }
                else
                {
                    // add elements
                    GraphicalDependencyShape hostShape = null;
                    bool bSource = true;

                    DomainClassInfo elementInfo            = this.MainElement.GetDomainClass();
                    ReadOnlyCollection <ElementLink> links = DomainRoleInfo.GetAllElementLinks(this.MainElement);
                    foreach (ElementLink link in links)
                    {
                        DomainRelationshipInfo info = link.GetDomainRelationship();
                        if (info.Id == filterItem.RelationshipType)
                        {
                            if (DomainRoleInfo.GetSourceRolePlayer(link) != this.MainElement)
                            {
                                bSource = false;
                            }

                            if (hostShape == null)
                            {
                                hostShape = CreateHostShape(link, info);

                                if (bSource)
                                {
                                    this.Diagram.TargetDependencyShapes.Add(hostShape);
                                }
                                else
                                {
                                    this.Diagram.SourceDependencyShapes.Add(hostShape);
                                }
                            }

                            if (bSource)
                            {
                                hostShape.AddNestedChild(CreateChildShape(link, true));
                            }
                            else
                            {
                                hostShape.AddNestedChild(CreateChildShape(link, false));
                            }
                        }
                    }

                    UpdateLayout();

                    if (hostShape != null)
                    {
                        UpdateLink(hostShape, !bSource);
                    }
                }

                t.Commit();
            }
            this.Store.UndoManager.UndoState = UndoState.Enabled;
        }