本文整理汇总了C#中System.Windows.Media.Int32Collection.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# Int32Collection.Freeze方法的具体用法?C# Int32Collection.Freeze怎么用?C# Int32Collection.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Int32Collection
的用法示例。
在下文中一共展示了Int32Collection.Freeze方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Terrain3D
static Terrain3D()
{
{
SX = new double[17];
SZ = new double[17];
int i = 0;
for (double d = 0; d < 2; d += 0.125)
{
i++;
SX[i] = Math.Cos(Math.PI * d);
SZ[i] = Math.Sin(Math.PI * d);
}
}
{
TEXTURE_COORDINATES = new PointCollection(17);
TEXTURE_COORDINATES.Add(new Point(0, 0));
Point p = new Point(1, 0);
int i = -1;
while (++i < 16) TEXTURE_COORDINATES.Add(p);
TEXTURE_COORDINATES.Freeze();
}
{
TRIANGLE_INDICES = new Int32Collection(48);
for (int i = 1; i < 16; i++)
{
TRIANGLE_INDICES.Add(0);
TRIANGLE_INDICES.Add(i + 1);
TRIANGLE_INDICES.Add(i);
}
TRIANGLE_INDICES.Add(0);
TRIANGLE_INDICES.Add(1);
TRIANGLE_INDICES.Add(16);
TRIANGLE_INDICES.Freeze();
}
}
示例2: Pokemon3D
static Pokemon3D()
{
TEXTURE_COORDINATES = new PointCollection(new Point[]
{ new Point(0, 1), new Point(0, 0), new Point(1, 1), new Point(1, 0) });
TRIANGLE_INDICES = new Int32Collection(new int[] { 0, 2, 1, 3, 1, 2 });
TEXTURE_COORDINATES.Freeze();
TRIANGLE_INDICES.Freeze();
}
示例3: CreateIndices
/// <summary>
/// Creates the triangle indices.
/// </summary>
/// <param name="n">
/// The number of points.
/// </param>
/// <returns>
/// The triangle indices.
/// </returns>
public Int32Collection CreateIndices(int n)
{
var indices = new Int32Collection(n * 6);
for (int i = 0; i < n; i++)
{
indices.Add(i * 4 + 2);
indices.Add(i * 4 + 1);
indices.Add(i * 4 + 0);
indices.Add(i * 4 + 2);
indices.Add(i * 4 + 3);
indices.Add(i * 4 + 1);
}
indices.Freeze();
return indices;
}
示例4: CreateIndices
/// <summary>
/// Creates the triangle indices.
/// </summary>
/// <param name="n">
/// The number of points.
/// </param>
/// <returns>
/// The triangle indices.
/// </returns>
public static Int32Collection CreateIndices(int n)
{
var indices = new Int32Collection(n * 6);
for (int i = 0; i < n; i++)
{
// bottom right triangle
indices.Add((i * 4) + 0);
indices.Add((i * 4) + 1);
indices.Add((i * 4) + 2);
// top left triangle
indices.Add((i * 4) + 2);
indices.Add((i * 4) + 3);
indices.Add((i * 4) + 0);
}
indices.Freeze();
return indices;
}
示例5: RenderDrawables
/// <summary>
/// Use the render packages returned from the visualization manager to update the visuals.
/// The visualization event arguments will contain a set of render packages and an id representing
/// the associated node. Visualizations for the background preview will return an empty id.
/// </summary>
/// <param name="e"></param>
public void RenderDrawables(VisualizationEventArgs e)
{
//check the id, if the id is meant for another watch,
//then ignore it
if (e.Id != _id)
{
return;
}
Debug.WriteLine(string.Format("Rendering visuals for {0}", e.Id));
var sw = new Stopwatch();
sw.Start();
Points = null;
Lines = null;
Mesh = null;
XAxes = null;
YAxes = null;
ZAxes = null;
PointsSelected = null;
LinesSelected = null;
MeshSelected = null;
Text = null;
MeshCount = 0;
//separate the selected packages
var packages = e.Packages.Where(x => x.Selected == false)
.Where(rp=>rp.TriangleVertices.Count % 9 == 0)
.ToArray();
var selPackages = e.Packages
.Where(x => x.Selected)
.Where(rp => rp.TriangleVertices.Count % 9 == 0)
.ToArray();
//pre-size the points collections
var pointsCount = packages.Select(x => x.PointVertices.Count/3).Sum();
var selPointsCount = selPackages.Select(x => x.PointVertices.Count / 3).Sum();
var points = new Point3DCollection(pointsCount);
var pointsSelected = new Point3DCollection(selPointsCount);
//pre-size the lines collections
//these sizes are conservative as the axis lines will be
//taken from the linestripvertex collections as well.
var lineCount = packages.Select(x => x.LineStripVertices.Count/3).Sum();
var lineSelCount = selPackages.Select(x => x.LineStripVertices.Count / 3).Sum();
var lines = new Point3DCollection(lineCount);
var linesSelected = new Point3DCollection(lineSelCount);
var redLines = new Point3DCollection(lineCount);
var greenLines = new Point3DCollection(lineCount);
var blueLines = new Point3DCollection(lineCount);
//pre-size the text collection
var textCount = e.Packages.Count(x => x.DisplayLabels);
var text = new List<BillboardTextItem>(textCount);
//http://blogs.msdn.com/b/timothyc/archive/2006/08/31/734308.aspx
//presize the mesh collections
var meshVertCount = packages.Select(x => x.TriangleVertices.Count / 3).Sum();
var meshVertSelCount = selPackages.Select(x => x.TriangleVertices.Count / 3).Sum();
var mesh = new MeshGeometry3D();
var meshSel = new MeshGeometry3D();
var verts = new Point3DCollection(meshVertCount);
var vertsSel = new Point3DCollection(meshVertSelCount);
var norms = new Vector3DCollection(meshVertCount);
var normsSel = new Vector3DCollection(meshVertSelCount);
var tris = new Int32Collection(meshVertCount);
var trisSel = new Int32Collection(meshVertSelCount);
foreach (var package in packages)
{
ConvertPoints(package, points, text);
ConvertLines(package, lines, redLines, greenLines, blueLines, text);
ConvertMeshes(package, verts, norms, tris);
}
foreach (var package in selPackages)
{
ConvertPoints(package, pointsSelected, text);
ConvertLines(package, linesSelected, redLines, greenLines, blueLines, text);
ConvertMeshes(package, vertsSel, normsSel, trisSel);
}
sw.Stop();
Debug.WriteLine(string.Format("RENDER: {0} ellapsed for updating background preview.", sw.Elapsed));
var vm = (IWatchViewModel)DataContext;
if (vm.CheckForLatestRenderCommand.CanExecute(e.TaskId))
{
vm.CheckForLatestRenderCommand.Execute(e.TaskId);
}
points.Freeze();
//.........这里部分代码省略.........
示例6: RebuildGeometry
private void RebuildGeometry()
{
double halfThickness = Thickness / 2.0;
int numLines = Points.Count / 2;
Point3DCollection positions = new Point3DCollection(numLines * 4);
for (int i = 0; i < numLines; i++)
{
int startIndex = i * 2;
Point3D startPoint = Points[startIndex];
Point3D endPoint = Points[startIndex + 1];
AddSegment(positions, startPoint, endPoint, halfThickness);
}
positions.Freeze();
_mesh.Positions = positions;
Int32Collection indices = new Int32Collection(Points.Count * 3);
for (int i = 0; i < Points.Count / 2; i++)
{
indices.Add(i * 4 + 2);
indices.Add(i * 4 + 1);
indices.Add(i * 4 + 0);
indices.Add(i * 4 + 2);
indices.Add(i * 4 + 3);
indices.Add(i * 4 + 1);
}
indices.Freeze();
_mesh.TriangleIndices = indices;
}
示例7: GenerateTreeMap3DModel
private static Model3D GenerateTreeMap3DModel(int index, int count)
{
MeshGeometry3D meshGeometry3D = new MeshGeometry3D();
Point3DCollection positions = new Point3DCollection();
positions.Add(new Point3D(0, 0, 1));
positions.Add(new Point3D(0, 0, 0));
positions.Add(new Point3D(1, 0, 0));
positions.Add(new Point3D(1, 0, 1));
positions.Add(new Point3D(0, 1, 1));
positions.Add(new Point3D(0, 1, 0));
positions.Add(new Point3D(1, 1, 0));
positions.Add(new Point3D(1, 1, 1));
positions.Freeze();
Int32Collection triangleIndices = new Int32Collection();
triangleIndices.Add(0);
triangleIndices.Add(1);
triangleIndices.Add(2);
triangleIndices.Add(2);
triangleIndices.Add(3);
triangleIndices.Add(0);
triangleIndices.Add(4);
triangleIndices.Add(7);
triangleIndices.Add(6);
triangleIndices.Add(6);
triangleIndices.Add(5);
triangleIndices.Add(4);
triangleIndices.Add(0);
triangleIndices.Add(3);
triangleIndices.Add(7);
triangleIndices.Add(7);
triangleIndices.Add(4);
triangleIndices.Add(0);
triangleIndices.Add(1);
triangleIndices.Add(5);
triangleIndices.Add(6);
triangleIndices.Add(6);
triangleIndices.Add(2);
triangleIndices.Add(1);
triangleIndices.Add(3);
triangleIndices.Add(2);
triangleIndices.Add(6);
triangleIndices.Add(6);
triangleIndices.Add(7);
triangleIndices.Add(3);
triangleIndices.Add(0);
triangleIndices.Add(4);
triangleIndices.Add(5);
triangleIndices.Add(5);
triangleIndices.Add(7);
triangleIndices.Add(0);
triangleIndices.Freeze();
// finally set the data
meshGeometry3D.TriangleIndices = triangleIndices;
meshGeometry3D.Positions = positions;
// create the geometry model
GeometryModel3D geom3D = new GeometryModel3D();
geom3D.Geometry = meshGeometry3D;
Color color = ColorHelper.HsbToRgb(index / (float)count, .9f, 1f);
SolidColorBrush solidColorBrush = color.ToBrush();
solidColorBrush.Freeze();
geom3D.Material = new DiffuseMaterial(solidColorBrush);
return geom3D;
}
示例8: RebuildGeometry
private void RebuildGeometry()
{
//double halfThickness = Thickness / 2.0;
//int numLines = Points.Count / 2;
//Point3DCollection positions = new Point3DCollection(numLines * 4);
//for (int i = 0; i < numLines; i++)
//{
// int startIndex = i * 2;
// Point3D startPoint = Points[startIndex];
// Point3D endPoint = Points[startIndex + 1];
// AddSegment(positions, startPoint, endPoint, halfThickness);
//}
//positions.Freeze();
//_mesh.Positions = positions;
Int32Collection indices = new Int32Collection(Points.Count * 6);
for (int i = 0; i < Points.Count; i++)
{
indices.Add(i * 4 + 2);
indices.Add(i * 4 + 1);
indices.Add(i * 4 + 0);
indices.Add(i * 4 + 2);
indices.Add(i * 4 + 3);
indices.Add(i * 4 + 1);
}
indices.Freeze();
_mesh.TriangleIndices = indices;
_mesh.Positions = CreatePositions(this.Points, this.Size, 0.0);
}
示例9: RenderDrawables
/// <summary>
/// Use the render packages returned from the visualization manager to update the visuals.
/// The visualization event arguments will contain a set of render packages and an id representing
/// the associated node. Visualizations for the background preview will return an empty id.
/// </summary>
/// <param name="e"></param>
private void RenderDrawables(VisualizationEventArgs e)
{
try
{
//check the id, if the id is meant for another watch,
//then ignore it
if (e.Id != _id)
{
return;
}
var sw = new Stopwatch();
sw.Start();
Points = null;
Lines = null;
Mesh = null;
XAxes = null;
YAxes = null;
ZAxes = null;
PointsSelected = null;
LinesSelected = null;
MeshSelected = null;
Text = null;
MeshCount = 0;
//separate the selected packages
var packages = e.Packages.Where(x => x.Selected == false).ToArray();
var selPackages = e.Packages.Where(x => x.Selected).ToArray();
//pre-size the points collections
var pointsCount = packages.Select(x => x.PointVertices.Count/3).Sum();
var selPointsCount = selPackages.Select(x => x.PointVertices.Count / 3).Sum();
var points = new Point3DCollection(pointsCount);
var pointsSelected = new Point3DCollection(selPointsCount);
//pre-size the lines collections
//these sizes are conservative as the axis lines will be
//taken from the linestripvertex collections as well.
var lineCount = packages.Select(x => x.LineStripVertices.Count/3).Sum();
var lineSelCount = selPackages.Select(x => x.LineStripVertices.Count / 3).Sum();
var lines = new Point3DCollection(lineCount);
var linesSelected = new Point3DCollection(lineSelCount);
var redLines = new Point3DCollection(lineCount);
var greenLines = new Point3DCollection(lineCount);
var blueLines = new Point3DCollection(lineCount);
//pre-size the text collection
var textCount = e.Packages.Count(x => x.DisplayLabels);
var text = new List<BillboardTextItem>(textCount);
//http://blogs.msdn.com/b/timothyc/archive/2006/08/31/734308.aspx
//presize the mesh collections
var meshVertCount = packages.Select(x => x.TriangleVertices.Count / 3).Sum();
var meshVertSelCount = selPackages.Select(x => x.TriangleVertices.Count / 3).Sum();
var mesh = new MeshGeometry3D();
var meshSel = new MeshGeometry3D();
var verts = new Point3DCollection(meshVertCount);
var vertsSel = new Point3DCollection(meshVertSelCount);
var norms = new Vector3DCollection(meshVertCount);
var normsSel = new Vector3DCollection(meshVertSelCount);
var tris = new Int32Collection(meshVertCount);
var trisSel = new Int32Collection(meshVertSelCount);
foreach (var package in packages)
{
ConvertPoints(package, points, text);
ConvertLines(package, lines, redLines, greenLines, blueLines, text);
ConvertMeshes(package, verts, norms, tris);
}
foreach (var package in selPackages)
{
ConvertPoints(package, pointsSelected, text);
ConvertLines(package, linesSelected, redLines, greenLines, blueLines, text);
ConvertMeshes(package, vertsSel, normsSel, trisSel);
}
points.Freeze();
pointsSelected.Freeze();
Points = points;
PointsSelected = pointsSelected;
lines.Freeze();
linesSelected.Freeze();
redLines.Freeze();
greenLines.Freeze();
blueLines.Freeze();
Lines = lines;
LinesSelected = linesSelected;
XAxes = redLines;
YAxes = greenLines;
ZAxes = blueLines;
//.........这里部分代码省略.........