public void Init() { Children = new Collection<object>(); //!!!!!!!!!!!!!!!! a voir !!!!!!!!!!!! //Transmi = false; ListOfObjects = new Collection<IXHtmlObject>(); Presentation = new XHtmlPresentation(this); }
public XHtmlGenericColumn(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); }
/// <summary> /// initialise la grille /// </summary> /// <param name="buffer"></param> private void SetGrid(DVBuffer buffer) { ProprietesWpf property; XHtmlPresentation gridPresentation = new XHtmlPresentation(); bool newGrid = false; uint gridId; ushort cellsCount; byte orientation; buffer.Get(out gridId); // Ident Unique de la grille (uint) buffer.Get(out cellsCount); // Nb de cellules (ushort) buffer.Get(out orientation); // Sens (byte : 1 = Vertical, 2 = Horizontal) buffer.Get(out property); // PRESENTATION_DEBUT gridPresentation.ReadProperties(buffer); Grid grid=null; //grid = GetGrid(gridId); BHGRILLE // BH c'est inutle si je ne garde pas les grilles coté serveur if (grid == null) // les pages et leur contenu peuvent être perdues côté XrtDiva => pour ne pas recréer systématiquement ici, on teste { grid = new Grid (this) { Id = gridId, Tag = gridPresentation, Orientation = orientation }; //// pour résoudre le pb de rebarres qui étaient bloquées par la taille min des cellules (idem pour les pages panel ci-dessous) //grid.Loaded += (s, e) => //{ // var sv = TreeHelper.FindAncestor<ScrollViewer>(grid); // if (sv.Name != "ScrollViewer") // pour exclure le scrollviewer de la fenêtre (sinon comportement non désiré) // { // grid.SetBinding(MaxHeightProperty, new Binding("ActualHeight") { Source = sv }); // grid.SetBinding(MaxWidthProperty, new Binding("ActualWidth") { Source = sv }); // } //}; // Grid parent = GetGrid(gridPresentation.GridId); // if (parent != null) // on ajoute dans la grille trouvée // { // // placement dans la cellule de la grille parent le cas échéant (en ligne ou colonne) // ScrollViewer sv = null; // // grille verticale // if (parent.RowDefinitions.Count > 0 && gridPresentation.CellIndex < parent.RowDefinitions.Count) // sv = parent.Children.OfType<ScrollViewer>().FirstOrDefault(s => GetRow(s) == gridPresentation.CellIndex); // // grille horizontale // else if (parent.ColumnDefinitions.Count > 0 && gridPresentation.CellIndex < parent.ColumnDefinitions.Count) // sv = parent.Children.OfType<ScrollViewer>().FirstOrDefault(s => GetColumn(s) == gridPresentation.CellIndex); // var children = ((Grid)sv.Content).Children; // if (children.Count > 0 && children[0] is XHtmlPage) children.Clear(); // garde-fou // children.Add(grid); // } // else // { // // on doit recalculer les marges pour le cas des onglets (uniquement lorsque la grille est enfant d'une page) // grid.Margin = new Thickness( // gridPresentation.OriginalLeft, // gridPresentation.OriginalTop, // Presentation.OriginalWidth - gridPresentation.OriginalLeft - gridPresentation.OriginalWidth, // Presentation.OriginalHeight - gridPresentation.OriginalTop - gridPresentation.OriginalHeight // ); // Children.Add(grid); // sinon on ajoute dans la page en cours // } // listOfGrids.Add(grid); // newGrid = true; //} // je saute tout le passage au dessus. je traite ca de l'autre coté. newGrid = true; listOfGrids.Add(grid); Children.Add(grid); } // ajout des cellules for (int i = 0; i < cellsCount; i++) { XHtmlPresentation cellPresentation = new XHtmlPresentation(); byte canResizeCell; buffer.Get(out property); // GRILLE_CELLULE_DEBUT buffer.Get(out canResizeCell); // Redimensionnable (byte : 0 ou 1) buffer.Get(out property); // PRESENTATION_DEBUT cellPresentation.ReadProperties(buffer); buffer.Get(out property); // GRILLE_CELLULE_FIN if (newGrid) SetGridCell(gridPresentation, cellPresentation, orientation, grid, canResizeCell, i == cellsCount - 1); } grid.AjouterEnvoisUnObjet(Html.Envois, this, Html.App.StackOfWindows.Count()); buffer.Get(out property); // GRILLE_FIN #region restauration des paramètres utilisateur stockés dans le registre //if (newGrid && !(bool)Application.Current.Properties["IgnoreUserSettings"]) //{ // RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Divalto\V7\Grilles\" + Window.MaskName + "-" + NumPage + "-" + gridId); // if (key == null) return; // // si l'orienation de la grille ne correspond pas à ce qui est stocké dans le registre : on r.à.z. // var gridOrientation = key.GetValue("GridOrientation") as string; // if (gridOrientation != null && gridOrientation != orientation.ToString(CultureInfo.InvariantCulture)) // { // key.DeleteValue("GridOrientation"); // return; // } // // si la taille de la grille ne correspond pas à ce qui est stocké dans le registre : on r.à.z. // var gridSize = key.GetValue("GridSize") as string; // if (gridSize != null && gridSize != ((orientation == 1) ? gridPresentation.OriginalHeight : gridPresentation.OriginalWidth).ToString(CultureInfo.InvariantCulture)) // { // key.DeleteValue("GridSize"); // return; // } // // récupération des données en elles-mêmes si tout est ok // var gridCellSizes = key.GetValue("GridCellSizes") as string; // if (gridCellSizes != null) // { // // si le nombre de cellules ne correspond pas à ce qui est stocké dans le registre : on r.à.z. // string[] storedGridCellSizes = gridCellSizes.Split(';'); // if (storedGridCellSizes.Length != cellsCount) // { // key.DeleteValue("GridCellSizes"); // return; // } // if (orientation == 1) // grille verticale // { // for (int i = 0; i < storedGridCellSizes.Length; i++) // { // try { grid.RowDefinitions[i].Height = (GridLength)new GridLengthConverter().ConvertFromString(storedGridCellSizes[i]); } // catch (FormatException) // { // key.DeleteValue("GridCellSizes"); // return; // } // } // } // else // grille horizontale // { // for (int i = 0; i < storedGridCellSizes.Length; i++) // { // try { grid.ColumnDefinitions[i].Width = (GridLength)new GridLengthConverter().ConvertFromString(storedGridCellSizes[i]); } // catch (FormatException) // { // key.DeleteValue("GridCellSizes"); // return; // } // } // } // } //} #endregion restauration des paramètres utilisateur stockés dans le registre }
/// <summary> /// initialise une cellule de la grille /// </summary> /// <param name="gridPresentation"></param> /// <param name="cellPresentation"></param> /// <param name="orientation"></param> /// <param name="grid"></param> /// <param name="canResizeCell"></param> private void SetGridCell(XHtmlPresentation gridPresentation, XHtmlPresentation cellPresentation, byte orientation, Grid grid, byte canResizeCell, bool lastCell) { XHtmlCelluleGrille cellule; cellule = new XHtmlCelluleGrille(); cellule.AvecResize = canResizeCell; cellule.DerniereCellule = lastCell; cellule.Presentation = cellPresentation; grid.Cellules.Add(cellule); //ScrollViewer sv = new ScrollViewer //{ // Tag = cellPresentation, // Content = new Grid(), // VerticalScrollBarVisibility = ScrollBarVisibility.Auto, // HorizontalScrollBarVisibility = ScrollBarVisibility.Auto //}; //sv.SizeChanged += (s, e) => { sv.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; sv.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; }; //grid.Children.Add(sv); //if (orientation == 1) // grille verticale //{ // var heightRatio = cellPresentation.OriginalHeight * 100 / gridPresentation.OriginalHeight; // grid.RowDefinitions.Add(new RowDefinition { Height = (GridLength)new GridLengthConverter().ConvertFromString(heightRatio + "*"), MinHeight = 20 }); // if (canResizeCell == 1 && !lastCell) // { // GridSplitter splitter = new GridSplitter // { // Height = 3, // HorizontalAlignment = HorizontalAlignment.Stretch, // VerticalAlignment = VerticalAlignment.Bottom, // Background = Brushes.Transparent, // Focusable = false // }; // splitter.PreviewMouseDown += (s, e) => { if (((App)Application.Current).Appli.AttenteInput) e.Handled = true; }; // on bloque les rebarres en input pour le pas perdre le focus // splitter.DragCompleted += GridSplitter_DragCompleted; // pour la sauvegarde de la taille des cellules de la grille dans le registre sur le mouseUp // SetRow(splitter, grid.RowDefinitions.Count - 1); // SetZIndex(splitter, 5); // grid.Children.Add(splitter); // } // SetRow(sv, grid.RowDefinitions.Count - 1); //} //else // grille horizontale //{ // var widthRatio = cellPresentation.OriginalWidth * 100 / gridPresentation.OriginalWidth; // grid.ColumnDefinitions.Add(new ColumnDefinition { Width = (GridLength)new GridLengthConverter().ConvertFromString(widthRatio + "*"), MinWidth = 20 }); // if (canResizeCell == 1 && !lastCell) // { // GridSplitter splitter = new GridSplitter // { // Width = 3, // HorizontalAlignment = HorizontalAlignment.Right, // VerticalAlignment = VerticalAlignment.Stretch, // Background = Brushes.Transparent, // Focusable = false // }; // splitter.PreviewMouseDown += (s, e) => { if (((App)Application.Current).Appli.AttenteInput) e.Handled = true; }; // on bloque les rebarres en input pour le pas perdre le focus // splitter.DragCompleted += GridSplitter_DragCompleted; // pour la sauvegarde de la taille des cellules de la grille dans le registre sur le mouseUp // SetColumn(splitter, grid.ColumnDefinitions.Count - 1); // SetZIndex(splitter, 5); // grid.Children.Add(splitter); // } // SetColumn(sv, grid.ColumnDefinitions.Count - 1); //} }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.ONGLET_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); // Presentation.SetProperties(); // pas de présentation pour les onglets (ignoré) break; case ProprietesWpf.CODE_PAGE: // Code page buffer.Get(out codePage); break; case ProprietesWpf.ONGLET_LIBELLE: // Libellé (string) string text; buffer.GetStringCP(out text, codePage); Header = text; break; case ProprietesWpf.ONGLET_IMAGE_DEBUT: // Libellé (string) imageFile = new XHtmlImageFile(); imageFile.ReadProperties(buffer); // Image = XHtmlImage.GetImage(imageFile); // voir si c utile !!!!!!!!!!!!!!!!! if (this.Page.Html.App.ImagesCss.FirstOrDefault(e => e.FileName == imageFile.FileName) == null) { imageFile.Css = imageFile.GenererCss(); this.Page.Html.App.ImagesCss.Add(imageFile); } break; case ProprietesWpf.ONGLET_NUMERO_PAGE: // Numéro de la page liée à l'onglet (byte) byte pageNumber; buffer.Get(out pageNumber); PageNumber = pageNumber; break; case ProprietesWpf.CODE_PAGE_BULLE: // Code page bulle buffer.Get(out codePageBulle); break; case ProprietesWpf.ONGLET_BULLE: // Texte de la bulle (string) string toolTip; buffer.GetStringCP(out toolTip, codePageBulle); ToolTip = string.IsNullOrEmpty(toolTip) ? null : toolTip.Replace("|", "\n"); // "|" = multi-ligne break; case ProprietesWpf.ONGLET_COULEUR_FOND: // Couleur du Fond (ushort) ushort id; buffer.Get(out id); // Brush background = Application.Current.Resources["Brush-" + id] as Brush; IdFond = id; // if (background != null) ContentBorder.Background = background; // else ContentBorder.ClearValue(Border.BackgroundProperty); break; case ProprietesWpf.ONGLET_VISIBILITE: // visibilité byte visibiliteValue; buffer.Get(out visibiliteValue); Visibilite = visibiliteValue; //Visibilites visibilite = (Visibilites)visibiliteValue; //switch (visibilite) // 0 = visible, 1 = grisé, 2 = illisible, 3 = caché //{ // case Visibilites.Visible: // IsEnabled = true; // Visibility = Visibility.Visible; // break; // case Visibilites.Grise: // IsEnabled = false; // Visibility = Visibility.Visible; // break; // case Visibilites.Cache: // IsEnabled = false; // Visibility = Visibility.Collapsed; // break; //} break; default: throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.TabItem, property.ToString()); } buffer.Get(out property); } }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; ushort id; buffer.Get(out property); while (property != ProprietesWpf.GROUPE_ONGLET_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.ONGLET_POLICE: // Police des headers d'onglets ushort idFont; buffer.Get(out idFont); idPolice = idFont; // XHtmlFont font = Application.Current.Resources["Font-" + idFont] as XHtmlFont; //if (font == null) //{ // Debug.WriteLine("police onglet non-chargée (ressource à null)"); // break; //} //if (font.Family != null) FontFamily = font.Family; //if (font.Size != null) FontSize = font.Size.Value; //if (font.Style != null) FontStyle = font.Style.Value; //if (font.Weight != null) FontWeight = font.Weight.Value; //if (font.Brush != null) Foreground = font.Brush; break; case ProprietesWpf.ONGLET_PADDING: // padding dans les headers d'onglets buffer.Get(out id); idPadding = id; //double? verticalPadding = Application.Current.Resources["VerticalPadding-" + idPadding] as double?; //double? horizontalPadding = Application.Current.Resources["HorizontalPadding-" + idPadding] as double?; //Thickness padding = Padding; //if (verticalPadding.HasValue) padding.Top = padding.Bottom = verticalPadding.Value; //if (horizontalPadding.HasValue) padding.Left = padding.Right = horizontalPadding.Value; //Padding = padding; break; case ProprietesWpf.ONGLET_TAILLE_IMAGE: // Image du bouton (ushort x ushort) ushort imageHeight, imageWidth; buffer.Get(out imageHeight); buffer.Get(out imageWidth); ImageHeight = imageHeight; ImageWidth = imageWidth; break; case ProprietesWpf.ONGLET_MULTILIGNE: // (Uniquement si multiligne) IsMultiLine = true; break; case ProprietesWpf.ONGLET_COURANT: // Onglet courant (byte) buffer.Get(out currentTabPageNum); //XHtmlTabItem currentTab = GetTabByPageNum(currentTabPageNum); //if (currentTab != null) //{ // currentTab.IsSelected = true; // //UpdateLayout(); // nécessaire pour que le BringIntoView fonctionne au tout premier affichage // //currentTab.BringIntoView(); //} break; case ProprietesWpf.ONGLET_ARRET: // Numéro du point d'arrêt (ushort) buffer.Get(out stopPoint); break; case ProprietesWpf.ONGLET_DEBUT: uint idTab; buffer.Get(out idTab); XHtmlTabItem tab = GetTabById(idTab); if (tab == null) { tab = new XHtmlTabItem(this) { Id = idTab }; tab.Page = this.Page; Items.Add(tab); } tab.ReadProperties(buffer); break; default: throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.TabControl, property.ToString()); } buffer.Get(out property); } }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.CASE_A_COCHER_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.CODE_PAGE: // Code page buffer.Get(out codePage); break; case ProprietesWpf.PARAM_SAISIE_SEQUENCE: // Point de séquence (ushort) ushort seqPoint; buffer.Get(out seqPoint); SeqPoint = seqPoint; break; case ProprietesWpf.CASE_A_COCHER_CADRAGE_TEXTE: // Position du texte par rapport à la case (byte) byte cadrage; buffer.Get(out cadrage); TexteAGauche = cadrage == 1; break; case ProprietesWpf.OBJET_NOTIFIER_SI_MODIF: // Envoyé si la notification est demandée ==> il faudra "réveiller" Ymeg si l'utilisateur clique sur la case //Checked += ValueChangedHandler; // traitement de la notification //Unchecked += ValueChangedHandler; // traitement de la notification NotificationSiModif = true; break; case ProprietesWpf.CASE_A_COCHER_LIBELLE: // Libellé de la case (string) string content; buffer.GetStringCP(out content, codePage); Libelle = content; break; case ProprietesWpf.OBJET_EN_AFFICHAGE: // (Uniquement si la case est en affichage seulement) IsReadOnly = true; break; case ProprietesWpf.CASE_A_COCHER_ETAT: // Etat de la case (byte : 0=non cochée ; 1=cochée) ushort etat; buffer.Get(out etat); IsChecked = (etat == 1); break; 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.CheckBox, property.ToString()); } buffer.Get(out property); } }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.TEXTE_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.CODE_PAGE: // Code page buffer.Get(out codePage); break; case ProprietesWpf.TEXTE_LIBELLE: // Contenu du Label (string avec code page) { string t; buffer.GetStringCP(out t, codePage); text = t; Content = text; } break; case ProprietesWpf.TEXTE_ANGLE: // Angle au sens trigo en ° (ushort) ushort ang; buffer.Get(out ang); this.Presentation.angle = ang; // HACK inversion des hauteurs et largeur si angle multiple de 90 if ((Presentation.angle + 90) % 180 == 0) { Presentation.Left += (Width - Height) / 2; Presentation.Top -= (Width - Height) / 2; var horizontalPaddingTemp = Presentation.HorizontalPadding; Presentation.HorizontalPadding = Presentation.VerticalPadding; Presentation.VerticalPadding = horizontalPaddingTemp; var widthTemp = Presentation.OriginalWidth; Presentation.OriginalWidth = Presentation.OriginalHeight; Presentation.OriginalHeight = widthTemp; Presentation.SetProperties(); } //!!!!!!!!!!!!!!!!! RenderTransform = new RotateTransform(-angle, Width / 2, Height / 2); break; default: throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.Label, property.ToString()); } buffer.Get(out property); } // gestion de l'illisibilité Content = (Presentation.Visibilite == Visibilites.Illisible) ? XHtmlApplication.Resources["UnreadableString"] as string : text; }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.GROUPBOX_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.CODE_PAGE: // Code page buffer.Get(out codePage); break; case ProprietesWpf.GROUPBOX_FOND_GROUPE: // fond du groupe ushort id; buffer.Get(out id); idFondGroupe = id; break; case ProprietesWpf.GROUPBOX_LIBELLE: // libellé du titre (string) string header; buffer.GetStringCP(out header, codePage); LibelleGroupe = header; break; default: throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.GroupBox, property.ToString()); } buffer.Get(out property); } }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.CHAMP_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.PARAM_SAISIE_SEQUENCE: // Point de séquence (ushort) ushort pointSequence; buffer.Get(out pointSequence); SeqPoint = pointSequence; break; case ProprietesWpf.PARAM_SAISIE_TABLE_ASSOCIEE: // (Uniquement si le champ peut appeler un zoom) IsZoomCaller = true; break; case ProprietesWpf.PARAM_SAISIE_TABLE_ASSOCIEE_EXT: // (Uniquement si le champ peut appeler un zoom) byte isZoomCaller; buffer.Get(out isZoomCaller); IsZoomCaller = (isZoomCaller != 0); break; case ProprietesWpf.OBJET_EN_AFFICHAGE: // (Uniquement si le champ est en affichage seulement) IsReadOnly = true; break; case ProprietesWpf.CHAMP_OBLIGATOIRE: // (Uniquement si le champ est obligatoire) byte isMandatory; buffer.Get(out isMandatory); IsMandatory = (isMandatory != 0); break; case ProprietesWpf.CHAMP_NUMERIQUE: // (Uniquement si le champ n'accepte que des valeurs numériques) isNumerical = true; // PreviewTextInput += (s, e) => { e.Handled = !IsValidNumericChar(e.Text); }; // Limitations aux caractères numériques + opérateurs pour la saisie break; case ProprietesWpf.CODE_PAGE: // Code page buffer.Get(out CodePage); break; case ProprietesWpf.CHAMP_VALEUR: // Contenu du champ (string) string wt; buffer.GetStringCP(out wt, CodePage); Text = wt; break; case ProprietesWpf.CHAMP_LONGUEUR_SAISIE: // Longueur de saisie autorisée (ushort) ushort maxLength; buffer.Get(out maxLength); MaxLengthProperty = (int)maxLength; // SetCurrentValue(MaxLengthProperty, (int)maxLength); break; case ProprietesWpf.TEXTE_ANGLE: // Angle au sens trigo en ° (ushort) buffer.Get(out angle); // HACK inversion des hauteurs et largeur si angle multiple de 90 if ((angle + 90) % 180 == 0) { Presentation.Left += (Width - Height) / 2; Presentation.Top -= (Width - Height) / 2; var horizontalPaddingTemp = Presentation.HorizontalPadding; Presentation.HorizontalPadding = Presentation.VerticalPadding; Presentation.VerticalPadding = horizontalPaddingTemp; var widthTemp = Presentation.OriginalWidth; Presentation.OriginalWidth = Presentation.OriginalHeight; Presentation.OriginalHeight = widthTemp; Presentation.SetProperties(); } // RenderTransform = new RotateTransform(-angle, Width / 2, Height / 2); break; 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.TextBox, property.ToString()); } buffer.Get(out property); } // numérique aligné à droite en affichage if (isNumerical && Presentation != null && Presentation.Cadrage == Cadrage.Defaut) TextAlignment = TextAlignment.Right; // gestion de l'illisibilité //if (textHasValue && Presentation != null && Presentation.Visibilite == Visibilites.Illisible) // Text = "xxxxxxxxxxxxxx"; }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.IMAGE_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: //début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.IMAGE_IMAGE_DEBUT: XHtmlImageFile imageFile = new XHtmlImageFile(); imageFile.ReadProperties(buffer); //Source = GetImage(imageFile); break; case ProprietesWpf.IMAGE_TRAITEMENT: //type de traitement (byte) byte stretchCode; buffer.Get(out stretchCode); stretchMode = (StretchMode)stretchCode; SetStretch(); break; } buffer.Get(out property); } }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.MULTICHOIX_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: //début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.PARAM_SAISIE_SEQUENCE: // Point de séquence (ushort) ushort pointSequence; buffer.Get(out pointSequence); SeqPoint = pointSequence; break; case ProprietesWpf.PARAM_SAISIE_TABLE_ASSOCIEE: // (Uniquement si le multichoix peut appeler un zoom) IsZoomCaller = true; break; case ProprietesWpf.PARAM_SAISIE_TABLE_ASSOCIEE_EXT: // (Uniquement si le multichoix peut appeler un zoom) byte isZoomCaller; buffer.Get(out isZoomCaller); IsZoomCaller = (isZoomCaller != 0); break; case ProprietesWpf.OBJET_NOTIFIER_SI_MODIF: // Envoyé si la notification est demandée ==> il faudra "réveiller" Ymeg si l'utilisateur change de choix actif this.Notification = true; break; case ProprietesWpf.OBJET_EN_AFFICHAGE: // (Uniquement si le champ est en affichage seulement) IsReadOnly = true; break; case ProprietesWpf.MULTICHOIX_BITMAP: // Uniquement si c'est un multichoix bitmap imageComboBox = true; HorizontalContentAlignment = HorizontalAlignment.Center; break; case ProprietesWpf.MULTICHOIX_LIBELLES: // Liste des libellés ignoreValueChanged = true; // pour ne pas notifier lors du réaffichage de la liste en Input int codepageChoix; buffer.Get(out codepageChoix); ushort nbItems; buffer.Get(out nbItems); int valueSaved = SelectedIndex; //construction de la liste d'items : Items.Clear(); // Garde-fou for (int i = 0; i < nbItems; i++) { var item = new UnItemMultiChoix(); if (imageComboBox) { buffer.Get(out property); // MULTICHOIX_IMAGE var imageFile = new XHtmlImageFile(); imageFile.ReadProperties(buffer); item.Libelle = imageFile.FileName; //!!!!!!!!!!! item.Content = new Image { Source = XHtmlImage.GetImage(imageFile), Stretch = Stretch.None }; } else { string itemContent; buffer.GetStringCP(out itemContent, codepageChoix); item.Libelle = itemContent; } Items.Add(item); } SelectedIndex = valueSaved; ignoreValueChanged = false; break; case ProprietesWpf.MULTICHOIX_VALEUR: // Valeur sélectionnée (ushort) ushort valeur; buffer.Get(out valeur); ignoreValueChanged = true; // on ne notifie pas le chagement de valeur PositionRecue = valeur - 1; //SetValue(SelectedIndexProperty, valeur - 1); ignoreValueChanged = false; break; case ProprietesWpf.MULTICHOIX_OUVERTURE_AUTO: // Si la comboBox doit s'ouvrir lors du passage en Input autoOpen = true; break; 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.ComboBox, property.ToString()); } buffer.Get(out property); } }
/// <summary> /// Reads the object's properties from the buffer /// </summary> /// <param name="buffer">DVBuffer where the properties are read</param> public void ReadProperties(DVBuffer buffer) { ProprietesWpf property; buffer.Get(out property); while (property != ProprietesWpf.BOUTON_FIN) { switch (property) { case ProprietesWpf.PRESENTATION_DEBUT: // Début présentation if (Presentation == null) Presentation = new XHtmlPresentation(this); Presentation.ReadProperties(buffer); Presentation.SetProperties(); break; case ProprietesWpf.CODE_PAGE: // Code page buffer.Get(out codePage); break; case ProprietesWpf.PARAM_SAISIE_SEQUENCE: // Point de séquence (ushort) ushort pointSequence; buffer.Get(out pointSequence); SeqPoint = pointSequence; break; case ProprietesWpf.OBJET_RACCOURCI: // touche de raccourcis (byte) byte shortcut; buffer.Get(out shortcut); Shortcut = (char)shortcut; break; 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; case ProprietesWpf.BOUTON_LIBELLE: // Libellé du bouton (string) buffer.GetStringCP(out text, codePage); Content = text; break; case ProprietesWpf.BOUTON_IMAGE_DEBUT: // Image du bouton imageDuBouton = new XHtmlImageFile(); imageDuBouton.ReadProperties(buffer); if (this.Page.Html.App.ImagesCss.FirstOrDefault(e => e.FileName == imageDuBouton.FileName) == null) { imageDuBouton.Css = imageDuBouton.GenererCss(); this.Page.Html.App.ImagesCss.Add(imageDuBouton); } //Content = image = new XHtmlImage(Page) //{ // Source = XHtmlImage.GetImage(imageFile), // HorizontalAlignment = HorizontalAlignment.Center, // VerticalAlignment = VerticalAlignment.Center, // Stretch = Stretch.Uniform, // StretchDirection = StretchDirection.DownOnly //}; break; case ProprietesWpf.BOUTON_NOM_SELECTION: // Nom de la sélection (string) buffer.GetString(out Selection); break; case ProprietesWpf.BOUTON_LOCAL: // Uniquement si le bouton est local à la page IsLocal = true; break; case ProprietesWpf.BOUTON_ACTION: // Type d'action (byte = 1, 2 ou 3) buffer.Get(out action); switch (action) { case 1: buffer.Get(out pointTraitement); break; // Type = 1 : point de traitement case 2: buffer.Get(out pointArret); break; // Type = 2 : point d'arrêt case 3: buffer.GetString(out generatedString); break; // Type = 3 : chaîne à générer } break; case ProprietesWpf.BOUTON_IMAGES_ET_TITRE: var backgroundImageFile = new XHtmlImageFile(); // Image fond backgroundImageFile.ReadProperties(buffer); //BackgroundImage = XHtmlImage.GetImage(backgroundImageFile); var backgroundClickedImageFile = new XHtmlImageFile(); // Image fond au clic backgroundClickedImageFile.ReadProperties(buffer); //BackgroundClickedImage = XHtmlImage.GetImage(backgroundClickedImageFile); buffer.GetString(out text); // Libellé (string) Content = text; ushort leftMargin, topMargin, rightMargin, bottomMargin; // Marges (ushort x 4) buffer.Get(out leftMargin); buffer.Get(out topMargin); buffer.Get(out rightMargin); buffer.Get(out bottomMargin); //!!!!!!!!!!!! Padding = new Thickness(leftMargin, topMargin, rightMargin, bottomMargin); break; #region image survol case ProprietesWpf.BOUTON_IMAGE_SURVOL_DEBUT: // Image au survol du bouton (string) var mouseOverImageFile = new XHtmlImageFile(); mouseOverImageFile.ReadProperties(buffer); //imageMouseOver = (string.IsNullOrEmpty(mouseOverImageFile.FileName)) ? null : new Image //{ // Source = XHtmlImage.GetImage(mouseOverImageFile), // HorizontalAlignment = HorizontalAlignment.Center, // VerticalAlignment = VerticalAlignment.Center, // Stretch = Stretch.Uniform, // StretchDirection = StretchDirection.DownOnly //}; break; #endregion image survol #region curseur survol case ProprietesWpf.BOUTON_CURSEUR_SURVOL: // Curseur au survol (string) buffer.GetString(out mouseOverCursorFile); //cursorMouseOver = GetCursor(mouseOverCursorFile); break; #endregion curseur survol #region son survol case ProprietesWpf.BOUTON_SON_SURVOL: // Son au survol (string) buffer.GetString(out mouseOverSoundFile); //player = new MediaPlayer(); //soundMouseOver = GetSound(mouseOverSoundFile); break; #endregion son survol #region son au clic case ProprietesWpf.BOUTON_SON_CLIC: // Son au clic (string) buffer.GetString(out clickSoundFile); //player = new MediaPlayer(); //soundClick = GetSound(clickSoundFile); break; #endregion son au clic default: throw new XHtmlException(XHtmlErrorCodes.UnknownProperty, XHtmlErrorLocations.Button, property.ToString()); } buffer.Get(out property); } }