using MetroFramework.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

namespace HSUCO_Cargo_Garage_Operation_Program.CustomForm
{

    public partial class ManualPermission : MetroForm
    {
        public int selectArea { get; set; }
        private BindingList<object> mAreas = new BindingList<object>();
        public ManualPermission(List<AreaSetting> areas)
        {
            InitializeComponent();

            metroComboBox_Area.Items.Clear();
            foreach (var area in areas)
            {
                mAreas.Add(new { Text = area.AreaName, Value = area.No });

            }
            metroComboBox_Area.DataSource = mAreas;
            metroComboBox_Area.DisplayMember = "Text";
            metroComboBox_Area.ValueMember = "Value";
        }

        private void metroButton_Ok_Click(object sender, System.EventArgs e)
        {
            if (metroComboBox_Area.SelectedIndex == -1)
            {
                DialogResult = DialogResult.Cancel;
            }
            else
            {
                string text = metroComboBox_Area.SelectedValue.ToString();
                selectArea = Convert.ToInt32(text);
                DialogResult = DialogResult.OK;
            }
        }

        private void metroButton_Close_Click(object sender, System.EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}