示例#1
0
        protected void TestTabInputChanged()
        {
            if (m_aEC == null)              // means it hasn't been set up yet.
            {
                return;
            }

            if (ecTextBoxInput.TextLength > 0)
            {
                buttonTest.Enabled = true;

                NormConversionType eType = (checkBoxTestReverse.Checked)
                                        ? EncConverter.NormalizeRhsConversionType(ConversionType) : EncConverter.NormalizeLhsConversionType(ConversionType);

                if (eType == NormConversionType.eLegacy)
                {
                    UpdateLegacyCodes(ecTextBoxInput.Text, m_aEC.CodePageInput, richTextBoxHexInput);
                }
                else
                {
                    UpdateUniCodes(ecTextBoxInput.Text, richTextBoxHexInput);
                }
            }
            else
            {
                richTextBoxHexInput.Clear();
                buttonTest.Enabled = false;
            }

            // whenever the input changes, clear out the output
            ecTextBoxOutput.Text      = null;
            richTextBoxHexOutput.Text = null;
        }
示例#2
0
 protected bool IsLhsLegacy(IEncConverter aEC)
 {
     if (aEC.DirectionForward)
     {
         return(EncConverter.NormalizeLhsConversionType(aEC.ConversionType) == NormConversionType.eLegacy);
     }
     else
     {
         return(EncConverter.NormalizeRhsConversionType(aEC.ConversionType) == NormConversionType.eLegacy);
     }
 }
示例#3
0
        private void buttonTest_Click(object sender, EventArgs e)
        {
            IEncConverter aEC = InitializeEncConverter;

            if (aEC != null)
            {
                try
                {
                    aEC.DirectionForward = !checkBoxTestReverse.Checked;
                    ecTextBoxOutput.Text = aEC.Convert(ecTextBoxInput.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format("Test failed! Reason: {0}", ex.Message),
                                    EncConverters.cstrCaption);
                }

                NormConversionType eType = (checkBoxTestReverse.Checked)
                                        ? EncConverter.NormalizeLhsConversionType(ConversionType) : EncConverter.NormalizeRhsConversionType(ConversionType);

                if (eType == NormConversionType.eLegacy)
                {
                    UpdateLegacyCodes(ecTextBoxOutput.Text, m_aEC.CodePageOutput, richTextBoxHexOutput);
                }
                else
                {
                    UpdateUniCodes(ecTextBoxOutput.Text, richTextBoxHexOutput);
                }
            }
        }
示例#4
0
        protected override unsafe void DoConvert
        (
            byte *lpInBuffer,
            int nInLen,
            byte *lpOutBuffer,
            ref int rnOutLen
        )
        {
            rnOutLen = 0;
            if (!String.IsNullOrEmpty(WorkingDir))
            {
                // we need to put it *back* into a string because the StreamWriter that will
                // ultimately write to the StandardInput uses a string. Use the correct codepg.
                byte [] baDst = new byte [nInLen];
                ECNormalizeData.ByteStarToByteArr(lpInBuffer, nInLen, baDst);
                Encoding enc;
                try
                {
                    enc = Encoding.GetEncoding(this.CodePageInput);
                }
                catch
                {
                    enc = Encoding.GetEncoding(EncConverters.cnIso8859_1CodePage);
                }
                string strInput = enc.GetString(baDst);

                // call the helper that calls the exe
                string strOutput = DoExeCall(strInput);

                // if there's a response...
                if (!String.IsNullOrEmpty(strOutput))
                {
                    // ... put it in the output buffer
                    // if the output is legacy, then we need to shrink it from wide to narrow
                    // it'll be legacy either if (the direction is forward and the rhs=eLegacy)
                    // or if (the direction is reverse and the rhs=eLegacy)
                    bool bLegacyOutput =
                        (
                            ((this.DirectionForward == true) &&
                             (EncConverter.NormalizeRhsConversionType(this.ConversionType) == NormConversionType.eLegacy)
                            ) ||
                            ((this.DirectionForward == false) &&
                             (EncConverter.NormalizeLhsConversionType(this.ConversionType) == NormConversionType.eLegacy)
                            )
                        );

                    if (bLegacyOutput)
                    {
                        try
                        {
                            enc = Encoding.GetEncoding(this.CodePageOutput);
                        }
                        catch
                        {
                            enc = Encoding.GetEncoding(EncConverters.cnIso8859_1CodePage);
                        }
                        byte [] baOut = enc.GetBytes(strOutput);
                        ECNormalizeData.ByteArrToByteStar(baOut, lpOutBuffer);
                        rnOutLen = baOut.Length;
                    }
                    else
                    {
                        rnOutLen = strOutput.Length * 2;
                        ECNormalizeData.StringToByteStar(strOutput, lpOutBuffer, rnOutLen);
                    }
                }
            }
            else
            {
                EncConverters.ThrowError(ErrStatus.RegistryCorrupt);
            }
        }