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

namespace HSUCO_Cargo_Garage_Operation_Program.CustomForm
{
    public partial class ManualPermission : MetroForm
    {
        private string _prifix = string.Empty;
        public int selectArea;

        public ManualPermission(string prifix, List<int> areas)
        {
            InitializeComponent();
            _prifix = prifix;
            metroComboBox_Area.Items.Clear();
            foreach (int i in areas)
            {
                metroComboBox_Area.Items.Add($"{prifix}-{i}");
            }
        }

        private void metroButton_Ok_Click(object sender, System.EventArgs e)
        {
            if (metroComboBox_Area.SelectedIndex == -1)
            {
                DialogResult = DialogResult.Cancel;
            }
            else
            {
                string text = metroComboBox_Area.Items[metroComboBox_Area.SelectedIndex].ToString();
                text = text.Replace($"{_prifix}-", "");
                selectArea = Convert.ToInt32(text);
                DialogResult = DialogResult.OK;
            }
        }

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