#pragma once

namespace CLIMulticube {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Description résumée de FormFormat
	/// </summary>
	public ref class FormFormat : public System::Windows::Forms::Form
	{
	public:
		FormFormat(void)
		{
			InitializeComponent();
			//
			//TODO: ajoutez ici le code du constructeur
			//
		}

	protected:
		/// <summary>
		/// Nettoyage des ressources utilisées.
		/// </summary>
		~FormFormat()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::TabControl^  tab_fmt;
	protected: 
	private: System::Windows::Forms::TabPage^  tabPage1;
	private: System::Windows::Forms::TextBox^  txt_format_string;
	private: System::Windows::Forms::Label^  lbl_format_string;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::ListBox^  cb_format_type;
	private: System::Windows::Forms::Button^  cmd_annuler;
	private: System::Windows::Forms::Button^  cmd_ok;

	private:
		/// <summary>
		/// Variable nécessaire au concepteur.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
		/// le contenu de cette méthode avec l'éditeur de code.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(FormFormat::typeid));
			this->tab_fmt = (gcnew System::Windows::Forms::TabControl());
			this->tabPage1 = (gcnew System::Windows::Forms::TabPage());
			this->txt_format_string = (gcnew System::Windows::Forms::TextBox());
			this->lbl_format_string = (gcnew System::Windows::Forms::Label());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->cb_format_type = (gcnew System::Windows::Forms::ListBox());
			this->cmd_annuler = (gcnew System::Windows::Forms::Button());
			this->cmd_ok = (gcnew System::Windows::Forms::Button());
			this->tab_fmt->SuspendLayout();
			this->tabPage1->SuspendLayout();
			this->SuspendLayout();
			// 
			// tab_fmt
			// 
			this->tab_fmt->Controls->Add(this->tabPage1);
			this->tab_fmt->Location = System::Drawing::Point(1, 1);
			this->tab_fmt->Name = L"tab_fmt";
			this->tab_fmt->SelectedIndex = 0;
			this->tab_fmt->Size = System::Drawing::Size(325, 161);
			this->tab_fmt->TabIndex = 1;
			// 
			// tabPage1
			// 
			this->tabPage1->Controls->Add(this->txt_format_string);
			this->tabPage1->Controls->Add(this->lbl_format_string);
			this->tabPage1->Controls->Add(this->label1);
			this->tabPage1->Controls->Add(this->cb_format_type);
			this->tabPage1->Location = System::Drawing::Point(4, 22);
			this->tabPage1->Name = L"tabPage1";
			this->tabPage1->Padding = System::Windows::Forms::Padding(3);
			this->tabPage1->Size = System::Drawing::Size(317, 135);
			this->tabPage1->TabIndex = 0;
			this->tabPage1->Text = L"Nombre";
			this->tabPage1->UseVisualStyleBackColor = true;
			// 
			// txt_format_string
			// 
			this->txt_format_string->Location = System::Drawing::Point(154, 28);
			this->txt_format_string->Name = L"txt_format_string";
			this->txt_format_string->Size = System::Drawing::Size(144, 20);
			this->txt_format_string->TabIndex = 3;
			// 
			// lbl_format_string
			// 
			this->lbl_format_string->AutoSize = true;
			this->lbl_format_string->Location = System::Drawing::Point(151, 11);
			this->lbl_format_string->Name = L"lbl_format_string";
			this->lbl_format_string->Size = System::Drawing::Size(39, 13);
			this->lbl_format_string->TabIndex = 2;
			this->lbl_format_string->Text = L"Format";
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(8, 11);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(40, 13);
			this->label1->TabIndex = 1;
			this->label1->Text = L"Type : ";
			// 
			// cb_format_type
			// 
			this->cb_format_type->FormattingEnabled = true;
			this->cb_format_type->Items->AddRange(gcnew cli::array< System::Object^  >(6) {L"Automatique", L"Nombre", L"Pourcentage", 
				L"Date", L"Texte", L"Personnalisé"});
			this->cb_format_type->Location = System::Drawing::Point(8, 30);
			this->cb_format_type->Name = L"cb_format_type";
			this->cb_format_type->Size = System::Drawing::Size(120, 95);
			this->cb_format_type->TabIndex = 0;
			this->cb_format_type->SelectedIndexChanged += gcnew System::EventHandler(this, &FormFormat::cb_format_type_SelectedIndexChanged);
			// 
			// cmd_annuler
			// 
			this->cmd_annuler->DialogResult = System::Windows::Forms::DialogResult::Cancel;
			this->cmd_annuler->Location = System::Drawing::Point(247, 168);
			this->cmd_annuler->Name = L"cmd_annuler";
			this->cmd_annuler->Size = System::Drawing::Size(75, 23);
			this->cmd_annuler->TabIndex = 4;
			this->cmd_annuler->Text = L"&Annuler";
			this->cmd_annuler->UseVisualStyleBackColor = true;
			// 
			// cmd_ok
			// 
			this->cmd_ok->DialogResult = System::Windows::Forms::DialogResult::OK;
			this->cmd_ok->Location = System::Drawing::Point(166, 168);
			this->cmd_ok->Name = L"cmd_ok";
			this->cmd_ok->Size = System::Drawing::Size(75, 23);
			this->cmd_ok->TabIndex = 3;
			this->cmd_ok->Text = L"&OK";
			this->cmd_ok->UseVisualStyleBackColor = true;
			// 
			// FormFormat
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(325, 199);
			this->Controls->Add(this->cmd_annuler);
			this->Controls->Add(this->cmd_ok);
			this->Controls->Add(this->tab_fmt);
			this->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"$this.Icon")));
			this->MaximizeBox = false;
			this->MinimizeBox = false;
			this->Name = L"FormFormat";
			this->Text = L"Format de cellule";
			this->Load += gcnew System::EventHandler(this, &FormFormat::FormFormat_Load);
			this->tab_fmt->ResumeLayout(false);
			this->tabPage1->ResumeLayout(false);
			this->tabPage1->PerformLayout();
			this->ResumeLayout(false);

		}
#pragma endregion
		
public:
		#pragma region formatString
		property String^ FormatString
        {
            String^ get()
            {
                return txt_format_string->Text;
            }
            void set(String^ value)
            {
                txt_format_string->Text = value;
            }
        }
		#pragma endregion

		#pragma region CellFormatType
        property CLITableur::Cellule::FormatType CellFormatType
        {
            CLITableur::Cellule::FormatType get()
            {
                switch (cb_format_type->SelectedIndex)
                {
                    default:
                        return CLITableur::Cellule::FormatType::PERSONNALISE;
                       
                    case 0:
                        return CLITableur::Cellule::FormatType::AUTOMATIQUE;                       

                    case 1:
                        return CLITableur::Cellule::FormatType::NOMBRE;                        

                    case 2:
                        return CLITableur::Cellule::FormatType::POURCENTAGE;

                    case 3:
                        return CLITableur::Cellule::FormatType::DATE;

                    case 4:
                        return CLITableur::Cellule::FormatType::TEXT;
                }
            }
        }
		#pragma endregion
                
	private: System::Void FormFormat_Load(System::Object^  sender, System::EventArgs^  e) {
			if(CellFormatType == CLITableur::Cellule::FormatType::AUTOMATIQUE)
                cb_format_type->SelectedIndex = 0;                    

            if(CellFormatType == CLITableur::Cellule::FormatType::NOMBRE)
                cb_format_type->SelectedIndex = 1;
                    
            if(CellFormatType == CLITableur::Cellule::FormatType::POURCENTAGE)
                cb_format_type->SelectedIndex = 2;
                    
            if(CellFormatType == CLITableur::Cellule::FormatType::DATE)
                cb_format_type->SelectedIndex = 3;
                    
            if(CellFormatType == CLITableur::Cellule::FormatType::TEXT)
                cb_format_type->SelectedIndex = 4;
            
            if(CellFormatType == CLITableur::Cellule::FormatType::PERSONNALISE)
                cb_format_type->SelectedIndex = 5;
                    
	}
private: System::Void cb_format_type_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
			 if(CellFormatType == CLITableur::Cellule::FormatType::AUTOMATIQUE)
                txt_format_string->Text = "";
                
            if(CellFormatType == CLITableur::Cellule::FormatType::NOMBRE)
                txt_format_string->Text = "{0:n2}";     
		 }
};
}
