Esempio n. 1
0
        bool TryGetIconRenderer(ElementIcon icon, out SvgRenderer renderer)
        {
            if (icon == null)
            {
                throw new ArgumentNullException("icon");
            }

            if (!rendererCache.TryGetValue(icon.Name, out renderer))
            {
                using (var iconStream = icon.GetStream())
                {
                    if (iconStream == null)
                    {
                        return(false);
                    }
                    var svgDocument = new XmlDocument();
                    svgDocument.XmlResolver = null;
                    svgDocument.Load(iconStream);
                    var element = SvgFactory.LoadFromXML(svgDocument, null);
                    renderer = CreateRenderer(element);
                    rendererCache.Add(icon.Name, renderer);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public SvgRenderer GetIconRenderer(ElementCategory category)
        {
            var categoryIcon = ElementIcon.FromElementCategory(category);

            if (!TryGetIconRenderer(categoryIcon, out SvgRenderer renderer))
            {
                rendererCache.Add(categoryIcon.Name, renderer);
            }

            return(renderer);
        }
Esempio n. 3
0
        public GraphNode(ExpressionBuilder value, int layer, IEnumerable <GraphEdge> successors)
        {
            Value      = value;
            Layer      = layer;
            Successors = successors;

            if (value != null)
            {
                var expressionBuilder        = ExpressionBuilder.Unwrap(value);
                var elementAttributes        = TypeDescriptor.GetAttributes(expressionBuilder);
                var elementCategoryAttribute = (WorkflowElementCategoryAttribute)elementAttributes[typeof(WorkflowElementCategoryAttribute)];
                var obsolete = (ObsoleteAttribute)elementAttributes[typeof(ObsoleteAttribute)] != null;
                if (expressionBuilder is DisableBuilder)
                {
                    Flags |= NodeFlags.Disabled;
                }

                var workflowElement = ExpressionBuilder.GetWorkflowElement(expressionBuilder);
                if (workflowElement != expressionBuilder)
                {
                    var builderCategoryAttribute = elementCategoryAttribute;
                    elementAttributes        = TypeDescriptor.GetAttributes(workflowElement);
                    elementCategoryAttribute = (WorkflowElementCategoryAttribute)elementAttributes[typeof(WorkflowElementCategoryAttribute)];
                    obsolete |= (ObsoleteAttribute)elementAttributes[typeof(ObsoleteAttribute)] != null;
                    if (elementCategoryAttribute == WorkflowElementCategoryAttribute.Default)
                    {
                        elementCategoryAttribute = builderCategoryAttribute;
                    }
                }

                if (obsolete)
                {
                    Flags |= NodeFlags.Obsolete;
                }
                Category        = elementCategoryAttribute.Category;
                BuildDependency = expressionBuilder.IsBuildDependency();
                Icon            = new ElementIcon(workflowElement);
                if (workflowElement is IWorkflowExpressionBuilder)
                {
                    if (Category == ElementCategory.Workflow)
                    {
                        Category = ElementCategory.Combinator;
                        Flags   |= NodeFlags.NestedGroup;
                    }
                    else
                    {
                        Flags |= NodeFlags.NestedScope;
                    }
                }
            }

            InitializeDummySuccessors();
        }