/// <summary> /// Event handler for F4 function key. Load additional saved event logs. /// </summary> /// <param name="sender">Reference to the object that raised the event.</param> /// <param name="e">Parameter passed from the object that raised the event.</param> protected override void F4_Click(object sender, EventArgs e) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } // Skip if the key isn't enabled. if (F4.Enabled == false) { return; } Cursor = Cursors.WaitCursor; F4.Checked = true; // Clear the status message. if (MainWindow != null) { MainWindow.WriteStatusMessage(string.Empty); } MenuInterfaceEvent menuInterfaceEvent = new MenuInterfaceEvent(MainWindow); // Create an event log file structure to hold the imported events. EventLogFile_t eventLogFile = menuInterfaceEvent.ImportEventLogFiles(); if (eventLogFile.EventRecordList.Count <= 0) { F4.Checked = false; Cursor = Cursors.Default; return; } // Create a temporary event log file structure so that we can use the AppendEventRecordList() method to add the the imported events to the existing events // while ignoring duplicate entries. EventLogFile_t temporaryEventLogFile = new EventLogFile_t(); temporaryEventLogFile.EventRecordList = new List<EventRecord>(); // Add the existing events to the list. temporaryEventLogFile.AppendEventRecordList(EventRecordList); // Append the imported events to the list ignoring duplicate entries. bool duplicationsFound; temporaryEventLogFile.AppendEventRecordList(eventLogFile.EventRecordList, out duplicationsFound); // Clear the EventRecordList property then add the events stored in the temporary event file structure. EventRecordList.Clear(); EventRecordList.AddRange(temporaryEventLogFile.EventRecordList); // Sort the list of events, most recent event first. This ensures that the first row of the DataGridView is selected when the event log is first shown. EventRecordList.Sort(CompareByDateTimeDescending); ClearDataGridViewRows(); AddList(EventRecordList); // Simulate a SelectionChanged event to display the event variables associated with the selected event. m_DataGridViewEventLog_SelectionChanged(m_DataGridViewEventLog, new EventArgs()); F4.Checked = false; Cursor = Cursors.Default; }
/// <summary> /// Event handler for F4 function key. Load additional saved event logs. /// </summary> /// <param name="sender">Reference to the object that raised the event.</param> /// <param name="e">Parameter passed from the object that raised the event.</param> protected override void F4_Click(object sender, EventArgs e) { // Skip, if the Dispose() method has been called. if (IsDisposed) { return; } // Skip if the key isn't enabled. if (F4.Enabled == false) { return; } Cursor = Cursors.WaitCursor; F4.Checked = true; // Clear the status message. if (MainWindow != null) { MainWindow.WriteStatusMessage(string.Empty); } MenuInterfaceEvent menuInterfaceEvent = new MenuInterfaceEvent(MainWindow); // Create an event log file structure to hold the imported events. EventLogFile_t eventLogFile = menuInterfaceEvent.ImportEventLogFiles(); if (eventLogFile.EventRecordList.Count <= 0) { F4.Checked = false; Cursor = Cursors.Default; return; } // Create a temporary event log file structure so that we can use the AppendEventRecordList() method to add the the imported events to the existing events // while ignoring duplicate entries. EventLogFile_t temporaryEventLogFile = new EventLogFile_t(); temporaryEventLogFile.EventRecordList = new List <EventRecord>(); // Add the existing events to the list. temporaryEventLogFile.AppendEventRecordList(EventRecordList); // Append the imported events to the list ignoring duplicate entries. bool duplicationsFound; temporaryEventLogFile.AppendEventRecordList(eventLogFile.EventRecordList, out duplicationsFound); // Clear the EventRecordList property then add the events stored in the temporary event file structure. EventRecordList.Clear(); EventRecordList.AddRange(temporaryEventLogFile.EventRecordList); // Sort the list of events, most recent event first. This ensures that the first row of the DataGridView is selected when the event log is first shown. EventRecordList.Sort(CompareByDateTimeDescending); ClearDataGridViewRows(); AddList(EventRecordList); // Simulate a SelectionChanged event to display the event variables associated with the selected event. m_DataGridViewEventLog_SelectionChanged(m_DataGridViewEventLog, new EventArgs()); F4.Checked = false; Cursor = Cursors.Default; }