コード例 #1
0
        void UpdateInventoryItem(TrackedInventory item)
        {
            for (int row = 7; row <= hudList.RowCount; row++)
            {
                if (((HudStaticText)hudList[row - 1][1]).Text == item.Name)
                {
                    ((HudStaticText)hudList[row - 1][2]).Text = item.LastKnownValue.ToString(CultureInfo.InvariantCulture);

                    if (item.LastKnownValue == 0)
                    {
                        ((HudStaticText)hudList[row - 1][3]).Text = String.Empty;
                        ((HudStaticText)hudList[row - 1][4]).Text = String.Empty;
                        ((HudStaticText)hudList[row - 1][5]).Text = String.Empty;
                    }
                    else
                    {
                        var oneHourItemCountDifferenceOverFiveMinutes = item.GetValueDifference(TimeSpan.FromMinutes(5), TimeSpan.FromHours(1));
                        ((HudStaticText)hudList[row - 1][3]).Text = oneHourItemCountDifferenceOverFiveMinutes == 0 ? String.Empty : oneHourItemCountDifferenceOverFiveMinutes.ToString("N1");

                        var oneHourItemCountDifferenceOverOneHour = item.GetValueDifference(TimeSpan.FromHours(1), TimeSpan.FromHours(1));
                        ((HudStaticText)hudList[row - 1][4]).Text = oneHourItemCountDifferenceOverOneHour == 0 ? String.Empty : oneHourItemCountDifferenceOverOneHour.ToString("N1");

                        var hoursRemaining = item.GetTimeToDepletion(TimeSpan.FromHours(1));
                        ((HudStaticText)hudList[row - 1][5]).Text = (hoursRemaining == TimeSpan.Zero || hoursRemaining == TimeSpan.MaxValue) ? String.Empty : hoursRemaining.TotalHours.ToString("N1");
                    }
                }
            }
        }