/// <summary>
        /// Append the specified list of event records to the existing event record list. Use the signature that specifies the duplicationsFound flag if
        /// duplicate entries are to be ignored.
        /// </summary>
        /// <param name="eventRecordList">The list of event records that are to be appended to the event record list.</param>
        public void AppendEventRecordList(List <EventRecord> eventRecordList)
        {
            Debug.Assert(eventRecordList != null, "FileHandling.AppendEventRecordList() - [eventRecordList != null]");

            EventRecord[] eventRecords = eventRecordList.ToArray();
            if (EventRecordList != null)
            {
                EventRecordList.AddRange(eventRecords);
            }
        }
        /// <summary>
        /// Append the specified list of event records to the existing event record list. Use the signature that specifies the duplicationsFound flag if
        /// duplicate entries are to be ignored.
        /// </summary>
        /// <param name="eventRecordList">The list of event records that are to be appended to the event record list.</param>
        /// <param name="duplicationsFound">A flag to indicate whether the specified event record list contained duplicated events. True, if duplate entries were
        /// found; otherwise, false.</param>
        public void AppendEventRecordList(List <EventRecord> eventRecordList, out bool duplicationsFound)
        {
            Debug.Assert(EventRecordList != null, "FileHandling.AppendEventRecordList() - [EventRecordList != null]");
            Debug.Assert(eventRecordList != null, "FileHandling.AppendEventRecordList() - [eventRecordList != null]");

            duplicationsFound = false;

            // Add the events contained within the selected file, however, exclude duplications.
            string   description, carIdentifier;
            DateTime dateTime;
            int      eventIndex, logIdentifier;

            EventRecord foundEventRecord;

            for (short recordIndex = 0; recordIndex < eventRecordList.Count; recordIndex++)
            {
                // Check whether the current event already exists.
                description   = eventRecordList[recordIndex].Description;
                carIdentifier = eventRecordList[recordIndex].CarIdentifier;
                dateTime      = eventRecordList[recordIndex].DateTime;
                eventIndex    = eventRecordList[recordIndex].EventIndex;
                logIdentifier = eventRecordList[recordIndex].LogIdentifier;

                foundEventRecord = EventRecordList.Find(delegate(EventRecord eventRecord)
                {
                    if ((eventRecord.Description == description) &&
                        (eventRecord.CarIdentifier == carIdentifier) &&
                        (eventRecord.LogIdentifier == logIdentifier) &&
                        (eventRecord.DateTime == dateTime) &&
                        (eventRecord.EventIndex == eventIndex))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });

                // If the current event doesn't already exist, add it.
                if (foundEventRecord == null)
                {
                    EventRecordList.Add(eventRecordList[recordIndex]);
                }
                else
                {
                    duplicationsFound = true;
                }
            }
        }
        /// <summary>
        /// Initialize a new instance of the class. Intialize the size of the various components, set-up the function keys and initialize the list of event records.
        /// </summary>
        public FormOpenEventLog(EventLogFile_t eventLogFile)
        {
            InitializeComponent();

            m_MutexDataGridView = new Mutex();
            m_MutexEventCount   = new Mutex();

            #region - [DataGridView] -
            // Ensure that the DataGridView is set up before performing a sort.
            m_DataGridViewEventLog.Columns[ColumnIndexCarIdentifier].Visible = true;
            m_DataGridViewEventLog.Columns[ColumnIndexLog].Visible           = (Parameter.ShowLogName) ? true : false;
            #endregion - [DataGridView] -

            EventLogFile    = eventLogFile;
            EventRecordList = EventLogFile.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);

            #region - [Size Definitions] -
            m_EventVariableControlSize                        = new VariableControlSize_t();
            m_EventVariableControlSize.Margin.Left            = MarginLeftEventControl;
            m_EventVariableControlSize.Margin.Right           = MarginRightEventControl;
            m_EventVariableControlSize.Margin.Top             = MarginTopEventControl;
            m_EventVariableControlSize.Margin.Bottom          = MarginBottomEventControl;
            m_EventVariableControlSize.WidthVariableNameField = WidthEventControlVariableNameField;
            m_EventVariableControlSize.WidthValueField        = WidthEventControlValueField;
            m_EventVariableControlSize.WidthUnitsField        = WidthEventControlUnitsField;
            m_EventVariableControlSize.Height                 = HeightEventControl;
            #endregion - [Size Definitions] -

            #region - [Function Keys] -
            DisplayFunctionKey(F3, Resources.FunctionKeyTextSave, Resources.FunctionKeyToolTipSaveEventLogs, Resources.Save);
            F3.Enabled = false;
            DisplayFunctionKey(F4, Resources.FunctionKeyTextLoad, Resources.FunctionKeyToolTipLoad, Resources.FolderOpen);
            DisplayFunctionKey(F12, Resources.FunctionKeyTextInfo, Resources.FunctionKeyToolTipInfo, Resources.FileInformation);
            #endregion - [Function Keys] -

            // InformationLabel 1  - Event Count
            DisplayLabel(InformationLabel1, Resources.InformationLegendEventCount, Color.FromKnownColor(KnownColor.Info));

            #region - [Titles] -
            Text            = string.Format(Resources.TitleOpenEventLog, EventLogFile.Filename);
            m_TabPage1.Text = string.Empty;
            #endregion - [Titles] -

            m_CommonEventVariableCount = Lookup.EventTable.CommonEventVariableCount;
        }
        /// <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;
        }