WarrickF Posted February 3, 2011 Share Posted February 3, 2011 Hi Guys, Is it possible to have Codelab output debug somewhere? I'm doing math and really need to see what a value evals to. Thanks Warrick Quote Link to comment Share on other sites More sharing options...
BoltBait Posted February 3, 2011 Share Posted February 3, 2011 Not normally. BUT, here's something I've done before: void Render(Surface dst, Surface src, Rectangle rect) { ColorBgra CurrentPixel; for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { CurrentPixel = src[x,y]; if (x == 0 && y == 0) // only call this ONCE per run! { MessageBox.Show( "R = " + CurrentPixel.R.ToString() + "; " + "G = " + CurrentPixel.G.ToString() + "; " + "B = " + CurrentPixel.B.ToString() ); } dst[x,y] = CurrentPixel; } } } Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
WarrickF Posted February 3, 2011 Author Share Posted February 3, 2011 Thanks, that def. helps. A feature request wold be to have Console.WriteLine output to something. Thanks again Warrick Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 5, 2011 Share Posted February 5, 2011 I've filed a v4 bug for this because I think it's a good idea. In the meantime, you can try this. 1) Get a hold of aprogram called DebugView. It's by Mark Russonovich, http://technet.micro...s/bb896647.aspx 2) You'll note that in the description for DebugView it says it works with output that is directed at the Win32 function "OutputDebugString". So, we need to get access to that function. Here's how: using System.Runtime.InteropServices; // at top of file, of course // put this wherever it's convenient for you // http://msdn.microsoft.com/en-us/library/aa363362(VS.85).aspx [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = false)] public static extern void OutputDebugStringW( [in] [MarshalAs(UnmanagedType.LPWStr)] string lpOutputString); There may be a way to use something like Console.Error.WriteLine(), but I haven't tried to verify that it'll work. So what you would do is 1) make sure DebugView is running, and 2) make sure your plugin is using OutputDebugStringW. (btw the 'W' suffic means Unicode text, which is what C#/.NET use. there is also an 'A' version for ANSI/ASCII text but nobody uses that stuff anymore, not since like win95/98) Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 5, 2011 Share Posted February 5, 2011 Actually, in reference to #2 above, there may be a simpler (and more "official") way. Create an instance of System.Diagnostics.DefaultTraceListener() and use its Write(string) method. If you look at its code with Reflector, it (eventually) sends your string to OutputDebugString anyway. (BTW I was able to find this very quickly by doing a search, with Reflector, for members named "OutputDebugString", across the .NET Framework DLLs. I then used right click -> Analyze and then right click -> Used By to trace back towards a public method that used it.) Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
BoltBait Posted February 5, 2011 Share Posted February 5, 2011 Can't put "using" lines in a CodeLab script. But, I'll research this for the next release. Quote Click to play: Download: BoltBait's Plugin Pack | CodeLab | and how about a Computer Dominos Game Link to comment Share on other sites More sharing options...
Rick Brewster Posted February 5, 2011 Share Posted February 5, 2011 Can't put "using" lines in a CodeLab script. Nope, true. In that case you'll have to fully quality attributes like DllImport and MarshalAs with a System.Runtime.InteropServices prefix. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
politician Posted July 11, 2011 Share Posted July 11, 2011 The typical way to do this is to use the Trace class. How to use Trace and Debug in C# http://support.microsoft.com/kb/815788 Trace Listeners Overview (MSDN) http://msdn.microsoft.com/en-us/library/4y5y10s7.aspx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.