示例#1
0
        public static string MakeGraphvizDot(TextDocument document, int offset, string rankdir)
        {
            GraphvizDotGenerator generator = new GraphvizDotGenerator(rankdir);
            var table = GraphvizTableGenerator.MakeTable(document, offset);

            return(generator.MakeGraphvizDot(table));
        }
示例#2
0
        /// Constructs an element at the specified offset.
        /// May return null if no element should be constructed.
        protected override InlineObjectElement ConstructMainElement(int offset)
        {
            Match m = FindMatch(offset);

            // check whether there's a match exactly at offset
            if (m.Success && m.Index == 0)
            {
                GraphGeneration wrapper = GetGraphGeneration();
                UIElement       uiElement;
                if (wrapper.IsGraphvizInstalled)
                {
                    string      rankdir  = m.Groups[2].Value.Trim();
                    string      dotGraph = GraphvizDotGenerator.MakeGraphvizDot(Document, offset, rankdir);
                    BitmapImage bitmap   = LoadBitmap(dotGraph);
                    if (bitmap != null)
                    {
                        string scale = m.Groups[1].Value;
                        uiElement = CreateImageControl(offset, scale, bitmap);
                    }
                    else
                    {
                        uiElement = CreateErrorMesageTextBlock("Invalid Graphviz");
                    }
                }
                else
                {
                    uiElement = CreateErrorMesageTextBlock("Graphviz is not installed");
                }

                // Pass the length of the match to the 'documentLength' parameter of InlineObjectElement.
                return(new InlineObjectElement(m.Length, uiElement));
            }

            return(null);
        }