本文整理汇总了C#中System.Windows.Forms.FontDialog类的典型用法代码示例。如果您正苦于以下问题:C# FontDialog类的具体用法?C# FontDialog怎么用?C# FontDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FontDialog类属于System.Windows.Forms命名空间,在下文中一共展示了FontDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditValue
/// <summary>
/// Edits the value
/// </summary>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
editedValue = value;
using (var fontDialog = new FontDialog())
{
fontDialog.ShowApply = false;
fontDialog.ShowColor = false;
fontDialog.AllowVerticalFonts = false;
fontDialog.AllowScriptChange = false;
fontDialog.FixedPitchOnly = true;
fontDialog.ShowEffects = false;
fontDialog.ShowHelp = false;
Font font = value as Font;
if (font != null) fontDialog.Font = font;
if (fontDialog.ShowDialog() == DialogResult.OK)
editedValue = fontDialog.Font;
}
value = editedValue;
editedValue = null;
return value;
}
示例2: btnFont_Click
/// <summary>
/// 选择(修改)字体
/// </summary>
/// <params name="sender"></params>
/// <params name="e"></params>
private void btnFont_Click(object sender, EventArgs e)
{
FontDialog pFontDialog = new FontDialog();
pFontDialog.ShowDialog();
if (pFontDialog.Font != null)
m_pFont = pFontDialog.Font;
}
示例3: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
FontDialog fd = new FontDialog();
System.Windows.Forms.DialogResult dr = fd.ShowDialog();
if (dr != System.Windows.Forms.DialogResult.Cancel)
{
FontFamily fontFamily = new System.Windows.Media.FontFamily(fd.Font.Name);
double fontSize = fd.Font.Size * 96.0 / 72.0; ;
FontWeight fontWeight = fd.Font.Bold ? FontWeights.Bold : FontWeights.Regular;
FontStyle fontStyle = fd.Font.Italic ? FontStyles.Italic : FontStyles.Normal;
tbSourse.FontFamily = fontFamily;
tbTranslated.FontFamily = fontFamily;
tbSourse.FontSize = fontSize;
tbTranslated.FontSize = fontSize;
tbSourse.FontWeight = fontWeight;
tbTranslated.FontWeight = fontWeight;
tbSourse.FontStyle = fontStyle;
tbTranslated.FontStyle = fontStyle;
Properties.Settings.Default.FontFamily = fontFamily;
Properties.Settings.Default.FontSize = fontSize;
Properties.Settings.Default.FontWeight = fontWeight;
Properties.Settings.Default.FontStyle = fontStyle;
Properties.Settings.Default.Save();
}
}
示例4: TextSetUp
public TextSetUp()
{
InitializeComponent();
m_fontDialog = new FontDialog();
m_fontDialog.ShowColor = true;
InitFontDialog();
}
示例5: buttonChangeFont_Click
private void buttonChangeFont_Click( object sender, EventArgs e )
{
var dialog = new FontDialog()
{ AllowScriptChange = true
, AllowSimulations = true
, AllowVectorFonts = true
, AllowVerticalFonts = true
, Font = (LastGdiFont==null) ? Configuration.Main.GdiFont : LastGdiFont
, FontMustExist = true
, ShowColor = false
};
var result = dialog.ShowDialog(this);
if ( result != DialogResult.OK ) return;
var font = LastGdiFont = dialog.Font;
Size touse = new Size(0,0);
for ( char ch=(char)0 ; ch<(char)255 ; ++ch ) {
if ( "\u0001 \t\n\r".Contains(ch) ) continue; // annoying outliers
var m = TextRenderer.MeasureText( ch.ToString(), font, Size.Empty, TextFormatFlags.NoPadding );
touse.Width = Math.Max( touse.Width , m.Width );
touse.Height = Math.Max( touse.Height, m.Height );
}
var scf = ShinyConsole.Font.FromGdiFont( font, touse.Width, touse.Height );
pictureBoxFontPreview.Image = scf.Bitmap;
}
示例6: btnWatermarkFont_Click
private void btnWatermarkFont_Click(object sender, EventArgs e)
{
try
{
using (FontDialog fontDialog = new FontDialog())
{
fontDialog.ShowColor = true;
try
{
fontDialog.Font = config.Text.TextFont;
fontDialog.Color = config.Text.TextColor;
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, "Error while initializing font.");
}
if (fontDialog.ShowDialog() == DialogResult.OK)
{
config.Text.TextFont = fontDialog.Font;
config.Text.TextColor = fontDialog.Color;
btnTextColor.Color = config.Text.TextColor;
lblWatermarkFont.Text = new FontConverter().ConvertToInvariantString(config.Text.TextFont);
UpdatePreview();
}
}
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, "Error while setting watermark font.");
}
}
示例7: btnWatermarkFont_Click
private void btnWatermarkFont_Click(object sender, EventArgs e)
{
try
{
using (FontDialog fontDialog = new FontDialog())
{
fontDialog.ShowColor = true;
try
{
fontDialog.Color = Config.WatermarkFontArgb;
fontDialog.Font = Config.WatermarkFont;
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, "Error while initializing font.");
}
if (fontDialog.ShowDialog() == DialogResult.OK)
{
Config.WatermarkFont = fontDialog.Font;
Config.WatermarkFontArgb = fontDialog.Color;
pbWatermarkFontColor.BackColor = Config.WatermarkFontArgb;
lblWatermarkFont.Text = Config.WatermarkFont.ToString();
UpdatePreview();
}
}
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, "Error while setting watermark font.");
}
}
示例8: ShowFontDialog
public static DialogResult ShowFontDialog(WatermarkConfig Config)
{
DialogResult result = DialogResult.Cancel;
try
{
var fDialog = new FontDialog
{
ShowColor = true
};
try
{
fDialog.Color = Config.WatermarkFontArgb;
fDialog.Font = Config.WatermarkFont;
}
catch (Exception err)
{
DebugHelper.WriteException(err, "Error while initializing Font and Color");
}
result = fDialog.ShowDialog();
if (result == DialogResult.OK)
{
Config.WatermarkFont = fDialog.Font;
Config.WatermarkFontArgb = fDialog.Color;
}
}
catch (Exception ex)
{
DebugHelper.WriteException(ex, "Error while setting Watermark Font");
}
return result;
}
示例9: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
this.value = value;
if ((provider != null) && (((IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService))) != null))
{
FontDialog dialog = new FontDialog();
dialog.ShowApply = false;
dialog.ShowColor = false;
dialog.AllowVerticalFonts = false;
dialog.AllowScriptChange = false;
dialog.FixedPitchOnly = true;
dialog.ShowEffects = false;
dialog.ShowHelp = false;
Font font = value as Font;
if (font != null)
{
dialog.Font = font;
}
if (dialog.ShowDialog() == DialogResult.OK)
{
this.value = dialog.Font;
}
dialog.Dispose();
}
value = this.value;
this.value = null;
return value;
}
示例10: EditValue
/// <summary>
/// Edits the value
/// </summary>
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
{
this.value = value;
if (provider != null)
{
IWindowsFormsEditorService service1 = (IWindowsFormsEditorService) provider.GetService(typeof(IWindowsFormsEditorService));
if (service1 != null)
{
FontDialog fontDialog = new FontDialog();
fontDialog.ShowApply = false;
fontDialog.ShowColor = false;
fontDialog.AllowVerticalFonts = false;
fontDialog.AllowScriptChange = false;
fontDialog.FixedPitchOnly = true;
fontDialog.ShowEffects = false;
fontDialog.ShowHelp = false;
Font font = value as Font;
if(font != null)
{
fontDialog.Font = font;
}
if (fontDialog.ShowDialog() == DialogResult.OK)
{
this.value = fontDialog.Font;
}
fontDialog.Dispose();
}
}
value = this.value;
this.value = null;
return value;
}
示例11: btnEdit_Click
private void btnEdit_Click(object sender, EventArgs e)
{
FontDialog dlg = new FontDialog();
dlg.Font = UserFont;
if (dlg.ShowDialog() == DialogResult.OK)
UserFont = dlg.Font;
}
示例12: OnMouseUp
protected override void OnMouseUp(MouseEventArgs mevent)
{
IsDragMode = false;
base.OnMouseUp(mevent);
if (mevent.Button == MouseButtons.Right)
{
using (ColorDialog cd = new ColorDialog())
{
cd.FullOpen = true;
if (cd.ShowDialog() == DialogResult.OK)
{
this.ForeColor = cd.Color;
}
}
using (FontDialog fd = new FontDialog())
{
try
{
fd.AllowScriptChange = false;
fd.AllowSimulations = false;
if (fd.ShowDialog() == DialogResult.OK)
{
this.Font = fd.Font;
}
}
catch (Exception ex)
{
//Not a truetype font
MessageBox.Show(this, ex.Message + Environment.NewLine + "Шрифт не изменен.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}
示例13: ChangeFontButton_Click
private void ChangeFontButton_Click(object sender, EventArgs e)
{
var fd = new FontDialog { Font = LogMessageTextBox.Font };
if (fd.ShowDialog() == DialogResult.OK)
{
LogMessageTextBox.Font = fd.Font;
}
}
示例14: fontBtn_Click
private void fontBtn_Click(object sender, EventArgs e)
{
FontDialog fontDlg = new FontDialog();
fontDlg.Font = textBox.Font;
if (fontDlg.ShowDialog() == DialogResult.OK)
textBox.Font = fontDlg.Font;
}
示例15: fontToolStripMenuItem1_Click
private void fontToolStripMenuItem1_Click(object sender, EventArgs e)
{
FontDialog font = new FontDialog();
font.Font = notepad_interface.SelectionFont;
if (font.ShowDialog() == DialogResult.OK){
notepad_interface.SelectionFont = font.Font;
}
}