/// <summary>
        /// Adds the link.
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        /// <returns></returns>
        public diagramLink AddLink(diagramNode from, diagramNode to, diagramLinkTypeEnum type, string description = "", string __hash = "", ILogBuilder logger = null)
        {
            diagramLink output = new diagramLink();

            output.from        = from;
            output.to          = to;
            output.type        = type;
            output.name        = getUID(output);
            output.description = description;
            links.Add(output);
            output.parent = this;

            if (!__hash.isNullOrEmpty())
            {
                if (linkByHash.ContainsKey(__hash))
                {
                    if (logger != null)
                    {
                        logger.log("AddLink() failed :: " + __hash);
                    }
                }
                else
                {
                    linkByHash.Add(__hash, output);
                }
            }
            return(output);
        }
 public override diagramLinkTypeEnum getLinkTypeEnum(diagramNode child, diagramLinkTypeEnum defType = diagramLinkTypeEnum.normal)
 {
     if (child.relatedObject is IContentBlock)
     {
         return(diagramLinkTypeEnum.thick);
     }
     if (child.relatedObject is IContentParagraph)
     {
         return(diagramLinkTypeEnum.normal);
     }
     if (child.relatedObject is IContentSentence)
     {
         return(diagramLinkTypeEnum.normal);
     }
     if (child.relatedObject is IContentToken)
     {
         return(diagramLinkTypeEnum.dotted);
     }
     return(defType);
 }
Esempio n. 3
0
 public virtual diagramLinkTypeEnum getLinkTypeEnum(diagramNode child, diagramLinkTypeEnum defType = diagramLinkTypeEnum.normal)
 {
     return(defType);
 }
        /// <summary>
        /// Builds the children and returns newly built nodes
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="source">The source.</param>
        /// <param name="defShapeType">Type of the definition shape.</param>
        /// <param name="defLinkType">Type of the definition link.</param>
        /// <param name="doDegradeImportance">if set to <c>true</c> [do degrade importance].</param>
        /// <returns></returns>
        public List <diagramNode> buildChildren(diagramModel model, diagramNode parent, IEnumerable source, diagramNodeShapeEnum defShapeType = diagramNodeShapeEnum.normal, diagramLinkTypeEnum defLinkType = diagramLinkTypeEnum.normal, bool doDegradeImportance = true)
        {
            List <diagramNode> childNodes = new List <diagramNode>();

            if (source == null)
            {
                return(childNodes);
            }

            foreach (IObjectWithPathAndChildSelector child in source)
            {
                diagramNode node = buildNode(model, child);
                node.shapeType = getShapeTypeEnum(child, defShapeType);
                //node.relatedObject = child;
                childNodes.Add(node);
                if (doDegradeImportance)
                {
                    node.importance = parent.importance - 1;
                }
                node.color = getColor(node);
            }

            foreach (diagramNode child in childNodes)
            {
                diagramLink link = model.AddLink(parent, child, diagramLinkTypeEnum.normal);
                link.type        = getLinkTypeEnum(child, defLinkType);
                link.description = getLinkDescription(link, "");
            }
            return(childNodes);
        }