Demonstrates how to get metadata and stream information from an event file with the KStudioEventFile class. Properties are gathered for display in the UI and/or output to the command window.
Example #1
0
        /// <summary>
        /// Handles the click event for the 'Compare Files' button
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">routed event args</param>
        private void CompareFiles_Click(object sender, RoutedEventArgs e)
        {
            State previous = this.currentState;
            this.WaitMessageText = Strings.WaitForCompareFiles;
            this.CurrentState = State.Wait;

            string file1 = string.Empty;
            string file2 = string.Empty;
            KStudioEventFile eventFile2 = null;

            try
            {
                // open the first file, if not already opened for View
                if (this.fileData == null)
                {
                    // open a new file
                    file1 = this.OpenFileForInspection();

                    // if user cancels from OpenFileDialog, return to previous state
                    if (string.IsNullOrEmpty(file1))
                    {
                        this.CurrentState = previous;
                        return;
                    }
                }

                // open a second file to compare with the first
                file2 = this.OpenFileForInspection();

                // if the user cancels from OpenFileDialog, return to the previous state
                if (string.IsNullOrEmpty(file2))
                {
                    this.CurrentState = previous;
                    return;
                }

                // create a FileData object for the first file, unless one already exists
                if (this.fileData == null)
                {
                    this.eventFile = this.client.OpenEventFile(file1);
                    this.fileData = new FileData(this.eventFile);
                }

                // create a second FileData object for comparison
                eventFile2 = this.client.OpenEventFile(file2);
                FileData fileData2 = new FileData(eventFile2);

                // compare data between files
                CompareFileData compareData = new CompareFileData(this.fileData, fileData2);
                this.ViewCompareFileDataGrid.DataContext = compareData;

                // show comparison data
                this.CurrentState = State.Compare;
            }
            catch (Exception ex)
            {
                this.ErrorMessageText = string.Format(Strings.ErrorCompareFilesFailed, ex.Message);
                this.CurrentState = State.Error;
            }
            finally
            {
                if (eventFile2 != null)
                {
                    eventFile2.Dispose();
                    eventFile2 = null;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Handles the click event for the View File button
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">routed event</param>
        private void ViewFile_Click(object sender, RoutedEventArgs e)
        {
            State previous = this.currentState;
            this.WaitMessageText = Strings.WaitForViewFile;
            this.CurrentState = State.Wait;

            try
            {
                string filePath = this.OpenFileForInspection();

                if (!string.IsNullOrEmpty(filePath))
                {
                    this.eventFile = this.client.OpenEventFile(filePath);
                    this.fileData = new FileData(this.eventFile);
                    this.ViewFileDataGrid.DataContext = this.fileData;

                    // show the data
                    this.CurrentState = State.ViewFile;
                }
                else
                {
                    // user canceled the OpenFileDialog, return to previous state
                    this.CurrentState = previous;
                }
            }
            catch (Exception ex)
            {
                this.ErrorMessageText = string.Format(Strings.ErrorLoadFileFailed, ex.Message);
                this.CurrentState = State.Error;
            }
        }
Example #3
0
        /// <summary>
        /// Handles the click event for the Exit button
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">routed event</param>
        private void CloseFile_Click(object sender, RoutedEventArgs e)
        {
            if (this.eventFile != null)
            {
                this.eventFile.Dispose();
                this.eventFile = null;
            }

            this.fileData = null;
            this.CurrentState = State.Welcome;
        }