Esempio n. 1
0
        //******************************************************************
        #region [Static ProcessParseFileAndClose() Method]
        //******************************************************************
        /// <summary>
        /// Uses the given transfer rules (oTransferRules) to process the
        /// parse trees in the indicated input file (sInputFileName). The
        /// modified parse trees are written to the indicate output file
        /// (sOutputFileName). A modal dialog displays status information as
        /// the file is processed. The dialog is automatically closed when
        /// the processing is finished. DialogResult.OK is returned if the
        /// process completed successfully. DialogResult.Cancel is returned
        /// if the process was canceled or if an error occurred.
        /// </summary>
        static public DialogResult ProcessParseFileAndClose(
            TransferRuleCollection oTransferRules, string sInputFileName,
            string sOutputFileName)
        {
            //**************************************************************
            // Validate the parameters.

            if (oTransferRules == null)
            {
                string sMessage = "Invalid argument: "
                                  + "TransferForm.ProcessParseFileAndClose() requires "
                                  + "a TransferRules collection that is not null.";
                throw new Exception(sMessage);
            }
            if (oTransferRules.Count == 0)
            {
                string sMessage = "Invalid argument: "
                                  + "TransferForm.ProcessParseFileAndClose() requires "
                                  + "a TransferRules collection that is not empty.";
                throw new Exception(sMessage);
            }
            if ((sInputFileName == null) || (sInputFileName == ""))
            {
                string sMessage = "Invalid argument: "
                                  + "TransferForm.ProcessParseFileAndClose() requires "
                                  + "an input-file name that is not null or blank.";
                throw new Exception(sMessage);
            }
            if ((sOutputFileName == null) || (sOutputFileName == ""))
            {
                string sMessage = "Invalid argument: "
                                  + "TransferForm.ProcessParseFileAndClose() requires "
                                  + "an output-file name that is not null or blank.";
                throw new Exception(sMessage);
            }

            //**************************************************************
            // Create an instance of the form.

            TransferForm oForm = new TransferForm();

            //**************************************************************
            // Set the form's TransferRules, InputFileName, OutputFileName
            // and CloseWhenFinished property values.

            oForm.moTransferRules     = oTransferRules;
            oForm.msInputFileName     = sInputFileName;
            oForm.msOutputFileName    = sOutputFileName;
            oForm.mbCloseWhenFinished = true;

            //**************************************************************
            // Show the form as a modal dialog. The form's Load event starts
            // a timer, and the timer's Tick event handler performs the
            // actual tree-transfer processing.

            DialogResult iResult = oForm.ShowDialog();

            //**************************************************************
            // Return the dialog result when the form is closed.

            oForm.Close();
            return(iResult);
        }
Esempio n. 2
0
        //******************************************************************
        /// <summary>
        /// Uses the given transfer rules (oTransferRules) to process the
        /// parse trees in the indicated input file (sInputFileName). The
        /// modified parse trees are written to the indicate output file
        /// (sOutputFileName). A modal dialog displays status information as
        /// the file is processed. The dialog is automatically closed when
        /// the processing is finished. DialogResult.OK is returned if the
        /// process completed successfully. DialogResult.Cancel is returned
        /// if the process was canceled or if an error occurred.
        /// </summary>
        public static DialogResult ProcessParseFileAndClose(
			TransferRuleCollection oTransferRules,string sInputFileName,
			string sOutputFileName)
        {
            //**************************************************************
            // Validate the parameters.

            if (oTransferRules == null)
            {
                string sMessage = "Invalid argument: "
                    + "TransferForm.ProcessParseFileAndClose() requires "
                    + "a TransferRules collection that is not null.";
                throw new Exception(sMessage);
            }
            if (oTransferRules.Count == 0)
            {
                string sMessage = "Invalid argument: "
                    + "TransferForm.ProcessParseFileAndClose() requires "
                    + "a TransferRules collection that is not empty.";
                throw new Exception(sMessage);
            }
            if ((sInputFileName == null) || (sInputFileName == ""))
            {
                string sMessage = "Invalid argument: "
                    + "TransferForm.ProcessParseFileAndClose() requires "
                    + "an input-file name that is not null or blank.";
                throw new Exception(sMessage);
            }
            if ((sOutputFileName == null) || (sOutputFileName == ""))
            {
                string sMessage = "Invalid argument: "
                    + "TransferForm.ProcessParseFileAndClose() requires "
                    + "an output-file name that is not null or blank.";
                throw new Exception(sMessage);
            }

            //**************************************************************
            // Create an instance of the form.

            TransferForm oForm = new TransferForm();

            //**************************************************************
            // Set the form's TransferRules, InputFileName, OutputFileName
            // and CloseWhenFinished property values.

            oForm.moTransferRules = oTransferRules;
            oForm.msInputFileName = sInputFileName;
            oForm.msOutputFileName = sOutputFileName;
            oForm.mbCloseWhenFinished = true;

            //**************************************************************
            // Show the form as a modal dialog. The form's Load event starts
            // a timer, and the timer's Tick event handler performs the
            // actual tree-transfer processing.

            DialogResult iResult = oForm.ShowDialog();

            //**************************************************************
            // Return the dialog result when the form is closed.

            oForm.Close();
            return iResult;
        }