Skip to content

Commit c599a18

Browse files
committed
Add FontFamily option
1 parent 7479a15 commit c599a18

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

Background-Terminal/BackgroundTerminalSettings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class BackgroundTerminalSettings
1313
public int Key2 { get; set; }
1414
public double FontSize { get; set; }
1515
public string FontColor { get; set; }
16+
public string FontFamily { get; set; }
1617
public double PosX { get; set; }
1718
public double PosY { get; set; }
1819
public double Width { get; set; }

Background-Terminal/MainWindow.xaml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
<RowDefinition Height="30" />
182182
<RowDefinition Height="30" />
183183
<RowDefinition Height="30" />
184+
<RowDefinition Height="30" />
184185
<RowDefinition Height="10" />
185186
<RowDefinition Height="30" />
186187
<RowDefinition Height="30" />
@@ -189,7 +190,7 @@
189190
<RowDefinition Height="100" />
190191
<RowDefinition Height="30" />
191192
</Grid.RowDefinitions>
192-
<Border Grid.RowSpan="12" Background="#F5F5F5" />
193+
<Border Grid.RowSpan="13" Background="#F5F5F5" />
193194
<Grid Grid.Row="0">
194195
<Grid.ColumnDefinitions>
195196
<ColumnDefinition Width="1*" />
@@ -291,6 +292,23 @@
291292
VerticalContentAlignment="Center" />
292293
</Grid>
293294
<Grid Grid.Row="5">
295+
<Grid.ColumnDefinitions>
296+
<ColumnDefinition Width="1*" />
297+
<ColumnDefinition Width="1*" />
298+
</Grid.ColumnDefinitions>
299+
<Label
300+
Grid.Column="0"
301+
VerticalAlignment="Center"
302+
HorizontalContentAlignment="Center"
303+
Content="Font Family:"
304+
FontFamily="Yu Gothic UI Light" />
305+
<TextBox
306+
x:Name="FontFamily_TextBox"
307+
Grid.Column="1"
308+
Margin="10,5,10,5"
309+
VerticalContentAlignment="Center" />
310+
</Grid>
311+
<Grid Grid.Row="6">
294312
<Grid.ColumnDefinitions>
295313
<ColumnDefinition Width="1*" />
296314
<ColumnDefinition Width="1*" />
@@ -307,14 +325,14 @@
307325
Margin="10,5,10,5"
308326
VerticalContentAlignment="Center" />
309327
</Grid>
310-
<Grid Grid.Row="6">
328+
<Grid Grid.Row="7">
311329
<Border
312330
Height="1"
313331
Margin="10,0,10,0"
314332
BorderBrush="Gray"
315333
BorderThickness="1" />
316334
</Grid>
317-
<Grid Grid.Row="7">
335+
<Grid Grid.Row="8">
318336
<Grid.ColumnDefinitions>
319337
<ColumnDefinition Width="1*" />
320338
<ColumnDefinition Width="1*" />
@@ -335,7 +353,7 @@
335353
Style="{StaticResource StandardButton1}" />
336354
</Grid>
337355
</Grid>
338-
<Grid Grid.Row="8">
356+
<Grid Grid.Row="9">
339357
<Grid.ColumnDefinitions>
340358
<ColumnDefinition Width="1*" />
341359
<ColumnDefinition Width="1*" />
@@ -378,7 +396,7 @@
378396
FontFamily="Yu Gothic UI" />
379397
</Grid>
380398
</Grid>
381-
<Grid Grid.Row="9">
399+
<Grid Grid.Row="10">
382400
<Grid.ColumnDefinitions>
383401
<ColumnDefinition Width="1*" />
384402
<ColumnDefinition Width="1*" />
@@ -421,14 +439,14 @@
421439
FontFamily="Yu Gothic UI" />
422440
</Grid>
423441
</Grid>
424-
<Grid Grid.Row="10">
442+
<Grid Grid.Row="11">
425443
<Border
426444
Height="1"
427445
Margin="10,0,10,0"
428446
BorderBrush="Gray"
429447
BorderThickness="1" />
430448
</Grid>
431-
<Grid Grid.Row="11">
449+
<Grid Grid.Row="12">
432450
<Grid.RowDefinitions>
433451
<RowDefinition Height="30" />
434452
<RowDefinition Height="1*" />
@@ -507,7 +525,7 @@
507525
</ListBox.ItemTemplate>
508526
</ListBox>
509527
</Grid>
510-
<Grid Grid.Row="12">
528+
<Grid Grid.Row="13">
511529
<Grid.ColumnDefinitions>
512530
<ColumnDefinition Width="1*" />
513531
<ColumnDefinition Width="1" />

Background-Terminal/MainWindow.xaml.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ public MainWindow() {
130130
Key1_Button.Content = _key1.ToString();
131131
Key2_Button.Content = _key2.ToString();
132132
FontSize_TextBox.Text = _settings.FontSize.ToString();
133-
FontColor_TextBox.Text = _settings.FontColor.ToString();
133+
FontColor_TextBox.Text = _settings.FontColor;
134+
FontFamily_TextBox.Text = _settings.FontFamily;
134135
PosX_TextBox.Text = _settings.PosX.ToString();
135136
PosY_TextBox.Text = _settings.PosY.ToString();
136137
Width_TextBox.Text = _settings.Width.ToString();
@@ -179,6 +180,9 @@ private void OutputSSHUsage() {
179180
private void ApplySettingsToTerminalWindow() {
180181
_terminalWindow.TerminalData_TextBox.FontSize = _settings.FontSize;
181182
_terminalWindow.Input_TextBox.FontSize = _settings.FontSize;
183+
if (_settings.FontFamily != null) {
184+
_terminalWindow.TerminalData_TextBox.FontFamily = new FontFamily(_settings.FontFamily);
185+
}
182186
_terminalWindow.TerminalData_TextBox.Foreground = (Brush)_brushConverter.ConvertFromString(_settings.FontColor);
183187
_terminalWindow.Input_TextBox.Foreground = (Brush)_brushConverter.ConvertFromString(_settings.FontColor);
184188
_terminalWindow.Left = _settings.PosX;
@@ -495,6 +499,13 @@ private void ApplyChangesButton_Click(object sender, RoutedEventArgs e) {
495499
return;
496500
}
497501

502+
try {
503+
new FontFamily(_settings.FontFamily);
504+
} catch {
505+
System.Windows.MessageBox.Show("There was an error interpreting font family input");
506+
return;
507+
}
508+
498509
try {
499510
posX = Convert.ToDouble(PosX_TextBox.Text);
500511
} catch {
@@ -530,11 +541,11 @@ private void ApplyChangesButton_Click(object sender, RoutedEventArgs e) {
530541
return;
531542
}
532543

533-
534544
_settings.Key1 = KeyInterop.VirtualKeyFromKey((Key)_key1);
535545
_settings.Key2 = KeyInterop.VirtualKeyFromKey((Key)_key2);
536546
_settings.FontSize = fontSize;
537547
_settings.FontColor = fontColor.ToString();
548+
_settings.FontFamily = FontFamily_TextBox.Text;
538549
_settings.PosX = posX;
539550
_settings.PosY = posY;
540551
_settings.Width = width;

Background-Terminal/TerminalWindow.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
x:Name="TerminalData_TextBox"
2121
Background="Transparent"
2222
BorderThickness="0"
23-
FontFamily="Consolas"
2423
IsReadOnly="True"
2524
IsReadOnlyCaretVisible="True"
2625
TextChanged="TerminalDataTextBox_TextChanged" />

Background-Terminal/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"Key1":162,"Key2":66,"FontSize":12.0,"FontColor":"#FFFFFFFF","PosX":0.0,"PosY":0.0,"Width":500.0,"Height":500.0}
1+
{"Key1":162,"Key2":66,"FontSize":12.0,"FontColor":"#FFFFFFFF","PosX":0.0,"PosY":0.0,"Width":500.0,"Height":500.0, "FontFamily": "Consolas"}

0 commit comments

Comments
 (0)