Skip to content

Commit

Permalink
Add dynamic scaling support and remove obsolete DpiDecorator
Browse files Browse the repository at this point in the history
Implemented dynamic scaling modes (Off, Simple, and Experimental) across the application for better UI adaptability. Removed the deprecated DpiDecorator as it's no longer necessary. Updated layout elements in various views to support new scaling logic and integrated settings to configure scaling behavior.
  • Loading branch information
HakuSystems committed Dec 27, 2024
1 parent ba5677d commit a01118c
Show file tree
Hide file tree
Showing 27 changed files with 2,437 additions and 2,120 deletions.
1 change: 1 addition & 0 deletions EasyExtractUnitypackageRework/Config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Windows;
using EasyExtractUnitypackageRework.Models;
using Newtonsoft.Json;
using Formatting = System.Xml.Formatting;

namespace EasyExtractUnitypackageRework.Config;
Expand Down
485 changes: 250 additions & 235 deletions EasyExtractUnitypackageRework/EasyExtract/Controls/About.xaml

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions EasyExtractUnitypackageRework/EasyExtract/Controls/About.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Windows.Media;
using EasyExtract.Config;
using EasyExtract.Models;
using EasyExtract.Services;
Expand Down Expand Up @@ -85,4 +86,34 @@ private void ChangeRandomMargins()
{
foreach (var card in _cards) card.Margin = RandomMargin();
}

private void About_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
switch (_configHelper.Config.DynamicScalingMode)
{
case DynamicScalingModes.Off:
break;

case DynamicScalingModes.Simple:
{
break;
}
case DynamicScalingModes.Experimental:
{
var scaleFactor = e.NewSize.Width / 1530.0;
switch (scaleFactor)
{
case < 0.5:
scaleFactor = 0.5;
break;
case > 2.0:
scaleFactor = 2.0;
break;
}

RootBorder.LayoutTransform = new ScaleTransform(scaleFactor, scaleFactor);
break;
}
}
}
}
1,115 changes: 586 additions & 529 deletions EasyExtractUnitypackageRework/EasyExtract/Controls/BetterSettings.xaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Windows.Media;
using EasyExtract.Config;
using EasyExtract.Models;
using EasyExtract.Services;
Expand Down Expand Up @@ -27,6 +28,11 @@ private async Task ChangeUiToMatchConfigAsync()
{
try
{
var dynamicScalingMode = Enum.GetValues(typeof(DynamicScalingModes))
.Cast<DynamicScalingModes>()
.ToList();
DynamicScalingComboBox.ItemsSource = dynamicScalingMode;

BorderMenuSwitch.IsChecked = _configHelper.Config.BorderThicknessActive;
ContextMenuSwitch.IsChecked = _configHelper.Config.ContextMenuToggle;
SkipIntroLogoAnimationToggleSwitch.IsChecked = _configHelper.Config.IntroLogoAnimation;
Expand Down Expand Up @@ -217,4 +223,43 @@ private async void BorderMenuSwitch_OnUnchecked(object sender, RoutedEventArgs e
{
await UpdateBorderThicknessConfigAsync();
}

private void BetterSettings_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
switch (_configHelper.Config.DynamicScalingMode)
{
case DynamicScalingModes.Off:
break;

case DynamicScalingModes.Simple:
{
break;
}
case DynamicScalingModes.Experimental:
{
var scaleFactor = e.NewSize.Width / 1100.0;
switch (scaleFactor)
{
case < 0.5:
scaleFactor = 0.5;
break;
case > 2.0:
scaleFactor = 2.0;
break;
}

RootShadowBorder.LayoutTransform = new ScaleTransform(scaleFactor, scaleFactor);
break;
}
}
}


private async void DynamicScalingComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (DynamicScalingComboBox.SelectedItem == null) return;
var selectedMode = (DynamicScalingModes)DynamicScalingComboBox.SelectedItem;
_configHelper.Config.DynamicScalingMode = selectedMode;
await _configHelper.UpdateConfigAsync();
}
}
125 changes: 61 additions & 64 deletions EasyExtractUnitypackageRework/EasyExtract/Controls/EasterEgg.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
KeyboardNavigation.TabNavigation="Cycle"
Loaded="EasterEgg_OnLoaded"
SizeChanged="EasterEgg_OnSizeChanged"
d:DataContext="{d:DesignInstance configModel:ConfigModel,
IsDesignTimeCreatable=True}"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d"
ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}"
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Expand All @@ -21,7 +20,6 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<!-- Subtle fade-in animation for the entire UserControl -->
<UserControl.Triggers>
<EventTrigger RoutedEvent="UserControl.Loaded">
<BeginStoryboard>
Expand All @@ -38,69 +36,68 @@
</UserControl.Triggers>

<Grid>
<Viewbox Stretch="Fill" StretchDirection="Both">
<Border
AutomationProperties.HelpText="Contains the pulsing heart icon and a thank-you message."
AutomationProperties.Name="EasterEggContainer"
CornerRadius="10"
Margin="12"
Opacity="0"
x:Name="RootShadowBorder">
<Border.Effect>
<DropShadowEffect
BlurRadius="10"
Color="#40000000"
Direction="320"
ShadowDepth="6" />
</Border.Effect>
<Border
AutomationProperties.HelpText="Contains the pulsing heart icon and a thank-you message."
AutomationProperties.Name="EasterEggContainer"
CornerRadius="10"
Margin="12"
Opacity="0"
x:Name="RootShadowBorder">
<Border.Effect>
<DropShadowEffect
BlurRadius="10"
Color="#40000000"
Direction="320"
ShadowDepth="6" />
</Border.Effect>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<ui:SymbolIcon
AutomationProperties.HelpText="Heart icon that pulsates to show appreciation."
AutomationProperties.Name="PulsingHeartIcon"
FontSize="100"
Foreground="Red"
Grid.Row="0"
Margin="5"
Opacity="0.2"
Symbol="Heart24"
x:Name="HeartIconToAnimate">
<ui:SymbolIcon.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
AutoReverse="True"
Duration="0:0:0.5"
From="100"
RepeatBehavior="Forever"
Storyboard.TargetName="HeartIconToAnimate"
Storyboard.TargetProperty="FontSize"
To="120" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ui:SymbolIcon.Triggers>
</ui:SymbolIcon>
<ui:SymbolIcon
AutomationProperties.HelpText="Heart icon that pulsates to show appreciation."
AutomationProperties.Name="PulsingHeartIcon"
FontSize="100"
Foreground="Red"
Grid.Row="0"
Margin="5"
Opacity="0.2"
Symbol="Heart24"
x:Name="HeartIconToAnimate">
<ui:SymbolIcon.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
AutoReverse="True"
Duration="0:0:0.5"
From="100"
RepeatBehavior="Forever"
Storyboard.TargetName="HeartIconToAnimate"
Storyboard.TargetProperty="FontSize"
To="120" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</ui:SymbolIcon.Triggers>
</ui:SymbolIcon>

<TextBlock
AutomationProperties.HelpText="Displays a friendly thank-you message for the user."
AutomationProperties.Name="ThankYouText"
FontSize="30"
FontWeight="Bold"
Grid.Row="0"
HorizontalAlignment="Center"
Margin="5"
Opacity="0.5"
Text="Thanks for using EasyExtract!"
VerticalAlignment="Center" />
</Grid>
</Border>
</Viewbox>
<TextBlock
AutomationProperties.HelpText="Displays a friendly thank-you message for the user."
AutomationProperties.Name="ThankYouText"
FontSize="30"
FontWeight="Bold"
Grid.Row="0"
HorizontalAlignment="Center"
Margin="5"
Opacity="0.5"
Text="Thanks for using EasyExtract!"
VerticalAlignment="Center"
x:Name="ThankYouText" />
</Grid>
</Border>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Windows.Media;
using EasyExtract.Config;
using EasyExtract.Models;
using EasyExtract.Services;
Expand Down Expand Up @@ -45,4 +46,35 @@ await BetterLogger.LogAsync($"Error updating Discord presence: {exception.Messag
await BetterLogger.LogAsync("EasterEgg UserControl loaded",
Importance.Info); // Log successful load
}

private void EasterEgg_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
switch (_configHelper.Config.DynamicScalingMode)
{
case DynamicScalingModes.Off:
break;

case DynamicScalingModes.Simple:
{
break;
}
case DynamicScalingModes.Experimental:
{
var scaleFactor = e.NewSize.Width / 800.0;

switch (scaleFactor)
{
case < 0.5:
scaleFactor = 0.5;
break;
case > 2.0:
scaleFactor = 2.0;
break;
}

RootShadowBorder.LayoutTransform = new ScaleTransform(scaleFactor, scaleFactor);
break;
}
}
}
}
Loading

0 comments on commit a01118c

Please sign in to comment.