ThinkGeo.com    |     Blog    |     Wiki    |     Support

Custom DrawCore

I develop an application using MapSuite 10 for Winforms. I want to know if there is a way to create a custom class that inherits any style (PointStyle, AreaStyle…) and overrides the DrawCore sub in order to display a feature from the IEnurable features input in a custom way (different images, texts…) or dynamically create/exclude features (as the ClusterPointStyle does)

I have already used this code.

Imports System.Collections.ObjectModel
Imports Microsoft.Office.Core
Imports ThinkGeo.MapSuite.Drawing
Imports ThinkGeo.MapSuite.Shapes
Imports ThinkGeo.MapSuite.Styles

<Serializable()>
Public Class MyCustomStyle

Inherits 

Sub New()
    MyBase.New()
End Sub

Protected Overrides Sub DrawCore(features As IEnumerable(Of Feature), canvas As GeoCanvas, labelsInThisLayer As Collection(Of SimpleCandidate), labelsInAllLayers As Collection(Of SimpleCandidate))
    MyBase.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers)
   'I don't want to use DrawCore as it is. Is there a way for me to create something more custom
End Sub

End Class

Hi Mario,

I think override DrawCore is enough for your requirement, because draw everything to canvas is in this function. Please let me know one of your detail scenario, so we can discuss it and help you solve the problem when implement it.

And in our map you need assign different style for different feature type, so you shouldn’t want to build a style which can draw for both area and point.

Regards,

Ethan

Can you send me an example where you draw features on the map from the inside of DrawCore sub with different image for each feature?

Hi Mario,

I think your scenario: show different image for different feature(point), don’t need write custom style.

Please view this sample: https://github.com/ThinkGeo/DefaultValueStyleSample-ForWpf

Value style can shows different style based on the value in target column value of feature.

You can set different image as point style for different feature based on it.

PointStyle ps = new PointStyle(new ThinkGeo.MapSuite.Drawing.GeoImage(“imagePath”));

Wish that’s helpful.

Regards,

Ethan