Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports ASPNET.StarterKit.Chart

Namespace ASPNET.StarterKit.TimeTracker.Web

    '*********************************************************************
    '	TimeEntryBarChart Page
    '
    '	This page is used to generate bar graph image dynamically for Time Entry Page
    '
    '*********************************************************************

    Public Class TimeEntryBarChart
        Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            ' Set return type to png image format
            Response.ContentType = "image/png"

            Dim xValues, yValues As String

            ' Get input parameters from query string
            xValues = Request.QueryString("xValues")
            yValues = Request.QueryString("yValues")

            If Not (xValues Is Nothing) And Not (yValues Is Nothing) Then
                Dim bmp As Bitmap
                Dim memStream As New MemoryStream()
                Dim bar As New BarGraph(Color.White)

                ' Set bar color for 7 days
                Dim i As Integer
                For i = 0 To 6
                    bar.SetColor(i, Color.Sienna)
                Next i
                ' Graph settings
                bar.VerticalTickCount = 2
                bar.ShowLegend = False
                bar.ShowData = True
                bar.Height = 119
                bar.Width = 195
                bar.TopBuffer = 5
                bar.BottomBuffer = 15
                bar.FontColor = Color.Gray

                bar.CollectDataPoints(xValues.Split("|".ToCharArray()), yValues.Split("|".ToCharArray()))
                bmp = bar.Draw()

                ' Render BitMap Stream Back To Client
                bmp.Save(memStream, ImageFormat.Png)
                memStream.WriteTo(Response.OutputStream)
            End If
        End Sub 'Page_Load
    End Class 'TimeEntryBarChart
End Namespace 'ASPNET.StarterKit.TimeTracker.Web


