Skip to content

Commit

Permalink
Merge pull request #37 from dremin/font-option
Browse files Browse the repository at this point in the history
Options for run at logon and font smoothing
  • Loading branch information
dremin authored Jul 11, 2021
2 parents 991b476 + bab40bd commit 96b7e99
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 63 deletions.
12 changes: 12 additions & 0 deletions RetroBar/Properties/Settings.Designer.cs

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

3 changes: 3 additions & 0 deletions RetroBar/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
<Setting Name="CollapseNotifyIcons" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="AllowFontSmoothing" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
95 changes: 49 additions & 46 deletions RetroBar/PropertiesWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
xmlns:Settings="clr-namespace:RetroBar.Utilities"
xmlns:converters="clr-namespace:RetroBar.Converters"
Title="RetroBar Properties"
Height="400"
Width="345"
Height="Auto"
Width="Auto"
ResizeMode="NoResize"
SizeToContent="WidthAndHeight"
Style="{DynamicResource PropertiesWindow}"
Closing="PropertiesWindow_OnClosing">
Closing="PropertiesWindow_OnClosing"
Loaded="PropertiesWindow_OnLoaded">
<Window.Resources>
<ResourceDictionary>
<converters:PropertiesImageSourceConverter x:Key="imageConverter" />
Expand Down Expand Up @@ -62,50 +64,51 @@
</Grid.RowDefinitions>
<TabControl Grid.Row="0">
<TabItem Header="Taskbar Options">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical"
Grid.Column="1">
<Image Width="274"
Height="130"
Margin="0,20">
<Image.Source>
<MultiBinding Converter="{StaticResource imageConverter}"
NotifyOnSourceUpdated="True">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding Source="{x:Static Settings:Settings.Instance}"
Path="ShowClock"
UpdateSourceTrigger="PropertyChanged" />
</MultiBinding>
</Image.Source>
</Image>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Theme:"
ToolTip="Install themes in the Themes folder." />
<ComboBox Name="cboThemeSelect"
IsDropDownOpen="False"
IsEditable="False"
SelectedValue="{Binding Source={x:Static Settings:Settings.Instance}, Path=Theme, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowClock, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Show clock" />
</CheckBox>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=CollapseNotifyIcons, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Collapse notification area icons" />
<StackPanel Orientation="Vertical"
Margin="20">
<Image Width="274"
Height="130"
Margin="0,0,0,10">
<Image.Source>
<MultiBinding Converter="{StaticResource imageConverter}"
NotifyOnSourceUpdated="True">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding Source="{x:Static Settings:Settings.Instance}"
Path="ShowClock"
UpdateSourceTrigger="PropertyChanged" />
</MultiBinding>
</Image.Source>
</Image>
<CheckBox Checked="AutoStartCheckBox_OnChecked"
Unchecked="AutoStartCheckBox_OnChecked"
Name="AutoStartCheckBox">
<Label Content="Automatically start at logon" />
</CheckBox>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Theme:"
ToolTip="Install themes in the Themes folder." />
<ComboBox Name="cboThemeSelect"
IsDropDownOpen="False"
IsEditable="False"
SelectedValue="{Binding Source={x:Static Settings:Settings.Instance}, Path=Theme, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=AllowFontSmoothing, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Allow font smoothing" />
</CheckBox>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=CollapseNotifyIcons, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Collapse notification area icons" />
</CheckBox>
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowClock, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Show clock" />
</CheckBox>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowQuickLaunch, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Show quick launch" />
</CheckBox>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Source={x:Static Settings:Settings.Instance}, Path=ShowQuickLaunch, UpdateSourceTrigger=PropertyChanged}">
<Label Content="Show quick launch" />
</CheckBox>
<Button Content="Select location..."
Click="SetQuickLaunchLocation_OnClick" />
</StackPanel>
<Button Content="Select location..."
Click="SetQuickLaunchLocation_OnClick" />
</StackPanel>
</Grid>
</StackPanel>
</TabItem>
</TabControl>
<StackPanel Orientation="Horizontal"
Expand All @@ -116,4 +119,4 @@
Click="OK_OnClick" />
</StackPanel>
</Grid>
</Window>
</Window>
66 changes: 62 additions & 4 deletions RetroBar/PropertiesWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using ManagedShell.Common.Helpers;
using RetroBar.Utilities;
using System.Windows;
using System.Windows.Controls;
using ManagedShell.Common.Logging;
using Microsoft.Win32;

namespace RetroBar
{
Expand All @@ -20,10 +26,8 @@ private PropertiesWindow(ThemeManager themeManager)

InitializeComponent();

LoadAutoStart();
LoadThemes();

Left = 10;
Top = (ScreenHelper.PrimaryMonitorDeviceSize.Height / DpiHelper.DpiScale) - Height - 40;
}

public static void Open(ThemeManager themeManager)
Expand All @@ -39,6 +43,31 @@ public static void Open(ThemeManager themeManager)
}
}

private void LoadAutoStart()
{
try
{
RegistryKey rKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", false);
List<string> rKeyValueNames = rKey?.GetValueNames().ToList();

if (rKeyValueNames != null)
{
if (rKeyValueNames.Contains("RetroBar"))
{
AutoStartCheckBox.IsChecked = true;
}
else
{
AutoStartCheckBox.IsChecked = false;
}
}
}
catch (Exception e)
{
ShellLogger.Error($"PropertiesWindow: Unable to load autorun setting from registry: {e.Message}");
}
}

private void LoadThemes()
{
foreach (var theme in _themeManager.GetThemes())
Expand Down Expand Up @@ -70,5 +99,34 @@ private void PropertiesWindow_OnClosing(object sender, CancelEventArgs e)
{
_instance = null;
}

private void PropertiesWindow_OnLoaded(object sender, RoutedEventArgs e)
{
Left = 10;
Top = (ScreenHelper.PrimaryMonitorDeviceSize.Height / DpiHelper.DpiScale) - Height - 40;
}

private void AutoStartCheckBox_OnChecked(object sender, RoutedEventArgs e)
{
try
{
RegistryKey rKey = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
var chkBox = (CheckBox)sender;

if (chkBox.IsChecked.Equals(false))
{
rKey?.DeleteValue("RetroBar");
}
else
{
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
rKey?.SetValue("RetroBar", exePath);
}
}
catch (Exception exception)
{
ShellLogger.Error($"PropertiesWindow: Unable to update registry autorun setting: {exception.Message}");
}
}
}
}
11 changes: 11 additions & 0 deletions RetroBar/Taskbar.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media;
using ManagedShell.ShellFolders;
using RetroBar.Utilities;
using Application = System.Windows.Application;
Expand All @@ -32,6 +33,7 @@ public Taskbar(ShellManager shellManager, CloakMonitor cloakMonitor, AppBarScree
DataContext = _shellManager;
DesiredHeight = Application.Current.FindResource("TaskbarHeight") as double? ?? 0;
AllowsTransparency = Application.Current.FindResource("AllowsTransparency") as bool? ?? false;
SetFontSmoothing();
SetupQuickLaunch();

_explorerHelper.HideExplorerTaskbar = true;
Expand Down Expand Up @@ -83,6 +85,11 @@ public override void SetPosition()
}
});
}

private void SetFontSmoothing()
{
VisualTextRenderingMode = Settings.Instance.AllowFontSmoothing ? TextRenderingMode.Auto : TextRenderingMode.Aliased;
}

private void SetupQuickLaunch()
{
Expand Down Expand Up @@ -130,6 +137,10 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
SetupQuickLaunch();
}
else if (e.PropertyName == "AllowFontSmoothing")
{
SetFontSmoothing();
}
}

private void Taskbar_OnLocationChanged(object? sender, EventArgs e)
Expand Down
2 changes: 0 additions & 2 deletions RetroBar/Themes/System.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

<Style TargetType="Window"
x:Key="Taskbar">
<Setter Property="TextOptions.TextRenderingMode"
Value="Aliased" />
<Setter Property="TextOptions.TextFormattingMode"
Value="Display" />
<Setter Property="Template">
Expand Down
2 changes: 0 additions & 2 deletions RetroBar/Themes/Watercolor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
<Style TargetType="Window"
x:Key="Taskbar"
BasedOn="{StaticResource Taskbar}">
<Setter Property="TextOptions.TextRenderingMode"
Value="Auto" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Window">
Expand Down
2 changes: 0 additions & 2 deletions RetroBar/Themes/Windows XP Blue.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@
<Style TargetType="Window"
x:Key="Taskbar"
BasedOn="{StaticResource Taskbar}">
<Setter Property="TextOptions.TextRenderingMode"
Value="Auto" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Window">
Expand Down
7 changes: 0 additions & 7 deletions RetroBar/Themes/Windows XP Classic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,4 @@

<BitmapImage x:Key="StartIconImage"
UriSource="../Resources/startxpclassic.png"/>

<Style TargetType="Window"
x:Key="Taskbar"
BasedOn="{StaticResource Taskbar}">
<Setter Property="TextOptions.TextRenderingMode"
Value="Auto" />
</Style>
</ResourceDictionary>
17 changes: 17 additions & 0 deletions RetroBar/Utilities/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ public bool CollapseNotifyIcons
}
}
}

public bool AllowFontSmoothing
{
get
{
return settings.AllowFontSmoothing;
}
set
{
if (settings.AllowFontSmoothing != value)
{
settings.AllowFontSmoothing = value;
}
}
}
#endregion

public void Save()
Expand All @@ -176,6 +191,8 @@ public void Upgrade()
_upgrading = true;
settings.Upgrade();
_upgrading = false;

if (IsFirstRun) IsFirstRun = false;
}

public object this[string propertyName]
Expand Down

0 comments on commit 96b7e99

Please sign in to comment.