//--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // c b P D L _ S e l e c t i o n C h a n g e d                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Print Language item has changed.                                   //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void cbPDL_SelectionChanged(object sender,
                                            SelectionChangedEventArgs e)
        {
            if (_initialised)
            {
                pdlOptionsStore();

                _indxPDL = cbPDL.SelectedIndex;
                _crntPDL = (ToolCommonData.ePrintLang)_subsetPDLs[_indxPDL];

                pdlOptionsRestore();

                if (_crntPDL == ToolCommonData.ePrintLang.PCL)
                {
                    lbResolution.Visibility = Visibility.Visible;
                    cbResolution.Visibility = Visibility.Visible;
                    lbPCLNote.Visibility    = Visibility.Visible;
                }
                else
                {
                    lbResolution.Visibility = Visibility.Hidden;
                    cbResolution.Visibility = Visibility.Hidden;
                    lbPCLNote.Visibility    = Visibility.Hidden;
                }
            }
        }
Exemple #2
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a r s e B u f f e r                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Parse provided buffer, assuming that the current print language is //
        // PJL.                                                               //
        //                                                                    //
        //--------------------------------------------------------------------//

        public Boolean parseBuffer(
            Byte []                             buf,
            ref Int32 fileOffset,
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref ToolCommonData.ePrintLang crntPDL,
            ref Boolean endReached,
            PrnParseLinkData linkData,
            PrnParseOptions options,
            DataTable table)
        {
            Boolean seqInvalid;

            //----------------------------------------------------------------//
            //                                                                //
            // Initialise.                                                    //
            //                                                                //
            //----------------------------------------------------------------//

            _buf        = buf;
            _linkData   = linkData;
            _options    = options;
            _table      = table;
            _fileOffset = fileOffset;

            _analysisLevel = _linkData.AnalysisLevel;

            seqInvalid = false;

            //----------------------------------------------------------------//

            _indxOffsetFormat = _options.IndxGenOffsetFormat;

            _options.getOptCharSet(ref _indxCharSetName,
                                   ref _indxCharSetSubAct,
                                   ref _valCharSetSubCode);

            _endOffset = _options.ValCurFOffsetEnd;

            _showPML = _options.FlagPMLWithinPJL;

            //----------------------------------------------------------------//

            if (linkData.isContinuation())
            {
                seqInvalid = parseContinuation(ref bufRem,
                                               ref bufOffset,
                                               ref crntPDL,
                                               ref endReached);
            }
            else
            {
                seqInvalid = parseSequences(ref bufRem,
                                            ref bufOffset,
                                            ref crntPDL,
                                            ref endReached);
            }

            return(seqInvalid);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // s e t F l a g U n i c o d e F o r m A s M a c r o                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Set or unset 'Render fixed text as overlay' flag.                  //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void setFlagUnicodeFormAsMacro(
            Boolean setFlag,
            ToolCommonData.ePrintLang crntPDL)
        {
            if (crntPDL == ToolCommonData.ePrintLang.PCL)
            {
                if (setFlag)
                {
                    _flagUnicodeFormAsMacroPCL = true;
                }
                else
                {
                    _flagUnicodeFormAsMacroPCL = false;
                }
            }
            else if (crntPDL == ToolCommonData.ePrintLang.PCLXL)
            {
                if (setFlag)
                {
                    _flagUnicodeFormAsMacroPCLXL = true;
                }
                else
                {
                    _flagUnicodeFormAsMacroPCLXL = false;
                }
            }
        }
        //--------------------------------------------------------------------//
        //                                              C o n s t r u c t o r //
        // T o o l P a t t e r n G e n e r a t e                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        public ToolPatternGenerate(ref ToolCommonData.ePrintLang crntPDL)
        {
            InitializeComponent();

            initialise();

            crntPDL = _crntPDL;
        }
        //--------------------------------------------------------------------//
        //                                              C o n s t r u c t o r //
        // T o o l I m a g e B i t m a p                                      //
        //                                                                    //
        //--------------------------------------------------------------------//

        public ToolImageBitmap(ref ToolCommonData.ePrintLang crntPDL)
        {
            InitializeComponent();

            initialise();

            crntPDL = _crntPDL;
        }
        //--------------------------------------------------------------------//
        //                                              C o n s t r u c t o r //
        // T o o l M a k e O v e r l a y                                      //
        //                                                                    //
        //--------------------------------------------------------------------//

        public ToolMakeOverlay(ref ToolCommonData.ePrintLang crntPDL)
        {
            InitializeComponent();

            initialise();

            crntPDL = _crntPDL;
        }
Exemple #7
0
        //--------------------------------------------------------------------//
        //                                              C o n s t r u c t o r //
        // T o o l P R N P r i n t                                            //
        //                                                                    //
        //--------------------------------------------------------------------//

        public ToolPrnPrint(ref ToolCommonData.ePrintLang crntPDL)
        {
            InitializeComponent();

            initialise();

            crntPDL = ToolCommonData.ePrintLang.Unknown;
        }
Exemple #8
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a r s e C o n t i n u a t i o n                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Handle continuation situation signalled on last pass.              //
        //                                                                    //
        //--------------------------------------------------------------------//

        private Boolean parseContinuation(
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref ToolCommonData.ePrintLang crntPDL,
            ref Boolean endReached)
        {
            PrnParseConstants.eContType contType;

            contType = PrnParseConstants.eContType.None;

            Int32 prefixLen   = 0,
                  contDataLen = 0,
                  downloadRem = 0;

            Boolean backTrack = false;

            Boolean invalidSeqFound = false;

            Byte prefixA = 0x00,
                 prefixB = 0x00;

            _linkData.getContData(ref contType,
                                  ref prefixLen,
                                  ref contDataLen,
                                  ref downloadRem,
                                  ref backTrack,
                                  ref prefixA,
                                  ref prefixB);

            if ((contType == PrnParseConstants.eContType.PJL)
                ||
                (contType == PrnParseConstants.eContType.Special)
                ||
                (contType == PrnParseConstants.eContType.Unknown)
                ||
                (contType == PrnParseConstants.eContType.Reset))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Previous 'block' ended with a partial match of a PJL       //
                // sequence, or with insufficient characters to identify      //
                // the type of sequence.                                      //
                // The continuation action has already reset the buffer, so   //
                // now unset the markers.                                     //
                //                                                            //
                //------------------------------------------------------------//

                _linkData.resetContData();
            }

            if ((_endOffset != -1) && ((_fileOffset + bufOffset) > _endOffset))
            {
                endReached = true;
            }

            return(invalidSeqFound);
        }
Exemple #9
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // m e t r i c s R e t u r n F i l e C a p t                          //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Load and return current target File capture metrics data.          //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void metricsReturnFileCapt(
            ToolCommonData.eToolIds crntToolId,
            ToolCommonData.eToolSubIds crntToolSubId,
            ToolCommonData.ePrintLang crntPDL,
            ref String saveFilename)
        {
            metricsLoadFileCapt(crntToolId, crntToolSubId, crntPDL);

            saveFilename = _saveFilename;
        }
        //--------------------------------------------------------------------//
        //                                              C o n s t r u c t o r //
        // T a r g e t F i l e                                                //
        //                                                                    //
        //--------------------------------------------------------------------//

        public TargetFile(ToolCommonData.eToolIds crntToolId,
                          ToolCommonData.eToolSubIds crntSubId,
                          ToolCommonData.ePrintLang crntPDL)
        {
            InitializeComponent();

            _crntToolId = crntToolId;
            _crntSubId  = crntSubId;
            _crntPDL    = crntPDL;

            initialise();
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // l o a d D a t a C a p t u r e                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Retrieve stored Prn Print capture file data.                       //
        // The 'current PDL' parameter is not relevant and is ignored.        //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void loadDataCapture(ToolCommonData.ePrintLang crntPDL,
                                           ref String captureFile)
        {
            RegistryKey keyMain =
                Registry.CurrentUser.CreateSubKey(_mainKey);

            String key = _subKeyTools + "\\" + _subKeyToolsPrnPrint;

            String defWorkFolder = ToolCommonData.DefWorkFolder;

            using (RegistryKey subKey = keyMain.CreateSubKey(key))
            {
                captureFile = (String)subKey.GetValue(_nameCaptureFile,
                                                      defWorkFolder + "\\" +
                                                      _defaultCaptureFile);
            }
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // s a v e D a t a C a p t u r e                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Store current Prn Print capture file data.                         //
        // The 'current PDL' parameter is not relevant and is ignored.        //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void saveDataCapture(ToolCommonData.ePrintLang crntPDL,
                                           String captureFile)
        {
            RegistryKey keyMain =
                Registry.CurrentUser.CreateSubKey(_mainKey);

            String key = _subKeyTools + "\\" + _subKeyToolsPrnPrint;

            using (RegistryKey subKey = keyMain.CreateSubKey(key))
            {
                if (captureFile != null)
                {
                    subKey.SetValue(_nameCaptureFile,
                                    captureFile,
                                    RegistryValueKind.String);
                }
            }
        }
Exemple #13
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // s a v e D a t a C a p t u r e                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Store current Status Readback capture file data.                   //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void saveDataCapture(ToolCommonData.ePrintLang crntPDL,
                                           String captureFile)
        {
            RegistryKey keyMain =
                Registry.CurrentUser.CreateSubKey(_mainKey);

            if (crntPDL == ToolCommonData.ePrintLang.PCL)
            {
                String key = _subKeyTools + "\\" + _subKeyToolsStatusReadback +
                             "\\" + _subKeyPCL;

                using (RegistryKey subKey = keyMain.CreateSubKey(key))
                {
                    if (captureFile != null)
                    {
                        subKey.SetValue(_nameCaptureFile,
                                        captureFile,
                                        RegistryValueKind.String);
                    }
                }
            }
            else if (crntPDL == ToolCommonData.ePrintLang.PJL)
            {
                String key = _subKeyTools + "\\" + _subKeyToolsStatusReadback +
                             "\\" + _subKeyPJL;

                using (RegistryKey subKey = keyMain.CreateSubKey(key))
                {
                    if (captureFile != null)
                    {
                        subKey.SetValue(_nameCaptureFile,
                                        captureFile,
                                        RegistryValueKind.String);
                    }
                }
            }
        }
Exemple #14
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a r s e S e q u e n c e s                                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Process sequences until end-point reached.                         //
        //                                                                    //
        //--------------------------------------------------------------------//

        private Boolean parseSequences(
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref ToolCommonData.ePrintLang crntPDL,
            ref Boolean endReached)
        {
            Int64 startPos;

            PrnParseConstants.eContType contType =
                PrnParseConstants.eContType.None;

            Boolean continuation    = false;
            Boolean langSwitch      = false;
            Boolean badSeq          = false;
            Boolean invalidSeqFound = false;
            Boolean dummyBool       = false;

            continuation = false;
            startPos     = _fileOffset + bufOffset;

            while (!continuation && !langSwitch &&
                   !endReached && (bufRem > 0))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Process data until language-switch or end of buffer, or    //
                // specified end point.                                       //
                //                                                            //
                //------------------------------------------------------------//

                if ((_endOffset != -1) &&
                    ((_fileOffset + bufOffset) > _endOffset))
                {
                    endReached = true;
                }
                else if (_buf[bufOffset] == PrnParseConstants.asciiEsc)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Escape character found.                                //
                    // Switch to PCL language processing.                     //
                    //                                                        //
                    // Note that, in theory, only a few escape sequences are  //
                    // expected:                                              //
                    //      <Esc>E          Printer Reset                     //
                    //      <Esc>%-12345X   Universal Exit Language           //
                    // but if we find an escape sequence, it's certainly not  //
                    // PJL.                                                   //
                    //                                                        //
                    //--------------------------------------------------------//

                    langSwitch = true;

                    crntPDL = ToolCommonData.ePrintLang.PCL;
                }
                else if (_buf[bufOffset] != PrnParseConstants.asciiAtSign)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Next character is NOT an @ symbol, so it can't be a    //
                    // PJL command.                                           //
                    // Switch to PCL language processing.                     //
                    //                                                        //
                    //--------------------------------------------------------//

                    langSwitch = true;

                    crntPDL = ToolCommonData.ePrintLang.PCL;
                }
                else
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Sequence does not start with an Escape character, so   //
                    // it should be a PJL command.                            //
                    // PJL commands should start with @PJL and end with a     //
                    // LineFeed (0x0a) character.                             //
                    //                                                        //
                    //--------------------------------------------------------//

                    if (bufRem < 5)
                    {
                        //----------------------------------------------------//
                        //                                                    //
                        // Insufficient characters remain in buffer to        //
                        // identify the sequence as PJL, so initiate a        //
                        // continuation action.                               //
                        //                                                    //
                        //----------------------------------------------------//

                        continuation = true;

                        contType = PrnParseConstants.eContType.PJL;

                        _linkData.setBacktrack(contType, -bufRem);
                    }
                    else if (_ascii.GetString(_buf, bufOffset, _lenPJLIntro)
                             != "@PJL")
                    {
                        //----------------------------------------------------//
                        //                                                    //
                        // Not a PJL sequence.                                //
                        // Display the unexpected sequence up to the next     //
                        // Escape character.                                  //
                        //                                                    //
                        //----------------------------------------------------//

                        invalidSeqFound = true;

                        PrnParseCommon.addTextRow(
                            PrnParseRowTypes.eType.MsgWarning,
                            _table,
                            PrnParseConstants.eOvlShow.None,
                            "",
                            "*** Warning ***",
                            "",
                            "Unexpected sequence found");

                        PrnParseData.processLines(
                            _table,
                            PrnParseConstants.eOvlShow.None,
                            _linkData,
                            ToolCommonData.ePrintLang.PJL,
                            _buf,
                            _fileOffset,
                            bufRem,
                            ref bufRem,
                            ref bufOffset,
                            ref dummyBool,
                            true,
                            true,
                            false,
                            PrnParseConstants.asciiEsc,
                            "Data",
                            0,
                            _indxCharSetSubAct,
                            (Byte)_valCharSetSubCode,
                            _indxCharSetName,
                            _indxOffsetFormat,
                            _analysisLevel);
                    }
                    else
                    {
                        //-------------------------------------------------------------//
                        //                                                             //
                        // PJL sequence detected.                                      //
                        //                                                             //
                        //-------------------------------------------------------------//

                        badSeq = processPJLCommand(ref bufRem,
                                                   ref bufOffset,
                                                   ref continuation,
                                                   ref langSwitch,
                                                   ref crntPDL);

                        if (badSeq)
                        {
                            invalidSeqFound = true;
                        }
                    }
                }
            }

            _linkData.MakeOvlAct       = PrnParseConstants.eOvlAct.Remove;
            _linkData.MakeOvlSkipBegin = startPos;
            _linkData.MakeOvlSkipEnd   = _fileOffset + bufOffset;

            return(invalidSeqFound);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // b t n S c a n _ C l i c k                                          //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Called when the 'Scan' button is clicked.                          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void btnScan_Click(object sender, RoutedEventArgs e)
        {
            Boolean validPDL = false;

            Int32 ptr;

            ToolCommonData.ePrintLang scanPDL;

            PrnParse parseFile = new PrnParse(PrnParse.eParseType.ScanForPDL,
                                              0);

            _tableProgress.Clear();

            scanPDL = ToolCommonData.ePrintLang.Unknown;

            parseFile.makeOverlayScan(_prnFilename,
                                      _options,
                                      ref scanPDL);

            ptr = _prnFilename.LastIndexOf(".");

            if (ptr <= 0)
            {
                ptr = _prnFilename.Length;
            }

            if ((scanPDL == ToolCommonData.ePrintLang.PCL)
                ||
                (scanPDL == ToolCommonData.ePrintLang.HPGL2))
            {
                validPDL = true;
                _crntPDL = ToolCommonData.ePrintLang.PCL;

                tabPCL.IsEnabled  = true;
                tabPCL.IsSelected = true;

                tabPCLXL.IsEnabled = false;

                _ovlFilenamePCL = _prnFilename.Substring(0, ptr) + ".ovl";

                txtPCLOvlFilename.Text = _ovlFilenamePCL;
            }
            else if ((scanPDL == ToolCommonData.ePrintLang.PCLXL)
                     ||
                     (scanPDL == ToolCommonData.ePrintLang.XL2HB))
            {
                validPDL = true;
                _crntPDL = ToolCommonData.ePrintLang.PCLXL;

                tabPCLXL.IsEnabled  = true;
                tabPCLXL.IsSelected = true;

                tabPCL.IsEnabled = false;

                _ovlFilenamePCLXL = _prnFilename.Substring(0, ptr) + ".ovx";

                txtPCLXLOvlFilename.Text = _ovlFilenamePCLXL;
            }

            if (validPDL)
            {
                grpOverlay.Visibility  = Visibility.Visible;
                btnGenerate.Visibility = Visibility.Visible;
            }
            else
            {
                MessageBox.Show("Source print file appears to be a '" +
                                scanPDL.ToString() +
                                "' printfile.\n\n" +
                                "This tool does not support the generation of an " +
                                "overlay from such a print file.",
                                "Page Description Language not supported",
                                MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
        }
Exemple #16
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g i v e C r n t P D L                                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        public void giveCrntPDL(ref ToolCommonData.ePrintLang crntPDL)
        {
            crntPDL = ToolCommonData.ePrintLang.Unknown;
        }
Exemple #17
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p r o c e s s P J L C o m m a n d                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Process current PJL command in buffer.                             //
        // Command format is one of:                                          //
        //                                                                    //
        //    @PJL [<CR>]<LF>                                                 //
        //                                                                    //
        //    Can be used to separate real commands, and add clarity to long  //
        //    sets of commands.                                               //
        //                                                                    //
        //    @PJL command [<words>] [<CR>}<LF>                               //
        //                                                                    //
        //    For the COMMENT and ECHO commands only.                         //
        //    <words>               Any string of printable characters        //
        //                          (range 0x21-0xff) or whitespace           //
        //                          (space (0x20) or horizontal tab (0x09)),  //
        //                          starting with a printable character.      //
        //                          The string may be enclosed in quote       //
        //                          characters (0x22), in which case it       //
        //                          cannot include a quote character.         //
        //                                                                    //
        //    @PJL command [modifier : value] [option [= value]] [<CR>}<LF>   //
        //                                                                    //
        //    command               One of the defined set of command names.  //
        //    modifier:value        is present for some commands to indicate  //
        //                          particular personality, or port, etc.     //
        //    option                Present for most commands.                //
        //    value                 Associated with 'option' name or (if      //
        //                          that is not present, the command).        //
        //                          There may be more than one option=value   //
        //                          pair.                                     //
        //                                                                    //
        // Whitespace (space or horizontal tab) characters MUST be present    //
        // between the @PJL introducer and the 'command', and between the     //
        // command and modifier names, and between the modifier value and the //
        // option name.                                                       //
        //                                                                    //
        // Interrupt process if an <Esc> character is encountered.            //
        // Long lines are split into shorter slices.                          //
        //                                                                    //
        //--------------------------------------------------------------------//

        private Boolean processPJLCommand(
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref Boolean continuation,
            ref Boolean langSwitch,
            ref ToolCommonData.ePrintLang crntPDL)
        {
            PrnParseConstants.eContType contType =
                PrnParseConstants.eContType.None;

            Byte crntByte;

            Char crntChar,
                 normChar;

            Int32 len,
                  cmdLen,
                  cmdRem,
                  langLen,
                  offset,
                  lineStart,
                  seqLen = 0;

            Int32 quoteStart = 0,
                  quoteEnd   = 0;

            Boolean invalidSeqFound,
                    endLoop,
                    foundTerm,
                    firstLine;

            Boolean foundStartQuote;
            Boolean seqKnown     = false;
            Boolean noWhitespace = false;

            String lang,
                   commandName,
                   commandParams,
                   line,
                   showChar,
                   desc = "";

            StringBuilder seq = new StringBuilder();

            StringBuilder cmd = new StringBuilder();

            StringBuilder cmdPart1 = new StringBuilder();
            StringBuilder cmdPart2 = new StringBuilder();

            cmdPart1.Append("@PJL");

            invalidSeqFound = false;
            foundStartQuote = false;
            foundTerm       = false;
            firstLine       = true;
            langSwitch      = false;

            lineStart = bufOffset;
            foundTerm = false;

            len    = bufRem;
            offset = bufOffset;

            continuation = false;
            foundTerm    = false;

            cmdRem = bufRem - _lenPJLIntro;
            offset = bufOffset + _lenPJLIntro;
            cmdLen = _lenPJLIntro;

            //----------------------------------------------------------------//
            //                                                                //
            // Search for termination character.                              //
            // This should be a LineFeed (<LF>, 0x0a) character, but may be   //
            // an Escape character (<Esc>, 0x1b) signalling return to PCL.    //
            //                                                                //
            // This is to make sure that the termination character is in the  //
            // buffer before processing the command, so that we don't have to //
            // cater for doing a 'continuation' read part way through         //
            // processing the command.                                        //
            //                                                                //
            // Initiate continuation action if terminator is not found in     //
            // buffer, subject to a maximum command length (to prevent        //
            // recursive continuation actions).                               //
            //                                                                //
            //----------------------------------------------------------------//

            while ((!foundTerm) && (cmdRem > 0) && (cmdLen < _maxPJLCmdLen))
            {
                crntByte = _buf[offset];

                if (crntByte == PrnParseConstants.asciiLF)
                {
                    foundTerm = true;
                    offset++;
                    cmdLen++;
                    cmdRem--;
                }
                else if (crntByte == PrnParseConstants.asciiEsc)
                {
                    foundTerm = true;
                }
                else
                {
                    offset++;
                    cmdLen++;
                    cmdRem--;
                }
            }

            if ((!foundTerm) && (cmdLen != _maxPJLCmdLen))              // ***** Should this be < rather than != ? ***** //
            {
                //------------------------------------------------------------//
                //                                                            //
                // Termination character not found before buffer exhausted,   //
                // or maximum command length exceeded.                        //
                // Initiate (backtracking) continuation action.               //
                //                                                            //
                //------------------------------------------------------------//

                continuation = true;

                contType = PrnParseConstants.eContType.PJL;

                _linkData.setBacktrack(contType, -bufRem);
            }
            else
            {
                //------------------------------------------------------------//
                //                                                            //
                // Process command.                                           //
                // At this point, we have in the buffer one of:               //
                //  - characters terminated by <LF> (counted in length).      //
                //  - characters terminated by <Esc> (not counted in length). //
                //  - characters not terminated, but maxmimum length.         //
                //                                                            //
                //------------------------------------------------------------//

                cmdRem = cmdLen - _lenPJLIntro;
                offset = bufOffset + _lenPJLIntro;

                //------------------------------------------------------------//
                //                                                            //
                // Stage 1: look for & skip past whitespace.                  //
                //                                                            //
                //------------------------------------------------------------//

                endLoop = false;

                while ((!endLoop) && (cmdRem > 0))
                {
                    crntByte = _buf[offset];

                    if ((crntByte == PrnParseConstants.asciiSpace)
                        ||
                        (crntByte == PrnParseConstants.asciiHT))
                    {
                        showChar = PrnParseData.processByte(
                            crntByte,
                            _indxCharSetSubAct,
                            (Byte)_valCharSetSubCode,
                            _indxCharSetName);

                        cmdPart1.Append(showChar);

                        offset++;
                        cmdRem--;
                    }
                    else
                    {
                        endLoop = true;
                    }
                }

                //------------------------------------------------------------//
                //                                                            //
                // Stage 2: look for command name.                            //
                //                                                            //
                //------------------------------------------------------------//

                endLoop = false;

                while ((!endLoop) && (cmdRem > 0))
                {
                    crntByte = _buf[offset];

                    //--------------------------------------------------------//
                    //                                                        //
                    // Check for special characters first.                    //
                    //                                                        //
                    //--------------------------------------------------------//

                    if ((crntByte == PrnParseConstants.asciiSpace)
                        ||
                        (crntByte == PrnParseConstants.asciiHT))
                    {
                        // nextstage = Whitespace;
                        endLoop = true;
                    }
                    else if ((cmdRem == 2) &&
                             (crntByte == PrnParseConstants.asciiCR))

                    {
                        // nextstage = Terminator;
                        endLoop = true;
                    }
                    else if ((cmdRem == 1) &&
                             (crntByte == PrnParseConstants.asciiLF))

                    {
                        // nextstage = Terminator;
                        endLoop = true;
                    }
                    else if (crntByte == PrnParseConstants.asciiEquals)

                    {
                        // nextstage = Part2;
                        endLoop      = true;
                        noWhitespace = true;
                    }
                    else
                    {
                        crntChar = (Char)crntByte;
                        normChar = Char.ToUpper(crntChar);
                        cmd.Append(normChar);

                        showChar = PrnParseData.processByte(
                            crntByte,
                            _indxCharSetSubAct,
                            (Byte)_valCharSetSubCode,
                            _indxCharSetName);

                        cmdPart1.Append(showChar);

                        offset++;
                        cmdRem--;
                    }
                }

                //------------------------------------------------------------//
                //                                                            //
                // Check whether command name known.                          //
                //                                                            //
                //------------------------------------------------------------//

                commandName = cmd.ToString();

                if (commandName == "")
                {
                    seqKnown = PJLCommands.checkCmd(PJLCommands.nullCmdKey,
                                                    ref desc,
                                                    _analysisLevel);
                }
                else
                {
                    seqKnown = PJLCommands.checkCmd(cmd.ToString(),
                                                    ref desc,
                                                    _analysisLevel);
                }

                //------------------------------------------------------------//
                //                                                            //
                // Stage 3: look for command remainder.                       //
                //          TODO : split this up into component parts?        //
                //                                                            //
                //------------------------------------------------------------//

                endLoop = false;

                while ((!endLoop) && (cmdRem > 0))
                {
                    crntByte = _buf[offset];

                    if (crntByte == PrnParseConstants.asciiQuote)
                    {
                        if (!foundStartQuote)
                        {
                            foundStartQuote = true;
                            quoteStart      = offset;
                        }
                        else
                        {
                            quoteEnd = offset;
                        }
                    }

                    crntChar = (Char)crntByte;
                    normChar = Char.ToUpper(crntChar);

                    showChar = PrnParseData.processByte(
                        crntByte,
                        _indxCharSetSubAct,
                        (Byte)_valCharSetSubCode,
                        _indxCharSetName);

                    cmdPart2.Append(showChar);

                    if ((crntByte == PrnParseConstants.asciiSpace)
                        ||
                        (crntByte == PrnParseConstants.asciiHT))
                    {
                    }
                    else if ((crntByte == PrnParseConstants.asciiDEL)
                             ||
                             (crntByte < PrnParseConstants.asciiSpace))
                    {
                        seq.Append((Char)PrnParseConstants.asciiPeriod);
                    }
                    else
                    {
                        seq.Append(normChar);
                    }

                    offset++;
                    cmdRem--;
                }

                //--------------------------------------------------------//
                //                                                        //
                // Stage 4: Output details of sequence.                   //
                //                                                        //
                //--------------------------------------------------------//

                commandParams = cmdPart2.ToString();

                len       = commandParams.Length;
                lineStart = 0;

                while ((firstLine) || (len > 0))
                {
                    if (len > _maxPJLLineLen)
                    {
                        line = commandParams.Substring(lineStart,
                                                       _maxPJLLineLen);
                        len       -= _maxPJLLineLen;
                        lineStart += _maxPJLLineLen;
                    }
                    else
                    {
                        line = commandParams.Substring(lineStart,
                                                       len);
                        len = 0;
                    }

                    if (firstLine)
                    {
                        firstLine = false;

                        if (!seqKnown)
                        {
                            PrnParseCommon.addTextRow(
                                PrnParseRowTypes.eType.MsgWarning,
                                _table,
                                PrnParseConstants.eOvlShow.None,
                                "",
                                "*** Warning ***",
                                "",
                                "Following PJL commmand name not recognised:");
                        }

                        if (noWhitespace)
                        {
                            PrnParseCommon.addTextRow(
                                PrnParseRowTypes.eType.MsgWarning,
                                _table,
                                PrnParseConstants.eOvlShow.None,
                                "",
                                "*** Warning ***",
                                "",
                                "Following PJL command name not terminated" +
                                " by space or tab character:");
                        }

                        PrnParseCommon.addDataRow(
                            PrnParseRowTypes.eType.PJLCommand,
                            _table,
                            PrnParseConstants.eOvlShow.Remove,
                            _indxOffsetFormat,
                            _fileOffset + bufOffset,
                            _analysisLevel,
                            "PJL Command",
                            cmdPart1.ToString(),
                            line);
                    }
                    else
                    {
                        PrnParseCommon.addTextRow(
                            PrnParseRowTypes.eType.PJLCommand,
                            _table,
                            PrnParseConstants.eOvlShow.Remove,
                            "",
                            "",
                            "",
                            line);
                    }
                }

                //--------------------------------------------------------//
                //                                                        //
                // Stage 5: Do any special processing.                    //
                //                                                        //
                //--------------------------------------------------------//

                commandParams = seq.ToString();

                if ((commandName.Length == 5)
                    &&
                    (commandName.Substring(0, 5) == "ENTER")
                    &&
                    (commandParams.Length > 9)
                    &&
                    (commandParams.Substring(0, 9) == "LANGUAGE="))
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Enter Language command encountered.                    //
                    //                                                        //
                    //--------------------------------------------------------//

                    langSwitch = true;

                    seqLen = seq.Length;

                    lang = commandParams.Substring(9, seqLen - 9);

                    langLen = lang.Length;

                    if ((langLen >= 5) &&
                        (lang.Substring(0, 5) == "PCLXL"))
                    {
                        crntPDL = ToolCommonData.ePrintLang.PCLXL;
                    }
                    else if ((langLen >= 7) &&
                             (lang.Substring(0, 7) == "PCL3GUI"))
                    {
                        crntPDL = ToolCommonData.ePrintLang.PCL3GUI;
                    }
                    else if ((langLen >= 3) &&
                             (lang.Substring(0, 3) == "PCL"))
                    {
                        crntPDL = ToolCommonData.ePrintLang.PCL;
                    }
                    else if ((langLen >= 10) &&
                             (lang.Substring(0, 10) == "POSTSCRIPT"))
                    {
                        crntPDL = ToolCommonData.ePrintLang.PostScript;
                    }
                    else if ((langLen >= 4) &&
                             (lang.Substring(0, 4) == "HPGL"))
                    {
                        crntPDL = ToolCommonData.ePrintLang.HPGL2;
                    }
                    else if ((langLen >= 5) &&
                             (lang.Substring(0, 5) == "XL2HB"))
                    {
                        crntPDL = ToolCommonData.ePrintLang.XL2HB;
                    }
                    else
                    {
                        crntPDL = ToolCommonData.ePrintLang.Unknown;
                    }
                }
                else if ((_showPML) &&
                         (((commandName.Length == 5)
                           &&
                           (commandName.Substring(0, 5) == "DMCMD"))
                          ||
                          ((commandName.Length == 6)
                           &&
                           (commandName.Substring(0, 6) == "DMINFO"))))
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // PML Device Management                                  //
                    //                                                        //
                    //--------------------------------------------------------//

                    if ((commandParams.Length > 9)
                        &&
                        (commandParams.Substring(0, 9) == "ASCIIHEX="))
                    {
                        //----------------------------------------------------//
                        //                                                    //
                        // PML sequence; encoded as ASCII HEX.                //
                        // Expected to be enclosed in " quotes and followed   //
                        // by <CR><LF> or <LF> PJL terminator characters.     //
                        // Note that the normalised sequence will have "."    //
                        // characters in place of the <CR> and <LF> control   //
                        // codes.                                             //
                        //                                                    //
                        //----------------------------------------------------//

                        PrnParsePML parsePML = new PrnParsePML();

                        seqLen = quoteEnd - quoteStart - 1;

                        if (seqLen > 0)
                        {
                            invalidSeqFound =
                                parsePML.processPMLASCIIHex(_buf,
                                                            _fileOffset,
                                                            seqLen,
                                                            quoteStart + 1,
                                                            _linkData,
                                                            _options,
                                                            _table);
                        }
                    }
                }

                bufOffset = offset;
                bufRem   -= cmdLen;
            }

            return(invalidSeqFound);
        }
Exemple #18
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // m e t r i c s S a v e F i l e C a p t                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Store current target File capture metrics data.                    //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void metricsSaveFileCapt(
            ToolCommonData.eToolIds crntToolId,
            ToolCommonData.eToolSubIds crntToolSubId,
            ToolCommonData.ePrintLang crntPDL,
            String saveFilename)
        {
            _targetType = eTarget.File;

            _saveFilename = saveFilename;

            TargetPersist.saveDataCommon((Int32)_targetType);

            //----------------------------------------------------------------//

            if (crntToolId == ToolCommonData.eToolIds.FontSample)
            {
                ToolFontSamplePersist.saveDataCapture(crntPDL,
                                                      saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.FormSample)
            {
                ToolFormSamplePersist.saveDataCapture(crntPDL,
                                                      saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.ImageBitmap)
            {
                ToolImageBitmapPersist.saveDataCapture(crntPDL,
                                                       saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.PrintArea)
            {
                ToolPrintAreaPersist.saveDataCapture(crntPDL,
                                                     saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.PrnPrint)
            {
                ToolPrnPrintPersist.saveDataCapture(crntPDL,
                                                    saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.StatusReadback)
            {
                ToolStatusReadbackPersist.saveDataCapture(crntPDL,
                                                          saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.TrayMap)
            {
                ToolTrayMapPersist.saveDataCapture(crntPDL,
                                                   saveFilename);
            }

            //----------------------------------------------------------------//

            else if (crntToolId == ToolCommonData.eToolIds.MiscSamples)
            {
                ToolMiscSamplesPersist.saveDataCapture(crntToolSubId,
                                                       crntPDL,
                                                       saveFilename);
            }

            //----------------------------------------------------------------//

            //  else
            //     Tool MakeOverlay // ***** Do DUMMY procs ? ***** //
            //     Tool PrintLang
            //     Tool PrnAnalyse
            //     Tool SoftFontGen
            //     Tool SymbolSetGen
            //     Tool XXXDiags
        }
Exemple #19
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // r e q u e s t S t r e a m O p e n                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Open target stream for print job / request.                        //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void requestStreamOpen(
            ref BinaryWriter binWriter,
            ToolCommonData.eToolIds crntToolId,
            ToolCommonData.eToolSubIds crntToolSubId,
            ToolCommonData.ePrintLang crntPDL)
        {
            //----------------------------------------------------------------//
            //                                                                //
            // Create output file.                                            //
            //                                                                //
            //----------------------------------------------------------------//

            if (_targetType == eTarget.File)
            {
                //------------------------------------------------------------//
                //                                                            //
                // Invoke 'Save As' dialogue.                                 //
                //                                                            //
                //------------------------------------------------------------//

                SaveFileDialog saveDialog;

                Int32 ptr,
                      len;

                String saveDirectory;

                ptr = _saveFilename.LastIndexOf("\\");

                if (ptr <= 0)
                {
                    saveDirectory = "";
                    _crntFilename = _saveFilename;
                }
                else
                {
                    len = _saveFilename.Length;

                    saveDirectory = _saveFilename.Substring(0, ptr);
                    _crntFilename = _saveFilename.Substring(ptr + 1,
                                                            len - ptr - 1);
                }

                saveDialog = new SaveFileDialog();

                saveDialog.Filter           = "Print Files | *.prn";
                saveDialog.DefaultExt       = "prn";
                saveDialog.RestoreDirectory = true;
                saveDialog.InitialDirectory = saveDirectory;
                saveDialog.OverwritePrompt  = true;
                saveDialog.FileName         = _crntFilename;

                Nullable <Boolean> dialogResult = saveDialog.ShowDialog();

                if (dialogResult == true)
                {
                    _saveFilename = saveDialog.FileName;
                    _crntFilename = _saveFilename;

                    metricsSaveFileCapt(crntToolId, crntToolSubId, crntPDL,
                                        _saveFilename);
                }
            }
            else
            {
                //------------------------------------------------------------//
                //                                                            //
                // The print file is created in the folder associated with    //
                // the TMP environment variable.                              //
                //                                                            //
                //------------------------------------------------------------//

                _crntFilename = Environment.GetEnvironmentVariable("TMP") +
                                "\\" +
                                DateTime.Now.ToString("yyyyMMdd_HHmmss_fff") +
                                ".dia";
            }

            try
            {
                _opStream = File.Create(_crntFilename);
            }

            catch (IOException e)
            {
                MessageBox.Show("IO Exception:\r\n" +
                                e.Message + "\r\n" +
                                "Creating file '" + _crntFilename,
                                "Target file",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }

            if (_opStream != null)
            {
                _binWriter = new BinaryWriter(_opStream);
                binWriter  = _binWriter;
            }
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // b t n G e n e r a t e _ C l i c k                                  //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Called when the 'Generate' button is clicked.                      //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void btnGenerate_Click(object sender, RoutedEventArgs e)
        {
            Int32 result = 0;

            Boolean bitmapOpen = false;

            //----------------------------------------------------------------//
            //                                                                //
            // Get current test metrics.                                      //
            // Note that the relevant (PDL-specific) stored option values     //
            // SHOULD already be up-to-date, since the fields all have        //
            // associated 'OnChange' actions. ***** Not with WPF ????? *****  //
            // But we'll save them all anyway, to make sure.                  //
            //                                                                //
            //----------------------------------------------------------------//

            _indxPDL = cbPDL.SelectedIndex;
            _crntPDL = (ToolCommonData.ePrintLang)_subsetPDLs[_indxPDL];

            pdlOptionsStore();

            //----------------------------------------------------------------//
            //                                                                //
            // Generate test print file.                                      //
            //                                                                //
            //----------------------------------------------------------------//

            bitmapOpen = ToolImageBitmapCore.bitmapOpen(_bitmapFilename);

            if (!bitmapOpen)
            {
                result = -1;
            }

            if (result == 0)
            {
                result = ToolImageBitmapCore.readBmpFileHeader();
            }

            if (result == 0)
            {
                result = ToolImageBitmapCore.readBmpInfoHeader();
            }

            if (result == 0)
            {
                result = ToolImageBitmapCore.readBmpPalette();
            }

            if (result == 0)
            {
                BinaryWriter binWriter = null;

                TargetCore.requestStreamOpen(
                    ref binWriter,
                    ToolCommonData.eToolIds.ImageBitmap,
                    ToolCommonData.eToolSubIds.None,
                    _crntPDL);

                if (result == 0)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Write test data to output file.                        //
                    //                                                        //
                    //--------------------------------------------------------//

                    if (_crntPDL == ToolCommonData.ePrintLang.PCL)
                    {
                        ToolImageBitmapPCL.generateJob(
                            binWriter,
                            _subsetPaperSizes[_indxPaperSizePCL],
                            _subsetPaperTypes[_indxPaperTypePCL],
                            _subsetOrientations[_indxOrientationPCL],
                            _destPosX,
                            _destPosY,
                            _destScalePercentX,
                            _destScalePercentY,
                            _indxRasterResolutionPCL);
                    }
                    else    // if (_crntPDL == (Int32)ToolCommonData.ePrintLang.PCLXL)
                    {
                        ToolImageBitmapPCLXL.generateJob(
                            binWriter,
                            _subsetPaperSizes[_indxPaperSizePCLXL],
                            _subsetPaperTypes[_indxPaperTypePCLXL],
                            _subsetOrientations[_indxOrientationPCLXL],
                            _destPosX,
                            _destPosY,
                            _destScalePercentX,
                            _destScalePercentY);
                    }
                }

                if (result == 0)
                {
                    TargetCore.requestStreamWrite(false);
                }
            }

            if (bitmapOpen)
            {
                ToolImageBitmapCore.bitmapClose();
            }
        }
Exemple #21
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p a r s e S e q u e n c e s                                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Process sequences until end-point reached.                         //
        //                                                                    //
        //--------------------------------------------------------------------//

        private Boolean parseSequences(
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref ToolCommonData.ePrintLang crntPDL,
            ref Boolean endReached)
        {
            Int64 startPos;

            Boolean continuation    = false;
            Boolean langSwitch      = false;
            Boolean badSeq          = false;
            Boolean invalidSeqFound = false;

            continuation = false;
            startPos     = _fileOffset + bufOffset;

            if (!_linkData.PrescribeIntroRead)
            {
                if ((_buf[bufOffset] ==
                     PrnParseConstants.prescribeSCRCDelimiter)
                    &&
                    (_buf[bufOffset + 1] == _linkData.PrescribeSCRC)
                    &&
                    (_buf[bufOffset + 2] ==
                     PrnParseConstants.prescribeSCRCDelimiter))
                {
                    String seq = _ascii.GetString(_buf, bufOffset, 3);
                    //  String desc = PrescribeCommands.getDescCmdIntro();
                    String desc = "";

                    PrescribeCommands.checkCmdIntro(ref desc,
                                                    _analysisLevel);

                    PrnParseCommon.addDataRow(
                        PrnParseRowTypes.eType.PrescribeCommand,
                        _table,
                        PrnParseConstants.eOvlShow.Remove,
                        _indxOffsetFormat,
                        _fileOffset + bufOffset,
                        _analysisLevel,
                        "Prescribe",
                        seq,
                        desc);

                    bufOffset += 3;
                    bufRem    -= 3;

                    _linkData.PrescribeIntroRead = true;
                }
                else
                {
                    // internal error ??
                }
            }

            while (!continuation && !langSwitch &&
                   !endReached && (bufRem > 0))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Process data until language-switch or end of buffer, or    //
                // specified end point.                                       //
                //                                                            //
                //------------------------------------------------------------//

                if ((_endOffset != -1) &&
                    ((_fileOffset + bufOffset) > _endOffset))
                {
                    endReached = true;
                }
                else if (_buf[bufOffset] == PrnParseConstants.asciiEsc)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Escape character found.                                //
                    // Switch to PCL language processing.                     //
                    //                                                        //
                    // Note that, in theory, only a few escape sequences are  //
                    // expected:                                              //
                    //      <Esc>E          Printer Reset                     //
                    //      <Esc>%-12345X   Universal Exit Language           //
                    // but if we find an escape sequence, it's certainly not  //
                    // Prescribe.                                             //
                    //                                                        //
                    //--------------------------------------------------------//

                    langSwitch = true;

                    crntPDL = ToolCommonData.ePrintLang.PCL;
                }
                else
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Sequence does not start with an Escape character, so   //
                    // it should be a Prescribe command.                      //
                    //                                                        //
                    //--------------------------------------------------------//

                    badSeq = processCommand(ref bufRem,
                                            ref bufOffset,
                                            ref continuation,
                                            ref langSwitch,
                                            ref crntPDL);

                    if (badSeq)
                    {
                        invalidSeqFound = true;
                    }
                }
            }

            _linkData.MakeOvlAct       = PrnParseConstants.eOvlAct.Remove;
            _linkData.MakeOvlSkipBegin = startPos;
            _linkData.MakeOvlSkipEnd   = _fileOffset + bufOffset;

            return(invalidSeqFound);
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // g i v e C r n t P D L                                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        public void giveCrntPDL(ref ToolCommonData.ePrintLang crntPDL)
        {
            crntPDL = _crntPDL;
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // l o a d D a t a C a p t u r e                                      //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Retrieve stored FormSample capture file data.                      //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void loadDataCapture(ToolCommonData.ePrintLang crntPDL,
                                           ref String captureFile)
        {
            RegistryKey keyMain =
                Registry.CurrentUser.CreateSubKey(_mainKey);

            String oldKey = _subKeyTools + "\\" + _subKeyToolsFormSample;
            String oldFile;

            Boolean update_from_v2_5_0_0 = false;

            String defWorkFolder = ToolCommonData.DefWorkFolder;

            //----------------------------------------------------------------//

            using (RegistryKey subKey = keyMain.OpenSubKey(oldKey, true))
            {
                oldFile = (String)subKey.GetValue(_nameCaptureFile);

                if (oldFile != null)
                {
                    update_from_v2_5_0_0 = true;

                    subKey.DeleteValue(_nameCaptureFile);
                }
            }

            if (update_from_v2_5_0_0)
            {
                String keyPCL = _subKeyTools +
                                "\\" + _subKeyToolsFormSample +
                                "\\" + _subKeyPCL;

                using (RegistryKey subKey = keyMain.CreateSubKey(keyPCL))
                {
                    subKey.SetValue(_nameCaptureFile,
                                    oldFile,
                                    RegistryValueKind.String);
                }

                String keyPCLXL = _subKeyTools +
                                  "\\" + _subKeyToolsFormSample +
                                  "\\" + _subKeyPCLXL;

                using (RegistryKey subKey = keyMain.CreateSubKey(keyPCLXL))
                {
                    subKey.SetValue(_nameCaptureFile,
                                    oldFile,
                                    RegistryValueKind.String);
                }
            }

            //----------------------------------------------------------------//

            if (crntPDL == ToolCommonData.ePrintLang.PCL)
            {
                String key = _subKeyTools + "\\" + _subKeyToolsFormSample +
                             "\\" + _subKeyPCL;

                using (RegistryKey subKey = keyMain.CreateSubKey(key))
                {
                    captureFile = (String)subKey.GetValue(
                        _nameCaptureFile,
                        defWorkFolder + "\\" + _defaultCaptureFilePCL);
                }
            }
            else if (crntPDL == ToolCommonData.ePrintLang.PCLXL)
            {
                String key = _subKeyTools + "\\" + _subKeyToolsFormSample +
                             "\\" + _subKeyPCLXL;

                using (RegistryKey subKey = keyMain.CreateSubKey(key))
                {
                    captureFile = (String)subKey.GetValue(
                        _nameCaptureFile,
                        defWorkFolder + "\\" + _defaultCaptureFilePCLXL);
                }
            }
        }
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // m e t r i c s L o a d                                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Load metrics from persistent storage.                              //
        //                                                                    //
        //--------------------------------------------------------------------//

        private void metricsLoad()
        {
            Int32 tempPosX = 100,
                  tempPosY = 100;

            Int32 tempRasterRes = 0;

            ToolImageBitmapPersist.loadDataCommon(ref _indxPDL,
                                                  ref _bitmapFilename,
                                                  ref tempPosX,
                                                  ref tempPosY,
                                                  ref _destScalePercentX,
                                                  ref _destScalePercentY,
                                                  ref tempRasterRes);

            if ((_indxPDL < 0) || (_indxPDL >= _ctPDLs))
            {
                _indxPDL = 0;
            }

            _crntPDL = (ToolCommonData.ePrintLang)_subsetPDLs[_indxPDL];

            _destPosX = (Single)(tempPosX / 100);
            _destPosY = (Single)(tempPosY / 100);

            if ((tempRasterRes < 0) ||
                (tempRasterRes >= _ctRasterResolutions))
            {
                _indxRasterResolutionPCL = 0;
            }
            else
            {
                _indxRasterResolutionPCL = tempRasterRes;
            }

            ToolImageBitmapPersist.loadDataPCL("PCL",
                                               ref _indxOrientationPCL,
                                               ref _indxPaperSizePCL,
                                               ref _indxPaperTypePCL);

            if ((_indxOrientationPCL < 0) ||
                (_indxOrientationPCL >= _ctOrientations))
            {
                _indxOrientationPCL = 0;
            }

            if ((_indxPaperSizePCL < 0) ||
                (_indxPaperSizePCL >= _ctPaperSizes))
            {
                _indxPaperSizePCL = 0;
            }

            if ((_indxPaperTypePCL < 0) ||
                (_indxPaperTypePCL >= _ctPaperTypes))
            {
                _indxPaperTypePCL = 0;
            }

            ToolImageBitmapPersist.loadDataPCL("PCLXL",
                                               ref _indxOrientationPCLXL,
                                               ref _indxPaperSizePCLXL,
                                               ref _indxPaperTypePCLXL);

            if ((_indxOrientationPCLXL < 0) ||
                (_indxOrientationPCLXL >= _ctOrientations))
            {
                _indxOrientationPCLXL = 0;
            }

            if ((_indxPaperSizePCLXL < 0) ||
                (_indxPaperSizePCLXL >= _ctPaperSizes))
            {
                _indxPaperSizePCLXL = 0;
            }

            if ((_indxPaperTypePCLXL < 0) ||
                (_indxPaperTypePCLXL >= _ctPaperTypes))
            {
                _indxPaperTypePCLXL = 0;
            }
        }
Exemple #25
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // m e t r i c s L o a d F i l e C a p t                              //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Load current target File capture metrics data.                     //
        //                                                                    //
        //--------------------------------------------------------------------//

        public static void metricsLoadFileCapt(
            ToolCommonData.eToolIds crntToolId,
            ToolCommonData.eToolSubIds crntToolSubId,
            ToolCommonData.ePrintLang crntPDL)
        {
            //----------------------------------------------------------------//

            if (crntToolId == ToolCommonData.eToolIds.FontSample)
            {
                ToolFontSamplePersist.loadDataCapture(crntPDL,
                                                      ref _saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.FormSample)
            {
                ToolFormSamplePersist.loadDataCapture(crntPDL,
                                                      ref _saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.ImageBitmap)
            {
                ToolImageBitmapPersist.loadDataCapture(crntPDL,
                                                       ref _saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.PrintArea)
            {
                ToolPrintAreaPersist.loadDataCapture(crntPDL,
                                                     ref _saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.PrnPrint)
            {
                ToolPrnPrintPersist.loadDataCapture(crntPDL,
                                                    ref _saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.StatusReadback)
            {
                ToolStatusReadbackPersist.loadDataCapture(crntPDL,
                                                          ref _saveFilename);
            }
            else if (crntToolId == ToolCommonData.eToolIds.TrayMap)
            {
                ToolTrayMapPersist.loadDataCapture(crntPDL,
                                                   ref _saveFilename);
            }

            //----------------------------------------------------------------//

            else if (crntToolId == ToolCommonData.eToolIds.MiscSamples)
            {
                ToolMiscSamplesPersist.loadDataCapture(
                    crntToolSubId,
                    crntPDL,
                    ref _saveFilename);
            }

            //----------------------------------------------------------------//

            else
            {
                //     Tool MakeOverlay // ***** Do DUMMY procs ? ***** //
                //     Tool PrintLang
                //     Tool PrnAnalyse
                //     Tool SoftFontGen
                //     Tool SymbolSetGen
                //     Tool XXXDiags

                _saveFilename = "";
            }
        }
Exemple #26
0
        //--------------------------------------------------------------------//
        //                                                        M e t h o d //
        // p r o c e s s C o m m a n d                                        //
        //--------------------------------------------------------------------//
        //                                                                    //
        // Process current Prescribe command in buffer.                       //
        //                                                                    //
        // Interrupt process if an <Esc> character is encountered.            //
        // Long commands are split into shorter slices.                       //
        //                                                                    //
        //--------------------------------------------------------------------//

        private Boolean processCommand(
            ref Int32 bufRem,
            ref Int32 bufOffset,
            ref Boolean continuation,
            ref Boolean langSwitch,
            ref ToolCommonData.ePrintLang crntPDL)
        {
            PrnParseConstants.eContType contType =
                PrnParseConstants.eContType.None;

            Byte crntByte,
                 cmdParaByte1 = 0x3f;

            Char crntChar,
                 normChar;

            Int32 len,
                  cmdLen,
                  cmdRem,
                  cmdStart,
                  offset,
                  lineStart;

            Int32 quoteStart = 0,
                  quoteEnd   = 0;

            Boolean invalidSeqFound,
                    cmdParaByte1Found,
                    endLoop,
                    foundTerm;

            //  Boolean flagWithinQuote;
            Boolean flagWithinQuoteDouble;
            Boolean flagWithinQuoteSingle;
            Boolean cmdKnown      = false;
            Boolean flagCmdExit   = false;
            Boolean flagCmdSetCRC = false;

            String command,
                   commandName,
                   commandDesc = "";

            StringBuilder cmd = new StringBuilder();

            invalidSeqFound = false;
            foundTerm       = false;
            langSwitch      = false;

            lineStart = bufOffset;
            foundTerm = false;

            len    = bufRem;
            offset = bufOffset;

            continuation = false;
            foundTerm    = false;

            cmdRem   = bufRem;
            cmdStart = offset;
            cmdLen   = 0;

            //----------------------------------------------------------------//
            //                                                                //
            // Search for termination character.                              //
            // This should be a Semi-colon (0x3b) character.                  //
            // But we may encounter an Escape character (<Esc>, 0x1b)         //
            // signalling return to PCL?                                      //
            //                                                                //
            // This is to make sure that the termination character is in the  //
            // buffer before processing the command, so that we don't have to //
            // cater for doing a 'continuation' read part way through         //
            // processing the command.                                        //
            //                                                                //
            // Initiate continuation action if terminator is not found in     //
            // buffer, subject to a maximum command length (to prevent        //
            // recursive continuation actions).                               //
            //                                                                //
            //----------------------------------------------------------------//

            //  flagWithinQuote = false;
            flagWithinQuoteDouble = false;
            flagWithinQuoteSingle = false;

            while ((!foundTerm) && (cmdRem > 0) && (cmdLen < _maxCmdLen))
            {
                crntByte = _buf[offset];

                if (crntByte == PrnParseConstants.asciiEsc)
                {
                    foundTerm = true;
                }
                else
                {
                    if (flagWithinQuoteDouble)
                    {
                        if (crntByte == PrnParseConstants.asciiQuote)
                        {
                            flagWithinQuoteDouble = false;
                            //  flagWithinQuote = false;
                            quoteEnd = offset;
                        }
                    }
                    else if (flagWithinQuoteSingle)
                    {
                        if (crntByte == PrnParseConstants.asciiApostrophe)
                        {
                            flagWithinQuoteSingle = false;
                            //  flagWithinQuote = false;
                            quoteEnd = offset;
                        }
                    }
                    else if (crntByte == PrnParseConstants.asciiQuote)
                    {
                        flagWithinQuoteDouble = true;
                        //  flagWithinQuote = true;
                        quoteStart = offset;
                    }
                    else if (crntByte == PrnParseConstants.asciiApostrophe)
                    {
                        flagWithinQuoteSingle = true;
                        //  flagWithinQuote = true;
                        quoteStart = offset;
                    }
                    else if (crntByte == PrnParseConstants.asciiSemiColon)
                    {
                        foundTerm = true;
                    }

                    offset++;
                    cmdLen++;
                    cmdRem--;
                }
            }

            if ((!foundTerm) && (cmdLen < _maxCmdLen))
            {
                //------------------------------------------------------------//
                //                                                            //
                // Termination character not found before buffer exhausted,   //
                // or maximum command length exceeded.                        //
                // Initiate (backtracking) continuation action.               //
                //                                                            //
                //------------------------------------------------------------//

                continuation = true;

                contType = PrnParseConstants.eContType.Prescribe;

                _linkData.setBacktrack(contType, -bufRem);
            }
            else
            {
                //------------------------------------------------------------//
                //                                                            //
                // Process command.                                           //
                // At this point, we have in the buffer one of:               //
                //  - characters terminated by <semi-colon> (counted in       //
                //    length).                                                //
                //  - characters terminated by <Esc> (not counted in length). //
                //  - characters not terminated, but maxmimum length.         //
                //                                                            //
                //------------------------------------------------------------//

                cmdRem = cmdLen;
                offset = bufOffset;

                //------------------------------------------------------------//
                //                                                            //
                // Stage 1: look for & skip past whitespace.                  //
                //                                                            //
                //------------------------------------------------------------//

                endLoop = false;

                while ((!endLoop) && (cmdRem > 0))
                {
                    crntByte = _buf[offset];

                    if ((crntByte == PrnParseConstants.asciiSpace)
                        ||
                        (crntByte == PrnParseConstants.asciiHT))
                    {
                        offset++;
                        cmdRem--;
                    }
                    else if ((crntByte == PrnParseConstants.asciiCR)
                             ||
                             (crntByte == PrnParseConstants.asciiLF))
                    {
                        offset++;
                        cmdRem--;
                    }
                    else
                    {
                        endLoop = true;
                    }
                }

                //------------------------------------------------------------//
                //                                                            //
                // Stage 2: look for command name.                            //
                //                                                            //
                //------------------------------------------------------------//

                endLoop = false;

                while ((!endLoop) && (cmdRem > 0))
                {
                    crntByte = _buf[offset];

                    //--------------------------------------------------------//
                    //                                                        //
                    // Check for special characters first.                    //
                    //                                                        //
                    //--------------------------------------------------------//

                    if ((cmdRem == 1) &&
                        (crntByte == PrnParseConstants.asciiSemiColon))

                    {
                        // nextstage = Parameters or Terminator;
                        endLoop = true;
                    }
                    else if (((crntByte >= PrnParseConstants.asciiAlphaUCMin)
                              &&
                              (crntByte <= PrnParseConstants.asciiAlphaUCMax))
                             ||
                             ((crntByte >= PrnParseConstants.asciiAlphaLCMin)
                              &&
                              (crntByte <= PrnParseConstants.asciiAlphaLCMax)))
                    {
                        crntChar = (Char)crntByte;
                        normChar = Char.ToUpper(crntChar);
                        cmd.Append(normChar);

                        offset++;
                        cmdRem--;
                    }
                    else
                    {
                        // nextstage = Parameters or Terminator;
                        endLoop = true;
                    }
                }

                //------------------------------------------------------------//
                //                                                            //
                // Check whether command name known.                          //
                //                                                            //
                //------------------------------------------------------------//

                commandName = cmd.ToString();

                cmdKnown = PrescribeCommands.checkCmd(cmd.ToString(),
                                                      ref commandDesc,
                                                      ref flagCmdExit,
                                                      ref flagCmdSetCRC,
                                                      _analysisLevel);

                //------------------------------------------------------------//
                //                                                            //
                // Stage 3: look for command remainder parameters, or the     //
                // terminator character.                                      //
                //                                                            //
                //------------------------------------------------------------//

                endLoop           = false;
                cmdParaByte1Found = false;

                while ((!endLoop) && (cmdRem > 0))
                {
                    crntByte = _buf[offset];

                    if (!cmdParaByte1Found)
                    {
                        if ((crntByte != PrnParseConstants.asciiSpace)
                            &&
                            (crntByte != PrnParseConstants.asciiHT))
                        {
                            cmdParaByte1      = crntByte;
                            cmdParaByte1Found = true;
                        }
                    }

                    offset++;
                    cmdRem--;
                }

                //------------------------------------------------------------//
                //                                                            //
                // Stage 4: Output details of command.                        //
                // Display sequence (in slices if necessary).                 //
                //                                                            //
                //------------------------------------------------------------//

                command = Encoding.ASCII.GetString(_buf, cmdStart, cmdLen);

                const Int32 indent = 2;

                lineStart = 0;
                len       = cmdLen; // or length of string? //

                Int32 sliceLen,
                      sliceLenMax,
                      sliceStart,
                      sliceOffset,
                      ccAdjust;

                Boolean firstSlice;

                String seq = "";

                Byte[] seqBuf = new Byte[PrnParseConstants.cRptA_colMax_Seq];

                firstSlice  = true;
                sliceOffset = 0;

                if (firstSlice)
                {
                    sliceLenMax = PrnParseConstants.cRptA_colMax_Seq;
                }
                else
                {
                    sliceLenMax = PrnParseConstants.cRptA_colMax_Seq - indent;
                }

                sliceStart = bufOffset + sliceOffset;

                while (len > sliceLenMax)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Sequence is too large to fit on one output line.       //
                    //                                                        //
                    //--------------------------------------------------------//

                    sliceLen = sliceLenMax;
                    ccAdjust = 0;

                    if (firstSlice)
                    {
                        seq = command.Substring(sliceOffset, sliceLen);

                        PrnParseCommon.addDataRow(
                            PrnParseRowTypes.eType.PrescribeCommand,
                            _table,
                            PrnParseConstants.eOvlShow.Remove,
                            _indxOffsetFormat,
                            _fileOffset + bufOffset + sliceOffset,
                            _analysisLevel,
                            "Prescribe command",
                            seq.ToString(),
                            "");
                    }
                    else
                    {
                        seq = "  " + // indent number of spaces
                              command.Substring(sliceOffset, sliceLen);

                        PrnParseCommon.addDataRow(
                            PrnParseRowTypes.eType.PrescribeCommand,
                            _table,
                            PrnParseConstants.eOvlShow.Remove,
                            _indxOffsetFormat,
                            _fileOffset + bufOffset + sliceOffset,
                            _analysisLevel,
                            "",
                            seq.ToString(),
                            "");
                    }

                    len         = len - sliceLen - ccAdjust;
                    sliceOffset = sliceOffset + sliceLen + ccAdjust;
                    sliceStart += (sliceLen + ccAdjust);
                    sliceLenMax = PrnParseConstants.cRptA_colMax_Seq - indent;

                    firstSlice = false;
                }

                //------------------------------------------------------------//
                //                                                            //
                // Display last (or only) slice of sequence.                  //
                //                                                            //
                //------------------------------------------------------------//

                sliceLen = len;
                ccAdjust = 0;

                if (len > 0)
                {
                    if (firstSlice)
                    {
                        seq = command.Substring(sliceOffset, sliceLen);

                        PrnParseCommon.addDataRow(
                            PrnParseRowTypes.eType.PrescribeCommand,
                            _table,
                            PrnParseConstants.eOvlShow.Remove,
                            _indxOffsetFormat,
                            _fileOffset + bufOffset + sliceOffset,
                            _analysisLevel,
                            "Prescribe Command",
                            seq,
                            commandDesc);
                    }
                    else
                    {
                        seq = "  " + // indent number of spaces
                              command.Substring(sliceOffset, sliceLen);

                        PrnParseCommon.addDataRow(
                            PrnParseRowTypes.eType.PrescribeCommand,
                            _table,
                            PrnParseConstants.eOvlShow.Remove,
                            _indxOffsetFormat,
                            _fileOffset + bufOffset + sliceOffset,
                            _analysisLevel,
                            "",
                            seq,
                            commandDesc);
                    }
                }

                //------------------------------------------------------------//
                //                                                            //
                // Stage 5: Do any special processing.                        //
                //                                                            //
                //------------------------------------------------------------//

                bufOffset = offset;
                bufRem   -= cmdLen;

                if (flagCmdExit)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Exit command found and processed.                      //
                    //                                                        //
                    //--------------------------------------------------------//

                    langSwitch = true;

                    crntPDL = _linkData.PrescribeCallerPDL;
                    _linkData.PrescribeIntroRead = false;
                }
                else if (flagCmdSetCRC)
                {
                    //--------------------------------------------------------//
                    //                                                        //
                    // Set Command Recognition Character command found and    //
                    // processed.                                             //
                    //                                                        //
                    //--------------------------------------------------------//

                    _linkData.PrescribeSCRC = cmdParaByte1;

                    PrnParseCommon.addTextRow(
                        PrnParseRowTypes.eType.MsgComment,
                        _table,
                        PrnParseConstants.eOvlShow.None,
                        "",
                        "Comment",
                        "",
                        "Set Prescribe CRC = " + (Char)cmdParaByte1);
                }
            }

            return(invalidSeqFound);
        }