提高Google日历导入的效果

时间:2016-05-08 13:02:52

标签: vb.net google-calendar-api

我正在处理一个连接到Google日历的日历的应用程序。 我从tablelayoutpanel创建了UI。

该应用程序正常。 我唯一的问题是导入子工作非常慢,并且 表格闪烁约3秒钟。 我想和你分享到目前为止我所做的事情,并问你是否 有任何想法如何使导入事件更加用户友好。 因此导入子(位于模块上)

Public Sub GetCalENtryList(ByRef service As CalendarService, minDate As Date, maxDate As Date)

    EmptyTabelLayoutPanel1()

    Dim requeust As ListRequest = service.Events.List(service.CalendarList.List().Execute().Items(0).Id) 'Entire events list

    requeust.TimeMin = minDate ' filtering between dates (mindate to maxdate)
    requeust.TimeMax = maxDate

    For Each calendarEvent As Data.Event In requeust.Execute().Items
        Try
            Dim dateSpan As TimeSpan = calendarEvent.Start.DateTime - minDate ' help me know what day of week is it
            Dim eventSpan As TimeSpan = (calendarEvent.End.DateTime - calendarEvent.Start.DateTime)  'Find out event length
            Dim pnl As myCalendarPanel = New myCalendarPanel 'item i designed that looks like panel with few labels

            With pnl
                .Name = "pnl" & index
                .lblEventSummary.Text = calendarEvent.Summary
                .Dock = DockStyle.Fill
            End With
            With frmMainForm.MyCalendar1.TableLayoutPanel1
                .SetCellPosition(pnl, New TableLayoutPanelCellPosition(Math.Abs(dateSpan.Days - 6), 2 * _
                                                                       (DateAndTime.Hour(calendarEvent.Start.DateTime) - 5))) 'set the pnl location on my calendar
                .SetColumnSpan(pnl, 1) 'event canoot be longer then one day
                .SetRowSpan(pnl, 2 * eventSpan.Hours) 'represent event length
                .Controls.Add(pnl) ' add pnl to tablelayoutpanel1
            End With
            index += 1
            SetlblTimeTime(pnl) 
        Catch ex As Exception
        End Try
    Next
End Sub

0 个答案:

没有答案