Custom draw using System.Drawing.Graphic

TatukGIS Internet Server LITE Samples


Source code    Project files

This sample shows how to expose full .NET drawing capabilities with the TatukGIS Internet Server.

OnBeforePaint, OnPaint and OnAfterPaint provide standard PaintEventArgs argument to allow the use of System.Drawing.Graphics object as the developer of the web mapping solution may require.

In this sample we simply display the current time in the upper corner and draw a semitransparent yellow circle.


customdraw.aspx    Top

                        
<%@ Page Language="VB" Debug="True" %>
<%@ Register TagPrefix="ttkGIS" Namespace="TatukGIS.IS" Assembly="TatukGIS.IS" %>
<script runat="server">

  Sub GIS_FullExtent_Click(sender As Object, e As ImageClickEventArgs)
    GIS.FullExtent
  End Sub

  Sub GIS_ZoomIn_Click(sender As Object, e As ImageClickEventArgs)
    GIS.ZoomIn
  End Sub

  Sub GIS_ZoomOut_Click(sender As Object, e As ImageClickEventArgs)
    GIS.ZoomOut
  End Sub

  Sub GIS_Smaller_Click(sender As Object, e As ImageClickEventArgs)
    GIS.Width  = Unit.Pixel( GIS.Width.Value  - 54 )
    GIS.Height = Unit.Pixel( GIS.Height.Value - 40 )
  End Sub

  Sub GIS_Larger_Click(sender As Object, e As ImageClickEventArgs)
    GIS.Width  = Unit.Pixel( GIS.Width.Value  + 54 )
    GIS.Height = Unit.Pixel( GIS.Height.Value + 40 )
  End Sub

  Sub GIS_Load(sender As Object, e As EventArgs)
    GIS.Open( Page.MapPath( "data/locate.ttkgp" ) )
  End Sub

  Sub GIS_AfterPaint(sender As Object, e As PaintEventArgs)
    Dim drawFont As New Drawing.Font("Arial", 10)
    Dim drawBrush As New Drawing.SolidBrush(Drawing.Color.Green)
    e.Graphics.DrawString( "Current time", drawFont, drawBrush, 10, 10 )

    Dim drawFont2 As New Drawing.Font("Arial", 12)
    Dim drawBrush2 As New Drawing.SolidBrush(Drawing.Color.Red)
    e.Graphics.DrawString( Now, drawFont2, drawBrush2, 10, 25 )

    Dim yellowPen As New Drawing.Pen(Drawing.Color.FromArgb(128, 255, 255, 0), 15)
    Dim x As Single = 100F
    Dim y As Single = 100F
    Dim width As Single = 200F
    Dim height As Single = 100F
    e.Graphics.DrawEllipse(yellowPen, x, y, width, height)
  End Sub


</script>
<html>
<head>
  <link href="style.css" type="text/css" rel="stylesheet" />
  <title>TatukGIS IS LITE Sample - Custom draw</title>
</head>
<body>
  <a name="top">
  <h1>Custom draw using System.Drawing.Graphic
  </h1>
  <h2 class="comment"><a href="../samplesLITE.htm">TatukGIS IS LITE Samples</a>
  </h2>

  <form runat="server">
    <p>
    <br />
    </p>
      <p>
        <table cellspacing="0" cellpadding="0" border="0">
          <tbody>
            <tr>
              <td>
                <asp:ImageButton id="GIS_FullExtent" onclick="GIS_FullExtent_Click" runat="server" ImageUrl="/TatukGIS_IS8/Img/fullextent.gif"></asp:ImageButton>
                <asp:ImageButton id="GIS_ZoomIn" onclick="GIS_ZoomIn_Click" runat="server" ImageUrl="/TatukGIS_IS8/Img/zoomin.gif"></asp:ImageButton>
                <asp:ImageButton id="GIS_ZoomOut" onclick="GIS_ZoomOut_Click" runat="server" ImageUrl="/TatukGIS_IS8/Img/zoomout.gif"></asp:ImageButton>
              </td>
              <td align="right">
                <asp:ImageButton id="GIS_Smaller" onclick="GIS_Smaller_Click" runat="server" ImageUrl="/TatukGIS_IS8/Img/smaller.gif"></asp:ImageButton>
              <asp:ImageButton id="GIS_Larger" onclick="GIS_Larger_Click" runat="server" ImageUrl="/TatukGIS_IS8/Img/larger.gif"></asp:ImageButton>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <p>
                  <ttkGIS:XGIS_VIEWERIS id="GIS" runat="server" OnAfterPaint="GIS_AfterPaint" Height="360px" BorderColor="CornflowerBlue" BorderWidth="1px" ImageType="PNG24" OnLoad="GIS_Load" Width="460px"></ttkGIS:XGIS_VIEWERIS>
                </p>
              </td>
            </tr>
          </tbody>
        </table>
      </p>
    </form>
  </a>
</body>
</html>

                        

locate.ttkgp    Top

                        
[TatukGIS]

[TatukGIS Layer1]
path=states.shp
name=states
                        

states.shp.ini    Top

                        
[TatukGIS Layer]
Area.OutlineWidth=-1
Area.OutlineColor=205:100:100
Area.Color=200:230:200

[TatukGIS Layer 1]
Style=FlushS
Area.Pattern=solid
Area.Color=98:180:96
Area.OutlineColor=205:100:100
Area.OutlineStyle=solid
Area.OutlineWidth=-1