在GTK中显示字体选择对话框# [英] Showing Font Selection Dialog in GTK#
本文介绍了在GTK中显示字体选择对话框#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
font
有人能指导我吗?
Gtk.FontSelectionDialog fs = new FontSelectionDialog()
fs.Show();
font = fs.FontName;
解决方案
根据其他问题更新
这应该有助于:
FontSelectionDialog dialog = null;
尝试{
dialog = new FontSelectionDialog(Choose a font);
dialog.Run();
var name = dialog.FontName;
var pattern = @^(?< fontName>。*)\s(?< fontSize> \d +(?: \.\d +)?)$;
var regex = new Regex(pattern);
var match = regex.Match(name);
if(match.Success)
{
var fontName = match.Groups [fontName]。Value;
var fontSize = float.Parse(match.Groups [fontSize]。Value);
var font = new System.Drawing.Font(fontName,fontSize);
}
} finally {
if(dialog!= null)
dialog.Destroy();
}
In MY gtk# Application im trying to show the font selection dialog.Im trying to use the following code,but the FontSelectionDialog constructor need some arguments also does the control execution wait for a font to be selected to set the string font
Can someone guide me?
Gtk.FontSelectionDialog fs = new FontSelectionDialog()
fs.Show ();
font=fs.FontName;
解决方案
Updated according to additional question
This should help:
FontSelectionDialog dialog = null;
try {
dialog = new FontSelectionDialog("Choose a font");
dialog.Run ();
var name = dialog.FontName;
var pattern = @"^(?<fontName>.*)\s(?<fontSize>\d+(?:\.\d+)?)$";
var regex = new Regex(pattern);
var match = regex.Match(name);
if(match.Success)
{
var fontName = match.Groups["fontName"].Value;
var fontSize = float.Parse(match.Groups["fontSize"].Value);
var font = new System.Drawing.Font(fontName, fontSize);
}
} finally {
if (dialog != null)
dialog.Destroy ();
}
这篇关于在GTK中显示字体选择对话框#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文