Skip to content

Portable Tool for an Ideal Windows Setup

fix arc angle reset for CPU/RAM at max load & add use dynamic BitmapCache for motion elements

Greedeksfef324d4b957
diff --git a/.Source/GTweak/Styles/Buttons/Buttons.xaml b/.Source/GTweak/Styles/Buttons/Buttons.xaml
index 429ffbe9..8e839db2 100644
--- a/.Source/GTweak/Styles/Buttons/Buttons.xaml
+++ b/.Source/GTweak/Styles/Buttons/Buttons.xaml
@@ -147,8 +147,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
- <Grid>
- <ContentPresenter x:Name="RootContent" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" IsHitTestVisible="False"/>
+ <Grid x:Name="ButtonRoot">
+ <ContentPresenter x:Name="RootContent" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" IsHitTestVisible="False"/>
<Border Background="{TemplateBinding Background}" CornerRadius="7">
<Border x:Name="HoverBackground" Background="{TemplateBinding BorderBrush}" CornerRadius="7" Opacity="0" />
</Border>
@@ -160,11 +160,19 @@
</Rectangle>
</Border>
</Grid>
+
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="120">
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonRoot" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0">
+ <DiscreteObjectKeyFrame.Value>
+ <BitmapCache RenderAtScale="1"/>
+ </DiscreteObjectKeyFrame.Value>
+ </DiscreteObjectKeyFrame>
+ </ObjectAnimationUsingKeyFrames>
<RectAnimation Storyboard.TargetName="AnimatedBrush" Storyboard.TargetProperty="Viewport" To="0,-1,1,1" Duration="0:0:0.9">
<RectAnimation.EasingFunction>
<BackEase EasingMode="EaseOut" Amplitude="0.5"/>
@@ -175,12 +183,22 @@
<CubicEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonRoot" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:1.0" Value="{x:Null}"/>
+ </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="120">
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonRoot" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0">
+ <DiscreteObjectKeyFrame.Value>
+ <BitmapCache RenderAtScale="1"/>
+ </DiscreteObjectKeyFrame.Value>
+ </DiscreteObjectKeyFrame>
+ </ObjectAnimationUsingKeyFrames>
<RectAnimation Storyboard.TargetName="AnimatedBrush" Storyboard.TargetProperty="Viewport" To="0,0,1,1" Duration="0:0:0.8">
<RectAnimation.EasingFunction>
<BackEase EasingMode="EaseOut" Amplitude="0.5"/>
@@ -191,6 +209,9 @@
<CubicEase EasingMode="EaseOut"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonRoot" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0.9" Value="{x:Null}"/>
+ </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
diff --git a/.Source/GTweak/Styles/Buttons/RadioButtons.xaml b/.Source/GTweak/Styles/Buttons/RadioButtons.xaml
index d745c119..18e3ea1c 100644
--- a/.Source/GTweak/Styles/Buttons/RadioButtons.xaml
+++ b/.Source/GTweak/Styles/Buttons/RadioButtons.xaml
@@ -52,7 +52,8 @@
</Border>
</Grid>
</Border>
- <ControlTemplate.Triggers>
+
+ <ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="InnerPanel" Property="Background" Value="{StaticResource Brush_BtnBG_Navigation}"/>
<Setter Property="Foreground" Value="{StaticResource Brush_Accent}"/>
@@ -60,6 +61,13 @@
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="120">
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0">
+ <DiscreteObjectKeyFrame.Value>
+ <BitmapCache RenderAtScale="1"/>
+ </DiscreteObjectKeyFrame.Value>
+ </DiscreteObjectKeyFrame>
+ </ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="Width" To="300" Duration="0:0:0.35" FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<PowerEase Power="3" EasingMode="EaseIn"/>
@@ -80,12 +88,23 @@
<CubicEase/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
+
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0.4" Value="{x:Null}"/>
+ </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard Timeline.DesiredFrameRate="120">
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0">
+ <DiscreteObjectKeyFrame.Value>
+ <BitmapCache RenderAtScale="1"/>
+ </DiscreteObjectKeyFrame.Value>
+ </DiscreteObjectKeyFrame>
+ </ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="Width" To="50" Duration="0:0:0.25" FillBehavior="HoldEnd">
<DoubleAnimation.EasingFunction>
<QuadraticEase/>
@@ -106,6 +125,9 @@
<CubicEase/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
+ <ObjectAnimationUsingKeyFrames Storyboard.TargetName="OuterPanel" Storyboard.TargetProperty="CacheMode">
+ <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Null}"/>
+ </ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
@@ -121,5 +143,5 @@
</Setter.Value>
</Setter>
</Style>
-
+
</ResourceDictionary>
\ No newline at end of file
diff --git a/.Source/GTweak/Utilities/Managers/TaskSchedulerManager.cs b/.Source/GTweak/Utilities/Managers/TaskSchedulerManager.cs
index 14d8a3cc..292cf608 100644
--- a/.Source/GTweak/Utilities/Managers/TaskSchedulerManager.cs
+++ b/.Source/GTweak/Utilities/Managers/TaskSchedulerManager.cs
@@ -16,28 +16,21 @@ namespace GTweak.Utilities.Managers
{
if (tasklist != null && tasklist.Length != 0)
{
- ParallelLoopResult result = Parallel.ForEach(tasklist, () => new Microsoft.Win32.TaskScheduler.TaskService(),
- (taskName, loopState, taskScheduler) =>
+ try
{
- try
+ using Microsoft.Win32.TaskScheduler.TaskService taskService = new Microsoft.Win32.TaskScheduler.TaskService();
+ foreach (string taskName in tasklist)
{
- Microsoft.Win32.TaskScheduler.Task scheduledTask = taskScheduler.GetTask(taskName);
-
+ Microsoft.Win32.TaskScheduler.Task scheduledTask = taskService.GetTask(taskName);
if (scheduledTask != null && scheduledTask.Enabled)
{
- loopState.Stop();
+ return true;
}
}
- catch (Exception ex) { ErrorLogging.LogDebug(ex); }
+ }
+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }
- return taskScheduler;
- },
- taskScheduler =>
- {
- try { taskScheduler.Dispose(); }
- catch (Exception ex) { ErrorLogging.LogDebug(ex); }
- });
- return !result.IsCompleted;
+ return false;
}
return false;
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index 09f63725..d3ebc262 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -58,8 +58,8 @@ namespace GTweak.View
private void StartMonitoringData()
{
- CPULoad.EndAngle = HardwareData.Processor.Usage * 3.6;
- RAMLoad.EndAngle = HardwareData.Memory.Usage * 3.6;
+ CPULoad.EndAngle = Math.Min(HardwareData.Processor.Usage * 3.6, 359.9);
+ RAMLoad.EndAngle = Math.Min(HardwareData.Memory.Usage * 3.6, 359.9);
_timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, async time =>
{
@@ -93,7 +93,7 @@ namespace GTweak.View
}
}
- private void AnimateArcProgress(Wpf.Ui.Controls.Arc arc, double percent) => arc.BeginAnimation(Wpf.Ui.Controls.Arc.EndAngleProperty, FactoryAnimation.CreateIn(arc.EndAngle, percent * 3.6, 0.2, useCubicEase: true));
+ private void AnimateArcProgress(Wpf.Ui.Controls.Arc arc, double percent) => arc.BeginAnimation(Wpf.Ui.Controls.Arc.EndAngleProperty, FactoryAnimation.CreateIn(arc.EndAngle, Math.Min(percent * 3.6, 359.9), 0.2, useCubicEase: true));
private void HandleCopyingData_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
diff --git a/.Source/GTweak/Windows/MainWindow.xaml b/.Source/GTweak/Windows/MainWindow.xaml
index 534a4db9..81d5b75f 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml
+++ b/.Source/GTweak/Windows/MainWindow.xaml
@@ -318,7 +318,7 @@
</Grid>
- <Grid x:Name="UpdateBanner" Grid.Row="2" Panel.ZIndex="200" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,12,0,0" Visibility="Collapsed" Opacity="0">
+ <Grid x:Name="UpdateBanner" Grid.Row="2" Panel.ZIndex="200" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,12,0,0" Visibility="Collapsed" Opacity="0" CacheMode="BitmapCache" d:CacheMode="{x:Null}">
<Grid.RenderTransform>
<TranslateTransform Y="-20"/>
</Grid.RenderTransform>
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index ba698cb5..dddb6ea6 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -124,8 +124,11 @@ namespace GTweak.Windows
HandleWindowState(true);
break;
case nameof(TglButtonSettings):
- TranslateTransform transform = (TranslateTransform)SettingsPanel.RenderTransform;
- transform.BeginAnimation(TranslateTransform.XProperty, FactoryAnimation.CreateIn(transform.X, TglButtonSettings.IsChecked.Value ? 0 : 400, 0.5, useCubicEase: true));
+ SettingsPanel.CacheMode = new BitmapCache { RenderAtScale = 1 };
+ if (SettingsPanel.RenderTransform is TranslateTransform transform)
+ {
+ transform.BeginAnimation(TranslateTransform.XProperty, FactoryAnimation.CreateIn(transform.X, TglButtonSettings.IsChecked.Value ? 0 : 400, 0.5, () => { SettingsPanel.CacheMode = null; }, useCubicEase: true));
+ }
break;
case nameof(TglButtonTheme):
SettingsEngine.SelfReboot();
@@ -234,12 +237,10 @@ namespace GTweak.Windows
await Task.Delay(500);
UpdateBanner.Visibility = Visibility.Visible;
-
UpdateBanner.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0, 1, 0.3));
-
if (UpdateBanner.RenderTransform is TranslateTransform transform)
{
- transform.BeginAnimation(TranslateTransform.YProperty, FactoryAnimation.CreateIn(-20, 0, 0.3, useCubicEase: true));
+ transform.BeginAnimation(TranslateTransform.YProperty, FactoryAnimation.CreateIn(-20, 0, 0.3, () => { UpdateBanner.CacheMode = null; }, useCubicEase: true));
}
}
}
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml b/.Source/GTweak/Windows/NotificationWindow.xaml
index 27ca89c9..ce803105 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml
@@ -8,7 +8,7 @@
mc:Ignorable="d" Icon="/GTweak.ico"
Background="Transparent" WindowStyle="None" IsTabStop="False" Focusable="False" SnapsToDevicePixels="True" UseLayoutRounding="True" ShowInTaskbar="False"
ExtendsContentIntoTitleBar="True" WindowBackdropType="Mica" SizeToContent="Height" ResizeMode="NoResize" WindowStartupLocation="Manual" KeyboardNavigation.TabNavigation="None"
- Title="{DynamicResource title_win_noty}" Topmost="True" MinHeight="125" MinWidth="375" MaxHeight="170" MaxWidth="375">
+ Title="{DynamicResource title_win_noty}" Topmost="True" MinHeight="125" MinWidth="375" MaxHeight="170" MaxWidth="375" CacheMode="BitmapCache" d:CacheMode="{x:Null}">
<Grid Background="{StaticResource Brush_Background}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index 4c4826a3..5ece58d3 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -43,7 +43,7 @@ namespace GTweak.Windows
}
BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0, 1, 0.2));
- BeginAnimation(LeftProperty, FactoryAnimation.CreateIn(primaryMonitorArea.Right + 10, primaryMonitorArea.Right - Width - 10, 0.35, useCubicEase: true));
+ BeginAnimation(LeftProperty, FactoryAnimation.CreateIn(primaryMonitorArea.Right + 10, primaryMonitorArea.Right - Width - 10, 0.35, () => { CacheMode = null; }, useCubicEase: true));
_timer = new TimerControlManager(TimeSpan.FromSeconds(3), TimerControlManager.TimerMode.CountDown, null, () => { Close(); });
_timer.Start();
diff --git a/.Source/GTweak/Windows/SettingsWindow.xaml b/.Source/GTweak/Windows/SettingsWindow.xaml
new file mode 100644
index 00000000..22d28180
--- /dev/null
+++ b/.Source/GTweak/Windows/SettingsWindow.xaml
@@ -0,0 +1,55 @@
+<Window x:Class="GTweak.Windows.SettingsWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:vm="clr-namespace:GTweak.Core.ViewModel"
+ xmlns:uc="clr-namespace:GTweak.Assets.UserControls"
+ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
+ mc:Ignorable="d"
+ Title="Настройки" Width="400" Height="600"
+ Background="{StaticResource Brush_Background}"
+ WindowStyle="None"
+
+ Topmost="True">
+
+ <Window.DataContext>
+ <vm:MainWinViewModel/>
+ </Window.DataContext>
+
+ <Grid RenderTransformOrigin="0,0">
+ <Grid.RenderTransform>
+ <TranslateTransform x:Name="SlideTransform" X="-400"/>
+ </Grid.RenderTransform>
+ <ScrollViewer VerticalScrollBarVisibility="Auto">
+ <StackPanel Margin="10">
+ <TextBlock FontSize="20" Text="{DynamicResource title_settings_main}" Foreground="{StaticResource Brush_Accent}" Margin="0,0,0,20"/>
+
+ <!-- Toggle кнопки -->
+ <uc:ToggleButton x:Name="BtnNotification" State="{Binding IsViewNotification}" TextResource="{DynamicResource btgl_noty_main}" Margin="0,5"/>
+ <uc:ToggleButton x:Name="BtnUpdate" State="{Binding IsUpdateCheckRequired}" TextResource="{DynamicResource btgl_update_main}" Margin="0,5"/>
+ <uc:ToggleButton x:Name="BtnTopMost" State="{Binding IsTopMost}" TextResource="{DynamicResource btgl_toast_main}" Margin="0,5"/>
+
+ <!-- Громкость -->
+ <StackPanel Orientation="Horizontal" Margin="0,10">
+ <TextBlock Text="{DynamicResource slider_volume_main}" VerticalAlignment="Center"/>
+ <ToggleButton x:Name="BtnVolume" IsChecked="{Binding IsPlayingSound}" Width="20" Height="20" Margin="10,0"/>
+ <Slider Value="{Binding CurrentVolume}" Minimum="1" Maximum="100" Width="150" Margin="10,0"/>
+ </StackPanel>
+
+ <!-- Язык -->
+ <StackPanel Orientation="Horizontal" Margin="0,10">
+ <TextBlock Text="{DynamicResource cmbox_lang_main}" VerticalAlignment="Center"/>
+ <ComboBox ItemsSource="{Binding Languages}" SelectedValue="{Binding SelectedLanguage}" DisplayMemberPath="Display" SelectedValuePath="Code" Width="150" Margin="10,0"/>
+ </StackPanel>
+
+ <!-- Кнопки Экспорт/Импорт/Удаление -->
+ <StackPanel Orientation="Horizontal" Margin="0,20">
+ <Button Content="{DynamicResource btn_export}" Width="100" Margin="0,0,10,0"/>
+ <Button Content="{DynamicResource btn_import}" Width="100" Margin="0,0,10,0"/>
+ <Button Content="{DynamicResource btn_selfremove}" Width="100"/>
+ </StackPanel>
+ </StackPanel>
+ </ScrollViewer>
+ </Grid>
+</Window>
\ No newline at end of file
diff --git a/.Source/GTweak/Windows/SettingsWindow.xaml.cs b/.Source/GTweak/Windows/SettingsWindow.xaml.cs
new file mode 100644
index 00000000..d0a90259
--- /dev/null
+++ b/.Source/GTweak/Windows/SettingsWindow.xaml.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using Wpf.Ui.Controls;
+
+namespace GTweak.Windows
+{
+
+ public partial class SettingsWindow : Window
+ {
+ public SettingsWindow()
+ {
+ InitializeComponent();
+ Loaded += SettingsWindow_Loaded;
+ }
+
+ private void SettingsWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ var slideIn = new DoubleAnimation
+ {
+ From = Width, // справа за экраном
+ To = 0,
+ Duration = TimeSpan.FromSeconds(0.4),
+ EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
+ };
+
+ SlideTransform.BeginAnimation(TranslateTransform.XProperty, slideIn);
+ }
+
+ public void SlideOutAndHide()
+ {
+ var slideOut = new DoubleAnimation
+ {
+ From = 0,
+ To = Width,
+ Duration = TimeSpan.FromSeconds(0.4),
+ EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }
+ };
+
+ slideOut.Completed += (s, e) => Hide();
+ SlideTransform.BeginAnimation(TranslateTransform.XProperty, slideOut);
+ }
+ }
+}