New C# DPLOTLIB example program
Posted: Thu Mar 30, 2006 4:25 pm
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? ). 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.
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? ). 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.