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

namespace NZSDK_CSharpSample
{
    public partial class PageNZSdkData : UserControl
    {
        #region Fields

        NZSDK sdk;

        #endregion

        #region Constructors

        public PageNZSdkData()
        {
            InitializeComponent();
        }

        #endregion

        #region Properties

        public NZSDK SDK
        {
            get { return sdk; }
            set { sdk = value; }
        }

        #endregion

        #region Private / Protected Methods

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            foreach (string name in Enum.GetNames(typeof(NZSDK.VmsDataTypes)))
            {
                NZSDK.VmsDataTypes value = (NZSDK.VmsDataTypes)Enum.Parse(typeof(NZSDK.VmsDataTypes), name);
                if (value == NZSDK.VmsDataTypes.Unknown)
                    continue;
                cboDataCategories.Items.Add(new GenericItem(name, value));
            }
            cboDataCategories.SelectedIndex = 0;
        }

        #endregion

        #region Public Methods

        #endregion

        #region Event Handlers

        private void butGet_Click(object sender, EventArgs e)
        {
            GenericItem item = cboDataCategories.SelectedItem as GenericItem;
            if (item == null)
                return;

            string data = string.Empty;
            if (sdk.GetDatas((NZSDK.VmsDataTypes)item.ItemValue, ref data))
                richTextBox1.Text = data;
        }

        #endregion
    }
}
