Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add changing font size in tray menu Ref #36 #45

Merged
merged 3 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ NOTE: hunt-n-peck is no longer maintained, please consider one of the various fo

https://github.com/zsims/hunt-and-peck/releases/download/release%2F1.6/HuntAndPeck-1.6.zip

# How to change font size

Find the application icon in tray, click right mouse button, select `Options`, then use the `FontSize` menu to change the font size.

# Screenshots

![ScreenShot](https://raw.github.com/zsims/hunt-n-peck/master/screenshots/explorer.png)
Expand Down
2 changes: 1 addition & 1 deletion src/HuntAndPeck/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
6 changes: 3 additions & 3 deletions src/HuntAndPeck/HuntAndPeck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HuntAndPeck</RootNamespace>
<AssemblyName>hap</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -184,9 +184,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<BootstrapperPackage Include=".NETFramework,Version=v4.5.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<ProductName>Microsoft .NET Framework 4.5.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
Expand Down
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
2 changes: 1 addition & 1 deletion src/NativeMethods/NativeMethods.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HuntAndPeck.NativeMethods</RootNamespace>
<AssemblyName>HuntAndPeck.NativeMethods</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
Expand Down