翻譯|使用教程|編輯:莫成敏|2019-10-21 10:35:46.383|閱讀 276 次
概述:VARCHART XGantt是用于工業(yè)4.0項(xiàng)目管理、交互式的甘特圖絕佳解決方案,世界級甘特圖大師。本教程介紹如何使用日歷,由于教程內(nèi)容較多,本文是該教程的第二部分內(nèi)容~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
VARCHART XGantt是一個交互式的甘特圖控件,其模塊化的設(shè)計(jì)讓您可以創(chuàng)建滿足您和您的客戶所需求的應(yīng)用程序。相較于其他甘特圖控件,VARCHART XGantt穩(wěn)定性高,開發(fā)時間長,各大行業(yè)的知名公司都在使用它。本文主要描述了如何使用日歷教程中的第二部分內(nèi)容,內(nèi)容緊接前文,現(xiàn)在就來了解一下吧~
點(diǎn)擊下載VARCHART XGantt免費(fèi)版
時鐘時間由對象DateTime設(shè)置。日期部分被忽略,因?yàn)樵谶@種情況下它毫無意義。只需要在構(gòu)造函數(shù)中設(shè)置日期,即可為構(gòu)造函數(shù)所需的所有參數(shù)設(shè)置一個值。在Interval_3中,指定0h或24h是很重要的,因?yàn)楹笳咴?strong>DateTime對象中不被接受。
一年中的定期日期(例如1月1日的除夕夜或12月25日至26日的圣誕節(jié)和節(jié)禮日),由涵蓋全年的日歷配置文件定義。
示例代碼
'Setting a profile of fixed annual holidays Dim calendarProfile As VcCalendarProfile Dim interval As VcInterval Set calendarProfile = calendar.CalendarProfileCollection.Add("YearProfile") calendarProfile.Type = vcYearProfile Set interval = calendarProfile.IntervalCollection.Add("New Year") interval.CalendarProfileName = "" interval.DayInStartMonth = 1 interval.StartMonth = vcJanuary interval.DayInEndMonth = 1 interval.EndMonth = vcJanuary Call SetAppearanceForHolidays(interval) Set interval = calendarProfile.IntervalCollection.Add("Christmas") interval.CalendarProfileName = "" interval.DayInStartMonth = 25 interval.StartMonth = vcDecember interval.DayInEndMonth = 26 interval.EndMonth = vcDecember Call SetAppearanceForHolidays(interval)
為了避免重復(fù)設(shè)置產(chǎn)生相同的外觀,我們使用名為SetAppearanceForHolidays的方法收集調(diào)用:
示例代碼
'Method to set the visual appearance of holidays Private Sub SetAppearanceForHolidays(ByVal interval As VcInterval) interval.BackColorAsARGB = &HFFFFA4A4 interval.Pattern = vcWeavePattern interval.PatternColorAsARGB = &HFF404040 interval.LineColor = &HFF808080 interval.LineThickness = 1 interval.LineType = vcSolid interval.UseGraphicalAttributes = True End Sub
請注意:顏色屬性僅在其CalendarProfileName設(shè)置為或的間隔內(nèi)有效。另外,間隔屬性UseGraphicalAttribute需要設(shè)置為true。對于calenderGrid屬性UseGraphicalAttributesOfIntervals同樣如此。
每年必須計(jì)算浮動假期(例如復(fù)活節(jié))和其他與之相關(guān)的假期,并且需要將其作為固定日期分配給日歷。下面的方法對此非常有用:
示例代碼
'Method to find floating holidays Const AshWednesday = 0 Const GoodFriday = 1 Const EasterSunday = 2 Const EasterMonday = 3 Const FeastOfCorpusChristi = 4 Const AscensionOfChrist = 5 Const WhitSunday = 6 Const WhitMonday = 7 Const CentralEuropeanSummerTimeStart = 8 Const CentralEuropeanSummerTimeEnd = 9 Private Function calculateAnniversaryForYear(ByVal year As Integer, ByVal specialDay As Integer) As Date Dim g As Integer Dim c As Integer Dim h As Integer Dim i As Integer Dim j As Integer Dim month As Integer Dim day As Integer Dim dayOffset As Integer g = year Mod 19 c = year Mod 100 h = (c - c / 4 - (8 * c + 13) / 25 + 19 * g + 15) Mod 30 i = h - (h / 28) * (1 - (29 / (h + 1)) * ((21 - g) / 11)) j = (year + year / 4 + i + 2 - c + c / 4) Mod 7 month = 3 + (i - j + 40) / 44 day = i - j + 28 - 31 * (month / 4) dayOffset = 0 Select Case specialDay Case AshWednesday dayOffset = -40 Case GoodFriday dayOffset = -2 Case EasterSunday dayOffset = 0 Case EasterMonday dayOffset = 1 Case AscensionOfChrist dayOffset = 39 Case WhitSunday dayOffset = 49 Case WhitMonday dayOffset = 50 Case FeastOfCorpusChristi dayOffset = 60 Case CentralEuropeanSummerTimeStart month = 3 day = 31 - Weekday("31.3" + yearConvert + 1) Case CentralEuropeanSummerTimeEnd month = 10 day = 31 - Weekday("31.10" + yearConvert + 1) End Select Dim tmpDate As Date tmpDate = day & "." & month & "." & year calculateAnniversaryForYear = tmpDate + dayOffset End Function
在下一步中,將周配置文件和假日配置文件作為間隔分配給日歷。然后以相同的方式計(jì)算浮動假期并將其分配給日歷:
示例代碼
'Assembling the week profile, the holiday profile and the floating holidays into an interval Set interval = calendar.IntervalCollection.Add("Weekly_Pattern") interval.CalendarProfileName = "WeekProfile" Set interval = calendar.IntervalCollection.Add("Yearly_Pattern") interval.CalendarProfileName = "YearProfile" Dim startYear As Integer Dim endYear As Integer startYear = year(VcGantt1.TimeScaleStart) endYear = year(VcGantt1.TimeScaleEnd) Dim i As Integer For i = startYear To endYear Step i + 1 Set interval = calendar.IntervalCollection.Add("GoodFriday_" & i) interval.CalendarProfileName = "" interval.StartDateTime = calculateAnniversaryForYear(i, GoodFriday) interval.EndDateTime = calculateAnniversaryForYear(i, EasterMonday) 'interval.StartDateTime Call SetAppearanceForHolidays(interval) Set interval = calendar.IntervalCollection.Add("EasterMonday_" & i) interval.CalendarProfileName = "" interval.StartDateTime = calculateAnniversaryForYear(i, EasterMonday) interval.EndDateTime = interval.StartDateTime Call SetAppearanceForHolidays(interval) Set interval = calendar.IntervalCollection.Add("FeastOfCorpusChristi_" & i) interval.CalendarProfileName = "" interval.StartDateTime = calculateAnniversaryForYear(i, FeastOfCorpusChristi) interval.EndDateTime = interval.StartDateTime Call SetAppearanceForHolidays(interval) Set interval = calendar.IntervalCollection.Add("AscensionOfChrist_" & i) interval.CalendarProfileName = "" interval.StartDateTime = calculateAnniversaryForYear(i, AscensionOfChrist) interval.EndDateTime = interval.StartDateTime Call SetAppearanceForHolidays(interval) Set interval = calendar.IntervalCollection.Add("WhitMonday_" & i) interval.CalendarProfileName = "" interval.StartDateTime = calculateAnniversaryForYear(i, WhitMonday) interval.EndDateTime = interval.StartDateTime Call SetAppearanceForHolidays(interval) Next VcGantt1.CalendarCollection.Update
這些是組裝日歷所需的摘要步驟。根據(jù)要求,可以省略單個步驟:
創(chuàng)建不同工作日的日配置文件
通過使用日配置文件組裝周配置文件
定義假期資料
將星期概要和假日概要分配給日歷的間隔集合
為間隔集合分配其他日期(例如,浮動假期)
間隔對象允許定義可解釋為工作時間或非工作時間的時間段。通過CalendarProfileName屬性將句點(diǎn)區(qū)分為或。通過此屬性,日歷還可以引用其他現(xiàn)有配置文件并采用其設(shè)置。設(shè)置此屬性時,請注意,根據(jù)間隔類型,只能分配某些配置文件類型。間隔類型由選定的配置文件類型隱式選擇。日歷配置文件的預(yù)設(shè)默認(rèn)值vcDayProfile可以在初始時(即在定義間隔之前)通過相應(yīng)的設(shè)置進(jìn)行修改。
配置文件類型建議允許的間隔類型。例如,日期配置文件始終需要vcDayProfileInterval類型的間隔。
日歷配置文件可以顯示類型為日配置文件、周配置文件、年配置文件和變量配置文件。在一天配置文件中,只能通過在一天的限制范圍內(nèi)的時鐘時間來定義間隔。一周配置文件包含要在某些天應(yīng)用的日期配置文件。年份配置文件分配選定的一天配置文件,這些配置文件適用于單個重復(fù)日期或幾個重復(fù)日期。變量配置文件包含一系列不同的工作時間。根據(jù)間隔類型vcCalendarInterval,vcDayProfileInterval,vcWeekProfileInterval,vcYearProfileInterval和vcVariableProfileInterval,僅對象的某些屬性是相關(guān)的。下表映射了概要文件類型和相關(guān)屬性。
CalendarInterval在精確定義的間隔中描述了唯一的時間跨度。例:2010年5月5日從11:30時到2010年9月15日17:00時。
YearProfileInterval允許定義每年重復(fù)一次的天數(shù)或時間跨度。例:5月1日或12月24日至26日。
WeekProfileInterval處理一周中的一天或幾天。例:星期六或星期一至星期五。
DayProfileInterval處理一天之內(nèi)的時間規(guī)格。例:8.00至17.00。
VariableProfile描述了時間跨度,而不引用定義的日期或時間。時間間隔的單位可以是天、小時、分鐘或秒,并且由時間間隔對象的屬性TimeUnit指定。例:4小時。
本教程內(nèi)容尚未完結(jié),敬請期待該教程最后一部分內(nèi)容“如何使用日歷進(jìn)行計(jì)算”~感興趣的朋友可以下載VARCHART XGantt免費(fèi)版評估一下~
相關(guān)內(nèi)容推薦:
VARCHART XGantt用戶手冊(ActiveX版):如何使用日歷(上)
想要購買VARCHART XGantt正版授權(quán),或了解更多產(chǎn)品信息請點(diǎn)擊
1024,慧都致敬程序員們,zend現(xiàn)金優(yōu)惠券限時放送,了解詳情請點(diǎn)擊下方圖片
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn