翻譯|使用教程|編輯:黃竹雯|2018-10-26 10:42:05.000|閱讀 555 次
概述:本文為使用我們產品VARCHART XGantt的開發人員送上.NET甘特圖控件工具提示中的持續時間的開發小技巧。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文為使用我們產品VARCHART XGantt的開發人員送上.NET甘特圖控件工具提示中的持續時間的開發小技巧。它顯示了如何使用最近引入的“InInteraction Events”功能在拖放交互期間自定義工具提示(InfoWindow)中持續時間的顯示。我們不僅給出了如何實現這一目標的逐步說明,還提供了所需的代碼。
我們假設客戶計劃在幾分鐘內完成。因此,您將在VARCHART XGantt屬性頁上選擇分鐘作為時間單位。因此,您將在VARCHART XGantt屬性頁上選擇分鐘作為時間單位。
如果您的用戶現在減少或增加了應用程序中條形的長度(表示例如任務或作業或操作),則在相應的用戶交互期間,此欄的持續時間將顯示在InfoWindow中。
但是,709分鐘給任何人的信息有多大意義?如果您能以天,小時和分鐘顯示持續時間,那么它對您的用戶來說不是更相關嗎?更重要的是:考慮到基礎班次日歷數據以及相應的工作和非工作間隔,顯示所有這些信息不是很好嗎?我們來看一下:
在上面的屏幕截圖中,每日工作時間定義為32,400秒,即9小時。以下是使用.NET Gantt圖表控件VARCHART XGantt實現此目的的方法。
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)); }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn