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

namespace CowainHmi
{
    public partial class S1顶部 : UserControl
    {
        public S1顶部()
        {
            InitializeComponent();
            foreach (var item in GlobalData.StationNames)
            {
                this.cbxStation.Items.Add(item);
            }
            if (GlobalData.StationNames.Count > 0)
            {
                this.cbxStation.SelectedIndex = GlobalData.StationId;
                this.cbxStation.SelectedIndexChanged += new System.EventHandler(this.cbxStation_SelectedIndexChanged);
            }
            else
            {
                this.cbxStation.Items.Add("读取错误");
                this.cbxStation.SelectedIndex = 0;
            }
        }
        private void cbxStation_SelectedIndexChanged(object sender, EventArgs e)
        {
            GlobalData.StationId = this.cbxStation.SelectedIndex;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PCHMI.GLOBAL.UserName))
            {
                this.lblUserName.Text = "无用户";
            }
            else
            {
                this.lblUserName.Text = PCHMI.GLOBAL.UserName;
            }
        }

        private void S1顶部_Load(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
        }
    }
}
