/// <summary>
        /// Initializes a new instance of the XHtmlButton class.
        /// </summary>
        public XHtmlButton(XHtmlPage page)
        {
            //!!!!!!!!!!!			InitializeComponent();
            Page = page;

            //!!!!!!!!!!!			Click += ClickHandler;
            //!!!!!!!!!!!PreviewMouseDown += PreviewMouseDownEffectsHandler;
            //!!!!!!!!!!!MouseEnter += MouseOverEffectsHandler;
            //!!!!!!!!!!!MouseLeave += MouseOverEffectsHandler;
            //!!!!!!!!!!!PreviewKeyDown += PreviewKeyDownHandler;
            //!!!!!!!!!!!LostFocus += LostFocusEventHandler;
        }
        /// <summary>
        /// Initializes a new instance of the XHtmlImage class.
        /// </summary>
        public XHtmlImage(XHtmlPage page)
        {
            Page = page;

            horizontalAlignment = HorizontalAlignment.Left;
            verticalAlignment = VerticalAlignment.Top;
            SnapsToDevicePixels = true;
            stretch = Stretch.None;

            //IsEnabledChanged += (sender, e) => Opacity = (bool)e.NewValue ? 1 : 0.4;
            //SizeChanged += (sender, e) => SetStretch(); // pour mettre à jour le stretch au redimensionnement
        }
 /// <summary>
 /// Initializes a new instance of the XHtmlLabel class.
 /// </summary>
 public XHtmlLabel(XHtmlPage page)
 {
     //			InitializeComponent();
     Page = page;
 }
        /// <summary>
        /// Reads the buffer to give the input to the proper object
        /// </summary>
        /// <param name="buffer">DVBuffer where the properties are read</param>
        /// <param name="page">Page containing the object getting the input</param>
        internal void ReadInput(DVBuffer buffer, XHtmlPage page)
        {
            IXHtmlEditableObject obj;

            uint id;	// variable de stockage temporaire des identifiants d'objets

            //page.UpdateLayout();

            ProprietesWpf property;
            buffer.Get(out property);
            switch (property)
            {
                #region Bouton
                case ProprietesWpf.BOUTON_DEBUT:						// Bouton (Xwin :  objet bouton)!!!!!!!!!!!!!!!!!!!!!!!!!
                    buffer.Get(out id);
                    var button = (XHtmlButton)page.GetObject(id);

                    if (button == null)
                    {
                        button = new XHtmlButton(page) { Id = id };
                        page.Children.Add(button);
                        page.ListOfObjects.Add(button);
                    }

                    button.ReadProperties(buffer);
                    page.Window.ActiveControl = button;
            //					button.IsEnabled = true;	// impératif pour être sûr que le bouton aura bien le focus (pas évident à cause de la gestion des boutons valides non faite côté serveur)
            //					button.Focusable = true;	// garde-fou. Le Focusable est repassé à false lors du lostFocus() (pour éviter qu'un bouton ne prenne le focus sans qu'on ne l'y autorise)
            //					button.Focus();
                    button.AjouterEnvoisUnObjet(this.Html.Envois, page, StackOfWindows.Count());
                    Html.Envois.Ajouter("xmeInput", page.Id.ToString(), HtmlGlobal.CalculerId(button.Id, page.Id, StackOfWindows.Count()));

                    obj = button;
                    break;
                #endregion Bouton

                #region Case à cocher
                case ProprietesWpf.CASE_A_COCHER_DEBUT:			// CheckBox (Xwin : objet case à cocher)
                    buffer.Get(out id);
                    var checkBox = (XHtmlCheckBox)page.GetObject(id);

                    if (checkBox == null)
                    {
                        checkBox = new XHtmlCheckBox(page) { Id = id };
                        page.Children.Add(checkBox);
                        page.ListOfObjects.Add(checkBox);
                    }

                    checkBox.ReadProperties(buffer);
                    page.Window.ActiveControl = checkBox;
                    checkBox.AjouterEnvoisUnObjet(this.Html.Envois, page, StackOfWindows.Count());
                    Html.Envois.Ajouter("xmeInput", page.Id.ToString(), HtmlGlobal.CalculerId(checkBox.Id, page.Id, StackOfWindows.Count()));
            //					checkBox.Focus();
                    obj = checkBox;
                    break;
                #endregion Case à cocher

                #region Champ
                case ProprietesWpf.CHAMP_DEBUT:						// TextBox (Xwin : objet champ)
                    buffer.Get(out id);
                    var textBox = (XHtmlTextBox)page.GetObject(id);

                    if (textBox == null)
                    {
                        textBox = new XHtmlTextBox(page) { Id = id };
                        page.Children.Add(textBox);
                        page.ListOfObjects.Add(textBox);
                    }
                    textBox.ReadProperties(buffer);
                    page.Window.ActiveControl = textBox;
                    textBox.AjouterEnvoisUnObjet(this.Html.Envois, page, StackOfWindows.Count());
                    Html.Envois.Ajouter("xmeInput", page.Id.ToString(), HtmlGlobal.CalculerId(textBox.Id, page.Id, StackOfWindows.Count()));
            //					textBox.EnFocus();
                    obj = textBox;
                    break;
                #endregion Champ

                #region MultiChoix
                case ProprietesWpf.MULTICHOIX_DEBUT:				// ComboBox (Xwin : objet multichoix)
                    buffer.Get(out id);
                    var comboBox = (XHtmlComboBox)page.GetObject(id);
                    if (comboBox == null)
                    {
                        comboBox = new XHtmlComboBox(page) { Id = id };
                        page.Children.Add(comboBox);
                        page.ListOfObjects.Add(comboBox);
                    }

                    comboBox.ReadProperties(buffer);
                    page.Window.ActiveControl = comboBox;
                    comboBox.AjouterEnvoisUnObjet(this.Html.Envois, page, StackOfWindows.Count());
                    Html.Envois.Ajouter("xmeInput", page.Id.ToString(), HtmlGlobal.CalculerId(comboBox.Id, page.Id, StackOfWindows.Count()));
            //					comboBox.Focus();
                    obj = comboBox;
                    break;
                #endregion MultiChoix

                //#region Champ Caché	!!!!!!!!!!!!!!!!!!!!!!
                //case ProprietesWpf.CHAMP_CACHE_DEBUT:				// PasswordBox (Xwin : objet champ caché)
                //   buffer.Get(out id);
                //   var passwordBox = (XHtmlPasswordBox)page.GetObject(id);
                //   passwordBox.ReadProperties(buffer);
                //   page.Window.ActiveControl = passwordBox.PasswordBox;
                //   passwordBox.Focus();
                //   obj = passwordBox;
                //   break;
                //#endregion Champ Caché

                //#region Champ Date
                //case ProprietesWpf.CHAMP_DATE_DEBUT:						// TextBox (Xwin : objet champ)
                //   buffer.Get(out id);
                //   var datePicker = (XHtmlDatePicker)page.GetObject(id);
                //   datePicker.ReadProperties(buffer);
                //   page.Window.ActiveControl = datePicker;
                //   datePicker.Focus();
                //   obj = datePicker;
                //   break;
                //#endregion Champ Date

                //#region MultiChoix
                //case ProprietesWpf.MULTICHOIX_DEBUT:				// ComboBox (Xwin : objet multichoix)
                //   buffer.Get(out id);
                //   var comboBox = (XHtmlComboBox)page.GetObject(id);
                //   comboBox.ReadProperties(buffer);
                //   page.Window.ActiveControl = comboBox;
                //   comboBox.Focus();
                //   obj = comboBox;
                //   break;
                //#endregion MultiChoix

                //#region Liste
                //case ProprietesWpf.LISTECHOIX_DEBUT:				// ListBox (Xwin : objet multichoix ouvert)
                //   buffer.Get(out id);
                //   var listBox = (XHtmlListBox)page.GetObject(id);
                //   listBox.ReadProperties(buffer);
                //   page.Window.ActiveControl = listBox;
                //   listBox.Focus();
                //   obj = listBox;
                //   break;
                //#endregion Liste

                //#region Groupe Radio
                //case ProprietesWpf.GROUPE_RADIO_DEBUT:				// Radiobutton (Xwin : objet groupe radio)
                //   buffer.Get(out id);
                //   var radioGroup = (XHtmlRadioGroup)page.GetObject(id);
                //   radioGroup.ReadProperties(buffer);
                //   page.Window.ActiveControl = radioGroup;
                //   radioGroup.Focus();
                //   obj = radioGroup;
                //   break;
                //#endregion Groupe Radio

                //#region RichText
                //case ProprietesWpf.RICHTEXT_DEBUT:					// RichTextBox (Xwin : objet texte riche)
                //   buffer.Get(out id);
                //   var richText = (XHtmlRichTextBox)page.GetObject(id);
                //   richText.ReadProperties(buffer);
                //   richText.Input();
                //   page.Window.ActiveControl = richText;
                //   richText.Focus();
                //   obj = richText;
                //   break;
                //#endregion RichText

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

            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  a faire !!!!!!!!!!!!!!!!!
            //StackOfWindows.Peek().UpdateLayout();			// force un recalcul des hauteurs/largeur pour être sûr que les valeurs dans le SetActiveGroup sont à jour
            //XHtmlTreeColumn.ResetCircles(StackOfWindows.Peek());
            //XHtmlGroupBox.SetActiveGroup((Control)obj);
            //ManageValidButtons(obj);
            //ManageValidMenuItems(obj);
            //ManageValidToolBarItems(obj);
            //ManageValidDataGrids(page.Id);
        }
        public void GetProperties(DVBuffer buffer)
        {
            string idPage; //stockage temporaire des id page, menuItem et toolbarItem
            ProprietesWpf property;
            XHtmlWindow window;
            XHtmlPage page = null;
            XHtmlDataGrid dataGrid;
            ushort? index = null; //pour renvoi d'un index colonne dans un tableau
            ushort? nbRows = null; //pour renvoi du nombre de lignes affichées dans un tableau
            string horizontalScrollbarTooltip = null; //pour renvoi de la bulle de l'ascenseur horizontal dans un tableau
            string verticalScrollbarTooltip = null; //pour renvoi de la bulle de l'ascenseur vertical dans un tableau
            int codepageBulleAscHor = 0, codepageBulleAscVer = 0;

            buffer.Get(out property);

            while (property != ProprietesWpf.CLIENTLEGER_FIN)
            {
                switch (property)
                {
                    case ProprietesWpf.CLIENTLEGER_DEBUT:
                        break;

                    case ProprietesWpf.MENU_SYSTEME_APERCU_ETAT:
                        byte printPreview;
                        buffer.Get(out printPreview);
                        IsPrintPreviewEnabled = (printPreview == 1);
            //						if (StackOfWindows.Any()) StackOfWindows.ToList()[0].UpdatePrintPreviewItem(IsPrintPreviewEnabled);
                        break;

                    case ProprietesWpf.MENU_SYSTEME_TRADUCTIONS:
                        buffer.GetString(out PrintPreviewText);
                        buffer.GetString(out CloseAllText);
                        buffer.GetString(out PrintCloseAllText);
                        buffer.GetString(out SavePrintPreviewText);
                        break;

                    case ProprietesWpf.COULEUR_CREATION_DEBUT:
                        XHtmlColor.Create(buffer,this.Html);
                        break;

                    case ProprietesWpf.POLICE_CREATION_DEBUT:
                        XHtmlFont.Create(buffer,this.Html);
                        break;

                    case ProprietesWpf.BORDURE_CREATION_DEBUT:
                        XHtmlBorder.Create(buffer,this.Html);
                        break;

                    case ProprietesWpf.PADDING_CREATION_DEBUT:
                        XHtmlPadding.Create(buffer,this.Html);
                        break;

                    #region Fenêtre
                    case ProprietesWpf.FENETRE_DEBUT:					// Id Masque (ushort) et Id Page (byte)
                        // ne concerne que les "vraies" fenêtres (i.e. : les fenêtres autres que la toute première, ouverte dans app.xaml.cs)

                        //Window lastWindow = StackOfWindows.Peek();
                        //if (!lastWindow.IsVisible) lastWindow.Show();
                        //lastWindow.IsEnabled = false;

                        window = new XHtmlWindow(); //  { Owner = lastWindow, ShowInTaskbar = false };
                        buffer.GetString(out window.MaskName);
                        buffer.Get(out window.PageNum);
                        window.ReadProperties(buffer);
                        window.Id = window.MaskName.Replace('.', '_') + "_" + window.PageNum.ToString() + "_" + (StackOfWindows.Count + 1).ToString();
                        StackOfWindows.Push(window);

                        ListeParametresComplementaires lc = new ListeParametresComplementaires();
                        lc.Ajouter("ty", window.minContentHeight.ToString());
                        lc.Ajouter("tx", window.minContentWidth.ToString());
                        lc.Ajouter("idFen", window.Id);
                        lc.Ajouter("libelle", window.MaskName);
                        lc.Ajouter("numpage", window.PageNum.ToString());

                        lc.Ajouter("tailleFixe", (window.ModeResize == System.Windows.ResizeMode.NoResize) ? "true" : "false");
                        lc.Ajouter("couleurFond", XHtmlColor.PrefixeCssFond + window.CouleurFond.ToString());
                        lc.Ajouter("titre", window.Title);
                        if (window.icon != null)
                            lc.Ajouter("icone", window.icon.Css);

                        string chaineFenetre = HtmlGlobal.ToJsonString(lc, this.Html.JsonParamCompl, false);
                        {
                            UnParametreEnvoye p = new UnParametreEnvoye();
                            p.commande = "ouvrirFenetre";
                            this.Html.Envois.commandes.Add(p);
                            p.valeur = chaineFenetre;
                        }
                        break;

                    case ProprietesWpf.FENETRE_TITRE:					// Titre de la fenêtre (string)
                        {
                            string title;
                            int codePage;
                            buffer.Get(out codePage);
                            buffer.GetStringCP(out title, codePage);
                            StackOfWindows.Peek().Title = title;

                            UnParametreEnvoye p = new UnParametreEnvoye();
                            p.commande = "xmeTitle";
                            this.Html.Envois.commandes.Add(p);
                            p.valeur = title;
                        }
                        break;

                    case ProprietesWpf.FENETRE_ICONE:					// Titre de la fenêtre (string)
                        var icon = new XHtmlImageFile();
                        icon.ReadProperties(buffer);
                        // StackOfWindows.Peek().SetIcon(icon);
                        break;

                    case ProprietesWpf.FENETRE_TAILLE_INITIALE:		// Taille de référence pour les calculs d'attachement - Hauteur (ushort) x Largeur (ushort)
                        window = StackOfWindows.Peek();
                        buffer.GetString(out window.MaskName);
                        buffer.Get(out window.PageNum);
                        window.SetMinContentSize(buffer);

                        this.Html.Envois.Ajouter("fenetreTailleInitiale",
                                window.MaskName + "," +
                                window.PageNum.ToString() + "," +
                                window.minContentWidth.ToString() + "," +
                                window.minContentHeight.ToString()
                            );

                        break;

                    case ProprietesWpf.FENETRE_FERMETURE:				// Pour fermer la fenêtre en cours
                        window = StackOfWindows.Pop();

                        this.Html.Envois.Ajouter("fermerFenetre", window.Id);

                        //FenetresADepiler.Push(window);
                        //window.Closing -= window.ClosingHandler;
                        //StackOfWindows.Peek().IsEnabled = true; // ne pas remplacer par "window": le StackOfWindow.Peek a changé de valeur à cause du pop() !
                        // window.Close();

                        break;
                    #endregion Fenêtre

                    case ProprietesWpf.PAGE_DEBUT:
                        buffer.GetString(out idPage); // Id Page (string)

                        window = StackOfWindows.Peek();
                        page = window.GetPage(idPage);
                        if (page == null)
                        {
                            window.ListOfPages.Add(page = new XHtmlPage(window,this.Html) { Id = idPage });
                            this.Html.Envois.Ajouter("nouvellePage", this.Html.CalculerIdPage(page.Id));
                            page.JeSuisAffichee = true;
                        }
                        // une page peut être supprimée (dans la gestion de l'effacement d'une autre page), il faut donc la remettre dans la fenêtre le cas échéant
                        //if (!window.MainCanvas.Children.Contains(page)) window.MainCanvas.Children.Add(page);
                        if (page.JeSuisAffichee == false)
                        {
                            this.Html.Envois.Ajouter("remettrePage", this.Html.CalculerIdPage(page.Id));
                        }
                        // cette ligne était plus bas, mais trop tard
                        this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(page.Id), page.StopPoint.ToString(), page.NumPage.ToString());
                        page.JeSuisAffichee = true;
                        // - lecture de la page et des objets
                        page.ReadProperties(buffer);

                        // je la remet aussi ici car avec les panels ca bouge !
                        this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(page.Id), page.StopPoint.ToString(), page.NumPage.ToString());
                        page.EnvoyerCouleurPositionAttachement(false);

                        // on affiche la fenêtre si c'est la toute première page et si la fenêtre n'est pas masquée (application sans fenêtre)
                        // !!!!!!!!!!if (!page.Window.IsVisible && application.Client.FenetreMereHide == 0)
                        // !!!!!!!!!!	page.Window.Show();
                        break;

                    case ProprietesWpf.TABLEAU_DEBUT:								// Mise à jour d'une propriété du tableau

                        dataGrid = GetDataGrid(buffer,out page);
                        dataGrid.ReadProperties(buffer);
                        dataGrid.AjouterEnvoisUnObjet(Html.Envois, page, Html.App.StackOfWindows.Count());
                        break;

                    case ProprietesWpf.TABLEAU_ASCHOR_A_GAUCHE:					// retour au début de la ligne d'un tableau
                        dataGrid = GetDataGrid(buffer,out page);
                        // ScrollIntoView sur la colonne dont le DisplayIndex est = FrozenColumnCount pour mettre l'ascenseur à gauche.
                        // (en tenant compte des colonnes figées)
                        // attention : le tableau peut être vide, d'où le "if Rows.Count > 0"
                        var column = dataGrid.Columns.FirstOrDefault(col => col.DisplayIndex == dataGrid.FrozenColumnCount);
                        //!!!!!!!!!!if (dataGrid.Rows.Count > 0 && column != null)
                        //!!!!!!!!!!	dataGrid.ScrollIntoView(dataGrid.Rows[0], column);
                        break;

                    case ProprietesWpf.TABLEAU_REMPLISSAGE_DEBUT:				// Remplissage du tableau
                        dataGrid = GetDataGrid(buffer,out page);
                        dataGrid.Fill(buffer);
                        dataGrid.AjouterEnvoisUnObjetRemplissageTableau(Html.Envois, page, Html.App.StackOfWindows.Count());
                        break;

                    #region Fonctions Get du tableau
                    case ProprietesWpf.TABLEAU_ASCHOR_GET_BULLE:					// Demande le texte de la bulle de l'ascenseur horizontal
                        dataGrid = GetDataGrid(buffer,out page);
                        horizontalScrollbarTooltip = dataGrid.HorizontalScrollBarToolTip;
                        codepageBulleAscHor = dataGrid.CodepageBulleAscHor;
                        break;

                    case ProprietesWpf.TABLEAU_ASCVER_GET_BULLE:					// Demande le texte de la bulle de l'ascenseur vertical
                        dataGrid = GetDataGrid(buffer,out page);
                        verticalScrollbarTooltip = dataGrid.VerticalScrollBarToolTip;
                        codepageBulleAscVer = dataGrid.CodepageBulleAscVer;
                        break;

                    case ProprietesWpf.TABLEAU_GET_NOMBRE_LIGNES:				// Demande du nombre de lignes affichables dans le tableau
                        {
                            string id = GetIdentDataGrid(buffer);
                            // dataGrid = GetDataGrid(buffer);
                            //!!!!!!!!!! dataGrid.UpdateLayout();	// indispensable, sinon le nombre de lignes envoyé au premier affichage du tableau est potentiellement faux (peut poser pb par la suite)
                            nbRows = 32; //  dataGrid.GetRowCount();
                            Html.Envois.Ajouter("tabGetNbLig", id);
                        }
                        break;

                    case ProprietesWpf.TABLEAU_GET_COL_SAISIE_PREMIERE:		// Demande le numéro de la première colonne en saisie dans la ligne donnée
                        dataGrid = GetDataGrid(buffer,out page);
                        index = dataGrid.GetFirstColumnIndex(buffer);
                        break;

                    case ProprietesWpf.TABLEAU_GET_COL_SAISIE_DERNIERE:		// Demande le numéro de la dernière colonne en saisie dans la ligne donnée
                        dataGrid = GetDataGrid(buffer,out page);
                        index = dataGrid.GetLastColumnIndex(buffer);
                        break;

                    case ProprietesWpf.TABLEAU_GET_COL_SAISIE_PRECEDENTE:		// Demande le numéro de la colonne précédente en saisie dans la ligne donnée
                        dataGrid = GetDataGrid(buffer,out page);
                        index = dataGrid.GetPreviousColumnIndex(buffer);
                        break;

                    case ProprietesWpf.TABLEAU_GET_COL_SAISIE_SUIVANTE:		// Demande le numéro de la colonne suivante en saisie dans la ligne donnée
                        dataGrid = GetDataGrid(buffer,out page);
                        index = dataGrid.GetNextColumnIndex(buffer);
                        break;
                    #endregion Fonctions Get du tableau

                    #region Input
                    case ProprietesWpf.XMEINPUT:
                        AsynchronousResponse = null; // garde-fou
                        buffer.GetString(out idPage);
                        window = StackOfWindows.Peek();
                        window.CurrentPage = window.GetPage(idPage);

                    //!!!!!!!!!!!!!!!!!!!!!!! idem pour consult etc....
            //						this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(window.CurrentPage.Id), window.CurrentPage.StopPoint.ToString(), page.NumPage.ToString());
                        this.Html.Envois.Ajouter("pageCourante", Html.CalculerIdPage(window.CurrentPage.Id), window.CurrentPage.StopPoint.ToString(), window.CurrentPage.NumPage.ToString());

                        ReadInput(buffer, window.CurrentPage);
            //						busyTimer.Stop();
            //						window.Cursor = null;
                        AttenteInput = true; // nécessairement à la fin pour que le HeightChanging potentiellement
                        // envoyé lors du UpdateLayout() contenu dans le readInput soit pris en compte et envoyé en différé
                        break;
                    #endregion Input

                    case ProprietesWpf.XMECONSULT:
                        buffer.GetString(out idPage);
                        Consult(idPage, null);
                        Html.Envois.Ajouter("xmeConsult", idPage);
                        break;

                    #region List Consult
                    case ProprietesWpf.XMELISTCONSULT:
                        {
                            uint idDataGrid;
                            buffer.GetString(out idPage);
                            buffer.Get(out idDataGrid);
                            Consult(idPage, null);
                            Html.Envois.Ajouter("xmeConsult", idPage);

                            string id = Html.CalculerIdDataGrid(idDataGrid, idPage);

                            //dataGrid = Consult(idPage, idDataGrid) as XHtmlDataGrid;
                            //dataGrid.SetIsActive(true); // nécessairement APRES le ManageValidDataGrids() dans le consult car ce dernier RAZ toutes les DataGrids affichées

                            // traitement des ronds dans l'entête de la colonne arbre le cas échéant
                            byte treeCount;
                            buffer.Get(out treeCount);
                            if (treeCount > 0)
                            {
                               byte treeCurrent;
                               buffer.Get(out treeCurrent);
                            //   XHtmlTreeColumn treeColumn = dataGrid.Columns.FirstOrDefault(col => ((IXHtmlDataGridColumn)col).ColumnType == ColumnType.Arbre) as XHtmlTreeColumn;
                            //   if (treeColumn != null) treeColumn.SetCircles(treeCount, treeCurrent);
                            }
                        }
                        break;
                    #endregion List Consult

                    case (ProprietesWpf)161 :
            //		ClientLegerProprietes.PROPCLIENTLEGER_AFFICHEERREUR:
                        AfficherErreurTransmise(buffer);
                        break;

                    case ProprietesWpf.FENETRE_ATTACHER_TOOLBARS_DEBUT:		// Bordel des toolbars
                        buffer.Get(out property);
                        while (property != ProprietesWpf.FENETRE_ATTACHER_TOOLBARS_FIN)
                        {
                            //switch (property)
                            {
                                //case ProprietesWpf.TOOLBAR_DEBUT:							// Création de toolbar

                                //   buffer.Get(out idToolBar);
                                //   toolBar = GetXwpfToolBar(idToolBar);

                                //   if (toolBar == null) listOfToolBars.Add(toolBar = new XwpfToolBar { Id = idToolBar });

                                //   toolBar.ReadProperties(buffer);
                                //   break;

                                //case ProprietesWpf.TOOLBAR_RECONSTRUCTION_DEBUT:							// Reconstruction de toolbar
                                //   buffer.Get(out idToolBar);
                                //   toolBar = GetXwpfToolBar(idToolBar);

                                //   if (toolBar == null) listOfToolBars.Add(toolBar = new XwpfToolBar { Id = idToolBar });

                                //   toolBar.ItemsList.Clear();
                                //   toolBar.ReadProperties(buffer);
                                //   foreach (XwpfWindow windowFromStack in StackOfWindows)
                                //   {
                                //      ToolBarTray toolBarTray = (toolBar.Primary) ? windowFromStack.PrimaryToolBarTray : windowFromStack.SecondaryToolBarTray;

                                //      ToolBar toolBarInList = toolBarTray.ToolBars.FirstOrDefault(tb => tb.DataContext == toolBar);
                                //      if (toolBarInList != null) toolBar.Display(windowFromStack, toolBarInList);
                                //   }
                                //   break;

                                //case ProprietesWpf.FENETRE_ATTACHER_TOOLBAR:				// Pour attacher une toolbar (identifiant menu: ushort)
                                //   buffer.Get(out idToolBar);
                                //   GetXwpfToolBar(idToolBar).Display(StackOfWindows.Peek());
                                //   break;

                                //case ProprietesWpf.FENETRE_DETTACHER_TOOLBAR:			// Pour supprimer une toolbar (identifiant menu: ushort)
                                //   buffer.Get(out idToolBar);
                                //   XwpfToolBar.Remove(idToolBar);
                                //   break;

                                //default:
                                //	throw new XwpfException(XwpfErrorCodes.UnknownProperty, XwpfErrorLocations.Application, property.ToString());
                            }
                            buffer.Get(out property);
                        }
                        break;

                    default:
                        throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.Application, property.ToString());
                }
                buffer.Get(out property);
            }

            var response = new DVBuffer();

            #region Réponse asynchrone
            //if (AsynchronousResponse != null && AttenteInput)	 // impossible d'avoir un double-clic en input
            //   AsynchronousResponse = null;
            //if (AsynchronousResponse != null && AttenteConsult)
            //{
            //   SetInputBuffer(AsynchronousResponse);
            //   Send(AsynchronousResponse); // response déjà replie dans le Handler mais pas encore envoyée pour synchronisation
            //   AsynchronousResponse = null;
            //   responseAlreadySent = true; // Pour bloquer le Send(response) vide dans Analyse()
            //   return;
            //}
            #endregion Réponse asynchrone

            #region Réponse asynchrone intertâche
            //if (interTaskResponses.Count > 0) // si réveil intertâche en attente
            //{
            //   if (AttenteInput) interTaskResponses.Clear(); // en input : r.à.z. de la liste des dialogues intertâches en attente
            //   else if (AttenteConsult || AttenteGetb)
            //   {
            //      SendInterTaskResponse();
            //      responseAlreadySent = true; // Pour bloquer le Send(response) vide dans Analyse()
            //      return;
            //   }
            //}
            #endregion Réponse asynchrone intertâche

            #region nb lignes tableau

            // positionne responseAlreadySend et c'est tout

            if (nbRows.HasValue)
            {
                //response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);
                //response.Put(ProprietesWpf.TABLEAU_NOMBRE_LIGNES);
                //response.Put(nbRows.Value);
                //Send(response);
                responseAlreadySent = true;					// Pour bloquer le Emettre(response) vide dans Analyser()
                return;
            }
            #endregion nb lignes tableau

            #region index colonne tableau
            if (index.HasValue)
            {
                response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);
                response.Put(ProprietesWpf.TABLEAU_COLONNE_SAISIE);
                response.Put(index.Value);
                Send(response);
                responseAlreadySent = true;							// Pour bloquer le Emettre(response) vide dans Analyser()
                return;
            }
            #endregion index colonne tableau

            #region bulle scrollbar horizontale tableau
            if (horizontalScrollbarTooltip != null)
            {
                response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);
                response.Put(ProprietesWpf.TABLEAU_ASCHOR_BULLE);
                response.PutStringCP(horizontalScrollbarTooltip, codepageBulleAscHor);
                Send(response);
                responseAlreadySent = true;						// Pour bloquer le Emettre(response) vide dans Analyser()
                return;
            }
            #endregion bulle scrollbar horizontale tableau

            #region bulle scrollbar verticale tableau
            if (verticalScrollbarTooltip != null)
            {
                response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);
                response.Put(ProprietesWpf.TABLEAU_ASCVER_BULLE);
                response.PutStringCP(verticalScrollbarTooltip, codepageBulleAscVer);
                Send(response);
                responseAlreadySent = true;						// Pour bloquer le Emettre(response) vide dans Analyser()
                return;
            }
            #endregion bulle scrollbar verticale tableau

            #region Retour Fonction YGraph (FA)
            //retour normal (ident ou retour par defaut)
            //if (yDrawingOperationRet.HasValue)
            //{
            //   response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);
            //   response.Put(yDrawingIsCreation ? yDrawingOperationRet.Value : (int)yDrawingOperationRet.Value);					//	pas de propriétéWPF identifiant la valeur de retour (14/09/2011)
            //   Send(response);
            //   responseAlreadySent = true;					// Pour bloquer le Emettre(response) vide dans Analyser()
            //   return;
            //}
            ////retour de la taille ecran
            //if (yScreenSize.HasValue)
            //{
            //   response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);
            //   response.Put((int)yScreenSize.Value.Width);					//	pas de propriétéWPF identifiant la valeur de retour (21/09/2011)
            //   response.Put((int)yScreenSize.Value.Height);

            //   Send(response);
            //   responseAlreadySent = true;					// Pour bloquer le Emettre(response) vide dans Analyser()
            //   return;
            //}
            #endregion //Retour Fonction YGraph (FA)

            #region Paramètres Initiaux Agenda
            //if (responseCalendarInit != null)
            //{
            //   Send(responseCalendarInit);
            //   responseAlreadySent = true;					// Pour bloquer le Emettre(response) vide dans Analyser()
            //}
            #endregion Paramètres Initiaux Agenda
        }
		public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
		{
			ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();
			ListeParametresEnvoyes paramsGrille = new ListeParametresEnvoyes();

			paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id));

			// presentation
			if (Tag != null)
				this.Tag.GenererHtml(paramsValeurs, this.Page.Html, 0, false);

			GridJson gj = new GridJson();
			gj.nbCellules = this.Cellules.Count();
			gj.vertical = this.Orientation == 1;
			gj.modePourcent = true;
			gj.tailleX = (int)this.Tag.OriginalWidth;
			gj.tailleY = (int)this.Tag.OriginalHeight;

			foreach (XHtmlCelluleGrille cell in this.Cellules)
			{
				CellJson gc = new CellJson();
				gj.cellules.Add(gc);
				gc.avecResize = cell.AvecResize;
//				if (cell.Presentation.idFond.HasValue)
//					gc.fond = page.Html.App.GenererUneValeurDeCouleur(cell.Presentation.idFond);
				gc.posX = (int)cell.Presentation.Left;
				gc.posY = (int)cell.Presentation.Top;
				gc.tailleX = (int)cell.Presentation.OriginalWidth;
				gc.tailleY = (int)cell.Presentation.OriginalHeight;
			}

			paramsGrille.Ajouter("paramsGrille", HtmlGlobal.ToJsonString(gj, this.Page.Html.JsonGrille, false));

			envois.Ajouter("creerGrille", HtmlGlobal.ToJsonString(paramsGrille, this.Page.Html.JsonParamsEnvoyes, false), HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
			envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));

			string p;
			if (this.Tag.GridId != 0)
			{
				p = "{" +
							"\"idGrille\":\"" + HtmlGlobal.CalculerId(this.Tag.GridId, this.Page.Id, niveau) + "\"," +
							"\"iCellule\":" + this.Tag.CellIndex +
							"}";
			}
			else
			{
				p = "{" +
							"\"idGrille\":\"" + "0" + "\"," +
							"\"iCellule\":" + 0 +
							"}";
			}
			
			envois.Ajouter("ajouterGrille", p); 
		}
		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
		}
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();
            ListeParametresEnvoyes paramsCreation = new ListeParametresEnvoyes();

            OngletVersJson cc = new OngletVersJson();

            paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id));

            if (this.idPolice.HasValue)
                cc.police = XHtmlFont.PrefixeCss + idPolice.ToString();

            if (this.idPadding.HasValue)
                cc.padding = XHtmlPadding.PrefixeCss + idPadding.ToString();

            if (this.ImageHeight.HasValue)
                cc.hauteurImage = this.ImageHeight;

            if (this.ImageWidth.HasValue)
                cc.largeurImage = this.ImageWidth;

            cc.multiLigne = this.IsMultiLine;

            cc.pointArret = this.stopPoint;
            cc.pageCourante = this.currentTabPageNum;

            if (Presentation != null)
                this.Presentation.GenererHtml(paramsValeurs, this.Page.Html, 0, false);

            foreach (XHtmlTabItem item in this.Items)
            {
                cc.items.Add(item.AjouterEnvoisUnItem(envois,page,niveau));
            }

            string parametresJson = HtmlGlobal.ToJsonString(cc, this.Page.Html.JsonParametresOnglet, false);
            paramsCreation.Ajouter("paramsCreation", parametresJson);

            //UnParametreEnvoye p = new UnParametreEnvoye();

            envois.Ajouter("creerOnglet", HtmlGlobal.ToJsonString(paramsCreation, this.Page.Html.JsonParamsEnvoyes, false), HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
        }
 /// <summary>
 /// Initializes a new instance of the XHtmlGroupBox class.
 /// </summary>
 public XHtmlGroupBox(XHtmlPage page)
 {
     //			InitializeComponent();
     Page = page;
 }
        //#region Ecouteurs
        ///// <summary>
        ///// Gestionnaire d'évènement "PreviewKeyDown" pour la fonction XMEInput
        ///// </summary>
        //private static void PreviewKeyDownHandler(object sender, KeyEventArgs e)
        //{
        //   var application = ((App)Application.Current).Appli;
        //   if (!application.AttenteInput) // cas impossible en théorie: un contrôle ne peut pas avoir le focus sans que l'on soit en Input
        //   {
        //      e.Handled = true;
        //      return;
        //   }
        //   if (e.Key == Key.Apps)
        //   {
        //      // TODO simuler un clic droit sur touche windows 2
        //      e.Handled = true;
        //   }
        //   string key;
        //   // Touches de fonction (Fn)
        //   if (e.Key == Key.System && e.SystemKey == Key.F10) key = "F10";
        //   else if (XHtmlApplication.FnKeys.Contains(e.Key)) key = e.Key.ToString();
        //   // Autres touches
        //   else // pas la peine de faire les tests spécifiques si une touche générique (Fn) a déjà été détetée
        //   {
        //      if (ValidKeys.Contains(e.Key) || (
        //            (Keyboard.Modifiers & ModifierKeys.Control) != 0
        //            && (Keyboard.Modifiers & ModifierKeys.Alt) == 0
        //            && ValidModifiedKeys.Contains(e.Key))
        //         )
        //         key = e.Key.ToString();
        //      else return; // les touches restantes ne sont pas bloquées
        //   }
        //   e.Handled = true;
        //   application.SendInputKeyDown(key);
        //}
        ///// <summary>
        ///// Gestionnaire d'évènement "PreviewMouseDown"
        ///// </summary>
        //private void PreviewMouseDownHandler(object sender, MouseButtonEventArgs e)
        //{
        //   if (IsReadOnly) // si IsReadOnly, on ne notifie pas l'appli
        //   {
        //      e.Handled = true;
        //      return;
        //   }
        //   // on laisse passer les clics gauches (simples & doubles) en input (géré par wpf)
        //   if (Page.Window.ActiveControl == this && e.ChangedButton == MouseButton.Left) return;
        //   ((App)Application.Current).Appli.SendMouseDown(this, e);
        //}
        ///// <summary>
        ///// Envoi des infos à l'appli pour ouverture de zoom
        ///// </summary>
        //private void ZoomButtonClickHandler(object sender, RoutedEventArgs e)
        //{
        //   e.Handled = true;
        //   var application = ((App)Application.Current).Appli;
        //   var response = new DVBuffer();
        //   response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);				//début de l'acquittement ou de la réponse
        //   application.SetInputBuffer(response);
        //   response.Put(ProprietesWpf.EVENEMENT_SOURIS_DEBUT);		// Début de l'envoi des évenements souris
        //   response.Put(ProprietesWpf.SOURIS_TYPE_EVENEMENT);			// Type d'évènement souris (byte)
        //   if (((App)Application.Current).Client.VersionInterneServeur <= 1)
        //      response.Put((byte)MouseEvent.ZoomCall);
        //   else
        //      response.Put((byte)(MouseEvent.ZoomComboCall));
        //   response.Put(ProprietesWpf.EVENEMENT_SOURIS_FIN);			// Fin de l'envoi des évenements souris
        //   application.Send(response);
        //}
        //#endregion Ecouteurs
        //// D & D non implémenté pour cause d'incompatibilité avec la gestion des mouseUp et MouseDown
        //#region Drag & Drop
        //public void PreviewMouseLeftButtonDownHandler(object sender, MouseEventArgs e)
        //{
        //   if (e == null) throw new ArgumentNullException("e");
        //   startPoint = e.GetPosition(null);
        //}
        //public void PreviewMouseMoveHandler(object sender, MouseEventArgs e)
        //{
        //   if (e == null) throw new ArgumentNullException("e");
        //   if (isDragging) return;
        //   if (e.LeftButton != MouseButtonState.Pressed) return;
        //   // on ne déclenche le drag&drop que si la souris a été suffisament déplacée
        //   Vector diff = startPoint - e.GetPosition(null);
        //   if (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
        //       Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
        //   {
        //      isDragging = true;
        //      DataObject data = new DataObject(DataFormats.UnicodeText, Text);
        //      DragDrop.DoDragDrop(this, data, DragDropEffects.All);
        //      isDragging = false;
        //   }
        //}
        //#endregion Drag & Drop
        /// <summary>
        /// ajouter les commandes necessaires pour le client
        /// </summary>
        /// <param name="envois"></param>
        /// <param name="page"></param>
        /// <param name="niveau"></param>
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();

            paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id));

            if (IsReadOnly.HasValue)
                paramsValeurs.Ajouter("lectureSeule", (bool)IsReadOnly ? "true" : "false");

            if (Presentation != null)
                this.Presentation.GenererHtml(paramsValeurs, this.Page.Html,this.CodePage,false);

            if (this.textHasValue)											// pour le caché etc, apres la presentation
                paramsValeurs.Ajouter("texteChamp", this.Text);

            paramsValeurs.Ajouter("pointSequence", this.SeqPoint.ToString(), page.NumPage.ToString());

            // n'est envoyé que pourle champ en cours de saisie
            if (this.MaxLengthProperty != 0)
                paramsValeurs.Ajouter("tailleSaisie", this.MaxLengthProperty.ToString());

            if (this.ListOfValidButtons != null && this.ListOfValidButtons.Count > 0)
            {
                StringBuilder vb = new StringBuilder();
                vb.Append("@");
                foreach (string n in ListOfValidButtons)
                {
                    vb.Append(n);
                    vb.Append("@");
                }
                paramsValeurs.Ajouter("boutonsValides", vb.ToString());
            }

            UnParametreEnvoye p = new UnParametreEnvoye();

            envois.Ajouter("creerObjet", "<input type='text'/>", HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
            envois.Ajouter("ajoutObjetCourant", "");
        }
        /// <summary>
        /// Initializes a new instance of the XHtmlTextBox class.
        /// </summary>
        public XHtmlTextBox(XHtmlPage page)
        {
            //			InitializeComponent();
            Page = page;

            //			PreviewKeyDown += PreviewKeyDownHandler;
            //			PreviewMouseDown += PreviewMouseDownHandler;
            //GotFocus += (sender, e) =>
            //{
            //   TextAlignment = TextAlignment.Left;
            //   SelectAll();
            //};

            //LostFocus += (sender, e) =>
            //{
            //   text = Text;
            //   Presentation.SetCadrage();
            //   if (isNumerical && Presentation != null && Presentation.Cadrage == Cadrage.Defaut)
            //      TextAlignment = TextAlignment.Right;
            //};
        }
 public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois,XHtmlPage page,int niveau)
 {
     throw new NotImplementedException();
 }
        /*
        #region Ecouteurs
        /// <summary>
        /// Gestionnaire d'évènement "PreviewKeyDown" pour la fonction XMEInput
        /// </summary>
        ///
        private void PreviewKeyDownHandler(object sender, KeyEventArgs e)
        {
            var application = ((App)Application.Current).Appli;

            if (!application.AttenteInput) // cas impossible en théorie: un contrôle ne peut pas avoir le focus sans que l'on soit en Input
            {
                e.Handled = true;
                return;
            }

            string key;

            // Touches de fonction (Fn)
            if (e.Key == Key.System && e.SystemKey == Key.F10) key = "F10";
            else if (XHtmlApplication.FnKeys.Contains(e.Key)) key = e.Key.ToString();

            // Autres touches
            else // pas la peine de faire les tests spécifiques si une touche générique (Fn) a déjà été détetée
            {
                if ((e.Key == Key.Return && !IsDropDownOpen) ||			// ne pas traiter quand combobox ouverte : géré par wpf
                        (e.Key == Key.Enter && !IsDropDownOpen) ||		// ne pas traiter quand combobox ouverte : géré par wpf
                        (e.Key == Key.Escape && !IsDropDownOpen) ||		// ne pas traiter quand combobox ouverte : géré par wpf
                        (e.Key == Key.Back && !IsDropDownOpen) ||			// ne pas traiter quand combobox ouverte : géré par wpf
                        (e.Key == Key.Tab && !IsDropDownOpen) ||			// ne pas traiter quand combobox ouverte : géré par wpf
                    //e.Key == Key.Space ||		// ne pas traiter : géré par wpf

                        e.Key == Key.Insert ||

                    //e.Key == Key.Next ||		// ne pas traiter : géré par wpf
                    //e.Key == Key.Prior ||		// ne pas traiter : géré par wpf
                    //e.Key == Key.PageDown ||	// ne pas traiter : géré par wpf
                    //e.Key == Key.PageUp ||	// ne pas traiter : géré par wpf
                    //e.Key == Key.Down ||		// ne pas traiter : géré par wpf
                    //e.Key == Key.Up ||			// ne pas traiter : géré par wpf

                        (((Keyboard.Modifiers & ModifierKeys.Control) != 0) && ValidModifiedKeys.Contains(e.Key))
                    )
                {
                    key = e.Key.ToString();
                }
                else return; // les touches restantes ne sont pas bloquées
            }

            e.Handled = true;
            application.SendInputKeyDown(key);
        }

        /// <summary>
        /// Gestionnaire d'évènement "PreviewMouseDown"
        /// </summary>
        private void PreviewMouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            if (IsReadOnly) // refusé si IsReadOnly
            {
                e.Handled = true;
                return;
            }

            // on laisse passer les clics gauches (simples & doubles) en input (géré par wpf)
            if (Page.Window.ActiveControl == this && e.ChangedButton == MouseButton.Left) return;

            ((App)Application.Current).Appli.SendMouseDown(this, e);
        }

        /// <summary>
        /// Gestionnaire d'évènement "SelectionChanged" pour la notification
        /// </summary>
        private void SelectionChangedHandler(object sender, SelectionChangedEventArgs e)
        {
            var application = ((App)Application.Current).Appli;

            // on ne notifie pas si le multichoix n'est pas le contrôle actif en input ou si le changement de valeur est fait par programme
            if (ignoreValueChanged || !(application.AttenteInput && Page.Window.ActiveControl == this)) return;

            var response = new DVBuffer();
            response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);			//début de l'acquittement ou de la réponse

            response.Put(ProprietesWpf.EVENEMENT_SOURIS_DEBUT);	// Début de l'envoi des évenements souris

            response.Put(ProprietesWpf.SOURIS_TYPE_EVENEMENT);		// Type d'évènement souris (byte)
            response.Put((byte)MouseEvent.Notification);
            response.Put(ProprietesWpf.PAGE_NUMERO);					// Numéro de la page contenant la donnée cliquée (byte)
            response.Put(Page.NumPage);
            response.Put(ProprietesWpf.IDENT_UNIQUE);					// Id de la donnée cliquée (uint)
            response.Put(Id);
            response.Put(ProprietesWpf.PARAM_SAISIE_SEQUENCE);		// Numéro du point de séquence de la donnée cliquée (ushort)
            response.Put(SeqPoint);

            response.Put(ProprietesWpf.EVENEMENT_SOURIS_FIN);		// Fin de l'envoi des évenements souris

            response.Put(ProprietesWpf.MULTICHOIX_VALEUR);			// Nouvelle valeur (ushort)
            response.Put((ushort)(SelectedIndex + 1));

            application.Send(response);
        }

        /// <summary>
        /// Envoi des infos à l'appli pour ouverture de zoom
        /// </summary>
        private void ZoomButtonClickHandler(object sender, RoutedEventArgs e)
        {
            e.Handled = true;

            var application = ((App)Application.Current).Appli;

            var response = new DVBuffer();
            response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);				//début de l'acquittement ou de la réponse

            application.SetInputBuffer(response);

            response.Put(ProprietesWpf.EVENEMENT_SOURIS_DEBUT);		// Début de l'envoi des évenements souris

            response.Put(ProprietesWpf.SOURIS_TYPE_EVENEMENT);			// Type d'évènement souris (byte)
            if (((App)Application.Current).Client.VersionInterneServeur <= 1)
                response.Put((byte)MouseEvent.ZoomCall);
            else
                response.Put((byte)(MouseEvent.ZoomComboCall));

            response.Put(ProprietesWpf.EVENEMENT_SOURIS_FIN);			// Fin de l'envoi des évenements souris

            application.Send(response);
        }
        #endregion Ecouteurs
        */
        /// <summary>
        /// ajouter les commandes necessaires pour le client
        /// </summary>
        /// <param name="envois"></param>
        /// <param name="page"></param>
        /// <param name="niveau"></param>
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ComboBoxVersJson cb = new ComboBoxVersJson();

            if (this.imageComboBox)
            {
                cb.formatSelection = "imageMultiChoix";
                cb.formatResult = "imageMultiChoix";
            }
            else
            {
                cb.formatSelection = "texteMultiChoix";
                cb.formatResult = "texteMultiChoix";
            }

            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();
            ListeParametresEnvoyes paramsCreation = new ListeParametresEnvoyes();

            // surtout pas, car ca casse le s2id			paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau));

            if (Presentation != null)
                this.Presentation.GenererHtml(paramsValeurs, this.Page.Html, 0,false);

            paramsValeurs.Ajouter("pointSequence", this.SeqPoint.ToString(), page.NumPage.ToString());

            if (IsReadOnly.HasValue)
                paramsValeurs.Ajouter("lectureSeule", (bool)IsReadOnly ? "true" : "false");

            int cpt = 0;
            foreach (UnItemMultiChoix item in Items)
            {
                UnItemJson j = new UnItemJson();
                j.id = cpt.ToString();
                cpt++;
                j.text = item.Libelle;
                cb.data.results.Add(j);
            }

            cb.autoOpen = autoOpen;

            if (this.PositionRecue.HasValue)
                cb.position = this.PositionRecue.Value.ToString();

            //			string datasJson = HtmlGlobal.ToJsonString(datas, this.Page.Html.JsonDataComboBox, false);
            string parametresJson = HtmlGlobal.ToJsonString(cb, this.Page.Html.JsonParametresComboBox, false);

            //		paramsCreation.Ajouter("liste", datasJson);
            paramsCreation.Ajouter("paramsCreation", parametresJson);

            envois.Ajouter("creerMultiChoix", HtmlGlobal.ToJsonString(paramsCreation, this.Page.Html.JsonParamsEnvoyes, false), HtmlGlobal.CalculerId(this.Id, page.Id, niveau));

            // je met les coordonnées + couleurs etc sur l'objet hidden, comme ca si on recrée l'objet (liste de choix modifiée), on reprend
            // les bonnes caractéristiques
            paramsValeurs.Ajouter("idPage", this.Page.Html.CalculerIdPage(page.Id));
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));

            // j'envoie la meme chose pour le conteneur du combo
            envois.Ajouter("setObjetCourant", "s2id_" + HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            paramsValeurs.Ajouter("idPage", this.Page.Html.CalculerIdPage(page.Id));
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
        }
        /// <summary>
        /// ajouter les commandes necessaires pour le client
        /// </summary>
        /// <param name="envois"></param>
        /// <param name="page"></param>
        /// <param name="niveau"></param>
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();

            paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id));

            if (this.textHasValue)
                paramsValeurs.Ajouter("texteLabel", this.text);

            if (Presentation != null)
                this.Presentation.GenererHtml(paramsValeurs,this.Page.Html,this.codePage,false);

            UnParametreEnvoye p = new UnParametreEnvoye();

            envois.Ajouter("creerObjet", "<P></P>", HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
            envois.Ajouter("ajoutObjetCourant","");

            ///////////////////////////////////////// MORCEAU qui génére tout le code HTML : beaucoup plus rapide a l'exec
            ////////////////////////////////////////  on devrait faire comme ca pour les objets les plus utilisés (label champ)
            /*
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();

            string css = this.Presentation.GenererHtml(paramsValeurs);

            css += "id='" + this.Id.ToString() + "'";

            int i = 0;
            UnParametreEnvoye p = new UnParametreEnvoye();
            envois.commandes.Add(p);
            p.commande = "html";
            p.valeur = "<P " + css + ">" + this.text + "</P>";

            p = new UnParametreEnvoye();
            envois.commandes.Add(p);
            p.commande = "script";
            p.valeur = "AjouterObjet(codeHtml,bodyCourant);";
            */
            //////////////////////////////////////////////////////////////
        }
        /// <summary>
        /// ajouter les commandes necessaires pour le client
        /// </summary>
        /// <param name="envois"></param>
        /// <param name="page"></param>
        /// <param name="niveau"></param>
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();

            paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id));

            if (this.LibelleGroupe != null)
                paramsValeurs.Ajouter("texteGroupe", this.LibelleGroupe);

            if (Presentation != null)
            {
                this.Presentation.GenererHtml(paramsValeurs, this.Page.Html, this.codePage,true);

                UnParametreEnvoye pp = paramsValeurs.commandes.FirstOrDefault(c => c.commande == "css-fond");
                if (pp != null)
                    pp.commande = "couleurTitreGroupe";

                pp = paramsValeurs.commandes.FirstOrDefault(c => c.commande == "css-police");
                if (pp != null)
                    pp.commande = "policeTitreGroupe";

                pp = paramsValeurs.commandes.FirstOrDefault(c => c.commande == "css-padding");
                if (pp != null)
                    pp.commande = "paddingTitreGroupe";

            }

            if (this.idFondGroupe.HasValue)
            {
                string ct = this.Page.Html.App.GenererUneValeurDeCouleur(this.idFondGroupe);
                if (ct != null)
                {
                    paramsValeurs.Ajouter("css-fond", ct);
                }
            }

            UnParametreEnvoye p = new UnParametreEnvoye();

            //			envois.Ajouter("creerObjet", "<P></P>", HtmlGlobal.CalculerId(this.Id, page.Id, niveau));

            envois.Ajouter("creerGroupBox", " ", HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            envois.Ajouter("ajoutObjetCourant", "");

            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
        }
        public ItemOngletVersJson AjouterEnvoisUnItem(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ItemOngletVersJson io = new ItemOngletVersJson();

            io.texte = this.Header;
            io.bulle = this.ToolTip;

            if (imageFile != null && string.IsNullOrEmpty(imageFile.FileName) == false)
            {
                io.bitmap = imageFile.FileName.Replace('.', '_');
            }

            //if (this.Presentation != null && this.Presentation.idFond.HasValue)
            //{
            //	io.fond = this.Page.Html.App.GenererUneValeurDeCouleur(this.Presentation.idFond);
            //}
            if (this.IdFond.HasValue)
            {
                io.fond = this.Page.Html.App.GenererUneValeurDeCouleur((ushort)this.IdFond);
            }

            io.numeroPage = this.PageNumber;
            io.visibilite = (byte)this.Visibilite;

            return io;
        }
        /// <summary>
        /// Initializes a new instance of the XHtmlCheckBox class.
        /// </summary>
        public XHtmlCheckBox(XHtmlPage page)
        {
            //			InitializeComponent();
            Page = page;

            //			PreviewKeyDown += PreviewKeyDownHandler;
            //			PreviewMouseDown += PreviewMouseDownHandler;
        }
 /// <summary>
 /// Initializes a new instance of the XHtmlTabControl class.
 /// </summary>
 public XHtmlTabControl(XHtmlPage page)
 {
     //!!!!!!!!!!!!!!! mettre un zindex pour qu'on soit derriere
     Page = page;
 }
        //#region Ecouteurs
        /// <summary>
        /// Gestionnaire d'évènement "PreviewKeyDown" pour la fonction XMEInput
        /// </summary>
        //private static void PreviewKeyDownHandler(object sender, KeyEventArgs e)
        //{
        //   var application = ((App)Application.Current).Appli;
        //   if (!application.AttenteInput) // cas impossible en théorie: un contrôle ne peut pas avoir le focus sans que l'on soit en Input
        //   {
        //      e.Handled = true;
        //      return;
        //   }
        //   string key = "";
        //   // Touches de fonction (Fn)
        //   if (e.Key == Key.System && e.SystemKey == Key.F10) key = "F10";
        //   else if (XHtmlApplication.FnKeys.Contains(e.Key)) key = e.Key.ToString();
        //   // Autres touches
        //   else // pas la peine de faire les tests spécifiques si une touche générique (Fn) a déjà été détetée
        //   {
        //      if (ValidKeys.Contains(e.Key) || (((Keyboard.Modifiers & ModifierKeys.Control) != 0) && ValidModifiedKeys.Contains(e.Key)))
        //         key = e.Key.ToString();
        //      else if (e.Key != Key.Left && e.Key != Key.Right) return; // les touches restantes ne sont pas bloquées, excepté flèches droite et gauche
        //   }
        //   e.Handled = true;
        //   application.SendInputKeyDown(key);
        //}
        /// <summary>
        /// Gestionnaire d'évènement "PreviewMouseDown"
        /// </summary>
        //private void PreviewMouseDownHandler(object sender, MouseButtonEventArgs e)
        //{
        //   if (IsReadOnly) // refusé si IsReadOnly
        //   {
        //      e.Handled = true;
        //      return;
        //   }
        //   // on laisse passer les clics gauches (simples & doubles) en input (géré par wpf)
        //   if (Page.Window.ActiveControl == this && e.ChangedButton == MouseButton.Left) return;
        //   ((App)Application.Current).Appli.SendMouseDown(this, e);
        //}
        /// <summary>
        /// Gestionnaire d'évènement "Checked ou Unchecked" pour la notification
        /// </summary>
        //private void ValueChangedHandler(object sender, RoutedEventArgs e)
        //{
        //   var application = ((App)Application.Current).Appli;
        //   // on ne notifie pas si la case n'est pas le contrôle actif en input
        //   if (!(application.AttenteInput && Page.Window.ActiveControl == this)) return;
        //   var response = new DVBuffer();
        //   response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);			//début de l'acquittement ou de la réponse
        //   response.Put(ProprietesWpf.EVENEMENT_SOURIS_DEBUT);	// Début de l'envoi des évenements souris
        //   response.Put(ProprietesWpf.SOURIS_TYPE_EVENEMENT);		// Type d'évènement souris (byte)
        //   response.Put((byte)MouseEvent.Notification);
        //   response.Put(ProprietesWpf.PAGE_NUMERO);					// Numéro de la page contenant la donnée cliquée (byte)
        //   response.Put(Page.NumPage);
        //   response.Put(ProprietesWpf.IDENT_UNIQUE);					// Id de la donnée cliquée (uint)
        //   response.Put(Id);
        //   response.Put(ProprietesWpf.PARAM_SAISIE_SEQUENCE);		// Numéro du point de séquence de la donnée cliquée (ushort)
        //   response.Put(SeqPoint);
        //   response.Put(ProprietesWpf.EVENEMENT_SOURIS_FIN);		// Fin de l'envoi des évenements souris
        //   response.Put(ProprietesWpf.CASE_A_COCHER_ETAT);			// Nouvelle valeur (ushort)
        //   response.Put((IsChecked.HasValue && IsChecked.Value) ? (ushort)1 : (ushort)0);
        //   application.Send(response);
        //}
        //#endregion Ecouteurs
        /// ajouter les commandes necessaires pour le client
        /// </summary>
        /// <param name="envois"></param>
        /// <param name="page"></param>
        /// <param name="niveau"></param>
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();
            ListeParametresEnvoyes paramsCreation = new ListeParametresEnvoyes();

            CaseACocherVersJson cc = new CaseACocherVersJson();

            paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id));

            if (this.IsChecked.HasValue)
                paramsValeurs.Ajouter("caseChecked", (bool)this.IsChecked ? "true" : "false");

            if (this.TexteAGauche.HasValue)
                cc.texteAGauche = (bool)this.TexteAGauche;

            if (string.IsNullOrEmpty(this.Libelle) == false)
                paramsValeurs.Ajouter("caseLibelle", this.Libelle);

            if (NotificationSiModif)
                cc.notification = true;

            if (IsReadOnly.HasValue)
                paramsValeurs.Ajouter("lectureSeule", (bool)IsReadOnly ? "true" : "false");

            if (Presentation != null)
                this.Presentation.GenererHtml(paramsValeurs, this.Page.Html,0,false);

            paramsValeurs.Ajouter("pointSequence", this.SeqPoint.ToString(), page.NumPage.ToString());

            string parametresJson = HtmlGlobal.ToJsonString(cc, this.Page.Html.JsonParametresCaseACocher, false);
            paramsCreation.Ajouter("paramsCreation", parametresJson);

            //UnParametreEnvoye p = new UnParametreEnvoye();

            envois.Ajouter("creerCaseACocher", HtmlGlobal.ToJsonString(paramsCreation, this.Page.Html.JsonParamsEnvoyes, false), HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            //			envois.Ajouter("ajoutObjetCourant", "");
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
        }
Exemple #20
0
		public byte Orientation;     // Sens (byte : 1 = Vertical, 2 = Horizontal)

		public Grid(XHtmlPage p)
		{
			this.Page = p;
		}
        /// <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;
        }
 public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
 {
 }
        //#region Ecouteurs
        ///// <summary>
        ///// Gestionnaire d'évènement "PreviewKeyDown" pour la fonction XMEInput
        ///// </summary>
        //private static void PreviewKeyDownHandler(object sender, KeyEventArgs e)
        //{
        //   var application = ((App)Application.Current).Appli;
        //   if (!application.AttenteInput)
        //   {
        //      e.Handled = true;
        //      return;
        //   }
        //   string key = "";
        //   // Touches de fonction (Fn)
        //   if (e.Key == Key.System && e.SystemKey == Key.F10) key = "F10";
        //   else if (XHtmlApplication.FnKeys.Contains(e.Key)) key = e.Key.ToString();
        //   // Autres touches
        //   else // pas la peine de faire les tests spécifiques si une touche générique (Fn) a déjà été détetée
        //   {
        //      if (ValidKeys.Contains(e.Key) || ((Keyboard.Modifiers & ModifierKeys.Control) != 0 && ValidModifiedKeys.Contains(e.Key)))
        //         key = e.Key.ToString();
        //      else if (e.Key != Key.Left && e.Key != Key.Right) return; // les touches restantes ne sont pas bloquées, excepté flèches droite et gauche
        //   }
        //   e.Handled = true;
        //   application.SendInputKeyDown(key);
        //}
        ///// <summary>
        ///// Gestionnaire d'évènement "Click" du bouton
        ///// </summary>
        //private void ClickHandler(object sender, RoutedEventArgs e)
        //{
        //   e.Handled = true;
        //   var application = ((App)Application.Current).Appli;
        //   var client = ((App)Application.Current).Client;
        //   if (application.AttenteInput || application.AttenteConsult || (application.AttenteGetb && action == 3))	// input ou consult ou get bloquant (traité AVANT le GetBegin car on peut être en GetBegin et faire un input/consult/get bloquant)
        //   {
        //      var response = new DVBuffer();
        //      response.Put(ProprietesWpf.CLIENTLEGER_DEBUT);				//début de l'acquittement ou de la réponse
        //      application.SetInputBuffer(response);
        //      response.Put(ProprietesWpf.EVENEMENT_SOURIS_DEBUT);		// Début de l'envoi des évenements souris
        //      response.Put(ProprietesWpf.SOURIS_TYPE_EVENEMENT);			// Type d'évènement souris (byte)
        //      response.Put((byte)MouseEvent.ClickButton);
        //      response.Put(ProprietesWpf.BOUTON_ACTION);					// Type d'action (byte = 1, 2 ou 3)
        //      response.Put(action);
        //      switch (action)
        //      {
        //         case 1: response.Put(pointTraitement); break;				// Type = 1 : point de traitement
        //         case 2: response.Put(pointArret); break;						// Type = 2 : point d'arrêt
        //         case 3: response.PutString(generatedString); break;		// Type = 3 : chaîne à générer
        //      }
        //      response.Put(ProprietesWpf.EVENEMENT_SOURIS_FIN);			// Fin de l'envoi des évenements souris
        //      application.Send(response);
        //      return;
        //   }
        //   if (client != null && client.GetBegin > 0 && action == 3)	// get non bloquant sur bouton "chaîne" (les autres types sont ignorés)
        //      client.Transport.EnvoyerUnGet("##" + OutilsString.ToHexa(generatedString));
        //}
        ///// <summary>
        ///// Gestionnaire d'effets du clic bouton (pour sons, curseurs et images)
        ///// </summary>
        //private void PreviewMouseDownEffectsHandler(object sender, RoutedEventArgs e)
        //{
        //   if (soundClick == null || !IsEnabled) return;
        //   player.Open(soundClick);
        //   player.Play();
        //}
        ///// <summary>
        ///// Gestionnaire d'effets du mouseOver bouton (pour sons, curseurs et images)
        ///// </summary>
        //private void MouseOverEffectsHandler(object sender, RoutedEventArgs e)
        //{
        //   if (IsMouseOver && IsEnabled)
        //   {
        //      if (imageMouseOver != null) Content = imageMouseOver;
        //      if (cursorMouseOver != null) Mouse.OverrideCursor = cursorMouseOver;
        //      if (soundMouseOver != null)
        //      {
        //         player.Open(soundMouseOver);
        //         player.Play();
        //      }
        //   }
        //   else if (!IsMouseOver)
        //   {
        //      if (text != null) Content = text;
        //      else if (image != null) Content = image;
        //      Mouse.OverrideCursor = null;
        //   }
        //}
        ///// <summary>
        ///// 
        ///// </summary>
        //private void LostFocusEventHandler(object sender, RoutedEventArgs e)
        //{
        //   Focusable = false; // garde-fou. Le Focusable est repassé à true lors du passage en input (pour éviter qu'un bouton ne prenne le focus sans qu'on ne l'y autorise)
        //}
        //#endregion Ecouteurs
        public void AjouterEnvoisUnObjet(ListeParametresEnvoyes envois, XHtmlPage page, int niveau)
        {
            ListeParametresEnvoyes paramsValeurs = new ListeParametresEnvoyes();

            if (Presentation != null)
                this.Presentation.GenererHtml(paramsValeurs,this.Page.Html,this.codePage,false);

            paramsValeurs.Ajouter("idObjet", HtmlGlobal.CalculerId(this.Id, page.Id, niveau), this.Page.Html.CalculerIdPage(page.Id)); //   this.Id.ToString());

            if (string.IsNullOrEmpty(this.text) == false)
                paramsValeurs.Ajouter("textBouton", this.text);
            //else
            //	paramsValeurs.Ajouter("textBouton", "pas de texte");

            if (imageDuBouton != null && string.IsNullOrEmpty(imageDuBouton.FileName) == false)
            {
                paramsValeurs.Ajouter("imagebouton", imageDuBouton.FileName.Replace('.','_'));
            }

            if (this.IsLocal)
                paramsValeurs.Ajouter("boutonLocal", "true");

            if (string.IsNullOrEmpty(this.Selection) == false)
                paramsValeurs.Ajouter("boutonNomSelection", Selection);

            UnParametreComplementaire compl;
            ListeParametresComplementaires compls = new ListeParametresComplementaires();
            compls.Ajouter("action:",action.ToString());
            compl = compls.Ajouter("param", "0");
            switch (action)
            {
                case 1: compl.v = pointTraitement.ToString(); break;				// Type = 1 : point de traitement
                case 2: compl.v = pointArret.ToString(); break;					// Type = 2 : point d'arrêt
                case 3: compl.v = generatedString; break;							// Type = 3 : chaîne à générer
            }

            string chaineAction = HtmlGlobal.ToJsonString(compls, this.Page.Html.JsonParamCompl,false);

            paramsValeurs.Ajouter("actionBouton", chaineAction.Replace("'", @"#quote"));

            envois.Ajouter("creerBouton", "<button></button>", HtmlGlobal.CalculerId(this.Id, page.Id, niveau));
            envois.Ajouter("propsObjet", HtmlGlobal.ToJsonString(paramsValeurs, this.Page.Html.JsonParamsEnvoyes, false));
            envois.Ajouter("ajoutObjetCourant", "");

            //			chaineAction = "data-harmony=" + "'" + chaineAction.Replace("'",@"#quote") + "'";
            //string id = "id=" + this.Id.ToString();
            //UnParametreEnvoye p = new UnParametreEnvoye();
            //envois.commandes.Add(p);
            //p.commande = "bouton";
            //p.valeur = "<button " + id + " " + css + " " + chaineAction +">" + this.text + "</button>";
        }