/// <summary>
        /// Initializes a new instance of the XHtmlTextBoxColumn class.
        /// </summary>
        public XHtmlTextBoxColumn(XHtmlDataGrid dataGrid)
        {
            if (dataGrid == null) throw new ArgumentNullException("dataGrid");
            DataGrid = dataGrid;

            Page = dataGrid.Page;
            ColumnType = ColumnType.Champ;
            Presentation = new XHtmlPresentation();
            ColumnHeader = new XHtmlDataGridColumnHeader();
            //!!!!!!!!!!Header = this;	// pour mettre la colonne en DataContext du Header (pour les bindings dans le style)

            string source = String.Format(CultureInfo.InvariantCulture, "[{0}].", dataGrid.Columns.Count);
            //§!!!!!!!!!!!base.Binding = new Binding(source + "Text");	// "base" permet d'éviter un pb en cas de surcharge de "Set_Binding"

            SetCellStyle(source);
        }
		public void ReadProperties(DVBuffer buffer)
		{
			ProprietesWpf property;
			uint idObj;	// variable de stockage temporaire des identifiants d'objets

			buffer.Get(out property);
			while (property != ProprietesWpf.PAGE_FIN)
			{
				switch (property)
				{
					case ProprietesWpf.PRESENTATION_GRILLE_MERE:	// Ident unique de la grille (unint) + Numéro de la cellule (début à 0)
						uint gridId;
						ushort cellIndex;
						buffer.Get(out gridId);
						buffer.Get(out cellIndex);
						Presentation.GridId = gridId;
						Presentation.CellIndex = cellIndex;
						break;

					case ProprietesWpf.PAGE_POSITION:				// position en x (ushort) et position en y (ushort)
						PositionLue = true;
						buffer.Get(out left);
						buffer.Get(out top);
						break;

					case ProprietesWpf.PAGE_TAILLE:					// largeur (ushort) et hauteur (ushort)
						TailleLue = true;
						buffer.Get(out OriginalWidth);
						buffer.Get(out OriginalHeight);
						break;

					case ProprietesWpf.PAGE_EFFACEMENT:				// type d'effacement (byte)
						byte overlapping;
						buffer.Get(out overlapping);
						this.Effacement = overlapping;
						SetOverlapping(overlapping);
						break;

					case ProprietesWpf.PAGE_ATTACHEMENT_DROITE:	// (uniquement si attachement à droite)
						attachementDroite = true;
						break;

					case ProprietesWpf.PAGE_ATTACHEMENT_BAS:		// (uniquement si attachement en bas)
						attachementBas = true;
						break;

					case ProprietesWpf.PAGE_LARGEUR_EXTENSIBLE:	// (uniquement si largeur variable)
						largeurVariable = true;
						break;

					case ProprietesWpf.PAGE_HAUTEUR_EXTENSIBLE:	// (uniquement si hauteur variable)
						hauteurVariable = true;
						break;

					case ProprietesWpf.PAGE_ARRET_SAISIE:			// numéro de point d'arrêt "Demande de saisie" (ushort)
						buffer.Get(out StopPoint);
						break;

					case ProprietesWpf.PAGE_COULEUR_FOND:			// identifiant de couleur (ushort)
						ushort idColor;
						buffer.Get(out idColor);
						CouleurDeFond = idColor;
//!!!!!!!!!!!						Brush background = Application.Current.Resources["Brush-" + idColor] as Brush;
//!!!!!!!!!!!!!						if (background != null) Background = background;
						break;


					case ProprietesWpf.BOUTON_DEBUT:						// Bouton (Xwin :  objet bouton)
						buffer.Get(out idObj);
						//!!!!!!!!!!!!!!!!!!!!!!!!!
						XHtmlButton button = (XHtmlButton)GetObject(idObj);
						if (button == null)
						{
							button = new XHtmlButton(this) { Id = idObj };
							Children.Add(button);
							ListOfObjects.Add(button);
						}
						button.ReadProperties(buffer);

						button.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());

						break;


					case ProprietesWpf.TEXTE_DEBUT:						// Label (Xwin : objet texte)
						{
							buffer.Get(out idObj);
							XHtmlLabel label = (XHtmlLabel)GetObject(idObj);
							if (label == null)
							{
								label = new XHtmlLabel(this) { Id = idObj };
								Children.Add(label);
								ListOfObjects.Add(label);
							}
							label.ReadProperties(buffer);
							label.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						}
						break;

					case ProprietesWpf.GROUPBOX_DEBUT:
						{
							buffer.Get(out idObj);
							XHtmlGroupBox groupe = (XHtmlGroupBox)GetObject(idObj);
							if (groupe == null)
							{
								groupe = new XHtmlGroupBox(this) { Id = idObj };
								Children.Add(groupe);
								ListOfObjects.Add(groupe);
							}
							groupe.ReadProperties(buffer);
							groupe.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						}
						break;

					#region Champ
					case ProprietesWpf.CHAMP_DEBUT:						// TextBox (Xwin : objet champ)
						buffer.Get(out idObj);
						XHtmlTextBox textBox = (XHtmlTextBox)GetObject(idObj);
						if (textBox == null)
						{
							textBox = new XHtmlTextBox(this) { Id = idObj };
							Children.Add(textBox);
							ListOfObjects.Add(textBox);
						}
						textBox.ReadProperties(buffer);
						textBox.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						break;
					#endregion Champ

					#region Multichoix
					case ProprietesWpf.MULTICHOIX_DEBUT:				// ComboBox (Xwin : objet multichoix)
						buffer.Get(out idObj);
						XHtmlComboBox comboBox = (XHtmlComboBox)GetObject(idObj);
						if (comboBox == null)
						{
							comboBox = new XHtmlComboBox(this) { Id = idObj };
							Children.Add(comboBox);
							ListOfObjects.Add(comboBox);
						}
						comboBox.ReadProperties(buffer);
						comboBox.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						break;
					#endregion Multichoix

					#region Case à cocher
					case ProprietesWpf.CASE_A_COCHER_DEBUT:			// CheckBox (Xwin : objet case à cocher)
						buffer.Get(out idObj);
						XHtmlCheckBox checkBox = (XHtmlCheckBox)GetObject(idObj);
						if (checkBox == null)
						{
							checkBox = new XHtmlCheckBox(this) { Id = idObj };
							Children.Add(checkBox);
							ListOfObjects.Add(checkBox);
						}
						checkBox.ReadProperties(buffer);
						checkBox.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						break;
					#endregion Case à cocher

					#region Groupe d'onglets
					case ProprietesWpf.GROUPE_ONGLET_DEBUT:					
						uint idTc;
						buffer.Get(out idTc);
						XHtmlTabControl tabControl; //  = Window.ListOfTabControls.FirstOrDefault(tc => (tc.Page.NumMasque == NumMasque && tc.Id == idTc));
//						if (tabControl == null)
						{
							tabControl = new XHtmlTabControl(this) { Id = idTc };
							// Window.ListOfTabControls.Add(tabControl);
						}
						//else
						//{
						//	tabControl.Page.Children.Remove(tabControl);
						//	tabControl.Page = this;
						//}
						Children.Add(tabControl); // on ajoute les groupes d'onglets à la page elle-même et non à InternalGrid pour pouvoir justement décaler InternalGrid par rapport aux onglets
						ListOfObjects.Add(tabControl); // !!!!!!!!!!!!!! bh je l'ai ajouté mais je ne sais pas si c utile
						tabControl.ReadProperties(buffer);
						tabControl.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						break;
					#endregion Groupe d'onglets


					case ProprietesWpf.GRILLE_DEBUT:									// Grille(s)
						SetGrid(buffer);
						break;

					#region Page panel
					case ProprietesWpf.PAGE_DEBUT:
						{
							string idPage;
							bool nouvelle = false;

							buffer.GetString(out idPage); // Id Page (string)

							XHtmlPage page = Window.GetPage(idPage);

							if (page == null)
							{
								nouvelle = true;
								page = new XHtmlPage(Window,this.Html) { Id = idPage, ParentPage = this };
								this.Html.Envois.Ajouter("nouveauPanel", this.Html.CalculerIdPage(page.Id));
								this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(page.Id)) ; // , page.StopPoint.ToString(), page.NumPage.ToString());
								page.ReadProperties(buffer);
								Window.ListOfPages.Add(page);
								page.JeSuisAffichee = true;

							}
							else
							{
								nouvelle = false;
								this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(page.Id)); // , page.StopPoint.ToString(), page.NumPage.ToString());
								page.ReadProperties(buffer);
								//!!!!!!!!!!!!!!!!!! que faut il faire ici ?
								// rien je pense : je envoie les objets modifiés
							}

							page.EnvoyerCouleurPositionAttachement(true);
							this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(page.Id), page.StopPoint.ToString(), page.NumPage.ToString());




							//ajout de la page panel à la cellule de grille (elle peut avoir été supprimée : cas des onglets)
							// bh on le fait de l'autre coté
							//if (page.Parent == null) AddToGrid(page);
							string p = "{" +
								        "\"idPanel\":\"" + this.Html.CalculerIdPage(page.Id) + "\"," +
										  "\"idMere\":\"" + Html.CalculerIdPage(this.Id) + "\"," +
										  "\"idGrille\":\"" + HtmlGlobal.CalculerId(page.Presentation.GridId, this.Id, this.Html.App.StackOfWindows.Count()) + "\"," +
										  "\"iCellule\":" + page.Presentation.CellIndex +
										  "}";

							this.Html.Envois.Ajouter("ajouterPanelAGrilleSiPasDedans",p);



						}
						break;
					#endregion Page panel



					#region Tableau
					case ProprietesWpf.TABLEAU_DEBUT:					// DataGrid (Xwin : objet tableau)
						buffer.Get(out idObj);
						XHtmlDataGrid dataGrid = (XHtmlDataGrid)GetObject(idObj);
						if (dataGrid == null)
						{
							dataGrid = new XHtmlDataGrid(this) { Id = idObj };
							Children.Add(dataGrid);
							ListOfObjects.Add(dataGrid);
						}
						dataGrid.ReadProperties(buffer);
						dataGrid.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count());
						break;
					#endregion Tableau



					case ProprietesWpf.BOUTONS_VALIDES_DEBUT:						// Boutons valides dans la page en cours
						ListOfValidButtons = new Collection<string>();
						buffer.Get(out property);
						while (property != ProprietesWpf.BOUTONS_VALIDES_FIN)
						{
							string buttonName;
							buffer.GetString(out buttonName);
							ListOfValidButtons.Add(buttonName);
							buffer.Get(out property);
						}
						break;

					default:
						throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.Page, property.ToString());
				}

				buffer.Get(out property);
			}

			SetSize(); // Mise à jour de la taille
			SetPosition(); // Mise à jour de la position
		}
        /// <summary>
        /// Reads the buffer for a page ID and a XwpfDataGrid Id and returns the corresponding XwpfDataGrid instance
        /// </summary>
        /// <param name="buffer">DVBuffer where the page and XwpfDataGrid IDs are read</param>
        /// <returns>instance of XwpfDataGrid matching the given page and XwpfDataGrid IDs</returns>
        private XHtmlDataGrid GetDataGrid(DVBuffer buffer, out XHtmlPage page)
        {
            XHtmlDataGrid retour,dataGrid;
            string idPage;
            uint idDataGrid;
            buffer.GetString(out idPage);			// Identifiant de la page (string)
            buffer.Get(out idDataGrid);			// Identifiant du tableau (uint)

            page = StackOfWindows.Peek().GetPage(idPage);

            retour = page.GetObject(idDataGrid) as XHtmlDataGrid;
            if (retour != null)
                return retour;

            // BH, si on ne le trouve pas, on le créée
            page = StackOfWindows.Peek().GetPage(idPage);

            dataGrid = new XHtmlDataGrid(page) { Id = idDataGrid };        // est ce que c'est le bon id ?
            page.Children.Add(dataGrid);
            page.ListOfObjects.Add(dataGrid);
            return dataGrid;
        }