Exemplo n.º 1
0
        private void btnDecode_Click(object sender, EventArgs e)
        {
            txtDecodeOutput.Text = "";
            lblDecoded.Text      = string.Format("Integers decoded: {0}", 0);

            string leftToDecode = txtVL64.Text;

            int decoded = 0;

            while (leftToDecode.Length > 0)
            {
                int length;
                int value = 0;

                try
                {
                    value = WireEncoding.DecodeInt32(leftToDecode, out length);
                }
                catch
                {
                    length = 0;
                }

                bool raiseError = false;

                if (length == 0)
                {
                    raiseError = true;
                }
                else if (leftToDecode.Substring(0, length).ToString() != WireEncoding.EncodeInt32(value))
                {
                    raiseError = true;
                }

                if (!raiseError)
                {
                    decoded++;
                    txtDecodeOutput.Text += leftToDecode.Substring(0, length) + " = " + value + Environment.NewLine;
                    lblDecoded.Text       = string.Format("Integers decoded: {0}", decoded);
                }
                else
                {
                    length = leftToDecode.Length;
                    txtDecodeOutput.Text += leftToDecode.Substring(0, length) + " = ERROR" + Environment.NewLine;
                }

                leftToDecode = leftToDecode.Substring(length);
            }
        }
Exemplo n.º 2
0
        private void btnFromVL64_Click(object sender, EventArgs e)
        {
            try
            {
                int i;
                int value = WireEncoding.DecodeInt32(txtFromVL64.Text, out i);
                txtToVL64.Text = value + "";

                if (WireEncoding.EncodeInt32(value).ToString() != txtFromVL64.Text)
                {
                    txtToVL64.Text = "ERROR";
                }
            }
            catch (Exception ex)
            {
                txtToVL64.Text = "ERROR";
            }
        }
Exemplo n.º 3
0
        private void btnToVL64_Click(object sender, EventArgs e)
        {
            try
            {
                string value = WireEncoding.EncodeInt32(int.Parse(txtToVL64.Text));
                txtFromVL64.Text = value;

                int len;
                if (WireEncoding.DecodeInt32(value, out len).ToString() != txtToVL64.Text)
                {
                    txtFromVL64.Text = "ERROR";
                }
            }
            catch (Exception ex)
            {
                txtFromVL64.Text = "ERROR";
            }
        }