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

using LFP_Manager.Forms;
using LFP_Manager.DataStructure;
using LFP_Manager.Function;

namespace LFP_Manager.Controls
{
    public partial class ucCommConfig2 : DevExpress.XtraEditors.XtraUserControl
    {
        #region VARIABLES
        public event ButtonEvent OnStart = null;

        string info;
        #endregion

        #region CONSTRUCTORS
        public ucCommConfig2()
        {
            InitializeComponent();
        }
        #endregion

        public void UpdateConfig(ref CommConfig Config)
        {
            if (Config.CommType == 1)
            {
                info = String.Format("INTERFACE: UART,  PORT: {0},  BAUDRATE: {1},  MODEL: {2}"
                    , Config.UartPort
                    , Config.UartBaudrate
                    , csConstData.CommType.UART_MODEL[Config.UartModelIndex]
                    );
            }
            else
            {
                info = String.Format("INF: CAN");
            }

            lbStatus.Text = info;
        }

        public void UpdateStatus(bool flag, int mId)
        {
            if (flag)
                btnStart.Text = "STOP";
            else
                btnStart.Text = "RUN";

            lbStatus.Text = String.Format("{0} - {1}", info, mId);
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            if (OnStart != null)
                OnStart(sender, e);
        }
    }
}
