Skip to content

Style

Namespace: ThinkGeo.Core

This abstract class is the root for all styles used for drawing features.

public abstract class Style

Inheritance objectStyle

Remarks:

If you need to create your own style in the future, we suggest that you first consider extending an existing style. If you are doing something new, then you can inherit from this class.

The key method to override is DrawCore. If you want to provide a sample for the legend, you will also want to extend the DrawSampleCore.

Properties

Name

This property gets and set the name of the style.

public string Name { get; set; }

Property Value

string
This property gets the name of the style.

Remarks:

This name is not used by the system; it is only for the developer. However, it can be used if you generate your own legend.

IsActive

This property gets and sets the active status of the style.

public bool IsActive { get; set; }

Property Value

bool
This property gets the active status of the style.

Remarks:

If the style is not active then it will not draw.

RequiredColumnNames

This property gets the collection of fields that are required for the style.

public Collection<string> RequiredColumnNames { get; }

Property Value

Collection<string>

Remarks:

This property gets the collection of fields that are required for the style. These are in addition to any other columns you specify in styles that inherit from this one. For example, if you have use a ValueStyle and it requires a column name for the value comparison, then that column does not need to be in this collection. You only use the RequiredColumnNames for columns you need beyond those required by specific inherited styles.

Filters

Gets the list of SQL-style filters applied to this style.

public Collection<string> Filters { get; }

Property Value

Collection<string>

LabelDisplayMode

Gets the current label display mode that determines whether labels, shapes, or both are rendered.

public LabelDisplayMode LabelDisplayMode { get; }

Property Value

LabelDisplayMode

Methods

CloneDeep()

Creates a deep clone of this style. By default, this method uses for cloning.

public Style CloneDeep()

Returns

Style
A cloned instance.

Remarks:

Deep cloning may be heavy or unreliable for custom styles. Override to provide a more efficient or specialized cloning implementation if necessary.

CloneDeepCore()

The core virtual method that performs the deep clone operation. By default, it uses .

protected Style CloneDeepCore()

Returns

Style
A cloned instance.

Draw(IEnumerable<Feature>, GeoCanvas, Collection<SimpleCandidate>, Collection<SimpleCandidate>)

This method draws the features on the view you provided.

public void Draw(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)

Parameters

features IEnumerable<Feature>
This parameter represents the features you want to draw on the view.

canvas GeoCanvas
This parameter represents the view you want to draw the features on.

labelsInThisLayer Collection<SimpleCandidate>
The labels will be drawn in the current layer only.

labelsInAllLayers Collection<SimpleCandidate>
The labels will be drawn in all layers.

Returns

void
None

Exceptions

ArgumentNullException
If you pass a null as the view, we will throw an ArgumentNullException.

ArgumentNullException
If you pass a null as the features, we will throw an ArgumentNullException.

InvalidOperationException
In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.

Remarks:

This method is the concrete wrapper for the abstract method DrawCore. In this method, we take the features you passed in and draw them on the view you provided. Each style (based on its properties) may draw each feature differently.

As this is a concrete public method that wraps a Core method, we reserve the right to add events and other logic to pre- or post-process data returned by the Core version of the method. In this way, we leave our framework open on our end, but also allow you the developer to extend our logic to suit your needs. If you have questions about this, please contact our support team as we would be happy to work with you on extending our framework.

Draw(IEnumerable<BaseShape>, GeoCanvas, Collection<SimpleCandidate>, Collection<SimpleCandidate>)

This method draws the shapes on the view you provided.

public void Draw(IEnumerable<BaseShape> shapes, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)

Parameters

shapes IEnumerable<BaseShape>
This parameter represents the shapes you want to draw on the view.

canvas GeoCanvas
This parameter represents the view you want to draw the shapes on.

labelsInThisLayer Collection<SimpleCandidate>
The labels will be drawn in the current layer only.

labelsInAllLayers Collection<SimpleCandidate>
The labels will be drawn in all layers.

Returns

void
None

Exceptions

ArgumentNullException
If you pass a null as the view, we will throw an ArgumentNullException.

ArgumentNullException
If you pass a null as the features, we will throw an ArgumentNullException.

InvalidOperationException
In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.

Remarks:

This method is the concrete wrapper for the abstract method DrawCore. In this method, we take the shapes you passed in and draw them on the view you provided. Each style (based on its properties) may draw each shape differently.

As this is a concrete public method that wraps a Core method, we reserve the right to add events and other logic to pre- or post-process data returned by the Core version of the method. In this way, we leave our framework open on our end, but also allow you the developer to extend our logic to suit your needs. If you have questions about this, please contact our support team as we would be happy to work with you on extending our framework.

DrawCore(IEnumerable<Feature>, GeoCanvas, Collection<SimpleCandidate>, Collection<SimpleCandidate>)

This method draws the features on the view you provided.

protected abstract void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)

Parameters

features IEnumerable<Feature>
This parameter represents the features you want to draw on the view.

canvas GeoCanvas
This parameter represents the view you want to draw the features on.

labelsInThisLayer Collection<SimpleCandidate>
The labels will be drawn in the current layer only.

labelsInAllLayers Collection<SimpleCandidate>
The labels will be drawn in all layers.

Returns

void
None

Remarks:

This abstract method is called from the concrete public method Draw. In this method, we take the features you passed in and draw them on the view you provided. Each style (based on its properties) may draw each feature differently.

When implementing this abstract method, consider each feature and its column data values. You can use the full power of the GeoCanvas to do the drawing. If you need column data for a feature, be sure to override the GetRequiredColumnNamesCore and add the columns you need to the collection. In many of the styles, we add properties to allow the user to specify which field they need; then, in the GetRequiredColumnNamesCore, we read that property and add it to the collection.

DrawWithoutLabeling(IEnumerable<Feature>, GeoCanvas)

Draws the style without evaluating any labeling rules and returns the candidates created during rendering.

public Collection<LabelingCandidate> DrawWithoutLabeling(IEnumerable<Feature> features, GeoCanvas canvas)

Parameters

features IEnumerable<Feature>
Features to render.

canvas GeoCanvas
Canvas that receives the drawing.

Returns

Collection<LabelingCandidate>
Labeling candidates generated during the draw pass.

DrawWithoutLabelingCore(IEnumerable<Feature>, GeoCanvas)

Provides the overridable implementation that draws without labeling.

protected Collection<LabelingCandidate> DrawWithoutLabelingCore(IEnumerable<Feature> features, GeoCanvas canvas)

Parameters

features IEnumerable<Feature>
The features.

canvas GeoCanvas
The to draw to.

Returns

Collection<LabelingCandidate>
The result of the operation.

GetRequiredColumnNames()

This method returns the column data for each feature that is required for the style to properly draw.

public Collection<string> GetRequiredColumnNames()

Returns

Collection<string>
This method returns a collection of column names that the style needs.

Remarks:

This method is the concrete wrapper for the abstract method GetRequiredColumnNamesCore. In this method, we return the column names that are required for the style to draw the feature properly. For example, if you have a style that colors areas blue when a certain column value is over 100, then you need to be sure you include that column name. This will ensure that the column data is returned to you in the feature when it is ready to draw.

In many of the styles, we add properties to allow the user to specify which field they need; then, in the GetRequiredColumnNamesCore we read that property and add it to the collection.
As this is a concrete public method that wraps a Core method, we reserve the right to add events and other logic to pre- or post-process data returned by the Core version of the method. In this way, we leave our framework open on our end, but also allow you the developer to extend our logic to suit your needs. If you have questions about this, please contact our support team as we would be happy to work with you on extending our framework.

4jI=(string, char, char, Action<string>)

internal static void 4jI=(string content, char start, char end, Action<string> oneParsed)

Parameters

content string

start char

end char

oneParsed Action<string>

Returns

void

GetRequiredColumnNamesCore()

This method returns the column data for each feature that is required for the style to properly draw.

protected Collection<string> GetRequiredColumnNamesCore()

Returns

Collection<string>
This method returns a collection of column names that the style needs.

Remarks:

This abstract method is called from the concrete public method GetRequiredFieldNames. In this method, we return the column names that are required for the style to draw the feature properly. For example, if you have a style that colors areas blue when a certain column value is over 100, then you need to be sure you include that column name. This will ensure that the column data is returned to you in the feature when it is ready to draw.

In many of the styles, we add properties to allow the user to specify which field they need; then, in the GetRequiredColumnNamesCore we read that property and add it to the collection.

DrawSample(GeoCanvas, DrawingRectangleF)

This method draws a sample feature on the view you provided.

public void DrawSample(GeoCanvas canvas, DrawingRectangleF drawingExtent)

Parameters

canvas GeoCanvas
This parameter represents the view you want to draw the features on.

drawingExtent DrawingRectangleF
Specifies the drawingExtent.

Returns

void
None

Exceptions

ArgumentNullException
If you pass a null as the view, we will throw an ArgumentNullException.

InvalidOperationException
In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.

Remarks:

This method is the concrete wrapper for the abstract method DrawSampleCore. In this method we draw a sample style on the view you provided. This is typically used to display a legend or other sample area.

As this is a concrete public method that wraps a Core method, we reserve the right to add events and other logic to pre- or post-process data returned by the Core version of the method. In this way, we leave our framework open on our end, but also allow you the developer to extend our logic to suit your needs. If you have questions about this, please contact our support team as we would be happy to work with you on extending our framework.

DrawSample(GeoCanvas)

Draws a sample representation of the style, typically for use in legends.

public void DrawSample(GeoCanvas canvas)

Parameters

canvas GeoCanvas
Canvas that receives the sample drawing.

Returns

void

DrawSampleCore(GeoCanvas, DrawingRectangleF)

This method draws a sample feature on the view you provided.

protected void DrawSampleCore(GeoCanvas canvas, DrawingRectangleF drawingExtent)

Parameters

canvas GeoCanvas
This parameter represents the view you want to draw the features on.

drawingExtent DrawingRectangleF
Specifies the drawingExtent.

Returns

void
None

Exceptions

ArgumentNullException
If you pass a null as the view, we will throw an ArgumentNullException.

InvalidOperationException
In the event you attempt to call this method when the GeoCanvas's IsDrawing mode is false, it will throw an InvalidOperationException.

Remarks:

This virtual method is called from the concrete public method Draw. In this method, we draw a sample style on the view you provided. This is typically used to display a legend or other sample area.

When implementing this virtual method, consider the view size and draw the sample image appropriately. You should keep in mind that the sample typically shows up on a legend.

SaveStyle(string)

Persists the style definition to a file using XML serialization.

public void SaveStyle(string filePathName)

Parameters

filePathName string
Destination path for the serialized style.

Returns

void

SaveStyle(Stream)

Persists the style definition to the provided stream.

public void SaveStyle(Stream stream)

Parameters

stream Stream
Writable stream receiving the serialized style.

Returns

void

LoadStyle(Uri)

Loads a style from the specified URI.

public static Style LoadStyle(Uri styleUri)

Parameters

styleUri Uri
Location of the serialized style document.

Returns

Style
A deserialized .

LoadStyle(Stream)

Loads a style from the provided stream.

public static Style LoadStyle(Stream styleStream)

Parameters

styleStream Stream
Stream that contains a serialized style.

Returns

Style
A deserialized .

SetLabelDisplayMode(LabelDisplayMode)

Sets the label display mode used for this style instance.

public void SetLabelDisplayMode(LabelDisplayMode displayMode)

Parameters

displayMode LabelDisplayMode
New mode describing how labels should be handled.

Returns

void

GetSubStyles()

Gets the collection of substyles that make up this style.

public Collection<Style> GetSubStyles()

Returns

Collection<Style>
A collection of child styles.

GetSubStylesCore()

Provides the overridable implementation that returns sub styles.

protected Collection<Style> GetSubStylesCore()

Returns

Collection<Style>
The result of the operation.