Foxtable(狐表)用户栏目专家坐堂 → [求助]甘特图的问题


  共有1827人关注过本帖树形打印复制链接

主题:[求助]甘特图的问题

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/16 19:20:00 [显示全部帖子]

static dic As new Dictionary(of String, brush)
If DrawGannt Then
    Dim cr As Row  = Tables("任务").Rows(e.Row.Index)
    For Each r As DataRow In cr.Table.DataTable.Select("工程名称 = '" & cr("工程名称") & "'", "开始日期")
        Dim dt1 As Date = r("开始日期")
        Dim dt3 As Date = r("实际开始")
        Dim dt2 As Date = r("结束日期")
        Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
       
        If dt = dt1 Then
            e.StartDraw()
            If dic.ContainsKey(dt) = False Then
                Dim br1 As Brush = New SolidBrush(Color.FromARGB(rand.Next(255),rand.Next(255),rand.Next(255),rand.Next(255)))
                dic.add(dt, br1)
            End If
            Dim sp1 As TimeSpan = dt3-dt1
            Dim sp2 As TimeSpan = dt2-dt3
            Dim sp3 As TimeSpan = dt2-dt1
            e.Graphics.FillRectangle(dic(dt),e.x ,e.y + 5, cint(e.Width*sp1.TotalDays/sp3.TotalDays), e.Height - 10)
           
            If dt3 <> Nothing Then
                Dim br2 As Brush = New SolidBrush(Color.green)
                e.Graphics.FillRectangle(br2,e.x+cint(e.Width*sp1.TotalDays/sp3.TotalDays) ,e.y + 5, cint(e.Width*sp2.TotalDays/sp3.TotalDays), e.Height - 10)
            End If
            Dim fnt As New Font("宋体",9)
            Dim msg As String = r("任务名称")
            e.Graphics.DrawString(msg,fnt,Brushes.Red,e.x,e.y+2)
            e.EndDraw()           
        End If
    Next
End If


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/17 9:35:00 [显示全部帖子]

static dic As new Dictionary(of String, brush)
If DrawGannt Then
    Dim cr As Row  = Tables("任务").Rows(e.Row.Index)
    For Each r As DataRow In cr.Table.DataTable.Select("工程名称 = '" & cr("工程名称") & "'", "开始日期")
        Dim dt1 As Date = r("开始日期")
        Dim dt3 As Date = r("实际开始")
        Dim dt2 As Date = r("结束日期")
        Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
       
        If dt = dt1 Then
            e.StartDraw()
            If dic.ContainsKey(dt) = False Then
                Dim br1 As Brush = New SolidBrush(Color.FromARGB(rand.Next(255),rand.Next(255),rand.Next(255),rand.Next(255)))
                dic.add(dt, br1)
            End If
            Dim sp1 As TimeSpan = dt3-dt1
            Dim sp2 As TimeSpan = dt2-dt3
            Dim sp3 As TimeSpan = dt2-dt1
            e.Graphics.FillRectangle(dic(dt),e.x ,e.y + 5, e.Width,e.Height - 10)
           
            If dt3 <> Nothing Then
                Dim br2 As Brush = New SolidBrush(Color.green)
                e.Graphics.FillRectangle(br2,e.x+cint(e.Width*sp1.TotalDays/sp3.TotalDays) ,e.y + 5, cint(Math.Ceiling(e.Width/sp3.TotalDays)), e.Height - 10)
            End If
            Dim fnt As New Font("宋体",9)
            Dim msg As String = r("任务名称")
            e.Graphics.DrawString(msg,fnt,Brushes.Red,e.x,e.y+2)
            e.EndDraw()           
        End If
    Next
End If

 回到顶部