Пример #1
0
        /// <summary>
        /// Creates a byte array representation of this IR Code.
        /// </summary>
        /// <returns>Byte array representation (internally it is in Pronto format).</returns>
        public byte[] ToByteArray()
        {
            StringBuilder output = new StringBuilder();

            ushort[] prontoData = Pronto.ConvertIrCodeToProntoRaw(this);

            for (int index = 0; index < prontoData.Length; index++)
            {
                output.Append(prontoData[index].ToString("X4"));
                if (index != prontoData.Length - 1)
                {
                    output.Append(' ');
                }
            }

            return(Encoding.ASCII.GetBytes(output.ToString()));
        }
Пример #2
0
        private void Save()
        {
            if (String.IsNullOrEmpty(_fileName))
            {
                if (!GetSaveFileName())
                {
                    return;
                }
            }

            if (!checkBoxStoreBinary.Checked)
            {
                Pronto.WriteProntoFile(_fileName, Pronto.ConvertIrCodeToProntoRaw(_code));
            }
            else
            {
                using (FileStream file = File.OpenWrite(_fileName))
                {
                    byte[] fileBytes = DataPacket(_code);

                    file.Write(fileBytes, 0, fileBytes.Length);
                }
            }
        }