本文整理汇总了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());
}
示例2: Main
static void Main()
{
Rectangle rect = new Rectangle(5);
Console.WriteLine(rect);
Rectangle rect2 = new Rectangle(30, 20);
Console.WriteLine(rect2.Area());
}
示例3: TestRectangleArea
public void TestRectangleArea()
{
var rect = new Rectangle(0, 0, 100, 10);
var area = rect.Area();
Assert.True(area == 1000);
}
示例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;
}
}
//.........这里部分代码省略.........
示例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++;
}
示例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++;
}