Esempio n. 1
0
        /**Form_Shown is used instead of Form_Load, because the form may be closed in case it failed to open the file.
         * But in Form_Load, we will not be able to call the Close() to close the form, since the handle hasn't been created at this step.
         */
        private void StreamParserForm_Shown(object sender, EventArgs e)
        {
            Result result = new Result();

            //Set the file name as the title.
            this.Text = streamFile;

            //Create a file stream reader to read the file.
            fileStreamParser = new WorkerFileRoutineParsing(this, ProcessWorkerMessage);

            //On stream start. Initialize the environment.
            OnStreamStart();

            //Start to parse it. A thread will be created.
            result = fileStreamParser.StartParse(streamFile);//To do normal SI/PSI parsing.

            if (!result.Fine)
            {
                MessageBox.Show("Failed to open the file. Check whether the file exists or it is being occupied by other application.\n", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                //Something is wrong.Close the form directly.
                Close();
            }
            else
            {
                //Create default nodes.
                CreateDefaultNodes();

                //Create SectionParser to parse and show all kinds of sections.
                dataParser = new DataParser(this);
            }
        }
Esempio n. 2
0
        private void stopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (null != fileStreamParser)
            {
                fileStreamParser.StopParse();
                fileStreamParser = null;
            }

            //Clean up all the left messages notifications, except for the last several ones.
            while (messageQueue.Count > 10)
            {
                messageQueue.Dequeue();//Pop out message.
            }
        }