本文整理汇总了C#中System.Drawing.Font类的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Font类的具体用法?C# System.Drawing.Font怎么用?C# System.Drawing.Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Drawing.Font类属于命名空间,在下文中一共展示了System.Drawing.Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: repaintNodes
// prekresli sa vrchol
private void repaintNodes(KDNode n)
{
System.Drawing.Font font = new System.Drawing.Font("Verdana", 10);
System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
System.Drawing.Pen myPen = new System.Drawing.Pen(System.Drawing.Color.Black);
if (n.highlight)
{
myBrush.Color = System.Drawing.Color.Green;
myPen.Color = System.Drawing.Color.Green;
}
if (n.highlightRed)
{
myBrush.Color = System.Drawing.Color.Red;
myPen.Color = System.Drawing.Color.Red;
}
if (n.highligthIn)
{
myBrush.Color = System.Drawing.Color.Red;
myPen.Color = System.Drawing.Color.Red;
g.DrawEllipse(myPen, n.getPoint().X - (RADIUS + 2), n.getPoint().Y - (RADIUS + 2), 2 * (RADIUS + 2), 2 * (RADIUS + 2));
myPen.Color = System.Drawing.Color.Black;
}
g.FillEllipse(myBrush, n.getPoint().X - RADIUS, n.getPoint().Y - RADIUS, 2*RADIUS, 2*RADIUS);
string s = "(" + n.getPoint().X.ToString() + "," + n.getPoint().Y.ToString() + ")";
g.DrawString(s, font, myBrush, n.getPoint().X - 35, n.getPoint().Y);
}
示例2: InsertExcel
public bool InsertExcel(string titleName, string unit, GridControl gridControl, TONLI.BZH.UI.DSOFramerWordControl wordcontrol)
{
try
{
System.Drawing.Font font = new System.Drawing.Font("���ו", 16);
wordcontrol.DoInsert("\n\n"+titleName+"\n" , font, TONLI.BZH.UI.WdParagraphAlignment.Center);
//wordcontrol.DoPaste();
font = new System.Drawing.Font("���ו", 12);
wordcontrol.DoInsert(unit + "\n", font, TONLI.BZH.UI.WdParagraphAlignment.Right);
//wordcontrol.DoPaste();
wordcontrol.DoInsert("", font, TONLI.BZH.UI.WdParagraphAlignment.Center);
string filename =System.Windows.Forms.Application.StartupPath + "\\BlogData\\Blog.xls";
gridControl.DefaultView.ExportToExcelOld(filename);
wordcontrol.DoInsertOleObject(filename);
//System.Drawing.Font font = new System.Drawing.Font("���ו", 16);
wordcontrol.DoInsert("", font, TONLI.BZH.UI.WdParagraphAlignment.Center);
//Microsoft.Office.Interop.Excel.Application ep = new Microsoft.Office.Interop.Excel.Application();
//Microsoft.Office.Interop.Excel._Workbook wb = ep.Workbooks.Add(filename);
//Microsoft.Office.Interop.Excel.Sheets sheets = wb.Worksheets;
//Microsoft.Office.Interop.Excel._Worksheet ws = (Microsoft.Office.Interop.Excel._Worksheet)sheets.get_Item(1);// [System.Type.Missing];//.get.get_Item("xx");
//ws.UsedRange.Select();
//ws.UsedRange.Copy(System.Type.Missing);
//wordcontrol.DoPaste();
return true;
}
catch { return false; }
}
示例3: DrawingFont
public DrawingFont(IToolkit toolkit, System.Drawing.Font properties, float dpi)
{
this.toolkit = toolkit;
this.properties = properties;
this.dpi = dpi;
CreateFont();
}
示例4: 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();
}
}
示例5: BaseNavMin
public BaseNavMin(
System.Windows.Forms.Control parentpal,
System.Drawing.Size size,
System.Drawing.Point point,
float fontSize,
System.Drawing.Color backcolor,
System.Drawing.Color backlight,
System.Drawing.Color forecolor,
System.Drawing.Color forelight,
System.Windows.Forms.AnchorStyles anchorstyle
)
{
Backlight = backlight;
Forelight = forelight;
BackColor = Backcolor = backcolor;
ForeColor = Forecolor = forecolor;
Size = size;
Location = point;
Text = @"-";
TextAlign = Helper.Align;
Cursor = Helper.HCursors;
Font = new System.Drawing.Font(Helper.FontSymbol, fontSize);
Anchor = anchorstyle;
parentpal.Controls.Add(this);
MouseClick += BaseNavMin_MouseClick;
MouseLeave += BaseNavMin_MouseLeave;
MouseUp += BaseNavMin_MouseUp;
MouseDown += BaseNavMin_MouseDown;
MouseHover += BaseNavMin_MouseHover;
}
示例6: GetFontId
private int GetFontId(FontDescriptor fd)
{
var fontId = String.Intern(fd.Id);
var index = m_registeredFonts.FindIndex(fm => Object.ReferenceEquals(fm.m_id, fontId));
if (index == -1)
{
var fontObject = new Font(fd.FamilyName, fd.Size, fd.Style);
m_registeredFonts.Add(new FontMetrics
{
m_id = fontId,
m_fontObject = fontObject,
m_outlineThickness = fd.OutlineThickness,
m_spaceWidth = MeasureSpace(fontObject).Width,
m_fullWidthSpaceWidth = MeasureFullwidthSpace(fontObject).Width,
m_ascentInPixels = CalculateAscentInPixel(fontObject)
});
index = m_registeredFonts.Count - 1;
}
if (index > 0xffff)
{
throw new OverflowException("Number of registered font has grown ridiculously too large.");
}
return index;
}
示例7: LoadingProcess
private void LoadingProcess(object param)
{
LoadingResourcesDlg dlg = (LoadingResourcesDlg)param;
try
{
// load symbols for elements
ElementPTFactory elements = ElementPTFactory.Instance;
System.Drawing.Font font = new System.Drawing.Font("Tahoma", 20);
float onePer = 100.0f / elements.Size;
float prog = 0;
foreach (PeriodicTableElement element in elements)
{
Texture tex = TextTexture.DrawTextToTexture(element.Symbol,
font, device, 64, 64).Texture;
symbolTextures[element.Symbol] = tex;
prog += onePer;
dlg.Progress = (int)prog;
}
dlg.TryClose();
}
catch { }
}
示例8: DrawBinaryImage
//BinaryWrite方法将一个二进制字符串写入HTTP输出流
//public void BinaryWrite(byte[] buffer)
public void DrawBinaryImage()
{
//要绘制的字符串
string word = "5142";
//设定画布大小,Math.Ceiling向上取整
int width = int.Parse(Math.Ceiling(word.Length * 20.5).ToString());
int height = 22;
//创建一个指定大小的画布
System.Drawing.Bitmap image = new System.Drawing.Bitmap(width, height);
//创建一个指定的GDI+绘图图面
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
try
{
//用白色填充图面
g.Clear(System.Drawing.Color.White);
//绘制背景噪音线
Random r = new Random();
int x1, x2, y1, y2;
for (int i = 0; i < 2; i++)
{
x1 = r.Next(image.Width);
x2 = r.Next(image.Width);
y1 = r.Next(image.Height);
y2 = r.Next(image.Height);
g.DrawLine(new System.Drawing.Pen(System.Drawing.Color.Black), x1, y1, x2, y2);
}
//绘制文字
System.Drawing.Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold));
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush
(new System.Drawing.Rectangle(0, 0, image.Width, image.Height),
System.Drawing.Color.Blue, System.Drawing.Color.DarkRed, 5.2f, true);
g.DrawString(word, font, brush, 2, 2);
//绘制前景噪点
int x, y;
for (int i = 0; i < 100; i++)
{
x = r.Next(image.Width);
y = r.Next(image.Height);
image.SetPixel(x, y, System.Drawing.Color.FromArgb(r.Next()));
}
//绘制边框
g.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
System.IO.MemoryStream ms = new MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
catch (Exception)
{
g.Dispose();
image.Dispose();
}
}
示例9: CustomListViewItem
public CustomListViewItem()
{
// Customize the ListViewItem control by setting various properties.
BackColor = System.Drawing.Color.White;
Font = new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Bold);
ForeColor = System.Drawing.Color.Gray;
}
示例10: OnMouseWheel
// Change the font size
//
protected override void OnMouseWheel(MouseEventArgs e)
{
base.OnMouseWheel(e);
if (e.Delta > 0)
Font = new System.Drawing.Font(Font.FontFamily, Font.Size + 0.2f);
else
Font = new System.Drawing.Font(Font.FontFamily, Font.Size - 0.2f);
}
示例11: TextCord
public TextCord(string st, float x, float y, System.Drawing.Font f, System.Drawing.Brush b)
{
X = x;
Y = y;
font = f;
brush = b;
str = st;
}
示例12: LibrarySpinEdit
public LibrarySpinEdit()
{
Properties.EditMask = "F0";
Properties.MinValue = 0;
Value = 0;
Properties.MaxValue = 2000000000;
Font = new System.Drawing.Font("Tahoma", 9, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
Properties.IsFloatValue = false;
}
示例13: SetFont
public static void SetFont()
{
FontDialog fd = new FontDialog();
if(sysfont!=null)fd.Font = sysfont;
if (fd.ShowDialog() == DialogResult.OK)
{
sysfont = fd.Font;
}
}
示例14: CustomRichTextBox
public CustomRichTextBox() {
BackColor = System.Drawing.Color.WhiteSmoke;
Font = new System.Drawing.Font("Arial", 10, System.Drawing.FontStyle.Regular);
Size = new System.Drawing.Size(460, 457);
Location = new System.Drawing.Point(0, 0);
WordWrap = true;
ReadOnly = true;
}
示例15: GetFont
public System.Drawing.Font GetFont(Styles.Font font)
{
System.Drawing.Font gdiFont;
if (!fonts.TryGetValue(font, out gdiFont))
{
gdiFont = new System.Drawing.Font(font.FontFamily, (float)font.Size);
}
return gdiFont;
}