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


C# Rectangle.Area方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            Rectangle rectangle = new Rectangle();
            rectangle.Length = 20;
            rectangle.Width = 10;
            Console.WriteLine(rectangle.Area());

            iRectangle inRectangle = rectangle;
            Console.WriteLine(inRectangle.Area());
            inRectangle.Width = 20;
            Console.WriteLine(inRectangle.Area());
            Console.WriteLine(rectangle.Area());
        }
开发者ID:xuzhiwei1989,项目名称:BookTest,代码行数:13,代码来源:Program.cs

示例2: Main

 static void Main()
 {
     Rectangle rect = new Rectangle(5);
     Console.WriteLine(rect);
     Rectangle rect2 = new Rectangle(30, 20);
     Console.WriteLine(rect2.Area());
 }
开发者ID:nickgenov,项目名称:ObjectOrientedProgramming,代码行数:7,代码来源:ConstructorChaining.cs

示例3: TestRectangleArea

        public void TestRectangleArea()
        {
            var rect = new Rectangle(0, 0, 100, 10);
            var area = rect.Area();

            Assert.True(area == 1000);
        }
开发者ID:bvssvni,项目名称:csharp-matrix2d,代码行数:7,代码来源:Test.cs

示例4: SplitPage

        internal RtreePage SplitPage(Storage storage, Rectangle r, IPersistent obj)
        {
            int i, j, seed0 = 0, seed1 = 0;
            long[] rectArea = new long[card + 1];
            long waste;
            long worstWaste = Int64.MinValue;
            //
            // As the seeds for the two groups, find two rectangles which waste
            // the most area if covered by a single rectangle.
            //
            rectArea[0] = r.Area();
            for (i = 0; i < card; i++)
            {
                rectArea[i + 1] = b[i].Area();
            }
            Rectangle bp = r;
            for (i = 0; i < card; i++)
            {
                for (j = i + 1; j <= card; j++)
                {
                    waste = Rectangle.JoinArea(bp, b[j - 1]) - rectArea[i] - rectArea[j];
                    if (waste > worstWaste)
                    {
                        worstWaste = waste;
                        seed0 = i;
                        seed1 = j;
                    }
                }
                bp = b[i];
            }
            byte[] taken = new byte[card];
            Rectangle group0, group1;
            long groupArea0, groupArea1;
            int groupCard0, groupCard1;
            RtreePage pg;

            taken[seed1 - 1] = 2;
            group1 = new Rectangle(b[seed1 - 1]);

            if (seed0 == 0)
            {
                group0 = new Rectangle(r);
                pg = new RtreePage(storage, obj, r);
            }
            else
            {
                group0 = new Rectangle(b[seed0 - 1]);
                pg = new RtreePage(storage, branch.GetRaw(seed0 - 1), group0);
                SetBranch(seed0 - 1, r, obj);
            }
            groupCard0 = groupCard1 = 1;
            groupArea0 = rectArea[seed0];
            groupArea1 = rectArea[seed1];
            //
            // Split remaining rectangles between two groups.
            // The one chosen is the one with the greatest difference in area
            // expansion depending on which group - the rect most strongly
            // attracted to one group and repelled from the other.
            //
            while (groupCard0 + groupCard1 < card + 1 && groupCard0 < card + 1 - minFill && groupCard1 < card + 1 - minFill)
            {
                int betterGroup = -1, chosen = -1;
                long biggestDiff = -1;
                for (i = 0; i < card; i++)
                {
                    if (taken[i] == 0)
                    {
                        long diff = (Rectangle.JoinArea(group0, b[i]) - groupArea0) - (Rectangle.JoinArea(group1, b[i]) - groupArea1);
                        if (diff > biggestDiff || -diff > biggestDiff)
                        {
                            chosen = i;
                            if (diff < 0)
                            {
                                betterGroup = 0;
                                biggestDiff = -diff;
                            }
                            else
                            {
                                betterGroup = 1;
                                biggestDiff = diff;
                            }
                        }
                    }
                }
                Assert.That(chosen >= 0);
                if (betterGroup == 0)
                {
                    group0.Join(b[chosen]);
                    groupArea0 = group0.Area();
                    taken[chosen] = 1;
                    pg.SetBranch(groupCard0++, b[chosen], branch.GetRaw(chosen));
                }
                else
                {
                    groupCard1 += 1;
                    group1.Join(b[chosen]);
                    groupArea1 = group1.Area();
                    taken[chosen] = 2;
                }
            }
//.........这里部分代码省略.........
开发者ID:kjk,项目名称:tenderbase,代码行数:101,代码来源:RtreePage.cs

示例5: Layer

        // Layer()
        //
        // Layer constructor which requires the initialization of both coordinate pairs, material name
        // and the ErrorHandler function to be passed in.
        /// <summary>
        /// Layer Constructor
        /// </summary>
        /// <param name="local_ErrorHandler">Main UI ErrorHandler</param>
        /// <param name="x_0">X-coordinate, upper left corner</param>
        /// <param name="y_0">Y-coordinate, upper left corner</param>
        /// <param name="x_f">X-coordinate, lower right corner</param>
        /// <param name="y_f">Y-coordinate, lower right corner</param>
        /// <param name="Mat_Name">Material for this layer</param>
        /// <param name="n_Nodes">Number of nodes for this layer</param>
        public Layer(ErrorHandler local_ErrorHandler, float x_0, float y_0, float x_f, float y_f, string Mat_Name, int n_Nodes)
        {
            Layer_Errors = local_ErrorHandler;
            Layer_Material = Mat_Name;

            Check_Positioning(x_0, y_0, x_f, y_f);

            Layer_Rectangle = new Rectangle(x_0, y_0, x_f, y_f);

            Layer_x0 = x_0;
            Layer_xf = x_f;
            Layer_y0 = y_0;
            Layer_yf = y_f;

            Layer_Area = Layer_Rectangle.Area();

            Nodes = n_Nodes;

            Layer_ID = LayerID++;
        }
开发者ID:robojames,项目名称:2D_Patankar,代码行数:34,代码来源:Layer.cs

示例6: Layer

        // Layer()
        //
        // Layer constructor which requires the initialization of both coordinate pairs, material name
        // and the ErrorHandler function to be passed in.
        /// <summary>
        /// Layer Constructor
        /// </summary>
        /// <param name="local_ErrorHandler">Main UI ErrorHandler</param>
        /// <param name="x_0">X-coordinate, upper left corner</param>
        /// <param name="y_0">Y-coordinate, upper left corner</param>
        /// <param name="x_f">X-coordinate, lower right corner</param>
        /// <param name="y_f">Y-coordinate, lower right corner</param>
        /// <param name="Mat_Name">Material for this layer</param>
        /// <param name="n_Nodes">Number of nodes for this layer</param>
        public Layer(double x_0, double y_0, double x_f, double y_f, string Mat_Name)
        {
            Layer_Material = Mat_Name;

            Layer_Rectangle = new Rectangle(x_0, y_0, x_f, y_f);

            Layer_x0 = x_0;
            Layer_xf = x_f;
            Layer_y0 = y_0;
            Layer_yf = y_f;

            Layer_Area = Layer_Rectangle.Area();

            Layer_ID = LayerID++;
        }
开发者ID:robojames,项目名称:TEModel,代码行数:29,代码来源:Layer.cs


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