Example #1
0
		public static void WriteString(View3D view,
											RectangleF RemainingBounds,
											string str, FontType fontType, ref float px, ref float py, float z, float scale, Color4 color,
											SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount,
											SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
		{
			float x, y, w, h;
			float pw, ph; 

			//UiStyleHelper.CovertToVertCoords(px, py, view.WindowSize, view.PixelSize, out x, out y);
			UiStyleHelper.CovertToVertCoords(RemainingBounds, view.WindowSize, view.PixelSize, out x, out y, out w, out h);

			x += px;
			y += py; 

			foreach (char @char in str)
			{
				RectangleF rect = Effect.TextFont[fontType, @char];

				//pw = rect.Width * Effect.TextFont.TextureSize * scale;
				//ph = rect.Height * Effect.TextFont.TextureSize * scale;

				w = rect.Width * Effect.TextFont.TextureSize * view.PixelSize.X * scale;
				h = rect.Height * Effect.TextFont.TextureSize * view.PixelSize.Y * scale;

				TriangleVerts.WriteRange(new UIVertex[] { 
					new UIVertex() { Color = color, Position = new Vector3(x, y, z), TextureCoords = new Vector2(rect.Left, rect.Top) },
					new UIVertex() { Color = color, Position = new Vector3(x + w, y, z), TextureCoords = new Vector2(rect.Right, rect.Top) },
					new UIVertex() { Color = color, Position = new Vector3(x, y - h, z), TextureCoords = new Vector2(rect.Left, rect.Bottom) },
					new UIVertex() { Color = color, Position = new Vector3(x + w, y - h, z), TextureCoords = new Vector2(rect.Right, rect.Bottom) }
				});

				int i = TriangleVertsCount;

				TriangleIndices.WriteRange(new int[] { 
					i + 0, i + 1, i + 2,
					i + 1, i + 3, i + 2
				});

				TriangleVertsCount += 4;
				TriangleIndicesCount += 6;

				x += w;
				px += w;
			}
		}
Example #2
0
		public override void WriteVisibleElements(View3D view, RectangleF ClientBounds, ref RectangleF RemainingBounds, SlimDX.DataStream LineVerts, ref int LineVertsCount, SlimDX.DataStream LinesIndices, ref int LinesIndicesCount, SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount, SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
		{
			float x, y, w, h;

			SizeF stringSize = TextRenderHelper.MessureString(m_Text, m_FontType, view, 1f);

			Size = new System.Drawing.Size((int)stringSize.Width + 20, Size.Height);

			m_Bounds = UiStyleHelper.LayoutControlBounds(RemainingBounds, Location, Size, Anchor, Docking, out RemainingBounds);

			UiStyleHelper.CovertToVertCoords(m_Bounds, view.WindowSize, view.PixelSize, out x, out y, out w, out h);

			Color4 lineColor = UiStyleHelper.GetControlLineColor(this);

			WriteLinesForBounds(x, y, w, h, lineColor, LineVerts, ref LineVertsCount, LinesIndices, ref LinesIndicesCount);

			Color4 backColor = UiStyleHelper.GetControlBackColor(this, IsOpen ? DisplayMode.Open : DisplayMode.Auto);

			WriteTrianglesForBounds(x, y, w, h, backColor, TriangleVerts, ref TriangleVertsCount, TriangleIndices, ref TriangleIndicesCount);

			Color4 textColor = UiStyleHelper.GetControlTextColor(this, IsOpen ? DisplayMode.Open : DisplayMode.Auto);

			TextRenderHelper.WriteString(view, Bounds,
													m_Text, m_FontType, new Vector3(view.PixelSize.X * 10, -view.PixelSize.Y * (Size.Height - stringSize.Height) * 0.5f, ZIndexForLines_Float), 1f, textColor,
													TriangleVerts, ref TriangleVertsCount,
													TriangleIndices, ref TriangleIndicesCount);			

			if (Items.Count > 0 && (IsOpen))
			{

				float maxWidth = m_Bounds.Width; 
				foreach (MenuItem item in Items)
				{
					float itemWidth = item.MessureTextWidth(view) + 20;

					if (itemWidth > maxWidth)
					{
						maxWidth = itemWidth; 
					}
				}

				float topMostLinesZ = Items[Items.Count - 1].ZIndexForLines_Float; 

				RectangleF ItemsBounds = new RectangleF(m_Bounds.Right, m_Bounds.Y, maxWidth, ClientBounds.Height - m_Bounds.Y);
				RectangleF MenuBounds = ItemsBounds; 

				foreach (MenuItem item in Items)
				{
					item.WriteVisibleElements(view, ClientBounds, ref ItemsBounds, LineVerts, ref LineVertsCount, LinesIndices, ref LinesIndicesCount, TriangleVerts, ref TriangleVertsCount, TriangleIndices, ref TriangleIndicesCount); 			
				}

				MenuBounds = new RectangleF(MenuBounds.X, MenuBounds.Y, MenuBounds.Width, MenuBounds.Height - ItemsBounds.Height);

				UiStyleHelper.CovertToVertCoords(MenuBounds, view.WindowSize, view.PixelSize, out x, out y, out w, out h);

				int i = LineVertsCount;

				LineVerts.WriteRange(new UIVertex[] { 
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y, topMostLinesZ), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y, topMostLinesZ), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y + h, topMostLinesZ), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y + h, topMostLinesZ), TextureCoords = new Vector2(0, 0) }
				});

				LinesIndices.WriteRange(new int[] { 
					i + 0, i + 1, 
					i + 0, i + 2, 
					i + 1, i + 3, 					
				});

				LineVertsCount += 4;
				LinesIndicesCount += 6;
			}
		}
Example #3
0
		protected void WriteLinesForBounds(float x, float y, float w, float h, Color4 lineColor, 
											SlimDX.DataStream LineVerts, ref int LineVertsCount, 
											SlimDX.DataStream LinesIndices, ref int LinesIndicesCount)
		{
			int i = LineVertsCount;

			if (Docking == System.Windows.Forms.DockStyle.Top)
			{
				LineVerts.WriteRange(new UIVertex[] { 
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) }
				});

				LinesIndices.WriteRange(new int[] { 
					i + 0, i + 1, 
				});

				LineVertsCount += 2;
				LinesIndicesCount += 2;
			}
			else if (Docking == System.Windows.Forms.DockStyle.Bottom)
			{
				LineVerts.WriteRange(new UIVertex[] { 
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
				});

				LinesIndices.WriteRange(new int[] { 
					i + 0, i + 1, 
				});

				LineVertsCount += 2;
				LinesIndicesCount += 2;
			}
			else if (Docking == System.Windows.Forms.DockStyle.Left)
			{
				LineVerts.WriteRange(new UIVertex[] { 					
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },					
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) }
				});

				LinesIndices.WriteRange(new int[] { 
					i + 0, i + 1, 
				});

				LineVertsCount += 2;
				LinesIndicesCount += 2;
			}
			else if (Docking == System.Windows.Forms.DockStyle.Right)
			{
				LineVerts.WriteRange(new UIVertex[] { 
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },					
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },					
				});

				LinesIndices.WriteRange(new int[] { 
					i + 0, i + 1, 
				});

				LineVertsCount += 2;
				LinesIndicesCount += 2;
			}
			else if (Docking != System.Windows.Forms.DockStyle.Fill)
			{
				LineVerts.WriteRange(new UIVertex[] { 
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
					new UIVertex() { Color = lineColor, Position = new Vector3(x + w, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) }
				});

				LinesIndices.WriteRange(new int[] { 
					i + 0, i + 1, 
					i + 1, i + 3, 
					i + 3, i + 2,
 					i + 2, i + 0,
				});

				LineVertsCount += 4;
				LinesIndicesCount += 8;
			}

		}
Example #4
0
		protected void WriteTrianglesForBounds(float x, float y, float w, float h, float z, Color4 backColor,
												SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount, 
												SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
		{
			TriangleVerts.WriteRange(new UIVertex[] { 
				new UIVertex() { Color = backColor, Position = new Vector3(x, y, z), TextureCoords = new Vector2(0, 0) },
				new UIVertex() { Color = backColor, Position = new Vector3(x + w, y, z), TextureCoords = new Vector2(0, 0) },
				new UIVertex() { Color = backColor, Position = new Vector3(x, y + h, z), TextureCoords = new Vector2(0, 0) },
				new UIVertex() { Color = backColor, Position = new Vector3(x + w, y + h, z), TextureCoords = new Vector2(0, 0) }
			});

			int i = TriangleVertsCount;

			TriangleIndices.WriteRange(new int[] { 
				i + 0, i + 1, i + 2,
				i + 1, i + 3, i + 2
			});

			TriangleVertsCount += 4;
			TriangleIndicesCount += 6;
		} 
Example #5
0
		public override void WriteDynamicElements(View3D view, SlimDX.DataStream LineVerts, ref int LineVertsCount, SlimDX.DataStream LinesIndices, ref int LinesIndicesCount, SlimDX.DataStream TriangleVerts, ref int TriangleVertsCount, SlimDX.DataStream TriangleIndices, ref int TriangleIndicesCount)
		{
			base.WriteDynamicElements(view, LineVerts, ref LineVertsCount, LinesIndices, ref LinesIndicesCount, TriangleVerts, ref TriangleVertsCount, TriangleIndices, ref TriangleIndicesCount); 

			float x, y, w, h;

			if (IsNested == true)
			{
				UiStyleHelper.CovertToVertCoords(Parent.Bounds, view.WindowSize, view.PixelSize, out x, out y, out w, out h);
			}
			else
			{
				UiStyleHelper.CovertToVertCoords(Bounds, view.WindowSize, view.PixelSize, out x, out y, out w, out h);
			}

			int i = LineVertsCount;
			float xInc = w / Values.Length;
			float xOffset;

			//foreach (int index in m_PeakLocations)

			for (int j = 0; j < m_PeakCount; j++)
			{
				int index = m_PeakLocations[j]; 

				if (index <= 0 || index >= Values.Length)
				{
					continue;
				}

				xOffset = x + (index * xInc);

				LineVerts.WriteRange(new UIVertex[] { 
							new UIVertex() { Color = m_PeakLineColor, Position = new Vector3(xOffset, y, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) },
							new UIVertex() { Color = m_PeakLineColor, Position = new Vector3(xOffset, y + h, ZIndexForLines_Float), TextureCoords = new Vector2(0, 0) }
						});

				LinesIndices.WriteRange(new int[] { 
							i + 0, i + 1, 
						});

				LineVertsCount += 2;
				LinesIndicesCount += 2;

				i += 2;
			}
		}