Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports PlexityHide.GTP

Namespace MainSample
	''' <summary>
	''' Summary description for WebForm1.
	''' </summary>
	Public Class WebForm1 : Inherits System.Web.UI.Page
	Protected WithEvents Gantt_ASP1 As PlexityHide.GTP.WEB.Gantt_ASP
	Protected Label1 As System.Web.UI.WebControls.Label
	Protected Label2 As System.Web.UI.WebControls.Label
	Protected Label3 As System.Web.UI.WebControls.Label
	Protected Label4 As System.Web.UI.WebControls.Label
	Protected Label5 As System.Web.UI.WebControls.Label
	Protected RBLTimeItemColor As System.Web.UI.WebControls.RadioButtonList
	Protected Label10 As System.Web.UI.WebControls.Label
	Protected Label6 As System.Web.UI.WebControls.Label
	Protected WithEvents RBLTimeItemArea As System.Web.UI.WebControls.RadioButtonList
	Protected Label7 As System.Web.UI.WebControls.Label
	Protected RBLGridColors As System.Web.UI.WebControls.RadioButtonList
	Protected cbRelations As System.Web.UI.WebControls.CheckBox
	Protected cbTimeItemTexts As System.Web.UI.WebControls.CheckBox
	Protected cbUserDraw As System.Web.UI.WebControls.CheckBox
	Protected Label8 As System.Web.UI.WebControls.Label
	Protected Label9 As System.Web.UI.WebControls.Label
	Protected Label11 As System.Web.UI.WebControls.Label
	Protected Label12 As System.Web.UI.WebControls.Label
	Protected WithEvents gantt_ASPSettings1 As PlexityHide.GTP.WEB.Gantt_ASPSettings


	Private Function AddDemoRow(ByVal parent As GridNode, ByVal s1 As String, ByVal s2 As String, ByVal s3 As String) As GridNode

	  Dim gn As GridNode
	  If Not parent Is Nothing Then
		gn=parent.SubNodes.AddNode()
	  Else
		gn=Gantt_ASP1.Gantt.Grid.GridStructure.RootNodes.AddNode()
	  End If

	  gn.GetCell(0).Content.Value=s1
	  gn.GetCell(1).Content.Value=s2
	  Return gn

	End Function

	Private Function AddDemoTimeItemLayout(ByVal Name As String, ByVal c1 As Color, ByVal c2 As Color, ByVal ts As TimeItemStyle) As TimeItemLayout
	  Dim til As TimeItemLayout = New TimeItemLayout()
	  til.Name=Name
	  gantt_ASPSettings1.Gantt.TimeItemLayouts.Add(til)
	  til.Color=c1
	  til.GradientColor=c2
	  til.BrushKind=BrushKind.GradientHorizontal
	  til.TimeItemStyle=ts
	  If til.TimeItemStyle=TimeItemStyle.Romb Then
		til.FixedSize=25
		til.FixedSizeUse=True
	  End If
	  til.TopInset=10
	  til.BottomInset=10

	  til.SelectHandles=Color.Black

	  Return til
	End Function

'TODO: INSTANT VB TODO TASK: stop is a keyword in VB.NET. Change the name or use square brackets to override it:
'INSTANT VB NOTE: The parameter stop was renamed since it is a keyword in VB:
	Private Function AddDemoTimeItem(ByVal gn As GridNode, ByVal start As Integer, ByVal stop_Renamed As Integer, ByVal aTimeItemLayoutName As String) As TimeItem
	  Dim ti As TimeItem=GanttRow.FromGridNode(gn).Layers(0).AddNewTimeItem()
	  ti.Start=Gantt_ASP1.Gantt.DateScaler.StartTime.AddDays(start)
	  ti.Stop=ti.Start.AddDays(stop_Renamed)
	  ti.TimeItemLayout=gantt_ASPSettings1.Gantt.TimeItemLayouts.GetFromName(aTimeItemLayoutName)
	  Return ti
	End Function

	Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

	  ' Initialize the Gantt, this can be done with databind or the api's

	  If (Not IsPostBack) Then

	  End If


	  Dim cl As CellLayout=Gantt_ASP1.Gantt.Grid.CellLayouts.GetFromName("Default")


		  If RBLGridColors.SelectedItem.Value="1" Then
		cl.HeaderBackgroundColor=Color.Wheat
		cl.Font = New Font("Geneva",10)
		cl.BackgroundColor=Color.WhiteSmoke
	  Else
	  If RBLGridColors.SelectedItem.Value="2" Then
		cl.HeaderBackgroundColor=Color.White
		cl.Font = New Font("Terminal",8)
		cl.BackgroundColor=Color.White
	  Else
	  If RBLGridColors.SelectedItem.Value="3" Then
		cl.HeaderBackgroundColor=Color.Beige
		cl.Font = New Font("Times",12)
		cl.BackgroundColor=Color.PeachPuff
	  Else
	  If RBLGridColors.SelectedItem.Value="4" Then
		cl.Font = New Font("Helvetica",10)
	  End If
	  End If
	  End If
	  End If

		  '--------------------------

		  If RBLTimeItemArea.SelectedItem.Value="2" Then
			Gantt_ASP1.Gantt.PyjamasColor=Color.Thistle
		Gantt_ASP1.Gantt.TimeItemArea.BackColor=Color.SaddleBrown
	  Else
	  If RBLTimeItemArea.SelectedItem.Value="3" Then
		Gantt_ASP1.Gantt.PyjamasColor=Color.Green
		Gantt_ASP1.Gantt.TimeItemArea.BackColor=Color.SeaShell
	  Else
	  If RBLTimeItemArea.SelectedItem.Value="4" Then
		Gantt_ASP1.Gantt.PyjamasColor=Color.Green
		Gantt_ASP1.Gantt.TimeItemArea.BackColor=Color.YellowGreen
	  End If
	  End If
	  End If

	  '--------------------------




	  If RBLTimeItemColor.SelectedItem.Value="1" Then
		AddDemoTimeItemLayout("span",Color.Tomato,Color.Red,TimeItemStyle.Span)
		AddDemoTimeItemLayout("square",Color.BlueViolet,Color.DarkBlue,TimeItemStyle.Square)
		AddDemoTimeItemLayout("romb",Color.White,Color.Lavender,TimeItemStyle.Romb)
		AddDemoTimeItemLayout("line",Color.BlanchedAlmond,Color.Aquamarine,TimeItemStyle.LineWEnd)
	  Else
	  If RBLTimeItemColor.SelectedItem.Value="2" Then
		AddDemoTimeItemLayout("span",Color.Azure,Color.Aquamarine,TimeItemStyle.Span)
		AddDemoTimeItemLayout("square",Color.Brown,Color.BurlyWood,TimeItemStyle.Square)
		AddDemoTimeItemLayout("romb",Color.LightGray,Color.DarkGray,TimeItemStyle.Romb)
		AddDemoTimeItemLayout("line",Color.BlanchedAlmond,Color.Aquamarine,TimeItemStyle.LineWEnd)
	  Else
	  If RBLTimeItemColor.SelectedItem.Value="3" Then
		AddDemoTimeItemLayout("span",Color.BlueViolet,Color.Blue,TimeItemStyle.Span)
		AddDemoTimeItemLayout("square",Color.Black,Color.LightGray,TimeItemStyle.Square)
		AddDemoTimeItemLayout("romb",Color.GreenYellow,Color.Green,TimeItemStyle.Romb)
		AddDemoTimeItemLayout("line",Color.CadetBlue,Color.Lavender,TimeItemStyle.LineWEnd)
	  Else
	  If RBLTimeItemColor.SelectedItem.Value="4" Then
		AddDemoTimeItemLayout("span",Color.Yellow,Color.YellowGreen,TimeItemStyle.Span)
		AddDemoTimeItemLayout("square",Color.Bisque,Color.Beige,TimeItemStyle.Square)
		AddDemoTimeItemLayout("romb",Color.White,Color.WhiteSmoke,TimeItemStyle.Romb)
		AddDemoTimeItemLayout("line",Color.Violet,Color.DarkBlue,TimeItemStyle.LineWEnd)
	  End If
	  End If
	  End If
	  End If


	  ' Put user code to initialize the page here
	  Gantt_ASP1.Gantt.Grid.RootNodes.Clear()


	  For i As Integer = 0 To 9
		Dim p1 As GridNode=AddDemoRow(Nothing,"Power" & i.ToString(),"Extra" & i.ToString(),i.ToString())
		AddDemoTimeItem(p1,1,10,"span")
		Dim p11 As GridNode=AddDemoRow(p1,"Extra","Upwards",i.ToString())
		AddDemoTimeItem(p11,5,13,"square")
		Dim p12 As GridNode=AddDemoRow(p1,"More","Reality","")
		AddDemoTimeItem(p12,5,13,"square")
		Dim p13 As GridNode=AddDemoRow(p1,"Detail","Positive","")
		Dim ti1 As TimeItem=AddDemoTimeItem(p13,5,5,"square")
		AddDemoTimeItem(p13,11,17,"square")
		Dim p14 As GridNode=AddDemoRow(p1,"Positive","Complete","")
		AddDemoTimeItem(p14,11,1,"romb")
		Dim p15 As GridNode=AddDemoRow(p1,"True","Everyday","")

		p1=AddDemoRow(Nothing,"Power","Upwards","")
		AddDemoTimeItem(p1,5,15,"span")
		AddDemoTimeItem(p1,-4,3,"line")
		p11=AddDemoRow(p1,"Extra","Upwards","")
		Dim ti2 As TimeItem=AddDemoTimeItem(p11,5,13,"square")
		p12=AddDemoRow(p1,"More","Reality","")
		AddDemoTimeItem(p12,5,13,"square")
		p13=AddDemoRow(p1,"Energy","Positive",i.ToString())
		AddDemoTimeItem(p13,5,5,"square")
		AddDemoTimeItem(p13,11,17,"square")
		p14=AddDemoRow(p1,"Positive","Complete","")
		AddDemoTimeItem(p14,11,1,"romb")
		p15=AddDemoRow(p1,"True","Everyday","")

		If cbRelations.Checked Then
		  Dim til As TimeItemLink=gantt_ASPSettings1.Gantt.TimeItemLinks.AddLink(ti1,ti2)
		  til.TimeItemLinkDrawStyle=TimeItemLinkDrawStyle.Straight
		  til.TimeItemLinkStyle=TimeItemLinkStyle.StartToStart
		  til.Width=3
		End If
		If cbTimeItemTexts.Checked Then
		  Dim tit As TimeItemText = New TimeItemText()
		  ti2.TimeItemTexts.Add(tit)
		  tit.Text="Place data here..."
		End If
	  Next i


	End Sub


		#Region "Web Form Designer generated code"
		Overrides Protected Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
	  Dim cellLayout1 As PlexityHide.GTP.CellLayout = New PlexityHide.GTP.CellLayout()
	  Dim lineOption1 As PlexityHide.GTP.LineOption = New PlexityHide.GTP.LineOption()
	  Dim lineOption2 As PlexityHide.GTP.LineOption = New PlexityHide.GTP.LineOption()
	  Dim lineOption3 As PlexityHide.GTP.LineOption = New PlexityHide.GTP.LineOption()
	  Dim lineOption4 As PlexityHide.GTP.LineOption = New PlexityHide.GTP.LineOption()
	  Dim gridColumn1 As PlexityHide.GTP.GridColumn = New PlexityHide.GTP.GridColumn()
	  Dim gridColumn2 As PlexityHide.GTP.GridColumn = New PlexityHide.GTP.GridColumn()
	  Me.gantt_ASPSettings1 = New PlexityHide.GTP.WEB.Gantt_ASPSettings()
'	  Me.RBLTimeItemArea.SelectedIndexChanged += New System.EventHandler(Me.RadioButtonList1_SelectedIndexChanged);
'	  Me.Gantt_ASP1.OnAreaAttributes += New PlexityHide.GTP.WEB.AreaAttributeEvent(Me.Gantt_ASP1_OnAreaAttributes);
'	  Me.Gantt_ASP1.OnTimeItem_ClientClick += New PlexityHide.GTP.TimeItemEvent(Me.Gantt_ASP1_OnTimeItem_ClientClick);
	  ' 
	  ' gantt_ASPSettings1
	  ' 
	  ' 
	  ' gantt_ASPSettings1.Gantt
	  ' 
	  Me.gantt_ASPSettings1.Gantt.CollisionDetectionSyncron = False
	  Me.gantt_ASPSettings1.Gantt.DateScalerHeight = 48
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.FishEyeColor = System.Drawing.Color.AliceBlue
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.FishEyeenabled = False
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.FishEyeMagnification = PlexityHide.GTP.FishEyeMagnification.M1
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.LowerBound = New System.DateTime(1000, 1, 1, 0, 0, 0, 0)
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.MarkerTextColor = System.Drawing.Color.Black
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.ResizeType = PlexityHide.GTP.ResizingType.StartAndStopLocked
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.ScaleMarkerColor = System.Drawing.Color.Black
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.ShowWeekNumbers = False
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.SpanTextColor = System.Drawing.Color.SlateGray
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.StartOfWeek = System.DayOfWeek.Sunday
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.StartTime = New System.DateTime(2003, 8, 5, 4, 40, 33, 773)
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.StopTime = New System.DateTime(2003, 9, 5, 7, 13, 44, 862)
	  Me.gantt_ASPSettings1.Gantt.DateScalerProperties.UpperBound = New System.DateTime(8000, 1, 1, 0, 0, 0, 0)
	  Me.gantt_ASPSettings1.Gantt.DrawPyjamas = True
	  Me.gantt_ASPSettings1.Gantt.FocusedTimeItem = Nothing
	  Me.gantt_ASPSettings1.Gantt.GridProperties.AutoCreateColumnsFromDataset = False
	  Me.gantt_ASPSettings1.Gantt.GridProperties.BackColor = System.Drawing.SystemColors.Control
	  Me.gantt_ASPSettings1.Gantt.GridProperties.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
	  Me.gantt_ASPSettings1.Gantt.GridProperties.BottomColor = System.Drawing.Color.White
	  cellLayout1.BackgroundColor = System.Drawing.Color.Gainsboro
	  cellLayout1.BackgroundUse = True
	  cellLayout1.DeSelectedColor = System.Drawing.SystemColors.Highlight
	  cellLayout1.EndEllipsis = False
	  cellLayout1.Font = New System.Drawing.Font("OCRB", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (CByte(0)))
	  cellLayout1.FontColor = System.Drawing.Color.Purple
	  cellLayout1.HeaderBackgroundColor = System.Drawing.Color.DarkKhaki
	  cellLayout1.HeaderBackgroundGradiantColor = System.Drawing.SystemColors.ControlLight
	  cellLayout1.HorzAlign = System.Drawing.StringAlignment.Near
	  cellLayout1.ImageIndex_Select = -1
	  cellLayout1.ImageIndex_UnSelect = -1
	  lineOption1.Color = System.Drawing.Color.LightGray
	  lineOption1.Use = True
	  lineOption1.Width = 1
	  cellLayout1.LineBottom = lineOption1
	  lineOption2.Color = System.Drawing.Color.LightGray
	  lineOption2.Use = False
	  lineOption2.Width = 1
	  cellLayout1.LineLeft = lineOption2
	  lineOption3.Color = System.Drawing.Color.LightGray
	  lineOption3.Use = True
	  lineOption3.Width = 1
	  cellLayout1.LineRight = lineOption3
	  lineOption4.Color = System.Drawing.Color.LightGray
	  lineOption4.Use = False
	  lineOption4.Width = 1
	  cellLayout1.LineTop = lineOption4
	  cellLayout1.MinHeight = 19
	  cellLayout1.Name = "Default"
	  cellLayout1.Padding = New System.Drawing.Rectangle(0, 0, 0, 0)
	  cellLayout1.SelectedColor = System.Drawing.SystemColors.Highlight
	  cellLayout1.Spacing = New System.Drawing.Rectangle(0, 0, 0, 0)
	  cellLayout1.VertAlign = System.Drawing.StringAlignment.Center
	  Me.gantt_ASPSettings1.Gantt.GridProperties.CellLayouts.Add(cellLayout1)
	  gridColumn1.AllowMove = True
	  gridColumn1.AllowResize = True
	  gridColumn1.ColumnDerivedFromDS = False
	  gridColumn1.DataSourceColumn = Nothing
	  gridColumn1.DataSourceColumnType = Nothing
	  gridColumn1.Hide = False
	  gridColumn1.LayoutName = "Default"
	  gridColumn1.ReadOnly = False
	  gridColumn1.SortEnable = False
	  gridColumn1.Title = "First"
	  gridColumn1.Tree = False
	  gridColumn1.Type = PlexityHide.GTP.CellType.SingleText
	  gridColumn1.Width = 300
	  gridColumn2.AllowMove = True
	  gridColumn2.AllowResize = True
	  gridColumn2.ColumnDerivedFromDS = False
	  gridColumn2.DataSourceColumn = Nothing
	  gridColumn2.DataSourceColumnType = Nothing
	  gridColumn2.Hide = False
	  gridColumn2.LayoutName = "Default"
	  gridColumn2.ReadOnly = False
	  gridColumn2.SortEnable = False
	  gridColumn2.Title = "Second"
	  gridColumn2.Tree = True
	  gridColumn2.Type = PlexityHide.GTP.CellType.SingleText
	  gridColumn2.Width = 300
	  Me.gantt_ASPSettings1.Gantt.GridProperties.Columns.Add(gridColumn1)
	  Me.gantt_ASPSettings1.Gantt.GridProperties.Columns.Add(gridColumn2)
	  Me.gantt_ASPSettings1.Gantt.GridProperties.DrawPyjamas = True
	  Me.gantt_ASPSettings1.Gantt.GridProperties.HasHeader = True
	  Me.gantt_ASPSettings1.Gantt.GridProperties.ImageList = Nothing
	  Me.gantt_ASPSettings1.Gantt.GridProperties.PyjamasColor = System.Drawing.SystemColors.ControlLight
	  Me.gantt_ASPSettings1.Gantt.GridProperties.PyjamasGradientColor = System.Drawing.SystemColors.ControlLightLight
	  Me.gantt_ASPSettings1.Gantt.GridProperties.RootNodes_DataMember = Nothing
	  Me.gantt_ASPSettings1.Gantt.GridProperties.RootNodes_DataSource = Nothing
	  Me.gantt_ASPSettings1.Gantt.GridProperties.RootNodes_DataSourceList = Nothing
	  Me.gantt_ASPSettings1.Gantt.GridWidth = 250
	  Me.gantt_ASPSettings1.Gantt.ImageList = Nothing
	  Me.gantt_ASPSettings1.Gantt.Location = New System.Drawing.Point(0, 0)
	  Me.gantt_ASPSettings1.Gantt.Name = "Gantt"
	  Me.gantt_ASPSettings1.Gantt.PyjamasColor = System.Drawing.SystemColors.ControlLightLight
	  Me.gantt_ASPSettings1.Gantt.PyjamasGradientColor = System.Drawing.SystemColors.ControlLight
	  Me.gantt_ASPSettings1.Gantt.Size = New System.Drawing.Size(648, 392)
	  Me.gantt_ASPSettings1.Gantt.TabIndex = 0
	  Me.gantt_ASPSettings1.Gantt.TodayLine = True
	  Me.gantt_ASPSettings1.Gantt.VerticalDayStripes = False
	  Me.gantt_ASPSettings1.Gantt.VerticalDayStripes_Days = New Boolean() { True, False, False, False, False, False, True}
	  Me.gantt_ASPSettings1.Gantt.VerticalLines = True
'	  Me.gantt_ASPSettings1.Gantt.OnTimeItemAreaPaintBackground += New PlexityHide.GTP.OffscreenDrawEvent(Me.gantt_ASPSettings1_Gantt_OnTimeItemAreaPaintBackground);
	  Me.gantt_ASPSettings1.Gantt_ASP = Me.Gantt_ASP1
'	  Me.Load += New System.EventHandler(Me.Page_Load);

		End Sub
		#End Region

	Private Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RBLTimeItemArea.SelectedIndexChanged

	End Sub

    ' I do not currently know how to do this in VB.NET in c# I simply assign an event handler in runtime... /HK
    'Private Sub gantt_ASPSettings1_Gantt_OnTimeItemAreaPaintBackground(ByVal aOffscreenDraw As PlexityHide.GTP.OffscreenDraw, ByVal e As PlexityHide.GTP.OffscreenDrawArgs) Handles gantt_ASPSettings1.Gantt.OnTimeItemAreaPaintBackground
    ' If cbUserDraw.Checked Then
    'e.G.DrawEllipse(New Pen(Color.Red,5),1,1,300,300)
    ' End If
    'End Sub

	Private Sub Gantt_ASP1_OnAreaAttributes(ByVal aGantt As PlexityHide.GTP.WEB.Gantt_ASP, ByVal e As PlexityHide.GTP.WEB.AreaAttributeEventArgs) Handles Gantt_ASP1.OnAreaAttributes
	  If e.AreaKind=PlexityHide.GTP.WEB.AreaKind.TimeItem Then
		e.Result=" Title=""You are now over a time item""  " & e.Result
	  Else
	  If e.AreaKind=PlexityHide.GTP.WEB.AreaKind.DateAdd OrElse e.AreaKind=PlexityHide.GTP.WEB.AreaKind.DateSubstract Then
		e.Result=" Title=""Click here to move in time""  " & e.Result
	  Else
	  If e.AreaKind=PlexityHide.GTP.WEB.AreaKind.ScaleDec OrElse e.AreaKind=PlexityHide.GTP.WEB.AreaKind.ScaleInc Then
		e.Result=" Title=""Click here to change the time resolution ""  " & e.Result
	  Else
	  End If
	  End If
	  End If
	End Sub

	Private Sub Gantt_ASP1_OnTimeItem_ClientClick(ByVal aGantt As PlexityHide.GTP.Gantt, ByVal e As PlexityHide.GTP.TimeItemEventArgs) Handles Gantt_ASP1.OnTimeItem_ClientClick
	  e.TimeItem.Selected=True
	End Sub

	Private Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
	End Sub
	End Class
End Namespace
