コード例 #1
0
        public void AdjustRow(GridElement grid, int row, double height, bool adjustGridHeight, bool preserveRects)
        {
            double computedHeight1 = grid.RowDefinitions[row].ComputedHeight;
            double num             = 0.0;

            grid.CacheComputedRowHeights();
            List <int> heightStarIndices         = this.GetHeightStarIndices(grid);
            List <LayoutCacheRecord> layoutCache = (List <LayoutCacheRecord>)null;

            if (preserveRects)
            {
                layoutCache = this.GetCurrentRects((BaseFrameworkElement)grid);
            }
            height = Math.Max(0.0, height);
            if (row + 1 < grid.RowDefinitions.Count)
            {
                num    = grid.RowDefinitions[row + 1].ComputedHeight;
                height = Math.Min(computedHeight1 + num, height);
            }
            else if (!adjustGridHeight)
            {
                return;
            }
            using (this.DeferTokenForGridDesignMode(grid))
            {
                this.SetRowHeightCore(grid, row, height);
                if (!adjustGridHeight)
                {
                    double height1 = Math.Max(computedHeight1 + num - height, 0.0);
                    this.SetRowHeightCore(grid, row + 1, height1);
                    grid.ViewModel.Document.OnUpdatedEditTransaction();
                    grid.ViewModel.DefaultView.UpdateLayout();
                    if (Tolerances.GreaterThan(grid.RowDefinitions[row].ComputedHeight, height))
                    {
                        height = grid.RowDefinitions[row].ComputedHeight;
                        double height2 = Math.Max(computedHeight1 + num - height, 0.0);
                        this.SetRowHeightCore(grid, row, height);
                        this.SetRowHeightCore(grid, row + 1, height2);
                    }
                    else if (Tolerances.GreaterThan(grid.RowDefinitions[row + 1].ComputedHeight, height1))
                    {
                        double computedHeight2 = grid.RowDefinitions[row + 1].ComputedHeight;
                        height = Math.Max(computedHeight1 + num - computedHeight2, 0.0);
                        this.SetRowHeightCore(grid, row, height);
                        this.SetRowHeightCore(grid, row + 1, computedHeight2);
                    }
                }
                else
                {
                    double height1 = this.GetSizeElement((BaseFrameworkElement)grid).GetComputedTightBounds().Height;
                    this.SetGridHeightCore(grid, Math.Max(height1 + height - computedHeight1, 0.0));
                    grid.ViewModel.Document.OnUpdatedEditTransaction();
                    grid.ViewModel.DefaultView.UpdateLayout();
                    if (Tolerances.GreaterThan(grid.RowDefinitions[row].ComputedHeight, height))
                    {
                        height = grid.RowDefinitions[row].ComputedHeight;
                        double height2 = Math.Max(height1 + height - computedHeight1, 0.0);
                        this.SetRowHeightCore(grid, row, height);
                        this.SetGridHeightCore(grid, height2);
                    }
                }
                this.NormalizeHeightStars(grid, heightStarIndices);
                grid.UncacheComputedRowHeights();
                if (!preserveRects)
                {
                    return;
                }
                grid.ViewModel.Document.OnUpdatedEditTransaction();
                grid.ViewModel.DefaultView.UpdateLayout();
                this.SetCurrentRects((BaseFrameworkElement)grid, layoutCache);
            }
        }
コード例 #2
0
        private bool TestGeometryAgainstFrustum(MeshGeometry3D rawGeometry, Material frontMaterial, Material backMaterial, BoundingVolume frustum, Matrix3D transform)
        {
            if (rawGeometry == null)
            {
                return(false);
            }
            TriangleEnumerator triangleEnumerator = new TriangleEnumerator(rawGeometry.Positions, rawGeometry.TriangleIndices);

            Point3D[] point3DArray = new Point3D[3];
            foreach (int[] numArray in triangleEnumerator.TriangleList)
            {
                point3DArray[0] = rawGeometry.Positions[numArray[0]];
                point3DArray[1] = rawGeometry.Positions[numArray[1]];
                point3DArray[2] = rawGeometry.Positions[numArray[2]];
                transform.Transform(point3DArray);
                if (frustum.IsPolygonContainedOrIntersecting(point3DArray))
                {
                    double num = Vector3D.DotProduct(Vector3D.CrossProduct(point3DArray[1] - point3DArray[0], point3DArray[2] - point3DArray[0]), point3DArray[0] - this.frustumCenterRay.Origin);
                    if (Tolerances.LessThanOrClose(num, 0.0) && frontMaterial != null || Tolerances.GreaterThan(num, 0.0) && backMaterial != null)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #3
0
        public void AdjustColumn(GridElement grid, int col, double width, bool adjustGridWidth, bool preserveRects)
        {
            double computedWidth1 = grid.ColumnDefinitions[col].ComputedWidth;
            double num            = 0.0;

            grid.CacheComputedColumnWidths();
            List <int> widthStarIndices          = this.GetWidthStarIndices(grid);
            List <LayoutCacheRecord> layoutCache = (List <LayoutCacheRecord>)null;

            if (preserveRects)
            {
                layoutCache = this.GetCurrentRects((BaseFrameworkElement)grid);
            }
            width = Math.Max(0.0, width);
            if (col + 1 < grid.ColumnDefinitions.Count)
            {
                num   = grid.ColumnDefinitions[col + 1].ComputedWidth;
                width = Math.Min(computedWidth1 + num, width);
            }
            else if (!adjustGridWidth)
            {
                return;
            }
            using (this.DeferTokenForGridDesignMode(grid))
            {
                this.SetColumnWidthCore(grid, col, width);
                if (!adjustGridWidth)
                {
                    double width1 = Math.Max(computedWidth1 + num - width, 0.0);
                    this.SetColumnWidthCore(grid, col + 1, width1);
                    grid.ViewModel.Document.OnUpdatedEditTransaction();
                    grid.ViewModel.DefaultView.UpdateLayout();
                    if (Tolerances.GreaterThan(grid.ColumnDefinitions[col].ComputedWidth, width))
                    {
                        width = grid.ColumnDefinitions[col].ComputedWidth;
                        double width2 = Math.Max(computedWidth1 + num - width, 0.0);
                        this.SetColumnWidthCore(grid, col, width);
                        this.SetColumnWidthCore(grid, col + 1, width2);
                    }
                    else if (Tolerances.GreaterThan(grid.ColumnDefinitions[col + 1].ComputedWidth, width1))
                    {
                        double computedWidth2 = grid.ColumnDefinitions[col + 1].ComputedWidth;
                        width = Math.Max(computedWidth1 + num - computedWidth2, 0.0);
                        this.SetColumnWidthCore(grid, col, width);
                        this.SetColumnWidthCore(grid, col + 1, computedWidth2);
                    }
                }
                else
                {
                    double width1 = this.GetSizeElement((BaseFrameworkElement)grid).GetComputedTightBounds().Width;
                    this.SetGridWidthCore(grid, Math.Max(width1 + width - computedWidth1, 0.0));
                    grid.ViewModel.Document.OnUpdatedEditTransaction();
                    grid.ViewModel.DefaultView.UpdateLayout();
                    if (Tolerances.GreaterThan(grid.ColumnDefinitions[col].ComputedWidth, width))
                    {
                        width = grid.ColumnDefinitions[col].ComputedWidth;
                        double width2 = Math.Max(width1 + width - computedWidth1, 0.0);
                        this.SetColumnWidthCore(grid, col, width);
                        this.SetGridWidthCore(grid, width2);
                    }
                }
                this.NormalizeWidthStars(grid, widthStarIndices);
                grid.UncacheComputedColumnWidths();
                if (!preserveRects)
                {
                    return;
                }
                grid.ViewModel.Document.OnUpdatedEditTransaction();
                grid.ViewModel.DefaultView.UpdateLayout();
                this.SetCurrentRects((BaseFrameworkElement)grid, layoutCache);
            }
        }