Exemple #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            INode listBoxNode = value as INode;

            if (listBoxNode != null)
            {
                graphControl.Graph.Clear();

                var    size        = FlowChartNodeStyle.GetNodeTypeSize(listBoxNode);
                var    node        = graphControl.Graph.CreateNode(new RectD(0, 0, size.Width, size.Height), listBoxNode.Style, listBoxNode.Tag);
                double labelHeight = 0;
                foreach (var label in listBoxNode.Labels)
                {
                    graphControl.Graph.AddLabel(node, label.Text, label.LayoutParameter, label.Style, label.PreferredSize, label.Tag);
                    labelHeight = Math.Max(labelHeight, label.GetLayout().Height);
                }
                graphControl.FitGraphBounds(new InsetsD(5));
                ContextConfigurator cc             = new ContextConfigurator(graphControl.ContentRect);
                var       renderContext            = cc.CreateRenderContext(graphControl);
                Transform transform                = cc.CreateWorldToIntermediateTransform();
                System.Windows.Media.Geometry clip = cc.CreateClip();
                var visualContent = graphControl.ExportContent(renderContext);

                VisualGroup container = new VisualGroup()
                {
                    Transform = transform, Clip = clip, Children = { visualContent }
                };
                VisualBrush brush = new VisualBrush(container);
                return(new DrawingImage(new GeometryDrawing(brush, null, new RectangleGeometry(new Rect(0, 0, size.Width, size.Height + labelHeight)))));
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Method that creates a node of the specified type. The method will specify the ports
        /// that the node should have based on its type.
        /// </summary>
        private void CreateNode(IGraph graph, PointD location, FlowChartType type)
        {
            var   size      = FlowChartNodeStyle.GetNodeTypeSize(type);
            RectD newBounds = new RectD(location, size);

            graph.CreateNode(newBounds, new FlowChartNodeStyle {
                FlowChartType = type
            });
        }