TextEditor2.Message.ConvertSevenByteControlCodeToTag C# (CSharp) Method

ConvertSevenByteControlCodeToTag() public method

public ConvertSevenByteControlCodeToTag ( int startIndex ) : void
startIndex int
return void
        public void ConvertSevenByteControlCodeToTag(int startIndex)
        {
            //Convert a SevenByte control code to a tag

            //Stores variable
            uint variable = 0;

            //Stores tag type
            string tagType = "";

            //Empty complete tag
            string completeTag = "";

            //Get tagType by comparing the type with
            //values in enum SevenByteTypes
            switch ((byte)charData[startIndex + 4])
            {
                case (byte)SevenByteTypes.SetTextSize:
                    tagType = "Scale";
                    break;
                case (byte)SevenByteTypes.WaitAndDismissWithPrompt:
                    tagType = "Wait + Dismiss (prompt)";
                    break;
                case (byte)SevenByteTypes.WaitAndDismiss:
                    tagType = "Wait + Dismiss";
                    break;
                case (byte)SevenByteTypes.Dismiss:
                    tagType = "Dismiss";
                    break;
                case (byte)SevenByteTypes.Dummy:
                    tagType = "Dummy";
                    break;
                case (byte)SevenByteTypes.Wait:
                    tagType = "Wait";
                    break;
                default:
                    tagType = "Unknown " + (byte)charData[startIndex + 4];
                    break;
            }

            //Create and fill buffer to prepare for short conversion
            byte[] buffer = new byte[] { (byte)charData[startIndex + 6], (byte)charData[startIndex + 5] };

            ///Convert two bytes to short
            variable = (ushort)BitConverter.ToInt16(buffer, 0);

            //Build complete tag
            completeTag = "<" + tagType + ":" + variable + ">";

            //Insert tag after the original code
            charData.InsertRange(startIndex + 7, Encoding.ASCII.GetBytes(completeTag));

            //Delete original code
            charData.RemoveRange(startIndex, 7);
        }