本文整理匯總了C#中System.Drawing.Rectangle.GetLargestRectangle方法的典型用法代碼示例。如果您正苦於以下問題:C# Rectangle.GetLargestRectangle方法的具體用法?C# Rectangle.GetLargestRectangle怎麽用?C# Rectangle.GetLargestRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.GetLargestRectangle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BuildDrawingResultSet
/// <summary>
/// Receives a Hana result set (and its meta data) and builds a drawing result set, including the coloring of points
/// </summary>
internal void BuildDrawingResultSet(List<ResultSetHana> resultSetHanaList, ResultSetHanaMetadata meta)
{
_resultSetHanaMeta = meta;
// Calculate the largest rectangle with aspect ratio of the result set, that can fit in the viewport
float widthMandle = Math.Abs(_resultSetHanaMeta.Xmax - _resultSetHanaMeta.Xmin);
float heightMandle = Math.Abs(_resultSetHanaMeta.Ymax - _resultSetHanaMeta.Ymin);
float aspectRatioMandle = widthMandle / heightMandle;
Rectangle viewportAtOrigin = new Rectangle(0, 0, _viewport.Width, _viewport.Height);
Rectangle biggestRectangleThatCanFitInViewport = viewportAtOrigin.GetLargestRectangle(aspectRatioMandle, 1f);
// The calculation above is just to give us the right scale and coordinates to fit in the viewport
float scale = biggestRectangleThatCanFitInViewport.Width / widthMandle;
float xStart = _viewport.X - (scale * _resultSetHanaMeta.Xmin);
float yStart = _viewport.Y - (scale * _resultSetHanaMeta.Ymin);
foreach (ResultSetHana rs in resultSetHanaList)
{
// Color
int a = 0;
int r = 0;
int g = 0;
int b = 0;
ConvertEscapedToColor(this.ColorAlgorithm, rs.Escaped, out a, out r, out g, out b);
ResultSetDraw rsd = new ResultSetDraw()
{
Id = rs.Id,
XRaw = rs.X,
YRaw = rs.Y,
EscapedRaw = rs.Escaped,
XDraw = xStart + (rs.X * scale),
YDraw = yStart + (rs.Y * scale),
Pen = new Pen(Color.FromArgb(a, r, g, b), BrushWidth),
};
_resultSetDraw.Add(rsd);
}
}