Hi,
Are there any examples or documentation on how to use "LineDashStyle.Custom" in LineStyles.CreateSimpleLineStyle() ?
Thanks.
Hi,
Are there any examples or documentation on how to use "LineDashStyle.Custom" in LineStyles.CreateSimpleLineStyle() ?
Thanks.
Lars,
Our LineDashStyle.Custom is the same as the LineDashStyle.Custom of System.Drawing.Drawing2D namespace, so you can reference the documentation on the MSDN directly, also here is the sample code for the LineDashStyle class so that you can understand it clearly below:
Also you can reference the link on the MSDN below:
protected void Page_Load(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(600, 120);
Graphics gph;
gph = Graphics.FromImage(bmp);
gph.Clear(Color.Green);
Pen mypen = new Pen(Color.Red, 2);
mypen.DashStyle = DashStyle.Custom;
gph.DrawLine(mypen, 10, 10, 300, 10);
mypen.DashStyle = DashStyle.Dash;
gph.DrawLine(mypen, 10, 30, 300, 30);
mypen.DashStyle = DashStyle.DashDot;
gph.DrawLine(mypen, 10, 50, 300, 50);
mypen.DashStyle = DashStyle.DashDotDot;
gph.DrawLine(mypen, 10, 70, 300, 70);
mypen.DashStyle = DashStyle.Dot;
gph.DrawLine(mypen, 10, 90, 300, 90);
mypen.DashStyle = DashStyle.Solid;
gph.DrawLine(mypen, 10, 110, 300, 110);
bmp.Save(Response.OutputStream, ImageFormat.Gif);
}
msdn.microsoft.com/en-us/lib...S.80).aspx
Any more questions please let us know,
Thanks,
Scott,
Hi Scott,
Hmm, I don't see how the sample code helps, as it doesn't include any setting of a "custom" (i.e. user defined) line style. I'll have a thorough look into the System.Drawing namespace, though.
On a related note: How can I define a new custom line style that incorporates complex styling on top of each other ? E.g. one that shows symbols at certain distances along a vector, left and right of the mid vector ?
I've looked at utilizing New LineStyle(New GeoPen(new GeoBrush(...))), but it looks like the GeoBrush class isn't included in the ThinkGeo.MapSuite.Core namespace, even though - according to the documentation - it ought to be there !??
Are the any samples on how to utilize GeoBrush in construction of complex LineStyle's ?
Is this also a matter of referring to the standard System.Drawing libraries ?
TIA
Hi again,
I later found the MustInherit tag on GeoBrush, and the 4 dependent classes, e.g. GeoSolidBrush. No worries then.
I also discovered the LineStyle.CustomLineStyles collection. That looks more like what I need.
But how is this collection used. I've tried to add two LineStyle's, but now my vectors aren't rendered at all.
The relevant code piece is below (I do end up in the "else" section) :
For Each ft As Feature In features
useLineStyle = m_lineStyle
If m_symColumnName1 <> "" Then
If ft.ColumnValues(m_symColumnName1) Is DBNull.Value OrElse ft.ColumnValues(m_symColumnName1).ToString().Trim() = "" Then
'default style
Else
useLineStyle = New LineStyle()
useLineStyle.CustomLineStyles.Clear()
Dim p1 = New GeoPen(New GeoColor(255, 255, 255), 3)
useLineStyle.CustomLineStyles.Add(New LineStyle(p1))
Dim p2 = New GeoPen(New GeoColor(255, 0, 0), 1)
useLineStyle.CustomLineStyles.Add(New LineStyle(p2))
End If
End If
Dim featureCollection As Collection(Of Feature) = New Collection(Of Feature)()
featureCollection.Add(ft)
useLineStyle.Draw(featureCollection, canvas, labelsInThisLayer, labelsInAllLayers)
Next
TIA
Hi again,
I had a sudden inspirational spark, and replaced the “useLineStyle = New LineStyle()” statement with a statement with initial content (a GeoPen definition). And lo and behold, it now renders as it should.
Apparently something’s amiss when creating a LineStyle object without an initial content. A small bug perhaps ? :-)
Lars,
Thanks for your post, accroding to our tests it is an real bug in our product, we have fixed it and please get the latest DailyBuild of development branch from web edition and try again.
Also if you want to use GeoBrush, please use it sub-class GeoSolidBrush, the GeoBrush is a abstract class, you can not instance it. You can refer the LoadAGridFileFeatureLayer.aspx sample in the HowDoISamples to understand how to use GeoSolidBrush with styls.
If you still have any more questions please let me know,
Thanks,
Scott,