private void starter_Tick( object sender, EventArgs e )
        {
            // Disable
            starter.Enabled = false;

            // Finsih
            if (null == File)
            {
                // Stop
                Close();

                // Done
                return;
            }

            // Set mode
            m_Loading = true;

            // May stop
            cmdStop.Enabled = true;

            // Reset GUI
            m_ListItems.Clear();
            m_Entries.Clear();

            // Be safe
            try
            {
                // Choose decoding mode
                Section.ISO6937Encoding = ckStandardSI.Checked;

                // The mode
                bool TSMode = (0 == string.Compare( File.Extension, ".ts", true ));

                // Blocksize
                byte[] Buffer = new byte[TSMode ? 10000000 : 100000];

                // Open the file and create parser
                using (FileStream read = new FileStream( File.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, Buffer.Length ))
                using (TSParser parser = new TSParser())
                {
                    // Skip junk
                    if (TSMode) parser.SetFilter( 0x12, true, EPGParser.OnData );

                    // Content
                    for (int n; (n = read.Read( Buffer, 0, Buffer.Length )) > 0; )
                    {
                        // Report progress
                        progress.Value = (int) (read.Position * progress.Maximum / read.Length);

                        // Show up
                        Application.DoEvents();

                        // Done
                        if (!cmdStop.Enabled) break;

                        // Check mode
                        if (TSMode)
                        {
                            // Feed into parser
                            parser.AddPayload( Buffer, 0, n );
                        }
                        else
                        {
                            // SI Table
                            EPGParser.OnData( Buffer, 0, n );
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Report
                MessageBox.Show( this, ex.Message );
            }
            finally
            {
                // Done
                m_Loading = false;
            }

            // Prepare load
            cmdStop.Text = m_LoadText;
            cmdStop.Enabled = true;

            // Load all we found
            lstEntries.Items.Clear();
            lstEntries.Items.AddRange( m_ListItems.ToArray() );

            // Prepare sorter
            lstEntries.ListViewItemSorter = new EPGEntry.Comparer();
        }
Exemple #2
0
        /// <summary>
        /// Überträgt den Dateiinhalt zur Analyse.
        /// </summary>
        /// <param name="target">Die Analyseinstanz, die befüllt werden soll.</param>
        private void ReadFile( TSParser target )
        {
            // Create buffer to read file
            var buffer = new byte[100000];

            // Open the file
            using (var file = new FileStream( Text, FileMode.Open, FileAccess.Read, FileShare.Read, buffer.Length ))
            {
                // Load the file size
                SubItems[1].Text = Math.Round( file.Length / 1024.0 / 1024.0 ).ToString( "N0" );

                // Load
                for (int n; (n = file.Read( buffer, 0, buffer.Length )) > 0; )
                    target.AddPayload( buffer, 0, n );
            }
        }