Skip to content

Commit

Permalink
feat: add option to change font size in the tray menu
Browse files Browse the repository at this point in the history
  • Loading branch information
DataMaster3000 committed Feb 16, 2023
1 parent 123f66b commit 4aade5d
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 10 deletions.
21 changes: 17 additions & 4 deletions src/HuntAndPeck/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/HuntAndPeck/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<Settings>
<Setting Name="FontSize" Type="System.String" Scope="User">
<Value Profile="(Default)">14</Value>
</Setting>
</Settings>
</SettingsFile>
9 changes: 9 additions & 0 deletions src/HuntAndPeck/ViewModels/HintViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using HuntAndPeck.Models;
using HuntAndPeck.Properties;

namespace HuntAndPeck.ViewModels
{
public class HintViewModel : NotifyPropertyChanged
{
private string _label;
private bool _active;
private string _fontSizeReadValue;

public HintViewModel(Hint hint)
{
Hint = hint;
FontSizeReadValue = Settings.Default.FontSize;
}

public Hint Hint { get; set; }
Expand All @@ -25,5 +28,11 @@ public string Label
get { return _label; }
set { _label = value; NotifyOfPropertyChange(); }
}

public string FontSizeReadValue
{
get { return _fontSizeReadValue; }
set { _fontSizeReadValue = value; NotifyOfPropertyChange(); }
}
}
}
50 changes: 47 additions & 3 deletions src/HuntAndPeck/ViewModels/OptionsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,56 @@
namespace HuntAndPeck.ViewModels
using HuntAndPeck.Properties;
using System;
using System.ComponentModel;
using System.Windows;

namespace HuntAndPeck.ViewModels
{
internal class OptionsViewModel
internal class OptionsViewModel : INotifyPropertyChanged
{
public OptionsViewModel()
{
DisplayName = "Options";
FontSize = Settings.Default.FontSize;
Settings.Default.PropertyChanged += OnSettingsPropertyChanged;
}

public string DisplayName { get; set; }

private string _fontSize;
public string FontSize
// Assign the font size value to a variable and update it every time user
// changes the option in tray menu
{
get { return _fontSize; }
set
{
if (_fontSize != value)
{
_fontSize = value;
OnPropertyChanged("FontSize");
Settings.Default.FontSize = value;
Settings.Default.Save();
}
}
}


private void OnSettingsPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "FontSize")
{
FontSize = Settings.Default.FontSize;
}
}

public event PropertyChangedEventHandler PropertyChanged;

private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
}
26 changes: 26 additions & 0 deletions src/HuntAndPeck/Views/OptionsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,31 @@
</Grid>
</TabItem.Content>
</TabItem>
<TabItem Header="FontSize">
<TabItem.Content>
<StackPanel>
<Label Content="Font Size" />
<ComboBox SelectedValue="{Binding FontSize}" SelectedValuePath="Content">
<ComboBoxItem>8</ComboBoxItem>
<ComboBoxItem>9</ComboBoxItem>
<ComboBoxItem>10</ComboBoxItem>
<ComboBoxItem>11</ComboBoxItem>
<ComboBoxItem>12</ComboBoxItem>
<ComboBoxItem>13</ComboBoxItem>
<ComboBoxItem>14</ComboBoxItem>
<ComboBoxItem>15</ComboBoxItem>
<ComboBoxItem>16</ComboBoxItem>
<ComboBoxItem>17</ComboBoxItem>
<ComboBoxItem>18</ComboBoxItem>
<ComboBoxItem>19</ComboBoxItem>
<ComboBoxItem>20</ComboBoxItem>
<ComboBoxItem>21</ComboBoxItem>
<ComboBoxItem>22</ComboBoxItem>
<ComboBoxItem>23</ComboBoxItem>
<ComboBoxItem>24</ComboBoxItem>
</ComboBox>
</StackPanel>
</TabItem.Content>
</TabItem>
</TabControl>
</Window>
2 changes: 1 addition & 1 deletion src/HuntAndPeck/Views/OverlayView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</Rectangle.Fill>
</Rectangle>-->
<Viewbox StretchDirection="DownOnly" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="1 1 0 0" Width="{Binding Hint.BoundingRectangle.Width}" Height="{Binding Hint.BoundingRectangle.Height}">
<TextBlock Text="{Binding Label}" FontFamily="Helvetica, Arial" FontWeight="Bold" FontSize="12" Style="{StaticResource HintStyle}">
<TextBlock Text="{Binding Label}" FontFamily="Helvetica, Arial" FontWeight="Bold" FontSize="{Binding FontSizeReadValue}" Style="{StaticResource HintStyle}">
</TextBlock>
</Viewbox>
</Grid>
Expand Down

0 comments on commit 4aade5d

Please sign in to comment.