mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Small cleanups [skip ci]
This commit is contained in:
parent
02a06a12b0
commit
98e6be5eb6
171 changed files with 1607 additions and 1769 deletions
|
@ -41,12 +41,16 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
|
||||
public FontFamilyComboBox() : base() {
|
||||
ComboBox.DataSource = FontFamily.Families;
|
||||
ComboBox.DisplayMember = "Name";
|
||||
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
|
||||
ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
|
||||
ComboBox.DrawItem += ComboBox_DrawItem;
|
||||
public FontFamilyComboBox()
|
||||
{
|
||||
if (ComboBox != null)
|
||||
{
|
||||
ComboBox.DataSource = FontFamily.Families;
|
||||
ComboBox.DisplayMember = "Name";
|
||||
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
|
||||
ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
|
||||
ComboBox.DrawItem += ComboBox_DrawItem;
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBox_DrawItem(object sender, DrawItemEventArgs e) {
|
||||
|
@ -58,7 +62,7 @@ namespace Greenshot.Controls {
|
|||
if (e.Index > -1) {
|
||||
FontFamily fontFamily = Items[e.Index] as FontFamily;
|
||||
FontStyle fontStyle = FontStyle.Regular;
|
||||
if (!fontFamily.IsStyleAvailable(FontStyle.Regular)) {
|
||||
if (fontFamily != null && !fontFamily.IsStyleAvailable(FontStyle.Regular)) {
|
||||
if (fontFamily.IsStyleAvailable(FontStyle.Bold)) {
|
||||
fontStyle = FontStyle.Bold;
|
||||
} else if (fontFamily.IsStyleAvailable(FontStyle.Italic)) {
|
||||
|
@ -70,10 +74,16 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
try {
|
||||
DrawText(e.Graphics, fontFamily, fontStyle, e.Bounds, fontFamily.Name);
|
||||
if (fontFamily != null)
|
||||
{
|
||||
DrawText(e.Graphics, fontFamily, fontStyle, e.Bounds, fontFamily.Name);
|
||||
}
|
||||
} catch {
|
||||
// If the drawing failed, BUG-1770 seems to have a weird case that causes: Font 'Lucida Sans Typewriter' does not support style 'Regular'
|
||||
DrawText(e.Graphics, FontFamily.GenericSansSerif, FontStyle.Regular, e.Bounds, fontFamily.Name);
|
||||
if (fontFamily != null)
|
||||
{
|
||||
DrawText(e.Graphics, FontFamily.GenericSansSerif, FontStyle.Regular, e.Bounds, fontFamily.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Uncomment this if you actually like the way the focus rectangle looks
|
||||
|
@ -89,7 +99,7 @@ namespace Greenshot.Controls {
|
|||
/// <param name="bounds"></param>
|
||||
/// <param name="text"></param>
|
||||
private void DrawText(Graphics graphics, FontFamily fontFamily, FontStyle fontStyle, Rectangle bounds, string text) {
|
||||
using (Font font = new Font(fontFamily, this.Font.Size + 5, fontStyle, GraphicsUnit.Pixel)) {
|
||||
using (Font font = new Font(fontFamily, Font.Size + 5, fontStyle, GraphicsUnit.Pixel)) {
|
||||
// Make sure the text is visible by centering it in the line
|
||||
using (StringFormat stringFormat = new StringFormat()) {
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue