using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace MetaEditor.Controls
{
    /// <summary>
    /// Used to display 'byte' and 'byte[]' value types
    /// </summary>
    public partial class Byte : UserControl
    {
        /// <summary>
        /// Creates a new control using a 'byte' value type
        /// </summary>
        /// <param name="value">Value to be displayed</param>
        /// <param name="name">Name of our value</param>
        public Byte(byte value, string name)
        {
            InitializeComponent();
            label2.Text = name;
            textBox1.Text = value.ToString();
        }
        /// <summary>
        /// Creates a new control using a 'byte[]' value type
        /// </summary>
        /// <param name="value">Value to be displayed</param>
        /// <param name="name">Name of our value</param>
        public Byte(byte[] value, string name)
        {
            InitializeComponent();
            label2.Text = name;
            textBox1.Text = value.ToString();
        }
        /// <summary>
        /// Reloads a 'byte' value into the control
        /// </summary>
        /// <param name="value">Value to be displayed</param>
        public void Reload(byte value)
        {
            textBox1.Text = value.ToString();
        }
        /// <summary>
        /// Reloads a 'byte[]' value into the control
        /// </summary>
        /// <param name="value">Value to be displayed</param>
        public void Reload(byte[] value)
        {
            textBox1.Text = value.ToString();
        }
        /// <summary>
        /// Returns the name of the controls value
        /// </summary>
        /// <returns></returns>
        public string ReturnName()
        {
            return label2.Text.Replace(' ', '_');
        }
        /// <summary>
        /// Returns the value of our control
        /// </summary>
        /// <returns></returns>
        public byte ReturnValue()
        {
            return byte.Parse(textBox1.Text);
        }
    }
}
