Go Back   Global Mapper Forum > Support > SDK

SDK Support for those working with the software developer's kit or SDK of Global Mapper

Reply
 
LinkBack Thread Tools Display Modes
Old 07-09-2009, 06:50 AM
Global Mapper User
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default fill color to area

Help me please,

i use Visual C# (VS2008) Sample Application , load shape file it have 2000 areas and i want to fill color some area but it can't.

this is my code

private void FillColor()
{
// theAreaStyle is global variable, i set value to it on load layer.
theAreaStyle.mBrushColor = ColorToUInt(Color.Red);

for (UInt32 i = 0; i <= 500; i++)
{
LastGMError = GlobalMapperDLL.GM_SetAreaFeatureDrawStyle(clsGlob alVARS.LayerHandles[0], i, ref theAreaStyle);
}
DrawLayersToBitmap();
}
private uint ColorToUInt(Color color)
{
return (uint)((color.A << 24) | (color.R << 16) |
(color.G << 8) | (color.B << 0));
}
public static extern GM_Error_t32 GM_SetAreaFeatureDrawStyle
(
IntPtr aLayer, // Layer the area is in
UInt32 aAreaIndex, // Index of area in layer
ref GM_AreaStyle_t aAreaStyle // New style to use for area
);

when i call FillColor function
LastGMError = GM_Error_None alway but area don't fill color.

Last edited by koko; 07-09-2009 at 06:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-09-2009, 02:26 PM
Administrator
 
Join Date: Jun 2007
Posts: 6,361
Thanks: 2
Thanked 516 Times in 503 Posts
Default

What do the other members of your global variable 'theAreaStyle' look like? You are just setting the color, but you will also need to set the fill style, etc. otherwise the fill color might not even be used.

Thanks,

Mike
Global Mapper Support
support@globalmapper.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-10-2009, 08:44 AM
Global Mapper User
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i set theAreaStyle :

theAreaStyle.mBorderPenStyle = 0;
theAreaStyle.mBorderPenWidth = 1;
theAreaStyle.mBorderPenColor = 0;
theAreaStyle.mBrushColor = 2164195328;
theAreaStyle.mBrushStyle = GM_BrushStyle_t16.GM_BRUSH_SOLID;
theAreaStyle.mDrawLabel = 1;
theAreaStyle.mDrawLabelAlways = 0;

it can work with C++ Sample Application but Visual C# (VS2008) Sample Application can't work. I must update about DrawLayersToBitmap() Function Right?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-10-2009, 10:51 AM
Global Mapper User
 
Join Date: Mar 2008
Posts: 69
Thanks: 8
Thanked 0 Times in 0 Posts
Default

A quick look suggests everything is ok. I am trying to identify the problem.
I suggest you use the ColorTranslator class rather than bit shifting.
System.Drawing.ColorTranslator.ToWin32((uint)Color .Red)

In your GM_AreaStyle_t structure, make sure the size of the structure is correct. You can check the size of the same structure in the C++ sample by getting the value of
sizeof(GM_AreaStyle_t).

The size being reported must be the same as
Marshal.SizeOf(typeof(GM_AreaStyle_t))

If the two are not the same, then you have to fix that ASAP as it can lead to memory issues that can affect the entire program later.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-10-2009, 01:41 PM
Administrator
 
Join Date: Jun 2007
Posts: 6,361
Thanks: 2
Thanked 516 Times in 503 Posts
Default

I'm not sure what your DrawLayersToBitmap function does, but typically after making changes to the display characteristics you would call Invalidate to cause your window to redraw.

If you can post your GM_AreaStyle_t declaration we can check that as well. Osei's recommendation to check the sizes between C++ and C# is good to help verify your declaration is correct.

Thanks,

Mike
Global Mapper Support
support@globalmapper.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-13-2009, 09:15 AM
Global Mapper User
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you very much Osei , Mike :

I check my GM_AreaStyle_t declaration and try it then it can work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright 2009 Globalmapperforum.com