private void OnEvent(string evt) { if (evt.CompareTo("ConfigLoaded") == 0) { for (int i = 0; i < m_processManager.Count; i++) { Database.Entry entry = m_processManager.GetEntryAtIndex(i); ListViewItem listitem = new ListViewItem(entry.name); listitem.SubItems.Add("Idle"); listView1.Items.Add(listitem); } SizeLastColumn(listView1); } if (evt.CompareTo("StatusUpdated") == 0) { for (int i = 0; i < m_processManager.Count; i++) { ProcessManager.Status status = m_processManager.GetProcessStatus(i); SetSubItemText(i, status); } } if (evt.CompareTo("StartFailure") == 0) { MessageBox.Show("Failed to start application. Please review the config.json for errors.", "Error"); } if (evt.CompareTo("StopFailure") == 0) { MessageBox.Show("Failed to stop application.", "Error"); } }
private void SetSubItemText(int index, ProcessManager.Status status) { if (this.listView1.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetSubItemText); this.Invoke(d, new object[] { index, status }); } else { listView1.Items[index].SubItems[1] = new ListViewItem.ListViewSubItem(listView1.Items[index], status.ToString()); } }