Skip to content

Commit

Permalink
Merge pull request #666 from dremin/settings-json
Browse files Browse the repository at this point in the history
Add new configuration backend
  • Loading branch information
dremin authored Aug 30, 2023
2 parents b8c006b + 265060c commit 3ecff6b
Show file tree
Hide file tree
Showing 20 changed files with 280 additions and 770 deletions.
81 changes: 0 additions & 81 deletions RetroBar/App.config

This file was deleted.

2 changes: 1 addition & 1 deletion RetroBar/Controls/NotifyBalloon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public CustomPopupPlacement[] PlacePopup(Size popupSize, Size targetSize, Point

DpiScale dpiScale = VisualTreeHelper.GetDpi(this);

switch ((AppBarEdge)Settings.Instance.Edge)
switch (Settings.Instance.Edge)
{
case AppBarEdge.Top:
if (FlowDirection == FlowDirection.LeftToRight)
Expand Down
4 changes: 2 additions & 2 deletions RetroBar/Controls/NotifyIcon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public NotifyIcon()

private void applyEffects()
{
if ((!EnvironmentHelper.IsWindows10OrBetter && Settings.Instance.InvertIconsMode == 0) || TrayIcon == null || Settings.Instance.InvertIconsMode == 2)
if ((!EnvironmentHelper.IsWindows10OrBetter && Settings.Instance.InvertIconsMode == Settings.InvertIconsOption.WhenNeededByTheme) || TrayIcon == null || Settings.Instance.InvertIconsMode == Settings.InvertIconsOption.Never)
{
return;
}
Expand All @@ -53,7 +53,7 @@ private void applyEffects()
}

bool invertByTheme = Application.Current.FindResource("InvertSystemNotifyIcons") as bool? ?? false;
bool performInvert = invertByTheme || Settings.Instance.InvertIconsMode == 1;
bool performInvert = invertByTheme || Settings.Instance.InvertIconsMode == Settings.InvertIconsOption.Always;

if (NotifyIconImage.Effect == null != performInvert)
{
Expand Down
10 changes: 5 additions & 5 deletions RetroBar/Controls/TaskList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void SetStyles()
MinButtonWidth = Application.Current.FindResource("TaskButtonMinWidth") as double? ?? 0;
Thickness buttonMargin;

if (Settings.Instance.Edge == (int)AppBarEdge.Left || Settings.Instance.Edge == (int)AppBarEdge.Right)
if (Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right)
{
buttonMargin = Application.Current.FindResource("TaskButtonVerticalMargin") as Thickness? ?? new Thickness();
}
Expand Down Expand Up @@ -98,7 +98,7 @@ private void Settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
}
else if (e.PropertyName == "ShowMultiMon")
{
if (Settings.Instance.MultiMonMode != 0)
if (Settings.Instance.MultiMonMode != Settings.MultiMonOption.AllTaskbars)
{
taskbarItems?.Refresh();
}
Expand All @@ -114,12 +114,12 @@ private bool Tasks_Filter(object obj)
return false;
}

if (!Settings.Instance.ShowMultiMon || Settings.Instance.MultiMonMode == 0)
if (!Settings.Instance.ShowMultiMon || Settings.Instance.MultiMonMode == Settings.MultiMonOption.AllTaskbars)
{
return true;
}

if (Settings.Instance.MultiMonMode == 2 && Host.Screen.Primary)
if (Settings.Instance.MultiMonMode == Settings.MultiMonOption.SameAsWindowAndPrimary && Host.Screen.Primary)
{
return true;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ private void TaskList_OnSizeChanged(object sender, SizeChangedEventArgs e)

private void SetTaskButtonWidth()
{
if (Settings.Instance.Edge == (int)AppBarEdge.Left || Settings.Instance.Edge == (int)AppBarEdge.Right)
if (Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right)
{
ButtonWidth = ActualWidth;
SetScrollable(true); // while technically not always scrollable, we don't run into DPI-specific issues with it enabled while vertical
Expand Down
2 changes: 1 addition & 1 deletion RetroBar/Converters/DockOrientationConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class DockOrientationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool vertical = Settings.Instance.Edge == (int)AppBarEdge.Left || Settings.Instance.Edge == (int)AppBarEdge.Right;
bool vertical = Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right;

// parameter is a string "leading" or "trailing"

Expand Down
2 changes: 1 addition & 1 deletion RetroBar/Converters/EdgeOrientationConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class EdgeOrientationConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (Settings.Instance.Edge == (int)AppBarEdge.Left || Settings.Instance.Edge == (int)AppBarEdge.Right)
if (Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right)
{
return Orientation.Vertical;
}
Expand Down
19 changes: 19 additions & 0 deletions RetroBar/Converters/EnumConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Globalization;
using System.Windows.Data;

namespace RetroBar.Converters
{
public class EnumConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Enum.ToObject(targetType, value);
}
}
}
2 changes: 1 addition & 1 deletion RetroBar/Converters/ToolTipHorizontalOffsetConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return double.NaN;
}

if (Settings.Instance.Edge == (int)AppBarEdge.Left || Settings.Instance.Edge == (int)AppBarEdge.Right)
if (Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right)
{
return (double)0;
}
Expand Down
6 changes: 3 additions & 3 deletions RetroBar/Converters/ToolTipPlacementConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class ToolTipPlacementConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (Settings.Instance.Edge == (int)AppBarEdge.Left)
if (Settings.Instance.Edge == AppBarEdge.Left)
{
return PlacementMode.Right;
}
else if (Settings.Instance.Edge == (int)AppBarEdge.Right)
else if (Settings.Instance.Edge == AppBarEdge.Right)
{
return PlacementMode.Left;
}
else if (Settings.Instance.Edge == (int)AppBarEdge.Top)
else if (Settings.Instance.Edge == AppBarEdge.Top)
{
return PlacementMode.Bottom;
}
Expand Down
2 changes: 1 addition & 1 deletion RetroBar/Converters/ToolTipVerticalOffsetConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
return double.NaN;
}

if (Settings.Instance.Edge == (int)AppBarEdge.Left || Settings.Instance.Edge == (int)AppBarEdge.Right)
if (Settings.Instance.Edge == AppBarEdge.Left || Settings.Instance.Edge == AppBarEdge.Right)
{
double placementTargetHeight = (double)values[0];
double toolTipHeight = (double)values[1];
Expand Down
Loading

0 comments on commit 3ecff6b

Please sign in to comment.