From: glenlow Date: Sat, 28 Jun 2008 07:19:08 +0000 (+0000) Subject: export dialog with selectable format X-Git-Tag: LAST_LIBGRAPH~32^2~3897 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93394a7c15c4ec10334ba010a62da40631b600ba;p=graphviz export dialog with selectable format --- diff --git a/windows/Graph.cs b/windows/Graph.cs index 07f440b1b..dd46d3093 100755 --- a/windows/Graph.cs +++ b/windows/Graph.cs @@ -24,12 +24,36 @@ namespace Graphviz { public class Graph : IDisposable { + public enum API + { + Render = 0, + Layout = 1, + TextLayout = 2, + Device = 3, + LoadImage = 4 + } + public class Exception : ApplicationException { public Exception(string message): base(message) { } } + + public static IList GetPlugins(API api, bool showFullPath) + { + SortedList plugins = new SortedList(); + IntPtr pluginList = gvplugin_list(_context, api, showFullPath ? ":" : ""); + foreach (string nextPlugin in Marshal.PtrToStringAnsi(pluginList).Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries)) + { + int lastColon = nextPlugin.LastIndexOf(':'); + string plugin = nextPlugin.Substring(0, lastColon == -1 ? nextPlugin.Length : lastColon); + plugins[plugin] = plugin; + } + + free(pluginList); + return plugins.Keys; + } public event EventHandler Changed; @@ -91,6 +115,12 @@ namespace Graphviz } } + public void Render(string format, string filename) + { + if (gvRenderFilename(_context, _graph, format, filename) != 0) + throw new Exception("bad render"); + } + public void NoteChanged(bool relayout) { if (relayout) { @@ -157,6 +187,9 @@ namespace Graphviz [DllImport("libgvc-4.dll")] private static extern int gvLayout(IntPtr context, IntPtr graph, string engine); + [DllImport("libgvc-4.dll")] + private static extern IntPtr gvplugin_list(IntPtr context, API api, string str); + [DllImport("libgvc-4.dll")] private static extern int gvRenderFilename(IntPtr context, IntPtr graph, string format, string filename); @@ -172,6 +205,9 @@ namespace Graphviz [DllImport("msvcrt.dll", SetLastError = true)] private static extern unsafe void free(byte* pointer); + [DllImport("msvcrt.dll", SetLastError = true)] + private static extern void free(IntPtr pointer); + private static readonly IntPtr _context = gvContext(); private readonly IntPtr _graph;