本文整理汇总了C#中System.Drawing.Font.GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Font.GetHeight方法的具体用法?C# System.Drawing.Font.GetHeight怎么用?C# System.Drawing.Font.GetHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Font
的用法示例。
在下文中一共展示了System.Drawing.Font.GetHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: m_printDocument_PrintPage
void m_printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
SelectedMealCollection colData = (SelectedMealCollection)this.FindResource("SelectedMealCollectionData");
float leftMargin = e.MarginBounds.Left;
float rightMargin = e.MarginBounds.Right;
float topMargin = e.MarginBounds.Top;
float yPos = leftMargin;
float xPos = 0;
float centrePos = 2 * (rightMargin - leftMargin) / 5;
float rightPos = 4 * (rightMargin - leftMargin) / 5;
int count = 0;
System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
// Work out the number of lines per page, using the MarginBounds.
float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
float lineCount = 0;
foreach (var selectedMeal in colData)
{
// calculate the next line position based on the height of the font according to the printing device
yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
e.Graphics.DrawString(selectedMeal.Date, printFont, myBrush, xPos, yPos);
lineCount++;
yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
e.Graphics.DrawString(selectedMeal.Meal, printFont, myBrush, xPos + 20, yPos);
lineCount++;
if (lineCount > linesPerPage) { break; }
}
lineCount = 0;
count = 0;
SelectedIngredientsCollection ingredientData = (SelectedIngredientsCollection)this.FindResource("SelectedIngredientsCollectionData");
foreach (SelectedIngredient ingredient in ingredientData)
{
// calculate the next line position based on the height of the font according to the printing device
yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
xPos = centrePos;
if (lineCount > linesPerPage) xPos = rightPos;
e.Graphics.DrawString(ingredient.Ingredient, printFont, myBrush, xPos, yPos);
lineCount++;
}
// If there are more lines, print another page.
if (lineCount > linesPerPage)
{
// e.HasMorePages = true;
}
else
{
e.HasMorePages = false;
myBrush.Dispose();
}
}