コード例 #1
0
ファイル: EntityNode.cs プロジェクト: aytacozkan/NetworkView
 public EntityNodeLink(EntityNode node,EntityLink link,int weight)
 {
     Target = node;
     Weight = weight;
     Link = link;
 }
コード例 #2
0
ファイル: EntityNode.cs プロジェクト: peterloudon/NetworkView
 public EntityNodeLink(EntityNode node, EntityLink link, int weight)
 {
     Target = node;
     Weight = weight;
     Link   = link;
 }
コード例 #3
0
 private static void SetLinkedIds(EntityNode target, EntityNode source, Entity sourceEntity, Entity targetEntity, EntityLink link)
 {
     if (source.LinkedToIds == null) source.LinkedToIds = new Dictionary<string, EntityNodeLink>();
     if (target.LinkedToIds == null) target.LinkedToIds = new Dictionary<string, EntityNodeLink>();
     source.LinkedToIds[targetEntity.Id] = new EntityNodeLink(target, link, 1);
     target.LinkedToIds[sourceEntity.Id] = new EntityNodeLink(source, link, 1);
 }
コード例 #4
0
        /// <summary>
        /// Adds a link from one entity to another
        /// </summary>
        /// <param name="delayAdd">creates the link but doesn't add it to the model yet</param>
        /// <returns></returns>
        private EntityLink AddLink(EntityNode target, EntityNode source, bool delayAdd)
        {
            Entity sourceEntity = (Entity)source.SourceData;
            Entity targetEntity = (Entity)target.SourceData;
            if ((target.LinkedToIds != null) && (source.LinkedToIds != null))
            {
                if (target.LinkedToIds.ContainsKey(sourceEntity.Id) && source.LinkedToIds.ContainsKey(targetEntity.Id))
                {
                    // return the current link
                    return target.LinkedToIds[sourceEntity.Id].Link;
                }
            }
            EntityLink link = new EntityLink();

            link.Source = source;
            link.Target = target;
            SetLinkedIds(link.Target, link.Source, sourceEntity, targetEntity, link);

            // If either side has an overflow - then set it to that instead
            if (!source.IsActivity && link.Source.ParentNode != null && link.Source.ParentNode.OverflowNode != null)
            {
                link.Source = link.Source.ParentNode.OverflowNode;
                link.Source.Links.Add(link);
            }
            else if (source.IsActivity && link.Source.OverflowNode != null)
            {
                link.Source = link.Source.OverflowNode;
                link.Source.Links.Add(link);
            }

            if (!target.IsActivity && link.Target.ParentNode != null && link.Target.ParentNode.OverflowNode != null)
            {
                link.Target = link.Target.ParentNode.OverflowNode;
            }
            else if (target.IsActivity && link.Target.OverflowNode != null)
            {
                link.Target = link.Target.OverflowNode;
                link.Target.Links.Add(link);
            }

            link.Id = GetLinkId(sourceEntity.Id, targetEntity.Id);

            if (!linkIndex.ContainsKey(link.Id))
            {
                if (!delayAdd)
                {
                    linkIndex[link.Id] = link;
                    Links.Add(link);
                }
            }
            return link;
        }
コード例 #5
0
        public void ExpandOverflow(EntityNode entityNode)
        {
            // Clear the selected user
            SelectedUserId.SetValue(null);
            SelectedConnectionRoles.RemoveAll();
            UnselectAll();
            OnSelectedNodesAdded(this, null);
            OnSelectedLinksAdded(this, null);

            if (entityNode.Children != null)
            {
                // Add any overflow nodes
                int expandedCount = 0;
                foreach (EntityNode node in entityNode.Children)
                {
                    node.X = entityNode.X;
                    node.Y = entityNode.Y;
                    node.Fixed = false;
                    if (!Nodes.Contains(node))
                        Nodes.Add(node);
                    node.ReplacedByOverflow = null;
                    expandedCount++;

                    // Add the links
                    foreach (KeyValuePair<string, EntityNodeLink> linkedTo in node.LinkedToIds)
                    {
                        EntityLink link = new EntityLink(); ;
                        link.Source = node;
                        link.Target = linkedTo.Value.Target;
                        link.Id = GetLinkId(((Entity)node.SourceData).Id, ((Entity)link.Target.SourceData).Id);

                        if (linkIndex.ContainsKey(link.Id))
                        {
                            link = linkIndex[link.Id];

                        }
                        else
                        {
                            linkIndex[link.Id] = link;
                            Links.Add(link);
                        }

                    }
                    if (expandedCount == OverflowMax && entityNode.Children.Count > (OverflowMax + 1))
                    {
                        break;
                    }
                }
                entityNode.Children.RemoveRange(0, expandedCount);
                entityNode.ParentNode.ActivityCount = entityNode.Children.Count;

                if (entityNode.Children.Count == 0)
                {
                    entityNode.Children = null;
                    // Remove the overflow links and node
                    Nodes.Remove(entityNode);
                    foreach (EntityLink link in entityNode.Links)
                    {
                        linkIndex.Remove(link.Id);
                        Links.Remove(link);
                    }
                }

                RaiseOnNodesChangedWithNoFastForward();

            }
        }