private void deleteEventLogToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete this log?", "Smoothy", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { TreeNode selectedNode = treeViewLogs.SelectedNode; if ((selectedNode != null) && (selectedNode.Tag != null)) { EventLog log = selectedNode.Tag as EventLog; EventLogViewer viewer = FindChildForLog(log); try { EventLog.Delete(log.LogDisplayName, log.MachineName); } catch (Exception ex) { MessageBox.Show("Could not delete log : " + ex.Message, "Smoothy", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (viewer != null) { viewer.Close(); } } RefreshEventLogs(selectedNode.Parent.Parent); } }
private void OpenChild(EventLog log) { this.Enabled = false; EventLogViewer viewer = FindChildForLog(log); if (viewer != null) { viewer.BringToFront(); viewer.Focus(); } else { EventLogViewer form = null; try { form = new EventLogViewer(log); if (!form.IsDisposed) { this.AddOwnedForm(form); form.MdiParent = this; form.Show(); form.BringToFront(); form.Focus(); } } catch (Exception ex) { MessageBox.Show("Failed to open Event Log : " + ex.Message, "Smoothy", MessageBoxButtons.OK, MessageBoxIcon.Error); if (form != null) { form.Close(); } } } this.Enabled = true; }