コード例 #1
0
ファイル: XHtmlPage.cs プロジェクト: shinesoleil/widgetJquery
		/// <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);
			//}
		}
コード例 #2
0
ファイル: XHtmlPage.cs プロジェクト: shinesoleil/widgetJquery
		/// <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

		}