What is the proper way to use DrawSample? I tried to simply provide it a canvas object but I get a purposeful NullException and see it is meant to be Inheritted but didn't exactly understand how.
thanks.
What is the proper way to use DrawSample? I tried to simply provide it a canvas object but I get a purposeful NullException and see it is meant to be Inheritted but didn't exactly understand how.
thanks.
Nevermind, the following snippet was sufficient. I didn't realize there was a GDIPlusCanvas:
Dim canvas As New GdiPlusGeoCanvas
Dim areaStyle As New AreaStyle(New GeoPen(GeoColor.FromArgb(255, picAreaOutlineColor.BackColor.R, picAreaOutlineColor.BackColor.G, picAreaOutlineColor.BackColor.B), numAreaOutlineSize.Value), New GeoSolidBrush(GeoColor.FromArgb(255, picAreaFillColor.BackColor.R, picAreaFillColor.BackColor.G, picAreaFillColor.BackColor.B)))
Dim rect As New RectangleShape(0, 6, 6, 0)
picPreview.ImageLocation = "C:\pic.bmp"
picPreview.Load()
canvas.BeginDrawing(picPreview.Image, rect, GeographyUnit.Meter)
areaStyle.DrawSample(canvas)
canvas.EndDrawing()
Great you make it, Nelson.
I have a quick question regarding this topic. I have read in passing that not all styles will DrawSample. Admittedly, I haven't looked to far into this, but I am unable to get PointStyle.DrawSample to draw. I will see my "unlicensed" labels draw though and no error occurs. The following code determines what type of sample i'm trying to create and renders accordingly. What do I seem to be missing?
Dim canvas As New GdiPlusGeoCanvas
Dim penOutline As GeoPen = Nothing
Dim brushFill As GeoSolidBrush = Nothing
Dim areaStyle As AreaStyle = Nothing
Dim lineStyle As LineStyle = Nothing
Dim pointStyle As PointStyle = Nothing
Dim rect As New RectangleShape(0, 10, 10, 0)
Dim colorOutline As New GeoColor(0, 0, 0, 0)
Dim colorFill As New GeoColor(0, 0, 0, 0)
Dim bmpPreview As New Bitmap(picPreview.Width, picPreview.Height, Imaging.PixelFormat.Format32bppArgb)
picPreview.Image = bmpPreview
canvas.BeginDrawing(picPreview.Image, rect, GeographyUnit.Meter)
Select Case cmbFeatureType.SelectedValue
Case LayerConfig.FeatureTypes.Point
If chkTransOutline.Checked = True Then
colorOutline = New GeoColor(picPointOutlineColor.BackColor.R, _
picPointOutlineColor.BackColor.G, _
picPointOutlineColor.BackColor.B)
End If
penOutline = New GeoPen(colorOutline, numAreaOutlineSize.Value)
If chkTransFill.Checked = True Then
colorFill = New GeoColor(picPointFillColor.BackColor.R, _
picPointFillColor.BackColor.G, _
picPointFillColor.BackColor.B)
Else
colorFill = New GeoColor(0, 0, 0, 0)
End If
brushFill = New GeoSolidBrush(colorFill)
'cmbPointStyle = 0, brush and pen are valid, numPointSize.value is 1D but even hard
'coding '1' does not work
pointStyle = New PointStyle(cmbPointStyle.SelectedValue, brushFill, penOutline, CInt(numPointSize.Value))
pointStyle.DrawSample(canvas)
Case LayerConfig.FeatureTypes.Line
If chkTransLine.Checked = True Then
colorOutline = New GeoColor(picLineColor.BackColor.R, _
picLineColor.BackColor.G, _
picLineColor.BackColor.B)
End If
penOutline = New GeoPen(colorOutline, numLineSize.Value)
lineStyle = New LineStyle(penOutline)
lineStyle.DrawSample(canvas)
Case LayerConfig.FeatureTypes.Polygon
If chkTransOutline.Checked = True Then
colorOutline = New GeoColor(picAreaOutlineColor.BackColor.R, _
picAreaOutlineColor.BackColor.G, _
picAreaOutlineColor.BackColor.B)
End If
penOutline = New GeoPen(colorOutline, numAreaOutlineSize.Value)
If chkTransFill.Checked = True Then
colorFill = New GeoColor(picAreaFillColor.BackColor.R, _
picAreaFillColor.BackColor.G, _
picAreaFillColor.BackColor.B)
Else
colorFill = New GeoColor(0, 0, 0, 0)
End If
brushFill = New GeoSolidBrush(colorFill)
areaStyle = New AreaStyle(penOutline, brushFill)
areaStyle.DrawSample(canvas)
End Select
canvas.EndDrawing()
It's worth noting that I can get the point styles to draw if I apply it to a FeatureLayer of any sort, so its specific to this particular scenario where I want to DrawSample a PointStyle. I noticed in Map Suite Explorer you do preview points so I am not sure that I am going about it correctly... While we're at it, what styles do not display samples? Thanks.
Nelson,
There is a known bug that the PointStyle and LineStyle’s DrawSample() doesn’t work properly. We will make it right in the next version and sorry for the inconvenience for now. Here is a relative post please have a look if you are interested.
gis.thinkgeo.com/Support/Dis...fault.aspx
Thanks,
Ben
Thank you.
You are welcome, Nelson.