コード例 #1
0
        private void UpdateLog(ActionStatusEnum actionStatus, DateTime runTime, TimeSpan elapsed, string message, ListViewItem item)
        {
            Color  color;
            string text;
            string lastRun;

            listViewControl.EnsureVisible(item.Index);
            switch (actionStatus)
            {
            case ActionStatusEnum.Executing:
                text    = "Executing";
                color   = Color.Blue;
                lastRun = "";
                break;

            case ActionStatusEnum.Succeeded:
                text    = "Success";
                color   = Color.Green;
                lastRun = runTime.ToString();
                break;

            default:
                text    = "Failure";
                color   = Color.Red;
                lastRun = runTime.ToString();
                break;
            }

            item.SubItems[1].Text        = text;
            item.SubItems[1].ForeColor   = color;
            item.UseItemStyleForSubItems = false;
            item.SubItems[2].Text        = lastRun;
            if (elapsed.TotalMilliseconds == 0)
            {
                item.SubItems[3].Text = "";
            }
            else
            {
                item.SubItems[3].Text = elapsed.ToString("c");
            }
            item.SubItems[4].Text = message;
            item.ToolTipText      = message;

            if (actionStatus == ActionStatusEnum.Succeeded)
            {
                try
                {
                    bool desiredValue = false;
                    _itemFlags.Create(item, desiredValue);
                    item.Checked = desiredValue;
                }
                finally
                {
                    _itemFlags.Remove(item);
                }
                item.Selected = false;
            }
        }