-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditFont.cs
61 lines (53 loc) · 1.82 KB
/
EditFont.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Type_Writer
{
public partial class EditFont : Form
{
private static Type_Writer TypeWriter = new Type_Writer();
private float fontSize = TypeWriter.GetFontSize();
private FontFamily fontStyle = TypeWriter.GetFontStyle();
public EditFont(FontFamily fontStyle, float fontSize)
{
InitializeComponent();
this.Load += ConfigureComboBoxes;
this.fontStyle = fontStyle;
this.fontSize = fontSize;
}
private void ConfigureComboBoxes(object sender, EventArgs e)
{
for (int i = 8; i <= 24; i += 2)
{
CBfontSize.Items.Add(i);
}
for (int i = 28; i <= 72; i += 4)
{
CBfontSize.Items.Add(i);
}
CBfontSize.SelectedItem = (int)fontSize;
InstalledFontCollection installedFonts = new InstalledFontCollection();
FontFamily[] fontFamilies = installedFonts.Families;
foreach (FontFamily fontFamily in fontFamilies)
{
CBfontStyle.Items.Add(fontFamily.Name);
}
CBfontStyle.SelectedItem = fontStyle.Name;
}
public Font NewFont()
{
string fontFamilyString = (string)CBfontStyle.SelectedItem;
FontFamily fontFamily = new FontFamily(fontFamilyString);
Font font = new Font(fontFamily, (int)CBfontSize.SelectedItem, FontStyle.Regular);
return font;
}
}
}