|
Please send the modified control to devarenu at mailme dot ae.
Thanks
|
|
|
|
|
Hi,
I also would appreciate the code.
Thanks in advance.
Svend email: svendn@yahoo.dk
|
|
|
|
|
Please send me the code to aquinn_21@yahoo.com. Thank you.
|
|
|
|
|
I am working on enhancing this to reflect project perspective, although my solution will be in VB not cs.
I have run into a major problem however. It appears that in non IE browsers, the left table containing text displays different row heights than the graphic rows in the scrollable table on the right.
Anybody know how to resolve this height difference problem between the two tables ?
|
|
|
|
|
I have also had this issue although I am using IE version 6.
Has anyone come up with a solution for this?
Also Jean-marc top work on creating the control, other than this little problem it is great.
|
|
|
|
|
See my response in the Firefox question. There are a couple of tweaks to the code and a browser capabilities fix that are needed.
|
|
|
|
|
is download now the latest version ?
|
|
|
|
|
No, I'm not the article author. I'm working on a project that I want to use a derivitive of this control for, so I've been fixing what I can and asking for some of the updates other people have mentioned having here. Cross browser support was a major hurdle, so that was what I tackled first.
I have emailed the original author, but haven't gotten a response yet. If I manage to make enough headway I may consider writing an updated article with the improvements.
|
|
|
|
|
Hi,
Thanks to Jean-Marc for posting his code.
Has anybody modified this to display dates instead of days (eg 1 2 3 instead of mo tu we)?
also has anybody got it to run based on data held in a table, eg a SQL Server db?
Any help/suggestions gratefully received
Thanks
|
|
|
|
|
For a simple change to display the dates, change the code in the RenderRightHandPane as follows:
// dayname = quarter.GetDayName(i,j);
// if(dayname == "M") week = !week;
dayname = j.ToString();
|
|
|
|
|
|
Did someone ever made a software project plan using this control?
i mean the complete one such as task management, resource management etc...
because i need help for developing web based project plan using this control, i need to define the critical path, realtion between task and .....yeah somekind of microsoft project.
if anyone has ever made it, could i get the source code for reference?
thanks before....
regards
Jonie Hermanto
|
|
|
|
|
EventCalendarControl.cs
If available , could someone post this code in vb ?
Also, it appears the transparent gif leaves a shadow imprint inside the gantt task bar, which is visible to the user. Appears in both IE 6and FF1.5 browsers. Anyway to resolve this ?
|
|
|
|
|
If your still interested.
---------oOo---------
Imports System
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml
<defaultproperty("xmldata"), toolboxdata("<{0}:eventkalendercontrol="" runat="server">")> _
Public Class EventKalenderControl
Inherits System.Web.UI.WebControls.WebControl
Dim _text As String
Private m_xmlData As String, m_blockColor As String, m_toggleColor As String, m_cellWidth As String, m_cellHeight As String, m_blankGifPath As String
Private m_year As Integer, m_quarter As Integer
Dim m_names() As String
Public Function EventCalendarControl()
m_names = New String(3) {}
End Function
#Region "Properties"
'
' Gets or sets a value that contains XML data containing the events.
'
<bindable(true), category("appearance"),="" defaultvalue("")=""> _
Public Property XMLData() As String
Get
Return m_xmlData
End Get
Set(ByVal Value As String)
m_xmlData = Value
End Set
End Property
'
' Gets or sets a value that indicates the quarter (1,2,3,4)
'
<bindable(true), category("appearance"),="" defaultvalue(1)=""> _
Public Property Quarter() As Integer
Get
Return m_quarter
End Get
Set(ByVal Value As Integer)
m_quarter = Value
End Set
End Property
'
' Gets or sets a value that indicates the Year e.g. 2005
'
<bindable(true), category("appearance"),="" defaultvalue("")=""> _
Public Property Year() As Integer
Get
Return m_year
End Get
Set(ByVal Value As Integer)
m_year = Value
End Set
End Property
'
' Gets or sets a value that indicates the default BlockColor
'
<bindable(true), category("appearance"),="" defaultvalue("red")=""> _
Public Property BlockColor() As String
Get
Return m_blockColor
End Get
Set(ByVal Value As String)
m_blockColor = Value
End Set
End Property
'
' Gets or sets a value that indicates the cell width of the event calendar 'grid'
'
<bindable(true), category("appearance"),="" defaultvalue("15")=""> _
Public Property CellWidth() As Integer
Get
Return Integer.Parse(m_cellWidth)
End Get
Set(ByVal Value As Integer)
m_cellWidth = Value.ToString()
End Set
End Property
'
' Gets or sets a value that indicates the cell height of the event calendar 'grid'
'
<bindable(true), category("appearance"),="" defaultvalue("15")=""> _
Public Property CellHeight() As Integer
Get
Return Integer.Parse(m_cellHeight)
End Get
Set(ByVal Value As Integer)
m_cellHeight = Value.ToString()
End Set
End Property
'
' Gets or sets a value that indicates a color the event calendar will use to delimit the day names and event names.
'
<bindable(true), category("appearance"),="" defaultvalue("#dcdcdc")=""> _
Public Property ToggleColor() As String
Get
Return m_toggleColor
End Get
Set(ByVal Value As String)
m_toggleColor = Value
End Set
End Property
'
' Gets or sets a value that indicates a color the event calendar will use to delimit the day names and event names.
'
<bindable(true), category("appearance"),="" defaultvalue("#dcdcdc")=""> _
Public Property BlankGifPath() As String
Get
Return m_blankGifPath
End Get
Set(ByVal Value As String)
m_blankGifPath = Value
End Set
End Property
#End Region
#Region "Event Handling"
'
' writes out some javascript so the calendar grid can resize itself
'
' <param name="e" />
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
MyBase.OnPreRender(e)
If Not MyBase.Page.IsStartupScriptRegistered("EventCalendar") Then
MyBase.Page.RegisterStartupScript("EventCalendar", _
"" + _
"function ResizeTables()" + _
"{" + _
"document.getElementById('divcal').style.width = '1px';" + _
"document.getElementById('divcal').style.width = document.getElementById('tblcal').clientWidth + 'px';" + _
"};" + _
"")
MyBase.Page.RegisterStartupScript("EventCalendarOnLoad", _
"" + _
"ResizeTables();" + _
"")
MyBase.Page.RegisterStartupScript("EventCalendarOnResize", _
"" + _
"ResizeTables();" + _
"")
End If
End Sub
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
' create a 2 column, 1 row table, the first column will contain the text for the tasks that
' is non scrollable.
writer.AddAttribute("border", "0")
writer.AddAttribute("cellSpacing", "0")
writer.AddAttribute("cellPadding", "0")
writer.AddAttribute("width", "100%")
writer.RenderBeginTag("table")
writer.RenderBeginTag("tr")
writer.AddAttribute("valign", "top")
writer.AddAttribute("align", "right")
writer.RenderBeginTag("td nowrap")
RenderLeftHandPane(writer)
writer.RenderEndTag()
writer.AddAttribute("id", "tblcal")
writer.AddAttribute("valign", "top")
writer.AddAttribute("align", "left")
writer.AddAttribute("width", "100%")
writer.RenderBeginTag("td nowrap")
RenderRightHandPane(writer)
writer.RenderEndTag()
writer.RenderEndTag()
writer.RenderEndTag()
End Sub
#End Region
#Region "Helper Functions"
Private Sub RenderLeftHandPane(ByVal writer As HtmlTextWriter)
Dim blocktext, grouptext As String
writer.AddAttribute("border", "1")
writer.AddAttribute("style", "FONT-SIZE: " + Font.Size.ToString + ";FONT-FAMILY: " + Font.Name + ";BORDER-COLLAPSE: collapse")
writer.AddAttribute("borderColor", "#000000")
writer.AddAttribute("cellSpacing", "0")
writer.AddAttribute("cellPadding", "0")
writer.RenderBeginTag("table")
'empty row to match month headers on right hand pane
writer.RenderBeginTag("tr")
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
writer.RenderEndTag()
'empty row to match day headers on right hand pane
writer.RenderBeginTag("tr")
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
writer.RenderEndTag()
' now need to write the rows
' Load the XML
Dim xmlDoc As New XmlDocument
xmlDoc.LoadXml(m_xmlData)
Dim xmlRows As XmlNodeList = xmlDoc.SelectNodes("//group")
Dim xmlRow As XmlNode
For Each xmlRow In xmlRows
grouptext = xmlRow.SelectSingleNode("name").InnerText
writer.RenderBeginTag("tr")
writer.AddAttribute("bgcolor", m_toggleColor)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td nowrap")
writer.Write((" " + grouptext + " "))
writer.RenderEndTag()
writer.RenderEndTag()
Dim xmlBlocks As XmlNodeList = xmlRow.SelectNodes("block")
Dim xmlBlock As XmlNode
For Each xmlBlock In xmlBlocks
writer.RenderBeginTag("tr")
blocktext = xmlBlock.SelectSingleNode("name").InnerText
'write the activity
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td nowrap")
writer.Write((" " + blocktext + " "))
writer.RenderEndTag()
writer.RenderEndTag()
Next xmlBlock
Next xmlRow
writer.RenderEndTag()
End Sub 'RenderLeftHandPane
Private Sub RenderRightHandPane(ByVal writer As HtmlTextWriter)
Dim startdate, enddate, dayname, href, blocktext, blockcolor As String
Dim startindex, endindex, imagewidth, month As Integer
Dim i As Integer
Dim week As Boolean = False
Dim quarter As New QuarterHelper(m_year, m_quarter)
writer.AddAttribute("style", "width:1px; overflow-x:scroll;")
writer.AddAttribute("id", "divcal")
writer.RenderBeginTag("div")
writer.AddAttribute("border", "1")
writer.AddAttribute("style", "FONT-SIZE: " + Font.Size.ToString + ";FONT-FAMILY: " + Font.Name + ";BORDER-COLLAPSE: collapse")
writer.AddAttribute("borderColor", "#000000")
writer.AddAttribute("cellSpacing", "0")
writer.AddAttribute("cellPadding", "0")
writer.RenderBeginTag("table")
'write month headers
writer.RenderBeginTag("tr")
For i = 1 To 3
month = i + 3 * (quarter.QuarterIndex - 1)
writer.AddAttribute("align", "center")
writer.AddAttribute("colspan", quarter.TotalDaysInMonth(month).ToString())
writer.RenderBeginTag("td")
writer.Write(quarter.GetMonthName(i))
writer.RenderEndTag()
Next i
writer.RenderEndTag()
'write day headers
writer.RenderBeginTag("tr")
For i = 3 * quarter.QuarterIndex - 2 To 3 * quarter.QuarterIndex
Dim j As Integer
For j = 1 To quarter.TotalDaysInMonth(i)
dayname = quarter.GetDayName(i, j)
If dayname = "M" Then
week = Not week
End If
writer.AddAttribute("align", "center")
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
If week Then
writer.AddAttribute("bgcolor", m_toggleColor)
End If
writer.RenderBeginTag("td")
writer.Write(dayname)
writer.RenderEndTag()
Next j
Next i
writer.RenderEndTag()
' now need to write the rows
' Load the XML
Dim xmlDoc As New XmlDocument
xmlDoc.LoadXml(m_xmlData)
Dim xmlRows As XmlNodeList = xmlDoc.SelectNodes("//group")
Dim xmlRow As XmlNode
For Each xmlRow In xmlRows
' empty row to match group name
writer.RenderBeginTag("tr")
writer.AddAttribute("colspan", quarter.Days.ToString())
writer.AddAttribute("width", (quarter.Days * Integer.Parse(m_cellWidth)).ToString())
writer.RenderBeginTag("td")
writer.Write((" "))
writer.RenderEndTag()
writer.RenderEndTag()
Dim node As XmlNode = xmlRow.SelectSingleNode("blockcolor")
If Not (node Is Nothing) Then
blockcolor = node.InnerText
Else
blockcolor = m_blockColor
End If
' write out the events
Dim strHTML As String
Dim xmlBlocks As XmlNodeList = xmlRow.SelectNodes("block")
Dim xmlBlock As XmlNode
For Each xmlBlock In xmlBlocks
writer.RenderBeginTag("tr")
startdate = xmlBlock.SelectSingleNode("StartDate").InnerText
enddate = xmlBlock.SelectSingleNode("EndDate").InnerText
href = xmlBlock.SelectSingleNode("href").InnerText
blocktext = xmlBlock.SelectSingleNode("name").InnerText
startindex = quarter.getColumnIndex(startdate)
endindex = quarter.getColumnIndex(enddate)
'write out the padding cells
For i = 0 To startindex - 1
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
Next i
'create the filled in block
writer.AddAttribute("colspan", (endindex - startindex + 1).ToString())
writer.AddAttribute("bgColor", blockcolor)
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td nowrap")
If href <> String.Empty Then
imagewidth = (endindex - startindex + 1) * Integer.Parse(m_cellWidth)
strHTML = ""
writer.Write(strHTML)
Else
writer.Write(" ")
End If
writer.RenderEndTag()
'
'write out the padding cells
For i = endindex To (quarter.Days - 1) - 1
writer.AddAttribute("width", m_cellWidth)
writer.AddAttribute("height", m_cellHeight)
writer.RenderBeginTag("td")
writer.Write(" ")
writer.RenderEndTag()
Next i
writer.RenderEndTag()
Next xmlBlock
Next xmlRow
writer.RenderEndTag() ' close table tag
writer.RenderEndTag() ' close div tag
End Sub 'RenderRightHandPane
#End Region
#Region "Helper Classes"
Private Class QuarterHelper
Private m_year As Integer
Private m_quarter As Integer
Private m_names(3) As String
Private m_NoOfDays As Integer
Public Sub New()
End Sub 'New
Public Sub New(ByVal year As Integer, ByVal quarter As Integer)
m_quarter = quarter
m_year = year
m_names = getQuarterNames()
m_NoOfDays = getDaysInQuarter(m_year, m_quarter)
End Sub 'New
Public ReadOnly Property Year() As Integer
Get
Return m_year
End Get
End Property
Public ReadOnly Property QuarterIndex() As Integer
Get
Return m_quarter
End Get
End Property
Public ReadOnly Property Names() As String()
Get
Return m_names
End Get
End Property
Public ReadOnly Property Days() As Integer
Get
Return m_NoOfDays
End Get
End Property
Public Function GetMonthName(ByVal i As Integer) As String
Return m_names((i - 1))
End Function 'GetMonthName
Public Function TotalDays() As Integer
Dim retval As Integer = 0
Select Case m_quarter
Case 1
retval = DateTime.DaysInMonth(m_year, 1)
retval += DateTime.DaysInMonth(m_year, 2)
retval += DateTime.DaysInMonth(m_year, 3)
Case 2
retval = DateTime.DaysInMonth(m_year, 4)
retval += DateTime.DaysInMonth(m_year, 5)
retval += DateTime.DaysInMonth(m_year, 6)
Case 3
retval = DateTime.DaysInMonth(m_year, 7)
retval += DateTime.DaysInMonth(m_year, 8)
retval += DateTime.DaysInMonth(m_year, 9)
Case 4
retval = DateTime.DaysInMonth(m_year, 10)
retval += DateTime.DaysInMonth(m_year, 11)
retval += DateTime.DaysInMonth(m_year, 12)
End Select
Return retval
End Function 'TotalDays
Public Function TotalDaysInMonth(ByVal i As Integer) As Integer
Return DateTime.DaysInMonth(m_year, i)
End Function 'TotalDaysInMonth
Public Function GetDayName(ByVal month As Integer, ByVal day As Integer) As String
Dim retval As String = String.Empty
Dim d As New DateTime(m_year, month, day)
Select Case d.DayOfWeek
Case DayOfWeek.Monday
retval = "M"
Case DayOfWeek.Tuesday
retval = "T"
Case DayOfWeek.Wednesday
retval = "O"
Case DayOfWeek.Thursday
retval = "T"
Case DayOfWeek.Friday
retval = "F"
Case DayOfWeek.Saturday
retval = "L"
Case DayOfWeek.Sunday
retval = "S"
'Case DayOfWeek.Monday
' retval = "M"
'Case DayOfWeek.Tuesday
' retval = "T"
'Case DayOfWeek.Wednesday
' retval = "W"
'Case DayOfWeek.Thursday
' retval = "T"
'Case DayOfWeek.Friday
' retval = "F"
'Case DayOfWeek.Saturday
' retval = "S"
'Case DayOfWeek.Sunday
' retval = "S"
End Select
Return retval
End Function 'GetDayName
Private Function getQuarterNames() As String()
Dim retval(3) As String
Select Case m_quarter
Case 1
retval(0) = "Januar"
retval(1) = "Febuar"
retval(2) = "Marts"
Case 2
retval(0) = "April"
retval(1) = "Maj"
retval(2) = "Juni"
Case 3
retval(0) = "Juli"
retval(1) = "August"
retval(2) = "September"
Case 4
retval(0) = "Oktober"
retval(1) = "November"
retval(2) = "December"
'Case 1
' retval(0) = "January"
' retval(1) = "Febuary"
' retval(2) = "March"
'Case 2
' retval(0) = "April"
' retval(1) = "May"
' retval(2) = "June"
'Case 3
' retval(0) = "July"
' retval(1) = "August"
' retval(2) = "September"
'Case 4
' retval(0) = "October"
' retval(1) = "November"
' retval(2) = "December"
End Select
Return retval
End Function 'getQuarterNames
Private Function getDaysInQuarter(ByVal year As Integer, ByVal quarter As Integer) As Integer
Dim dtS, dtE As DateTime
If quarter < 4 Then
dtS = New DateTime(year, 3 * quarter - 2, 1)
dtE = New DateTime(year, 3 * quarter - 2 + 3, 1)
Else
dtS = New DateTime(year, 3 * quarter - 2, 1)
dtE = New DateTime(year + 1, 1, 1)
End If
Dim ts As New TimeSpan(dtE.Subtract(dtS).Ticks)
Return ts.Days
End Function 'getDaysInQuarter
Public Function getColumnIndex(ByVal day As String) As Integer
Dim dt As DateTime = DateTime.Parse(day)
Dim offset As Integer = 0
Dim retval As Integer = 0
Dim i As Integer
For i = 1 To m_quarter - 1
offset += getDaysInQuarter(m_year, i)
Next i
retval = dt.DayOfYear - 1 - offset
If retval < 0 Then
retval = 0
End If
If retval > getDaysInQuarter(m_year, m_quarter) Then
retval = getDaysInQuarter(m_year, m_quarter)
End If
Return retval
End Function 'getColumnIndex
End Class 'QuarterHelper
#End Region
End Class
------o0o----------
Regards
Svend
|
|
|
|
|
Jean-marc,
I found a small bug in your control. Its handle in a wrong way events that the year is not the same of the control's year.
I did some modifications on the getColumnIndex() function to fix it.
I created a new propertie to set the Culture and I changed the code to get the Days and Month's names in the desired language.
If you, or somebody, wants the code please tell me.
Calixto
|
|
|
|
|
just post the suggested changes here
(in case you croak tomorrow)
|
|
|
|
|
Hi,
I would appreciate the code,
Thanks
|
|
|
|
|
Hi,
I also would appreciate the code,
Thanks
|
|
|
|
|
I would like to get your changes.
|
|
|
|
|
Hi Eduardo,
I would appreciate the code,
Thanks
Andoni
|
|
|
|
|
Hi Calixto, i'm interested on the "Fix".
Can u send me a copy of the code?
Thx
Luca
(sluca@hotmail.com)
|
|
|
|
|
This is a lovely control.
Are there any addition to it, such as events, databinding, etc?
Please email me, if so,
Thanks
|
|
|
|
|
I am unable to get an xml file (instead of a string) to load in the gannt chart. It gives the following error.
The data at the root level is invalid. Line 1, position 1.
Can anyone please tell me what i am doing wrong.
Thank you
|
|
|
|
|
cant you read the file into a string?
|
|
|
|
|
Thank you very much for the response. I finaly got that to work but I get the dreded Object reference not set to an instance of the object
My code is :
Dim myds As New DataSet
Dim myGroupAdapter As SqlDataAdapter
Dim myBlockAdapter As SqlDataAdapter
Dim myconn As New SqlConnection
myconn.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings("connectionString")
myGroupAdapter = New SqlDataAdapter("select name, blockcolor, carid from [group]", myconn)
myBlockAdapter = New SqlDataAdapter("Select href, startdate, enddate, name, carid from block", myconn)
myGroupAdapter.Fill(myds, "group")
myBlockAdapter.Fill(myds, "block")
Dim primaryKey As DataColumn = myds.Tables("group").Columns("CarID")
Dim ForeginKey As DataColumn = myds.Tables("block").Columns("CarID")
Dim relation As New DataRelation("group", primaryKey, ForeginKey)
relation.Nested = True
myds.Relations.Add(relation)
Dim xmldata As String
xmldata = myds.GetXml()
EventCalendarControl2.XMLData = xmldata
EventCalendarControl2.BlankGifPath = "trans.gif"
EventCalendarControl2.Year = 2005
EventCalendarControl2.Quarter = 2
EventCalendarControl2.BlockColor = "blue"
EventCalendarControl2.ToggleColor = "#dcdcdc"
EventCalendarControl2.CellHeight = 15
EventCalendarControl2.CellWidth = 15
End Sub
Can any one please tell me what i am doing wrong.
|
|
|
|
|