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

namespace ProjetDotNet.fenetre
{
    public partial class FenetreChoixFormTransformation : Form
    {
        private metier.ListeForme tousLesFormes;
        private bool isClicked;
        private string name;

        public FenetreChoixFormTransformation(metier.ListeForme tousLesFormes)
        {
            isClicked = false;
            this.tousLesFormes = new metier.ListeForme(tousLesFormes.TousLesFormes); 
            InitializeComponent();
            this.tousLesFormes.GenerateTreeView(this.treeViewForme);
            name = null;
            
        }

        public string getName()
        {
            return name;
        }

        private void treeViewFormeSelected(object sender, TreeViewEventArgs e)
        {
            if (isClicked)
            {
                if (e.Node.ForeColor == Color.Black)
                {
                    name = e.Node.Text;
                    this.DialogResult = DialogResult.OK;

                    this.Close();
                }
            }
            else 
            { 
                this.treeViewForme.SelectedNode = null; 
            }
            isClicked = true;
        }
    }
}
