翻譯|使用教程|編輯:黃竹雯|2018-10-26 10:42:05.000|閱讀 555 次
概述:本文為使用我們產(chǎn)品VARCHART XGantt的開發(fā)人員送上.NET甘特圖控件工具提示中的持續(xù)時(shí)間的開發(fā)小技巧。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
本文為使用我們產(chǎn)品VARCHART XGantt的開發(fā)人員送上.NET甘特圖控件工具提示中的持續(xù)時(shí)間的開發(fā)小技巧。它顯示了如何使用最近引入的“InInteraction Events”功能在拖放交互期間自定義工具提示(InfoWindow)中持續(xù)時(shí)間的顯示。我們不僅給出了如何實(shí)現(xiàn)這一目標(biāo)的逐步說明,還提供了所需的代碼。
我們假設(shè)客戶計(jì)劃在幾分鐘內(nèi)完成。因此,您將在VARCHART XGantt屬性頁上選擇分鐘作為時(shí)間單位。因此,您將在VARCHART XGantt屬性頁上選擇分鐘作為時(shí)間單位。
如果您的用戶現(xiàn)在減少或增加了應(yīng)用程序中條形的長度(表示例如任務(wù)或作業(yè)或操作),則在相應(yīng)的用戶交互期間,此欄的持續(xù)時(shí)間將顯示在InfoWindow中。
但是,709分鐘給任何人的信息有多大意義?如果您能以天,小時(shí)和分鐘顯示持續(xù)時(shí)間,那么它對(duì)您的用戶來說不是更相關(guān)嗎?更重要的是:考慮到基礎(chǔ)班次日歷數(shù)據(jù)以及相應(yīng)的工作和非工作間隔,顯示所有這些信息不是很好嗎?我們來看一下:
在上面的屏幕截圖中,每日工作時(shí)間定義為32,400秒,即9小時(shí)。以下是使用.NET Gantt圖表控件VARCHART XGantt實(shí)現(xiàn)此目的的方法。
int _durationInMinutes = -9999; int _secondsPerWorkday = 0; private void vcGantt1_VcInteractionStarted(object sender, VcInteractionStartedEventArgs e) { //Get calendar name and initial duration of the node being modified if (e.ObjectType == VcObjectType.vcObjTypeNodeInDiagram) { VcNode node = (VcNode)e.InteractionObject; _durationInMinutes = Convert.ToInt32(node.get_DataField(6)); //6: Tasks:Duration string calName = node.get_DataField(9).ToString(); //9: Tasks:CalendarName _cal = vcGantt1.CalendarCollection.CalendarByName(calName); if (_cal == null) { //Use the default calendar _cal = vcGantt1.CalendarCollection.Active; } _secondsPerWorkday = cal.SecondsPerWorkday; if (_secondsPerWorkday == 0) { _secondsPerWorkday = 86400; //24 hours } } } private void vcGantt1_VcTextEntrySupplying(object sender, VcTextEntrySupplyingEventArgs e) { switch (e.ControlIndex) { case VcTextEntryIndex.vcTXEInfWndMinPl: case VcTextEntryIndex.vcTXEInfWndMinSi: e.Text = " Minutes"; break; case VcTextEntryIndex.vcTXEInfWndDuration: e.Text = "Current Duration"; break; case VcTextEntryIndex.vcTXEInfWndStart: e.Text = "Current Start"; break; case VcTextEntryIndex.vcTXEInfWndEnd: e.Text = "Current End"; break; case VcTextEntryIndex.vcTXEInfWndDurationValue: //Split _durationInMinutes into Days, Hours and Minutes int durationInSeconds = _durationInMinutes * 60; int days = durationInSeconds / _secondsPerWorkday; int rest = durationInSeconds % _secondsPerWorkday; int hours = rest / 3600; int minutes = (rest % 3600) / 60; e.Text = days.ToString() + " Days, " + hours.ToString() + " Hours, " + minutes.ToString(); break; } } private void vcGantt1_VcNodeModifying(object sender, VcNodeModifyingEventArgs e) { //Update current duration of the node being modified _durationInMinutes = Convert.ToInt32(e.Node.get_DataField(6)); }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn