当前位置: 首页>>代码示例>>C#>>正文


C# SlimDX.WriteRange方法代码示例

本文整理汇总了C#中SlimDX.WriteRange方法的典型用法代码示例。如果您正苦于以下问题:C# SlimDX.WriteRange方法的具体用法?C# SlimDX.WriteRange怎么用?C# SlimDX.WriteRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SlimDX的用法示例。


在下文中一共展示了SlimDX.WriteRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteString

		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;
			}
		}
开发者ID:RugCode,项目名称:drg-pt,代码行数:46,代码来源:TextRenderHelper.cs

示例2: WriteVisibleElements

		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;
			}
		}
开发者ID:RugCode,项目名称:drg-pt,代码行数:74,代码来源:MenuItem.cs

示例3: WriteLinesForBounds

		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;
			}

		}
开发者ID:RugCode,项目名称:drg-pt,代码行数:83,代码来源:UiControlBase.cs

示例4: WriteTrianglesForBounds

		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;
		} 
开发者ID:RugCode,项目名称:drg-pt,代码行数:21,代码来源:UiControlBase.cs

示例5: WriteDynamicElements

		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;
			}
		}
开发者ID:RugCode,项目名称:drg-pt,代码行数:47,代码来源:PeekGraph.cs


注:本文中的SlimDX.WriteRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。