當前位置: 首頁>>代碼示例>>C#>>正文


C# Int32Collection.Freeze方法代碼示例

本文整理匯總了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();
       }
 }
開發者ID:sunoru,項目名稱:PBO,代碼行數:35,代碼來源:Terrain.cs

示例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();
 }
開發者ID:sunoru,項目名稱:PBO,代碼行數:8,代碼來源:Pokemon.cs

示例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;
        }
開發者ID:BEEden,項目名稱:Diplomarbeit,代碼行數:27,代碼來源:PointGeometryBuilder.cs

示例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;
        }
開發者ID:ORRNY66,項目名稱:helix-toolkit,代碼行數:28,代碼來源:BillboardGeometryBuilder.cs

示例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();
//.........這裏部分代碼省略.........
開發者ID:whztt07,項目名稱:Dynamo,代碼行數:101,代碼來源:Watch3DView.xaml.cs

示例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;
        }
開發者ID:XiBeichuan,項目名稱:hydronumerics,代碼行數:36,代碼來源:ScreenSpaceLines3D.cs

示例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;
            }
開發者ID:edealbag,項目名稱:bot,代碼行數:82,代碼來源:TreeMap3D.cs

示例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);
        }
開發者ID:777ondro,項目名稱:sw-en,代碼行數:29,代碼來源:CNode.cs

示例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;
//.........這裏部分代碼省略.........
開發者ID:TheChosen0ne,項目名稱:Dynamo,代碼行數:101,代碼來源:Watch3DView.xaml.cs


注:本文中的System.Windows.Media.Int32Collection.Freeze方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。