-- C++ Functions prototype and C# P/Invoke Calls ----------
- QueAPIExport QueErrT16 QueCreatePoint( const QuePointType* point, QuePointHandle* handle );
QueAPIExport QueErrT16 QueClosePoint( QuePointHandle point );
. - [DllImport("QueAPI.dll")]
private static extern QueErrT16 QueCreatePoint(ref QuePointType point, ref uint handle);
[DllImport("QueAPI.dll")]
private static extern QueErrT16 QueRouteToPoint(uint point);
-- QueErrT16 ----------
- typedef uint16 QueErrT16; enum { ... }
. - public enum QueErrT16 : ushort { ... }
-- QuePointType ----------
- typedef struct
{
char id[25];
QueSymbolT16 smbl;
QuePositionDataType posn;
} QuePointType;
. - public struct QuePointType
{
public string id;
public QueSymbolT16 smbl;
public QuePositionDataType posn;
}
-- QueSymbolT16 ----------
- typedef uint16 QueSymbolT16; enum { ... }
. - public enum QueSymbolT16 : ushort { ... }
-- QuePositionDataType ----------
- typedef struct
{
sint32 lat;
sint32 lon;
float altMSL;
} QuePositionDataType;
. - public struct QuePositionDataType
{
public int lat;
public int lon;
public float altMSL;
}
-- QuePointHandle ----------
- typedef uint32 QuePointHandle;
. - In C# i manage it as uint var.
-- And this is my current C# function to call all this ----------
Expand|Select|Wrap|Line Numbers
- public static QueErrT16 GarminNavigateToCoordinates(double latitude , double longitude)
- {
- QueErrT16 err = new QueErrT16();
- // Open API
- err = QueAPIOpen();
- if(err != QueErrT16.queErrNone)
- {
- return err;
- }
- // Create position
- QuePositionDataType position = new QuePositionDataType();
- position.lat = GradosDecimalesASemicirculos(latitude);
- position.lon = GradosDecimalesASemicirculos(longitude);
- // Create point
- QuePointType point = new QuePointType();
- point.posn = position;
- // Crete point handle
- uint hPoint = new uint();
- err = QueCreatePoint(ref point, ref hPoint); // HERE i got a NotSupportedException
- if (err == QueErrT16.queErrNone)
- {
- err = QueRouteToPoint(hPoint);
- }
- // Close API
- QueAPIClose();
- return err;
- }
I will appreciate any help. Thanks.