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 TIAOpennessGenerator
{
    public partial class AddDevice : Form
    {
        public static string Error;

        private TIAGenerator form;

        //Konstruktor
        public AddDevice(TIAGenerator instance)
        {
            InitializeComponent();
            this.form = instance;
        }
        
        //Přidání zařízení
        private void AddDevice_Button_Click(object sender, EventArgs e)
        {
            TreeNode Device = Device_Tree.SelectedNode;
            //Jak je pojmenovan Node
            string NodeName;

            if (Device == null)
                txt_Status.Text = "Je třeba vybrat typ a verzi zařízení";
            else
            {
                NodeName = Device.Name;

                if (NodeName != "Version")
                    txt_Status.Text = "Nevybrali jste verzi zařízení";
                else
                {
                    this.form.Device = Device;

                    this.form.AddDevice();

                    this.Close();  
                    this.Dispose();
                }

            }
        }

        //Tlačítko back
        private void btn_Back_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
