本文整理汇总了C#中System.Drawing.Font.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Font.ToString方法的具体用法?C# Font.ToString怎么用?C# Font.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Font
的用法示例。
在下文中一共展示了Font.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainForm
public MainForm()
{
InitializeComponent();
wordOutlines = new List<WordOutlineDrawing>();
Font font = new Font(new FontFamily("����"), 100f);
tbFont.Text = font.ToString();
tbFont.Tag = font;
}
示例2: OnTaskClerkInit
/// <summary>
/// This method is called after the engine has initalised the component
/// </summary>
protected override void OnTaskClerkInit()
{
base.OnTaskClerkInit();
Font font = new Font("Arial", 9);
font = (Font) Engine.SettingsProvider.Get("GeneralFont", font);
textBox1.Text = font.ToString();
for (int i = 0; i < checkedListBox.Items.Count; i++)
{
bool set = (bool) Engine.SettingsProvider.Get(checkedListBox.Items[i], true);
checkedListBox.SetItemChecked(i, set);
}
checkedListBox.ItemCheck +=
new ItemCheckEventHandler(checkedListBox_ItemCheck);
}
示例3: frmQuery
//.........这里部分代码省略.........
// _tvQueries
//
this._tvQueries.Dock = System.Windows.Forms.DockStyle.Top;
this._tvQueries.ImageIndex = -1;
this._tvQueries.Location = new System.Drawing.Point(0, 0);
this._tvQueries.Name = "_tvQueries";
this._tvQueries.SelectedImageIndex = -1;
this._tvQueries.Size = new System.Drawing.Size(768, 136);
this._tvQueries.TabIndex = 0;
this._tcpQuery.Controls.Add(this._param);
this._tcpQuery.Controls.Add(this._splitQ);
this._tcpQuery.Controls.Add(this._tvQueries);
#endregion
_commParamDef = new ucParamDef(false);
_commParamDef.Location = new Point(5, 5);
_commParamDef.Size = new Size(_tcpXSLTInc.Width - 10, _tcpXSLTInc.Height - 10);
_commParamDef.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
_tcpXSLTInc.Controls.Add(_commParamDef);
NewSession();
_param.pPerf = _task;
_commParamDef.SetData(_task.pCommonParamCollection);
int iconSize = 0;
try
{
iconSize = Convert.ToInt32(Registry.CurrentUser.OpenSubKey(AppConst.REG_APP_PATH).GetValue("IconSize"));
}
catch { }
if (iconSize < 16)
iconSize = 32;
_iconColl = new QueryIconCollection(iconSize);
_tb.ImageList = _iconColl.pImageList;
_tbbExecRTab.ImageIndex = _iconColl.Index(QueryIconCollection.ExecRTab);
_tbbExecRExcel.ImageIndex = _iconColl.Index(QueryIconCollection.ExecRExcel);
_tbbExecRHTML.ImageIndex = _iconColl.Index(QueryIconCollection.ExecRHTML);
_tbbNewQuery.ImageIndex = _iconColl.Index(QueryIconCollection.New);
_tbbDelQuery.ImageIndex = _iconColl.Index(QueryIconCollection.Delete);
_tbbSaveSession.ImageIndex = _iconColl.Index(QueryIconCollection.Save);
_tbbLoadSession.ImageIndex = _iconColl.Index(QueryIconCollection.DocOpen);
_tbbEditSQL.ImageIndex = _iconColl.Index(QueryIconCollection.TextSQL);
_tbbEditParam.ImageIndex = _iconColl.Index(QueryIconCollection.TextParam);
_tbbEditXSLT.ImageIndex = _iconColl.Index(QueryIconCollection.TextXSLT);
_tbbAbout.ImageIndex = _iconColl.Index(QueryIconCollection.About);
_tbbExecRTab.Tag = _mnuExecRTab;
_tbbExecRExcel.Tag = _mnuExecRExcel;
_tbbExecRHTML.Tag = _mnuExecRHTML;
_tbbEditSQL.Tag = _mnuEditSQL;
_tbbEditParam.Tag = _mnuEditParam;
_tbbEditXSLT.Tag = _mnuEditXSLT;
_tvQueries.HideSelection = false;
_lcmTV = new ContextMenu();
_miExecute = new MenuItem("Выполнить", new EventHandler(_mnuExecRTab_Click), Shortcut.F5);
_lcmTV.MenuItems.Add(_miExecute);
_lcmTV.MenuItems.Add(new MenuItem("-"));
_lcmTV.MenuItems.Add(new MenuItem("Новый", new EventHandler(DoCommandNewQuery)));
_miDeleteQuery = new MenuItem("Удалить", new EventHandler(DoCommandDeleteQuery));
_lcmTV.MenuItems.Add(_miDeleteQuery);
_miEditQuery = new MenuItem(this._mnuEdit.Text);
MenuItem miEditSQL = new MenuItem(this._mnuEditSQL.Text, new EventHandler(DoCommandEditQuery));
MenuItem miEditParam = new MenuItem(this._mnuEditParam.Text, new EventHandler(DoCommandEditQueryParam));
MenuItem miEditXSLT = new MenuItem(this._mnuEditXSLT.Text, new EventHandler(DoCommandEditQuery));
_miEditQuery.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { miEditSQL, miEditParam, miEditXSLT });
_lcmTV.MenuItems.Add(_miEditQuery);
_lcmTV.MenuItems.Add(new MenuItem("-"));
_miPropertyQuery = new MenuItem("Свойства", new EventHandler(DoCommandPropertyQuery), Shortcut.F2);
_lcmTV.MenuItems.Add(_miPropertyQuery);
_lcmTV.Popup += new EventHandler(DoCommandTVQContextMenuPopup);
_tvQueries.AfterSelect += new TreeViewEventHandler(DoCommandTVQAfterSelect);
_tvQueries.DoubleClick += new EventHandler(DoCommandTVQDoubleClick);
_cmdPassword.Click += new EventHandler(_cmdPassword_Click);
_tc.SelectedIndexChanged += new EventHandler(_tc_SelectedIndexChanged);
Load += new EventHandler(DoLoad);
Closing += new CancelEventHandler(DoClosing);
Activated += new EventHandler(DoActivated);
TitleText();
_txtFont.Text = _sesFont.ToString();
_modified = false;
_mnuExec.Enabled = false;
_tbbExecRTab.Enabled = false;
_tbbExecRExcel.Enabled = false;
_tbbExecRHTML.Enabled = false;
_mnuDeleteQuery.Enabled = false;
_tbbDelQuery.Enabled = false;
Icon = new Icon(GetType(), "Images.Icons.Query.ico");
_img = null;
_pnlImg.Paint += new PaintEventHandler(_pnlImg_Paint);
}
示例4: SetDefaultValues
/// <summary>
/// Set default values to the canvas fields
/// </summary>
private void SetDefaultValues()
{
//When the context is created, the font of the context must be set to 10px sans-serif.
_family = new FontFamily(GenericFontFamilies.Serif);
_parsedFont = new Font(_family, 10, FontStyle.Regular, GraphicsUnit.Pixel);
_font = _parsedFont.ToString();
path = new GraphicsPath();
path.FillMode = FillMode.Winding;
stack = new Stack<CanvasState> {};
//_fillStyle = "rgba(0,0,0,0)";
_transformation = new Matrix();
_globalAlpha = 1.0;
_globalCompositeOperation = "source-over";
_textAlign = "start";
_textBaseLine = "alphabetic";
lineWidth = 1.0;
lineCap = "butt";
lineJoin = "miter";
miterLimit = 10.0;
_shadowColor = "rgba(0,0,0,0)";
_shadowOffsetX = 0;
_shadowOffsetY = 0;
_shadowBlur = 0;
surface.SmoothingMode = SmoothingMode.HighQuality;
surface.InterpolationMode = InterpolationMode.HighQualityBicubic;
surface.PixelOffsetMode = PixelOffsetMode.HighQuality;
surface.PageUnit = GraphicsUnit.Pixel;
//scale(surface.DpiX/96, surface.DpiY/96);
//surface.PageScale = surface.DpiX * 2/96;
_compositier = new Compositer();
}
示例5: EnsureInterop
private static TextServiceDirectWriteInterop EnsureInterop(Font font)
{
if (interops == null)
{
interops = new List<KeyValuePair<Font, TextServiceDirectWriteInterop>>(MaxCachedInterops);
}
if (lastWidth != Screen.PrimaryScreen.Bounds.Width)
{
ClearCache();
}
lastWidth = Screen.PrimaryScreen.Bounds.Width;
int index = -1;
for (int i = 0; i < interops.Count; i++)
{
if (font.Equals(interops[i].Key))
{
index = i;
}
}
if (index < 0)
{
if (interops.Count >= MaxCachedInterops)
{
ClearCache();
}
index = interops.Count;
TextServiceDirectWriteInterop interop = new TextServiceDirectWriteInterop();
interop.Reset(TextServiceDirectWrite.InteropGlobals, font, lastWidth);
interops.Add(new KeyValuePair<Font, TextServiceDirectWriteInterop>(font, interop));
#if DEBUG
Debugger.Log(
1,
"TextServiceDirectWrite",
String.Concat(
DateTime.Now.ToString(),
": Added DirectWrite interop for ",
font.ToString(),
" ",
font.Style.ToString(),
Environment.NewLine));
#endif
}
return interops[index].Value;
}
示例6: GetIFontFromFont
protected static object GetIFontFromFont(Font font) {
if (font == null) return null;
if (font.Unit != GraphicsUnit.Point)
throw new ArgumentException(SR.GetString(SR.AXFontUnitNotPoint), "font");
try {
return (UnsafeNativeMethods.IFont)UnsafeNativeMethods.OleCreateIFontIndirect(GetFONTDESCFromFont(font), ref ifont_Guid);
}
catch {
Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "Failed to create IFrom from font: " + font.ToString());
return null;
}
}
示例7: getBaseline
/// <summary>
/// Caclulate the baseline from a font and a TextRenderingHint
/// </summary>
/// <param name="font">the font</param>
/// <param name="hint">the used TextRenderingHint</param>
/// <returns></returns>
private static int getBaseline(Font font, TextRenderingHint hint)
{
lock (baselines)
{
String key = font.ToString() + hint.ToString();
int baseline;
if (!baselines.TryGetValue(key, out baseline))
{
FontFamily family = font.FontFamily;
FontStyle style = font.Style;
float ascent = family.GetCellAscent(style);
float lineSpace = family.GetLineSpacing(style);
baseline = (int)Math.Round(font.GetHeight() * ascent / lineSpace);
// Until this point the calulation use only the Font. But with different TextRenderingHint there are smal differences.
// There is no API that calulate the offset from TextRenderingHint that we messure it.
const int w = 3;
const int h = 3;
Bitmap bitmap = new Bitmap(w, h);
Graphics g = Graphics.FromImage(bitmap);
g.TextRenderingHint = hint;
g.FillRectangle(new SolidBrush(Color.White), 0, 0, w, h);
g.DrawString("A", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT);
g.DrawString("X", font, new SolidBrush(Color.Black), 0, -baseline, FORMAT);
g.Dispose();
int y = 0;
LINE:
while (y < h)
{
for (int x = 0; x < w; x++)
{
Color color = bitmap.GetPixel(x, y);
if (color.GetBrightness() < 0.5)
{
//there is a black pixel, we continue in the next line.
baseline++;
y++;
goto LINE;
}
}
break; // there was a line without black pixel
}
baselines[key] = baseline;
}
return baseline;
}
}