New C# DPLOTLIB example program

Q&A for C, C++, and/or C# developers using DPlot
Post Reply
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

New C# DPLOTLIB example program

Post by DPlotAdmin »

Warning: This is the fish-out-of-water version of a C# demo program. The limited examples in this demo work, but you may run into problems with DPLOTLIB functions not used in this demo. Requires Visual Studio 2005 (Express version is fine and was used to create this demo.)

Get the demo source from [Edit: removed. C# source is now part of the DPLOTLIB distribution: http://www.dplot.com/lib/dplotlib.zip ] I wasn't entirely sure what files were absolutely necessary, so everything (other than executables) is included.

This demo makes use of DPLOTLIB calls:
DPlot_GetVersion
DPlot_Plot8
DPlot_Request
DPlot_SetErrorMethod

As far as I can tell, the interface to other DPLOTLIB commands is correct. But not tested, so use at your own risk.

A couple of notes:

All of the interface stuff and the structure definitions are found in the file dplot.cs. This file was added to the demo project with Add>Class. This file will likely be made into a class library DLL eventually, to avoid forcing you to copy/paste the code every time you create a new project. Or maybe not. Honestly I don't know enough about this stuff to make much of an informed decision right now.

Finding DPLOTLIB.DLL: This was always confusing for VB users and I wanted to avoid that confusion this time around. If DPLOTLIB.DLL is located in the same folder as your executable then finding the DLL is no problem; it will always be found. But finding the DLL is a bit more trouble while debugging within the VS environment, unless, again, the DLL is located in your project's \bin\Debug folder (or is it \obj\Debug? What IS all that stuff, anyway? :D ). That is of course doable, but it is at best inconvenient to remember to copy/paste the DLL for all new projects. Starting with version 2.0.4.1 of DPlot/DPlot Jr, the installation scripts write the location of DPLOTLIB.DLL to the registry at HKCU\Software\DPLOT\DPLOTLIB\Folder. If you don't have that version of DPlot or DPlot Jr you can of course get it, or make this change to the registry yourself. In the demo program's Form_Load event it calls the function FindDPLOTLIB in dplot.cs, which in turn checks the registry for the location. If found, it then changes the current directory to that folder so that all references to DPLOTLIB functions will be resolved.

I'm open to suggestions if anyone believes this is a bad idea. I can't think of a down side unless your application makes assumptions at startup about what the current directory is.

As always, your comments, suggestions, and criticisms are welcome. I'll be adding additional examples similar to the VB and C demos as time allows.
Last edited by DPlotAdmin on Sat Apr 08, 2006 12:00 am, edited 1 time in total.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Round 2: The original source has been replaced, new source is in the same location: [Edit: removed. C# source is now part of the DPLOTLIB distribution: http://www.dplot.com/lib/dplotlib.zip ] . This iteration contains a couple of bug fixes: replacing "int" with "IntPtr" in dplot.cs, and also contains 2 new demo programs. One that retrieves a bitmap image from a hidden DPlot or DPlot Jr and displays it in a PictureBox control in the application, the second does the same thing with an enhanced metafile. The bitmap demo also illustrates converting mouse position to plot coordinates (2D renderings only).

Image
Last edited by DPlotAdmin on Sat Apr 08, 2006 12:02 am, edited 2 times in total.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

One more example, same location: [Edit: removed. C# source is now part of the DPLOTLIB distribution: http://www.dplot.com/lib/dplotlib.zip ]

This iteration includes a real-time simulation that sends data to DPlot at regular intervals. See the test3 project.
Visualize Your Data
support@dplot.com
abolakomadic
Posts: 1
Joined: Fri Jun 02, 2006 6:42 am

Post by abolakomadic »

i don't like it.
its me
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Can you be a little more specific? What is it you don't like?
Visualize Your Data
support@dplot.com
Juffman
Posts: 1
Joined: Sat Mar 08, 2008 6:21 am

Post by Juffman »

Well Dave, I don't know what Mr Abolakomadic was smoking, but I thought you your C# examples for calling Dplot were bloody good. I reckon the free C# Visual Express from MS and your Dplot program is a fantastic programming platform for engineering/scientific plotting & graphing.

For complete nubes to C# (like myself), here are some tips to get the examples running properly:

1. Download and extract the dplotlib.dll and the C# example codes from:
http://www.dplot.com/lib/dplotlib.zip

2. Put the dplotlib.dll in a new directory called:
C:\Program Files\DPlot\addin

3. Double click the *.csproj files in the dplotlib\csharp\test? folders which you extracted from the dplotlib.zip file.

4. If you have installed the recently issued Visual Express 2008, then let the program do the necessay conversions from Dave's 2005 edition code.

5. Hit the 'play' button to run the program!

My favorite was the 'test4' example which shows how you can put a Dplot graph on a C# form. This will save me about a million hours of programming time for developing my own graphs. :D
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Well Dave, I don't know what Mr Abolakomadic was smoking...
I thought he might have a legitimate gripe and so left the post in place, but now I think Mr. Abolakomadic was likely just another spammer hoping to get a link to his site back when this forum was plagued with that sort of nonsense.

In any case, thanks for your post and particularly for your instructions.
Visualize Your Data
support@dplot.com
Post Reply