private void UpdateLog(ActionStatusEnum actionStatus, string resultMessage, ListViewItem item) { Color color; Color colorStartupHignlight = Color.Black; string text; switch (actionStatus) { case ActionStatusEnum.Executing: text = "Executing"; color = Color.Blue; item.ImageIndex = 0; break; case ActionStatusEnum.Succeeded: text = ((ServiceController)item.Tag).Status.ToString(); ServicesHelper.ServiceStartModeExt startupType = (ServicesHelper.ServiceStartModeExt)Enum.Parse(typeof(ServicesHelper.ServiceStartModeExt), item.SubItems[3].Text, true); if ((((ServiceController)item.Tag).Status != ServiceControllerStatus.Running) && (startupType == ServicesHelper.ServiceStartModeExt.Automatic || startupType == ServicesHelper.ServiceStartModeExt.DelayedAutomatic || startupType == ServicesHelper.ServiceStartModeExt.UNKNOWN )) { colorStartupHignlight = Color.Red; } color = Color.Green; item.Checked = false; break; default: text = ((ServiceController)item.Tag).Status.ToString(); color = Color.Red; break; } if (((ServiceController)item.Tag).Status == ServiceControllerStatus.Running) { item.ImageIndex = 1; } else if (((ServiceController)item.Tag).Status == ServiceControllerStatus.Stopped) { item.ImageIndex = 2; } item.SubItems[2].Text = text; item.SubItems[2].ForeColor = colorStartupHignlight; //item.SubItems[3].ForeColor = colorStartupHignlight; item.SubItems[4].ForeColor = color; item.SubItems[4].Text = resultMessage; item.UseItemStyleForSubItems = false; item.ToolTipText = resultMessage; }
private void UpdateStartupType(ActionStatusEnum actionStatus, string resultMessage, ListViewItem item) { Color color = Color.Black; string text; switch (actionStatus) { case ActionStatusEnum.Executing: text = "Loading..."; resultMessage = "Loading..."; break; case ActionStatusEnum.Succeeded: text = ((ServiceController)item.Tag).Status.ToString(); ServicesHelper.ServiceStartModeExt startupType = (ServicesHelper.ServiceStartModeExt)Enum.Parse(typeof(ServicesHelper.ServiceStartModeExt), resultMessage, true); if ((((ServiceController)item.Tag).Status != ServiceControllerStatus.Running) && (startupType == ServicesHelper.ServiceStartModeExt.Automatic || startupType == ServicesHelper.ServiceStartModeExt.DelayedAutomatic || startupType == ServicesHelper.ServiceStartModeExt.UNKNOWN )) { color = Color.Red; } item.Checked = false; break; default: text = ((ServiceController)item.Tag).Status.ToString(); color = Color.Red; break; } item.SubItems[2].ForeColor = color; // item.SubItems[3].ForeColor = color; item.SubItems[3].Text = resultMessage; item.UseItemStyleForSubItems = false; item.ToolTipText = resultMessage; }