This project has moved and is read-only. For the latest updates, please go here.

HighlightFillColor not highlighted

Topics: WinForms Controls
May 10, 2007 at 6:41 AM
First of all, thanks for the wonderful project.

I have been testing SharpMap for couple of months and having fun with it. I have set the HighlightFillColor to some color and saw that its not changing its color when clicked on certain polygon. I triggered the query tool as in:

mapBox1.MapQueried += new MapBox.MapQueryHandler(mapBox1_MapQueried);

But to my surprise, when I removed the all the layers, I see the selected polygon was painted with the color that I specified on the form. So I see it is being selected but not highlighted even when refreshed.

This is certainly a good feature to flash the selected polygon in a different color. Try to see if this can be resolved, I'll post any update if I have any break through.
May 14, 2007 at 8:33 AM
Edited May 14, 2007 at 8:34 AM
If this issue is related to the MapBox control, the problem is we have no feedback about any modification of the Layers property (no event is fired on list change)... so we know that a layer has been removed only in the code where it is actually removed... That's why the control provides a ClearSelection function that should be called when the selected layer is removed from the collection, or the collection is cleared.
It could be possible to fire events on list modifications, but this mean to change Layers methods to reflect this behaviour.
If you need that on refresh selection is automatically cleared, just add a ClearSelection call as shown in this code fragment
public override void Refresh()
            if (m_Map != null)
                if (ClientSize != m_Map.Size)
                    m_Map.Size = ClientSize;
                    m_SelectionMap.Size = ClientSize;
                    m_UpdateSelection = true;
                if (m_Map.Layers == null || m_Map.Layers.Count == 0)
                    if (m_Image != null)
                        m_Image = null;
                    ClearSelection();                       // <----------- Here ^^ 
                    Cursor c = Cursor;
                    Cursor = Cursors.WaitCursor;
                    m_Image = m_Map.GetMap();
                    Cursor = c;
                if (MapRefreshed != null)
                    MapRefreshed(this, null);

Latest update of the MapBox control can be downloaded here.
May 14, 2007 at 2:20 PM
I'm currently looking at the SharpMap 2.0 alpha code, if the code is stable and I can use a couple of good fixes (label layer enhancements and point styles) found in the issue tracker section, I'll move to that version of SharpMap (note: it's not V2 version found on google code repository... since I can't find a way to make it work --').
In this version LayersCollection handles a collection changed event well suited for this job, so this issue could be wasily fixed :P
May 23, 2007 at 11:25 AM
Blade, sorry I could get back to this earlier. I could not find the function: ClearSelection(); in the code. I see you commented it, in your file for download. Where is this?

Also, can we use this funtion: GetGeometryByID and recongnise the poligon we are selecting? (Without using NTS..)

May 24, 2007 at 7:07 PM
I worked a bit with MapBox control, and I'll update submission soon (there were few bugs I found while using it... maybe the ClearSelection was commented out since it was not complete when I submitted my code).
About GetGeometryByID... I don't know... I fear the function searches in the full layer, and this way it can be very slow on large layer files... I think NTS is the only way to retreive exact geometry ATM :(