Example #1
0
        /// <summary>
        /// Event handler for the Apply button <c>Click</c> event. Update the workset.
        /// </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 m_ButtonApply_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            IWatchFile iWatchFile = CalledFrom as IWatchFile;

            Debug.Assert(iWatchFile != null, "FormPlotDefine.m_ButtonApply_Click() - [iWatchFile != null]");

            Cursor = Cursors.WaitCursor;

            // Yes - Update the WatchFile property with the new workset.
            WatchFile_t watchFile = iWatchFile.WatchFile;

            if (m_RestoreDefault == true)
            {
                watchFile.DataStream.Workset.PlotTabPages = null;
            }
            else
            {
                Workset_t workset = ConvertToWorkset(m_Workset.Name);
                watchFile.DataStream.Workset = workset;
            }
            iWatchFile.WatchFile = watchFile;
            iWatchFile.SaveWatchFile();

            m_ButtonApply.Enabled = false;

            // Let the calling form know that the watchfile has been modified.
            DialogResult = DialogResult.Yes;
            Cursor       = Cursors.Default;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and 
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormOpenWatch(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

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

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleOpenWatchFile, WatchFile.Filename);
            #endregion - [Title] -

            // Display any available supplemental information.
            m_PanelSupplementalInformation.Visible = true;
            m_LabelSupplementalInformation.Text = WatchFile.DataStream.Workset.Name;
            m_LegendSupplementalInformation.Text = Resources.LegendWorkset;

            // The trip time is not relevant to recorded watch variables therefore set it to the invalid state.
            DateTime tripTime = Parameter.InvalidDateTime;

            // Initialize the structure used to manage the plotter range.
            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormOpenWatch(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

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

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleOpenWatchFile, WatchFile.Filename);
            #endregion - [Title] -

            // Display any available supplemental information.
            m_PanelSupplementalInformation.Visible = true;
            m_LabelSupplementalInformation.Text    = WatchFile.DataStream.Workset.Name;
            m_LegendSupplementalInformation.Text   = Resources.LegendWorkset;

            // The trip time is not relevant to recorded watch variables therefore set it to the invalid state.
            DateTime tripTime = Parameter.InvalidDateTime;

            // Initialize the structure used to manage the plotter range.
            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
Example #4
0
        /// <summary>
        /// Event handler for the OK button <c>Click</c> event. Closes the form.
        /// </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>
        private void m_ButtonOK_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Check whether the comments text of the header has been modified.
            if (m_TextBoxComments.Text != m_Header.Comments)
            {
                Cursor = Cursors.WaitCursor;

                // Check whether the calling form implements the IWatchFile interface.
                IWatchFile iWatchFile = CalledFrom as IWatchFile;
                if (iWatchFile != null)
                {
                    // Yes - Update the WatchFile property with the current header.
                    WatchFile_t watchFile = iWatchFile.WatchFile;
                    watchFile.Header.Comments = m_TextBoxComments.Text;
                    iWatchFile.WatchFile      = watchFile;
                    iWatchFile.SaveWatchFile();
                }
                else
                {
                    // No - Check whether the calling form implements the IEventLogFIle interface.
                    IEventLogFile iEventLogFile = CalledFrom as IEventLogFile;
                    if (iEventLogFile != null)
                    {
                        // Yes - Update the EventLogFile property with the current header.
                        EventLogFile_t eventLogFile = iEventLogFile.EventLogFile;
                        Header_t       header       = eventLogFile.Header;
                        header.Comments            = m_TextBoxComments.Text;
                        eventLogFile.Header        = header;
                        iEventLogFile.EventLogFile = eventLogFile;
                        iEventLogFile.SaveEventLogFile();
                    }
                }

                Cursor = Cursors.Default;
            }

            Close();
        }
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormViewFaultLog(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

            #region - [Function Keys] -
            DisplayFunctionKey(F3, Resources.FunctionKeyTextSave, Resources.FunctionKeyToolTipSaveFaultLog, Resources.Save);
            F3.Enabled = true;

            // Disable the 'F5-Edit' function key as changing the plot layout is not supported on live fault log data. This feature is
            // only available once the fault log has been saved to disk.
            F5.Enabled = false;
            #endregion - [Function Keys] -

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleFaultLog, WatchFile.DataStream.EventDescription);
            #endregion - [Title]

            // Tab page title.
            if (m_TabControl != null && m_TabControl.TabPages.Count > 0)
            {
                m_TabControl.TabPages[0].Text = watchFile.DataStream.EventDescription;
            }

            // Initialize the structure used to manage the plotter range.
            DateTime tripTime;
            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
Example #6
0
        /// <summary>
        /// Event handler for the 'Show All' button <c>Click</c> event. Set the PlotTabPages field of the workset to the default values i.e. base the layout of the plot
        /// screen upon the contents of the Column field of the workset.
        /// </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>
        private void m_ButtonRestoreDefaults_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            IWatchFile iWatchFile = CalledFrom as IWatchFile;

            Debug.Assert(iWatchFile != null, "FormPlotDefine.m_ButtonRestoreDefaults_Click() - [iWatchFile != null]");

            Cursor           = Cursors.WaitCursor;
            m_RestoreDefault = true;
            m_ButtonRestoreDefault.Enabled = false;

            // Restore the default plot values.
            for (int columnIndex = 0; columnIndex < m_Workset.Column.Length; columnIndex++)
            {
                m_TextBoxHeaders[columnIndex].Text = m_Workset.Column[columnIndex].HeaderText;
                WatchItemAddRange(m_ListBoxes[columnIndex], m_Workset.Column[columnIndex]);
            }

            m_ListItemCount = m_Workset.Count;

            // Yes - Update the WatchFile property with the new workset.
            WatchFile_t watchFile = iWatchFile.WatchFile;

            if (watchFile.DataStream.Workset.PlotTabPages != null)
            {
                EnableApplyAndOKButtons();
            }
            else
            {
                DisableApplyAndOKButtons(string.Empty);
            }

            UpdateCount();

            Cursor = Cursors.Default;
        }
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormOpenFaultLog(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

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

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleOpenFaultLog, WatchFile.Filename);
            #endregion - [Title] -

            // Tab page title.
            if (m_TabControl != null && m_TabControl.TabPages.Count > 0)
            {
                m_TabControl.TabPages[0].Text = watchFile.DataStream.EventDescription;
            }

            // Initialize the structure used to manage the plotter range.
            DateTime tripTime;
            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and 
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormOpenFaultLog(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

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

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleOpenFaultLog, WatchFile.Filename);
            #endregion - [Title] -

			// Tab page title.
			if (m_TabControl != null && m_TabControl.TabPages.Count > 0)
			{
				m_TabControl.TabPages[0].Text = watchFile.DataStream.EventDescription;
			}

            // Initialize the structure used to manage the plotter range.
            DateTime tripTime;
            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormOpenSimulatedFaultLog(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

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

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleOpenSimulatedFaultLog, WatchFile.Filename);
            #endregion - [Title] -

            // Display any available supplemental information.
            m_PanelSupplementalInformation.Visible = true;
            m_LabelSupplementalInformation.Text    = WatchFile.DataStream.Workset.Name;
            m_LegendSupplementalInformation.Text   = Resources.LegendWorkset;

            // Initialize the structure used to manage the plotter range.
            DateTime tripTime;
            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and 
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormOpenSimulatedFaultLog(WatchFile_t watchFile)
            : base(watchFile)
        {
            InitializeComponent();

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

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleOpenSimulatedFaultLog, WatchFile.Filename);
            #endregion - [Title] -

            // Display any available supplemental information.
            m_PanelSupplementalInformation.Visible = true;
            m_LabelSupplementalInformation.Text = WatchFile.DataStream.Workset.Name;
            m_LegendSupplementalInformation.Text = Resources.LegendWorkset;

            // Initialize the structure used to manage the plotter range.
            DateTime tripTime;
            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
Example #11
0
        /// <summary>
        /// The event handler for the <c>Shown</c> event.
        /// </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>
        private void FormPlotDefine_Shown(object sender, EventArgs e)
        {
            if (CalledFrom == null)
            {
                return;
            }

            WatchFile_t watchFile = ((IWatchFile)CalledFrom).WatchFile;
            DataStreamTypeParameters_t datastreamTypeParameters = watchFile.DataStream.DataStreamTypeParameters;

            // Check whether the workset is a data stream rather than a recorded watch file or a simulated data stream and, if so, hide the TabPages,
            // Labels and TextBoxes that aren't required and update the TabPage header text.
            if (watchFile.DataStream.LogType.Equals(LogType.DataStream))
            {
                // Only one column is required fot this workset so delete the tab pages associated with columns 2 and 3.
                m_TabControlColumn.TabPages.Remove(m_TabPageColumn2);
                m_TabControlColumn.TabPages.Remove(m_TabPageColumn3);
                m_LabelCountTotal.Visible = false;
                m_LegendHeader1.Visible   = false;
                m_TextBoxHeader1.Enabled  = false;
                m_TextBoxHeader1.Visible  = false;
                m_TabPageColumn1.Text     = Resources.HeaderTextDataStream;
            }
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the class. Initialize: (1) Any additional function keys or information labels that are required; (2) the <c>Form</c> and 
        /// <c>TabPage</c> titles; (3) the time axis and (4) the information label values.
        /// </summary>
        /// <param name="watchFile">The structure containing the fault log data that is to be plotted.</param>
        public FormViewFaultLog(WatchFile_t watchFile) 
            : base(watchFile)
        {
            InitializeComponent();

            #region - [Function Keys] -
            DisplayFunctionKey(F3, Resources.FunctionKeyTextSave, Resources.FunctionKeyToolTipSaveFaultLog, Resources.Save);
            F3.Enabled = true;

            // Disable the 'F5-Edit' function key as changing the plot layout is not supported on live fault log data. This feature is 
            // only available once the fault log has been saved to disk.
            F5.Enabled = false;
            #endregion - [Function Keys] -

            #region - [InformationLabels/Legend] -
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text = string.Format(Resources.TitleFaultLog, WatchFile.DataStream.EventDescription);
            #endregion - [Title] 

            // Tab page title.
			if (m_TabControl != null && m_TabControl.TabPages.Count > 0)
			{
				m_TabControl.TabPages[0].Text = watchFile.DataStream.EventDescription;
			}

            // Initialize the structure used to manage the plotter range.
            DateTime tripTime;
            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            InitializePlotterRangeSelection(tripTime);

            // Update the status labels with the plotter range information.
            UpdateStatusLabels();
        }
        /// <summary>
        /// Event handler for the F3 <c>Click</c> event. Save the fault log to disk.
        /// </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 F3_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Skip if the key isn't enabled.
            if (F3.Enabled == false)
            {
                return;
            }

            Cursor     = Cursors.WaitCursor;
            F3.Checked = true;

            // Clear the status message.
            if (MainWindow != null)
            {
                MainWindow.WriteStatusMessage(string.Empty);
            }

            // Show the form that allows the user to add user comments to the header information.
            // Get the time of the trip.
            DateTime tripTime;

            try
            {
                tripTime = m_HistoricDataManager.AllFrames[WatchFile.DataStream.DataStreamTypeParameters.TripIndex].CurrentDateTime;
            }
            catch (Exception)
            {
                TimeSpan postTripMs = new TimeSpan(0, 0, 0, WatchFile.DataStream.DurationPostTripMs);
                tripTime = m_HistoricDataManager.AllFrames[m_HistoricDataManager.AllFrames.Count - 1].CurrentDateTime.Subtract(postTripMs);
            }

            FormAddComments formAddComments = new FormAddComments(FileHeader.HeaderCurrent, tripTime);

            formAddComments.CalledFrom = this;
            formAddComments.ShowDialog();

            WatchFile_t watchFile = WatchFile;

            watchFile.Header = formAddComments.Header;
            WatchFile        = watchFile;

            // ----------------------
            // Save the file to disk.
            // ----------------------
            // For consistency, use the DeriveName() method to derive the default filename of the simulated fault log file that is to be saved to disk.
            string defaultFilename           = General.DeriveName(FileHeader.HeaderCurrent.TargetConfiguration.CarIdentifier, tripTime, CommonConstants.ExtensionFaultLog, WatchFile.DataStream.EventDescription);
            string fullyQualifiedFaulLogFile = General.FileDialogSaveFaultLog(defaultFilename, InitialDirectory.FaultLogsWrite);

            if (fullyQualifiedFaulLogFile != string.Empty)
            {
                // Serialize the data to the specified file.
                FileHandling.Serialize <WatchFile_t>(fullyQualifiedFaulLogFile, WatchFile, FileHandling.FormatType.Binary);

                // Update the initial directory with the path of the selected file.
                InitialDirectory.FaultLogsWrite = Path.GetDirectoryName(fullyQualifiedFaulLogFile);
            }

            F3.Checked = false;
            Cursor     = Cursors.Default;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="watchFile">The file structure of the log that was saved to disk.</param>
        public HistoricDataManager(WatchFile_t watchFile)
        {
            // Create the list containing all the frames associated with the set.
            Debug.Assert(watchFile.DataStream.WatchFrameList.Count > 1, "HistoricDataManager.Ctor() - [watchFile.WatchFrameList.Count > 1]");
            m_FramesAll = new List<WatchFrame_t>();
            m_FramesAll = watchFile.DataStream.WatchFrameList;

            // Copy All the records in the above list to the list associated with the frames associated with the start and stop times.
            m_FramesToPlot = new List<WatchFrame_t>();
            m_FramesToPlot = m_FramesAll;

            m_StartTime = m_FramesAll[0].CurrentDateTime;
            m_StopTime = m_FramesAll[m_FramesAll.Count - 1].CurrentDateTime;

            m_LogType = watchFile.DataStream.LogType;

            Debug.Assert(watchFile.DataStream.FrameIntervalMs > 0, "HistoricDataManager.Ctor() - [watchFile.DataStream.FrameIntervalMs > 0]");
            m_FrameIntervalMs = watchFile.DataStream.FrameIntervalMs;
            m_Workset = watchFile.DataStream.Workset;

            m_WatchFile = watchFile;

            // Convert the DataStream.AutoScaleWatchValues property of the watch file to a list.
            m_AutoScaleWatchValueList = new List<AutoScale_t>();
            AutoScale_t autoScale;
            for (int watchElementIndex = 0; watchElementIndex < m_WatchFile.DataStream.AutoScaleWatchValues.Length; watchElementIndex++)
            {
                autoScale = m_WatchFile.DataStream.AutoScaleWatchValues[watchElementIndex];
                m_AutoScaleWatchValueList.Add(autoScale);
            }
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="historicDataManager">Reference to the <c>HistoricDataManager</c> object containing the data frames that are to be displayed.</param>
        /// <param name="watchFile">The saved watch data file.</param>
        public FormDataStreamReplay(IHistoricDataManager historicDataManager, WatchFile_t watchFile ) : base(watchFile.DataStream.Workset)
        {
            InitializeComponent();

            WatchFile = watchFile;
            m_Workset = WatchFile.DataStream.Workset;
            m_HistoricDataManager = historicDataManager;

            // Instantiate the class that helps manage the user controls.
            m_WatchControlLayout = new WatchControlLayout(this, m_HistoricDataManager);

            #region - [Function Keys] -
            // Escape - Exit
            // F1 - Help
            // F2 - Print
            // F3 - Save (Not  Used)
            // F4 - YTPlot
            // F5 - Trip
            // F6 - First
            // F7 - Previous
            // F8 - Next
            // F9 - Last
            // F11 - Play
            // F12 - Header Information
            DisplayFunctionKey(F3, Resources.FunctionKeyTextSave, Resources.FunctionKeyToolTipSave, Resources.Save);
            F3.Enabled = false;
            DisplayFunctionKey(F4, Resources.FunctionKeyTextYTPlot, Resources.FunctionKeyToolTipYTPlot, Resources.YTPlot);

            // Only display the trip function key if the historic data is a fault log or simulated fault log.
            if ((m_HistoricDataManager.LogType == LogType.DataStream) || (m_HistoricDataManager.LogType == LogType.SimulatedDataStream))
            {
                DisplayFunctionKey(F5, Resources.FunctionKeyTextTrip, Resources.FunctionKeyToolTipTrip, Resources.Trip);
            }

            DisplayFunctionKey(F6, Resources.FunctionKeyTextFirst, Resources.FunctionKeyToolTipFirst, Resources.MoveFirst);
            DisplayFunctionKey(F7, Resources.FunctionKeyTextPrevious, Resources.FunctionKeyToolTipPrevious, Resources.MovePrevious);
            DisplayFunctionKey(F8, Resources.FunctionKeyTextNext, Resources.FunctionKeyToolTipNext, Resources.MoveNext);
            DisplayFunctionKey(F9, Resources.FunctionKeyTextLast, Resources.FunctionKeyToolTipLast, Resources.MoveLast);
            DisplayFunctionKey(F11, Resources.FunctionKeyTextPlay, Resources.FunctionKeyToolTipPlay, Resources.Play);
            DisplayFunctionKey(F12, Resources.FunctionKeyTextInfo, Resources.FunctionKeyToolTipInfo, Resources.FileInformation);
            #endregion - [Function Keys] -

            #region - [InformationLabels/Legend] -
            // InformationLabel 1  - Date
            // InformationLabel 2  - Start Time
            // InformationLabel 3  - Stop Time
            // InformationLabel 4  - Duration
            // InformationLabel 5  - Time
            // InformationLabel 6  - Frame
            DisplayLabel(InformationLabel1, Resources.InformationLegendDate, Color.MintCream);
            DisplayLabel(InformationLabel2, Resources.InformationLegendStartTime, Color.PaleGreen);
            DisplayLabel(InformationLabel3, Resources.InformationLegendStopTime, Color.LightCoral);
            DisplayLabel(InformationLabel4, Resources.InformationLegendDuration, Color.Khaki);
            DisplayLabel(InformationLabel5, Resources.InformationLegendRTC, Color.FromKnownColor(KnownColor.GradientInactiveCaption));
            DisplayLabel(InformationLabel6, Resources.InformationLegendFrame, Color.FromKnownColor(KnownColor.Info));
            #endregion - [InformationLabels/Legend] -

            #region - [Title] -
            Text =  Resources.TitleReplay + CommonConstants.Colon + WatchFile.Filename;
            #endregion - [Title] -

            #region - [Play Timer] -
            m_TimerPlay = new System.Windows.Forms.Timer();
            m_TimerPlay.Tick += new EventHandler(DisplayNextFrame);
            m_TimerPlay.Interval = IntervalTimerPlayInitialValue;
            m_TimerPlay.Enabled = true;
            m_TimerPlay.Stop();
            #endregion - [Play Timer] -
            
            UpdateStatusLabels();

            // Update the tab with the name of the workset.
            m_TabControl.TabPages[m_TabControl.SelectedIndex].Text = m_Workset.Name;

            // Display the values associated with the first frame.
            m_Index = 0;

            // Frame.
            InformationLabel6.Text = m_Index.ToString();

            // Don't allow the user to attempt to modify watch variable data values from this form.
            VariableControl.ReadOnly = true;
        }
        /// <summary>
        /// Configure the specified <c>TabControl</c> control so that it can be used to plot the watch values saved within the specified file.
        /// (1) Create a tab page for every display column in the workset that contains watch variables, (2) add a layout panel to each of the tab
        /// pages and (3) add configured plotter user controls corresponding to the watch variables associated with the display column to each layout
        /// panel. The size and range information is not configured at this stage.
        /// </summary>
        /// <param name="tabControl">The <c>TabControl</c> that is to be configured.</param>
        /// <param name="watchFile">The watch file containing the data that is to be plotted.</param>
        private void ConfigureTabControl(TabControl tabControl, WatchFile_t watchFile)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Load the workset associated with the saved log file.
            Workset_t workset = watchFile.DataStream.Workset;

            // Load the auto-scaling information associated with the saved log file.
            AutoScale_t[] autoScaleWatchValues = watchFile.DataStream.AutoScaleWatchValues;

            tabControl.TabPages.Clear();

            // Use the Tag field of the control to record the log type.
            tabControl.Tag = WatchFile.DataStream.LogType;

            // Check whether the TabPagePlots attribute of the workset is defined and set the flag that indicates whether the plot layout is the
            // default layout accordingly.
            m_IsDefaultLayout = false;
            if (workset.PlotTabPages == null)
            {
                m_IsDefaultLayout = true;

                // Update the information used to plot the workset values to match the column definitions of the workset.
                workset.PlotTabPages = new PlotTabPage_t[workset.Column.Length];
                for (int columnIndex = 0; columnIndex < workset.Column.Length; columnIndex++)
                {
                    workset.PlotTabPages[columnIndex].HeaderText = workset.Column[columnIndex].HeaderText;
                    workset.PlotTabPages[columnIndex].OldIdentifierList = new List<short>();
                    workset.PlotTabPages[columnIndex].DisplayMaskList = new List<uint>();
                    for (int rowIndex = 0; rowIndex < workset.Column[columnIndex].OldIdentifierList.Count; rowIndex++)
                    {
                        workset.PlotTabPages[columnIndex].OldIdentifierList.Add(workset.Column[columnIndex].OldIdentifierList[rowIndex]);
                        workset.PlotTabPages[columnIndex].DisplayMaskList.Add(uint.MaxValue);
                    }
                }
            }

            // Create a tab page for tab page definition defined within the TabPagePlots attribute of the workset.
            TableLayoutPanel tableLayoutPanel;
            TabPage tabPage;
            for (int tabPageIndex = 0; tabPageIndex < workset.PlotTabPages.Length; tabPageIndex++)
            {
                // Only add a tab page to the list if the tab page definition contains watch identifiers.
                if (workset.PlotTabPages[tabPageIndex].OldIdentifierList.Count != 0)
                {
                    tableLayoutPanel = ConstructLayoutPanel(tabPageIndex);
                    ConfigureTableLayoutPanel(tableLayoutPanel, workset, autoScaleWatchValues, tabPageIndex);
                    tabPage = ConstructTabPage(workset.PlotTabPages[tabPageIndex].HeaderText, tableLayoutPanel);
                    tabControl.TabPages.Add(tabPage);
                }
            }
        }
        /// <summary>
        /// Close the form cleanly.
        /// </summary>
        public override void Exit()
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            Escape.Checked = true;

            this.SuspendLayout();

            // Clear the status message.
            MainWindow.WriteStatusMessage(string.Empty);

            // -------------------------------------------------------------------------------------------------------------------------------------
            // Check whether one or more plots have been removed by the user and, if so, update the PlotTabPages property of the workset associated
            // with the current watch file.
            // -------------------------------------------------------------------------------------------------------------------------------------
            bool itemsRemoved;
            PlotTabPage_t[] plotTabPages = ConstructPlotTabPages(m_TabControl, out itemsRemoved);
            if (itemsRemoved == true)
            {
                // Update the WatchFile property with the new workset.
                WatchFile_t watchFile = WatchFile;
                watchFile.DataStream.Workset.PlotTabPages = plotTabPages;
                WatchFile = watchFile;
                SaveWatchFile();
            }

            MainWindow.WriteCarIdentifier(FileHeader.HeaderCurrent.TargetConfiguration.CarIdentifier);
            DisposeOfUserControls();
            this.PerformLayout();

            Escape.Checked = false;
            Cursor = Cursors.Default;

            base.Exit();
        }
        /// <summary>
        /// Event handler for the F5 function key. Displays the dialog box that allows the user to configure the screen layout. 
        /// </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 F5_Click(object sender, EventArgs e)
        {
            // Skip, if the Dispose() method has been called.
            if (IsDisposed)
            {
                return;
            }

            // Skip if the key isn't enabled.
            if (F5.Enabled == false)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            F5.Checked = true;

            try
            {
                // -------------------------------------------------------------------------------------------------------------------------
                // Check whether one or more plots have been removed by the user and, if so, update the PlotTabPages property of the workset
                // associated with the current watch file.
                // -------------------------------------------------------------------------------------------------------------------------
                bool itemsRemoved;
                PlotTabPage_t[] plotTabPages = ConstructPlotTabPages(m_TabControl, out itemsRemoved);
                if (itemsRemoved == true)
                {
                    // Update the WatchFile property with the new workset.
                    WatchFile_t watchFile = WatchFile;
                    watchFile.DataStream.Workset.PlotTabPages = plotTabPages;
                    WatchFile = watchFile;
                    SaveWatchFile();
                }

                FormPlotDefine formPlotDefine = new FormPlotDefine(WatchFile.DataStream.Workset);

                // The CalledFrom property is used to allow the called form to reference back to this form.
                formPlotDefine.CalledFrom = this;
                DialogResult dialogResult = formPlotDefine.ShowDialog();

                // Check whether the PlotTabPages field of the workset has been modified.
                if (dialogResult == DialogResult.Yes)
                {
                    Cursor = Cursors.WaitCursor;

                    // ----------------------------------------------------------------------
                    // Re-draw the plot based upon the modified Workset.PlotTabPages setting.
                    // ----------------------------------------------------------------------
                    m_TabControl.Hide();
                    m_TabControl.SuspendLayout();
                    ConfigureTabControl(m_TabControl, WatchFile);
                    m_HistoricDataManager.Reset();
                    FormDataStreamPlot_Shown(this, new EventArgs());
                    m_TabControl.PerformLayout();
                    m_TabControl.Show();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            F5.Checked = false;
            Cursor = Cursors.Default;
        }
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        /// <param name="watchFile">The structure containing the data stream that is to be plotted.</param>
        public FormDataStreamPlot(WatchFile_t watchFile)
        {
            InitializeComponent();

            // Make the file accessible to all members methods.
            WatchFile = watchFile;
            Debug.Assert(watchFile.DataStream.FrameIntervalMs > 0, "FormDataStreamPlot.Ctor() - [watchFile.DataStream.FrameIntervalMs > 0");

            m_HistoricDataManager = new HistoricDataManager(WatchFile);

            // Instantiate the class that supports the plotting of historic data.
            m_PlotterControlLayout = new PlotterControlLayout(this, m_HistoricDataManager);

            #region - [UserControl Event Handlers] -
            m_PlotterControlLayout.RangeChanged += new EventHandler(RangeChanged);
            m_PlotterControlLayout.RangeReset += new EventHandler(RangeReset);
            m_PlotterControlLayout.ZoomSelected += new EventHandler(ZoomSelected);
            m_PlotterControlLayout.RemoveSelected += new EventHandler(RemoveSelected);
            #endregion - [Event Handlers] -

            ConfigureTabControl(m_TabControl, WatchFile);

            #region - [Function Keys] -
            // Escape - Exit
            // F1 - Help
            // F2 - Print
            // F4 - Replay
            // F5 - Configure Plot
			// F6 - MultiCursor
            DisplayFunctionKey(F4, Resources.FunctionKeyTextReplay, Resources.FunctionKeyToolTipReplay, Resources.Replay);
            DisplayFunctionKey(F5, Resources.FunctionKeyTextEdit, Resources.FunctionKeyToolTipEditPlotLayout, Resources.Modify);
			DisplayFunctionKey(F6, Resources.FunctionKeyTextMultiCursor, Resources.FunctionKeyToolTipMultiCursor, Resources.MultiCursor);
            #endregion - [Function Keys] -

            #region - [InformationLabels/Legend] -
            // InformationLabel 1  - Date
            // InformationLabel 2  - Start Time
            // InformationLabel 3  - Stop Time
            // InformationLabel 4  - Duration
            DisplayLabel(InformationLabel1, Resources.InformationLegendDate, Color.MintCream);
            DisplayLabel(InformationLabel2, Resources.InformationLegendStartTime, Color.LightGreen);
            DisplayLabel(InformationLabel3, Resources.InformationLegendStopTime, Color.Red);
            DisplayLabel(InformationLabel4, Resources.InformationLegendDuration, Color.Khaki);
            #endregion - [InformationLabels/Legend] -

            // Ensure that the single cursor option is used as the default.
            Plotter.MultiCursor = false;
        }