Skip to content

Portable Tool for an Ideal Windows Setup

upd. Addons (finished page) & ref anim

Greedeks6f55a34c308e
diff --git a/.Source/GTweak/Assets/UserControl/FileCard.xaml b/.Source/GTweak/Assets/UserControl/FileCard.xaml
index e5da101e..d2b82537 100644
--- a/.Source/GTweak/Assets/UserControl/FileCard.xaml
+++ b/.Source/GTweak/Assets/UserControl/FileCard.xaml
@@ -6,8 +6,10 @@
xmlns:local="clr-namespace:GTweak.Assets.UserControl"
mc:Ignorable="d"
d:Height="Auto" d:Width="Auto" IsTabStop="False" KeyboardNavigation.TabNavigation="None" SnapsToDevicePixels="True"
- UseLayoutRounding="True" Cursor="Hand" MaxWidth="200">
- <Grid>
+ UseLayoutRounding="True" Cursor="Hand" MaxWidth="200" >
+ <Grid Cursor="Hand">
+ <ProgressBar x:Name="ProgressBar" Height="4" Margin="8,0,8,0" Width="Auto" VerticalAlignment="Top" Visibility="Collapsed" Value="0" Maximum="100" Foreground="{StaticResource Brush_Accent}" />
+
<Border CornerRadius="8" Opacity="0.45" Background="#33000000" IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Panel.ZIndex="0">
<Border.RenderTransform>
<TranslateTransform X="3" Y="6" />
diff --git a/.Source/GTweak/Assets/UserControl/FileCard.xaml.cs b/.Source/GTweak/Assets/UserControl/FileCard.xaml.cs
index 22fed9b9..cc17c12d 100644
--- a/.Source/GTweak/Assets/UserControl/FileCard.xaml.cs
+++ b/.Source/GTweak/Assets/UserControl/FileCard.xaml.cs
@@ -1,4 +1,5 @@
using System.Windows;
+using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;
using GTweak.Utilities.Animation;
@@ -44,19 +45,23 @@ namespace GTweak.Assets.UserControl
InitializeComponent();
}
- private void Card_MouseEnter(object sender, MouseEventArgs e) => CardBody.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(1.0, 0.6, 0.2));
-
+ private void Card_MouseEnter(object sender, MouseEventArgs e) => CardBody.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(1.0, 0.7, 0.2));
+
+
+ private void Card_MouseLeave(object sender, MouseEventArgs e) => CardBody.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0.7, 1.0, 0.2));
+
- private void Card_MouseLeave(object sender, MouseEventArgs e) => CardBody.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0.6, 1.0, 0.2));
-
private void Card_MouseClick(object sender, MouseButtonEventArgs e)
{
+ ProgressBar.Visibility = Visibility.Visible;
+
if (Command != null && Command.CanExecute(CommandParameter))
{
Command.Execute(CommandParameter);
}
- CardBody.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(1.0, 0.7, 0.1, reverse: true));
+
+ ProgressBar.BeginAnimation(RangeBase.ValueProperty, FactoryAnimation.CreateIn(0, 100, 0.2, () => { ProgressBar.Visibility = Visibility.Collapsed; }, reverse: true));
}
}
diff --git a/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs b/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs
index dcffa58f..fc5b01e2 100644
--- a/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs
+++ b/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs
@@ -220,8 +220,8 @@ namespace GTweak.Assets.UserControl
{
if (IsEnabled)
{
- DotScale.BeginAnimation(ScaleTransform.ScaleXProperty, FactoryAnimation.CreateIn(1, 1.1, 0.15, null, false, true));
- DotScale.BeginAnimation(ScaleTransform.ScaleYProperty, FactoryAnimation.CreateIn(1, 1.1, 0.15, null, false, true));
+ DotScale.BeginAnimation(ScaleTransform.ScaleXProperty, FactoryAnimation.CreateIn(1, 1.1, 0.15, useCubicEase: true));
+ DotScale.BeginAnimation(ScaleTransform.ScaleYProperty, FactoryAnimation.CreateIn(1, 1.1, 0.15, useCubicEase: true));
}
}
@@ -229,8 +229,8 @@ namespace GTweak.Assets.UserControl
{
if (IsEnabled)
{
- DotScale.BeginAnimation(ScaleTransform.ScaleXProperty, FactoryAnimation.CreateIn(1.1, 1, 0.15, null, false, true));
- DotScale.BeginAnimation(ScaleTransform.ScaleYProperty, FactoryAnimation.CreateIn(1.1, 1, 0.15, null, false, true));
+ DotScale.BeginAnimation(ScaleTransform.ScaleXProperty, FactoryAnimation.CreateIn(1.1, 1, 0.15, useCubicEase: true));
+ DotScale.BeginAnimation(ScaleTransform.ScaleYProperty, FactoryAnimation.CreateIn(1.1, 1, 0.15, useCubicEase: true));
}
}
diff --git a/.Source/GTweak/Core/Model/AddonsModel.cs b/.Source/GTweak/Core/Model/AddonsModel.cs
index 020a3d64..a22f8111 100644
--- a/.Source/GTweak/Core/Model/AddonsModel.cs
+++ b/.Source/GTweak/Core/Model/AddonsModel.cs
@@ -1,7 +1,23 @@
-namespace GTweak.Core.Model
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace GTweak.Core.ViewModel
{
- internal class AddonsModel
+ public class AddonModel
{
+ public string FilePath { get; }
+ public string FileName { get; }
+ public ImageSource IconImage { get; }
+ public ICommand RunCommand { get; }
+ public bool RequiresElevation { get; }
+ public AddonModel(string filePath, string fileName, ImageSource iconImage, ICommand runCommand, bool requiresElevation = false)
+ {
+ FilePath = filePath;
+ FileName = fileName;
+ IconImage = iconImage;
+ RunCommand = runCommand;
+ RequiresElevation = requiresElevation;
+ }
}
-}
+}
\ No newline at end of file
diff --git a/.Source/GTweak/Core/ViewModel/AddonsViewModel.cs b/.Source/GTweak/Core/ViewModel/AddonsViewModel.cs
index 1fcdd8f9..0fb96591 100644
--- a/.Source/GTweak/Core/ViewModel/AddonsViewModel.cs
+++ b/.Source/GTweak/Core/ViewModel/AddonsViewModel.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
@@ -9,70 +10,26 @@ using System.Windows.Input;
using System.Windows.Media;
using GTweak.Core.Base;
using GTweak.Utilities.Controls;
+using GTweak.Utilities.Helpers;
using Ookii.Dialogs.Wpf;
namespace GTweak.Core.ViewModel
{
internal class AddonsViewModel : ViewModelBase
{
- internal class AddonItem
- {
- public string FilePath { get; }
- public string FileName { get; }
- public ImageSource IconImage { get; }
- public ICommand RunCommand { get; }
- private readonly Action _onRunComplete;
- public bool RequiresElevation { get; }
-
- public AddonItem(string filePath, string fileName, ImageSource iconImage, Action onRunComplete, bool requiresElevation = false)
- {
- FilePath = filePath;
- FileName = fileName;
- IconImage = iconImage;
- _onRunComplete = onRunComplete;
- RequiresElevation = requiresElevation;
-
- RunCommand = new RelayCommand(async _ => await RunFileAsync());
- }
-
- private async Task RunFileAsync()
- {
- try
- {
- var ext = Path.GetExtension(FilePath).ToLowerInvariant();
-
- if (RequiresElevation)
- {
-
- }
- else
- {
-
- }
-
- _onRunComplete?.Invoke();
- }
- catch (Exception ex) { ErrorLogging.LogDebug(ex); }
- }
- }
-
- private static readonly string[] AllowedExtensions = new[] { ".ps1", ".bat", ".cmd", ".reg" };
-
- public ObservableCollection<AddonItem> Addons { get; } = new ObservableCollection<AddonItem>();
+ public ObservableCollection<AddonModel> Addons { get; } = new ObservableCollection<AddonModel>();
public ICommand SelectFolderCommand { get; }
public ICommand UpdateCommand { get; }
private bool _isRunAsTrustedInstaller;
+ private readonly object _locker = new object();
+ private string _lastKnownFolderPath = string.Empty;
public bool IsRunAsTrustedInstaller
{
get => _isRunAsTrustedInstaller;
- set
- {
- _isRunAsTrustedInstaller = value;
- OnPropertyChanged();
- }
+ set { _isRunAsTrustedInstaller = value; OnPropertyChanged(); }
}
public AddonsViewModel()
@@ -93,26 +50,57 @@ namespace GTweak.Core.ViewModel
{
try
{
- var folderDialog = new VistaFolderBrowserDialog();
- if (folderDialog.ShowDialog() == false)
+ VistaFolderBrowserDialog folderDialog = new VistaFolderBrowserDialog
{
- return;
+ UseDescriptionForTitle = true,
+ SelectedPath = SettingsEngine.UserAddonsPath ?? Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
+ };
+
+ bool? dialogResult = folderDialog.ShowDialog();
+
+ if (dialogResult != null && dialogResult.Value)
+ {
+ string selectedPath = folderDialog.SelectedPath;
+ if (!string.IsNullOrWhiteSpace(selectedPath) && Directory.Exists(selectedPath))
+ {
+ SettingsEngine.UserAddonsPath = selectedPath;
+ ScanFolder();
+ }
}
+ }
+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }
+ }
+
+ private void RunFile(AddonModel addon)
+ {
+ try
+ {
+ string fileName = string.Empty, arguments = string.Empty;
- string selectedPath = folderDialog.SelectedPath;
- if (!string.IsNullOrWhiteSpace(selectedPath) && Directory.Exists(selectedPath))
+ switch (Path.GetExtension(addon.FilePath).ToLowerInvariant())
{
- SettingsEngine.UserAddonsPath = selectedPath;
- ScanFolder();
+ case ".reg":
+ fileName = "reg.exe";
+ arguments = $"import \"{addon.FilePath}\"";
+ break;
+
+ case ".ps1":
+ fileName = PathLocator.Executable.PowerShell;
+ arguments = $"-ExecutionPolicy Bypass -File \"{addon.FilePath}\"";
+ break;
+ default:
+ fileName = PathLocator.Executable.CommandShell;
+ arguments = $"/k \"{addon.FilePath}\"";
+ break;
}
+
+ Task.Run(() => { CommandExecutor.RunCommandShow(fileName, CommandExecutor.CleanCommand(arguments), addon.RequiresElevation); });
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
}
private void ScanFolder()
{
- Addons.Clear();
-
try
{
string path = SettingsEngine.UserAddonsPath;
@@ -122,12 +110,42 @@ namespace GTweak.Core.ViewModel
return;
}
+ if (_lastKnownFolderPath != path)
+ {
+ lock (_locker)
+ {
+ Addons.Clear();
+ }
+
+ _lastKnownFolderPath = path;
+ }
+
IOrderedEnumerable<string> files = Directory.EnumerateFiles(path, "*.*", SearchOption.TopDirectoryOnly)
- .Where(f => AllowedExtensions.Contains(Path.GetExtension(f), StringComparer.OrdinalIgnoreCase))
- .OrderBy(f => Path.GetFileName(f));
+ .Where(f => new[] { ".ps1", ".bat", ".cmd", ".reg" }.Contains(Path.GetExtension(f), StringComparer.OrdinalIgnoreCase))
+ .OrderBy(f => Path.GetFileName(f));
+
+ List<string> currentFilePaths = Addons.Select(a => a.FilePath).ToList();
+
+ bool collectionChanged = false;
+
+ List<AddonModel> addonsToRemove = Addons.Where(a => !files.Contains(a.FilePath)).ToList();
+
+ foreach (var addon in addonsToRemove)
+ {
+ lock (_locker)
+ {
+ Addons.Remove(addon);
+ }
+ collectionChanged = true;
+ }
foreach (string file in files)
{
+ if (currentFilePaths.Contains(file))
+ {
+ continue;
+ }
+
string iconRes = Path.GetExtension(file).ToLowerInvariant() switch
{
".ps1" => "Img_PowershellFile",
@@ -140,21 +158,40 @@ namespace GTweak.Core.ViewModel
ImageSource iconImage = null;
try
{
- if (Application.Current != null)
+ if (Application.Current != null && !string.IsNullOrEmpty(iconRes) && Application.Current.Resources.Contains(iconRes))
{
- if (Application.Current.Resources.Contains(iconRes))
- {
- iconImage = Application.Current.Resources[iconRes] as ImageSource;
- }
+ iconImage = Application.Current.Resources[iconRes] as ImageSource;
}
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
- AddonItem addonItem = new AddonItem(file, Path.GetFileName(file), iconImage, () => ScanFolder(), IsRunAsTrustedInstaller);
- Addons.Add(addonItem);
+ iconImage ??= Application.Current.Resources["Img_BatFile"] as ImageSource;
+
+ RelayCommand runCommand = new RelayCommand(_ => RunFile(new AddonModel(file, Path.GetFileName(file), iconImage, null, IsRunAsTrustedInstaller)));
+ AddonModel addonItem = new AddonModel(file, Path.GetFileName(file), iconImage, runCommand, IsRunAsTrustedInstaller);
+
+ lock (_locker)
+ {
+ Addons.Add(addonItem);
+ }
+
+ collectionChanged = true;
+ }
+
+ if (collectionChanged)
+ {
+ lock (_locker)
+ {
+ var sortedAddons = Addons.OrderBy(a => a.FileName).ToList();
+ Addons.Clear();
+ foreach (var addon in sortedAddons)
+ {
+ Addons.Add(addon);
+ }
+ }
}
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
}
}
-}
+}
\ No newline at end of file
diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
index 4ded72fa..bebaa188 100644
--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
@@ -68,13 +68,34 @@ namespace GTweak.Utilities.Helpers
};
using Process process = new Process { StartInfo = startInfo };
- try
+ try { process.Start(); }
+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }
+ }).ConfigureAwait(false);
+ }
+
+ internal static async void RunCommandShow(string fileName, string arguments = "", bool isElevationRequired = false)
+ {
+ await Task.Run(() =>
+ {
+ if (isElevationRequired)
{
- process.Start();
+ TrustedInstaller.CreateProcessAsTrustedInstaller(PID, $"{fileName} {arguments}", true);
}
- catch (Exception ex)
+ else
{
- ErrorLogging.LogDebug(ex);
+ ProcessStartInfo startInfo = new ProcessStartInfo()
+ {
+ FileName = fileName,
+ Arguments = arguments,
+ WindowStyle = ProcessWindowStyle.Normal,
+ UseShellExecute = true,
+ Verb = "runas",
+ CreateNoWindow = false
+ };
+
+ using Process process = new Process() { StartInfo = startInfo };
+ try { process.Start(); }
+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }
}
}).ConfigureAwait(false);
}
diff --git a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs
index a0dfda22..57937bc7 100644
--- a/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs
+++ b/.Source/GTweak/Utilities/Helpers/TrustedInstaller.cs
@@ -225,7 +225,7 @@ namespace GTweak.Utilities.Helpers
throw new Win32Exception("QueryServiceStatusEx failed: " + Marshal.GetLastWin32Error());
}
- internal static void CreateProcessAsTrustedInstaller(int parentProcessId, string binaryPath)
+ internal static void CreateProcessAsTrustedInstaller(int parentProcessId, string binaryPath, bool showWindow = false)
{
ImpersonateSystem();
_ = new PROCESS_INFORMATION();
@@ -247,9 +247,18 @@ namespace GTweak.Utilities.Helpers
var ts = new SECURITY_ATTRIBUTES();
ps.nLength = Marshal.SizeOf(ps);
ts.nLength = Marshal.SizeOf(ts);
- _ = CreateProcess(null, binaryPath, ref ps, ref ts, true, EXTENDED_STARTUPINFO_PRESENT | CREATE_NO_WINDOW, IntPtr.Zero, null, ref siEx, out PROCESS_INFORMATION pInfo);
- _ = pInfo.dwProcessId.ToString();
+ STARTUPINFO startInfo = new STARTUPINFO
+ {
+ cb = Marshal.SizeOf(typeof(STARTUPINFO)),
+ dwFlags = 0x00000001,
+ wShowWindow = showWindow ? (short)5 : (short)0
+ };
+
+ siEx.StartupInfo = startInfo;
+
+ _ = CreateProcess(null, binaryPath, ref ps, ref ts, true, EXTENDED_STARTUPINFO_PRESENT, IntPtr.Zero, null, ref siEx, out PROCESS_INFORMATION pInfo);
+ _ = pInfo.dwProcessId.ToString();
}
}
}
diff --git a/.Source/GTweak/View/AddonsView.xaml b/.Source/GTweak/View/AddonsView.xaml
index 4e3b0928..ef254dc9 100644
--- a/.Source/GTweak/View/AddonsView.xaml
+++ b/.Source/GTweak/View/AddonsView.xaml
@@ -43,7 +43,7 @@
<Grid Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<Grid>
- <ItemsControl ItemsSource="{Binding Addons}">
+ <ItemsControl ItemsSource="{Binding Addons}" VirtualizingPanel.IsVirtualizing="True">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<uc:FlowPanel Margin="20,10,0,20" EqualizeItemSize="True" ItemWidth="200" UseMasonryLayout="True" HorizontalSpacing="5" VerticalSpacing="5" ContentAlignment="Stretch" HorizontalAlignment="Left" VerticalAlignment="Top"/>
@@ -57,7 +57,7 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
- <Grid>
+ <Grid x:Name="EmptyStateGrid">
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Collapsed"/>
@@ -74,16 +74,65 @@
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
- <ui:SymbolIcon Symbol="DocumentFlowchart20" Foreground="{StaticResource Brush_TextBlock_Inactivity}" FontSize="55" Margin="0,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0"/>
- <TextBlock Width="Auto" Height="Auto" TextWrapping="Wrap" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="{StaticResource Jura}" FontSize="17pt" Foreground="{StaticResource Brush_TextBlock_Inactivity}" Grid.Row="1" Margin="0,5,0,0">
- <Run Text="{DynamicResource text_info_adds}"/><LineBreak/>
- <Run FontSize="15pt" Text="{DynamicResource scripts_info_adds}"/>
+
+ <ui:SymbolIcon Opacity="0" Symbol="DocumentFlowchart20" Foreground="{StaticResource Brush_TextBlock_Inactivity}" FontSize="55" Margin="0,0,5,0" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0">
+ <ui:SymbolIcon.RenderTransform>
+ <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
+ </ui:SymbolIcon.RenderTransform>
+ <ui:SymbolIcon.Triggers>
+ <EventTrigger RoutedEvent="FrameworkElement.Loaded">
+ <BeginStoryboard>
+ <Storyboard Timeline.DesiredFrameRate="120">
+ <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.6" BeginTime="0:0:0.1">
+ <DoubleAnimation.EasingFunction>
+ <QuadraticEase/>
+ </DoubleAnimation.EasingFunction>
+ </DoubleAnimation>
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" From="0.5" To="1" Duration="0:0:0.5" DecelerationRatio="0.5" BeginTime="0:0:0.1">
+ <DoubleAnimation.EasingFunction>
+ <CubicEase/>
+ </DoubleAnimation.EasingFunction>
+ </DoubleAnimation>
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleY" From="0.5" To="1" Duration="0:0:0.5" DecelerationRatio="0.5" BeginTime="0:0:0.1">
+ <DoubleAnimation.EasingFunction>
+ <CubicEase/>
+ </DoubleAnimation.EasingFunction>
+ </DoubleAnimation>
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger>
+ </ui:SymbolIcon.Triggers>
+ </ui:SymbolIcon>
+
+ <TextBlock x:Name="EmptyStateText" Width="Auto" Height="Auto" TextWrapping="Wrap" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="{StaticResource Jura}" FontSize="17pt" Foreground="{StaticResource Brush_TextBlock_Inactivity}" Grid.Row="1" Margin="0,15,0,0" Opacity="0" RenderTransformOrigin="0.5,0.5">
+ <TextBlock.RenderTransform>
+ <TranslateTransform Y="20"/>
+ </TextBlock.RenderTransform>
+ <Run Text="{DynamicResource text_info_adds}"/><LineBreak/>
+ <Run FontSize="15pt" Text="{DynamicResource scripts_info_adds}"/>
+ <TextBlock.Triggers>
+ <EventTrigger RoutedEvent="FrameworkElement.Loaded">
+ <BeginStoryboard>
+ <Storyboard Timeline.DesiredFrameRate="120">
+ <DoubleAnimation Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.6" BeginTime="0:0:0.3">
+ <DoubleAnimation.EasingFunction>
+ <QuadraticEase/>
+ </DoubleAnimation.EasingFunction>
+ </DoubleAnimation>
+ <DoubleAnimation Storyboard.TargetProperty="RenderTransform.Y" From="20" To="0" Duration="0:0:0.5" DecelerationRatio="0.7" BeginTime="0:0:0.3">
+ <DoubleAnimation.EasingFunction>
+ <CubicEase/>
+ </DoubleAnimation.EasingFunction>
+ </DoubleAnimation>
+ </Storyboard>
+ </BeginStoryboard>
+ </EventTrigger>
+ </TextBlock.Triggers>
</TextBlock>
</Grid>
</Grid>
</Grid>
</ScrollViewer>
</Grid>
-
</Grid>
</UserControl>
diff --git a/.Source/GTweak/View/AddonsView.xaml.cs b/.Source/GTweak/View/AddonsView.xaml.cs
index b30ac845..30d32c5b 100644
--- a/.Source/GTweak/View/AddonsView.xaml.cs
+++ b/.Source/GTweak/View/AddonsView.xaml.cs
@@ -1,12 +1,30 @@
+using System;
using System.Windows.Controls;
+using GTweak.Core.ViewModel;
+using GTweak.Utilities.Managers;
namespace GTweak.View
{
public partial class AddonsView : UserControl
{
+ private TimerControlManager _timer = default;
public AddonsView()
{
InitializeComponent();
+
+ Unloaded += delegate { _timer.Stop(); };
+ Loaded += delegate
+ {
+ _timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, async time =>
+ {
+ if ((int)time.TotalSeconds % 5 == 0 && DataContext is AddonsViewModel viewModel)
+ {
+ viewModel.UpdateCommand.Execute(null);
+ }
+ });
+
+ _timer.Start();
+ };
}
}
-}
+}
\ No newline at end of file
diff --git a/.Source/GTweak/View/DataSystemView.xaml.cs b/.Source/GTweak/View/DataSystemView.xaml.cs
index d9a1df3c..ceddab47 100644
--- a/.Source/GTweak/View/DataSystemView.xaml.cs
+++ b/.Source/GTweak/View/DataSystemView.xaml.cs
@@ -90,8 +90,8 @@ namespace GTweak.View
{
Dispatcher.BeginInvoke(new Action(() =>
{
- CPULoad.BeginAnimation(RangeBase.ValueProperty, FactoryAnimation.CreateIn(CPULoad.Value, cpuValue, 0.2, null, false, true));
- RAMLoad.BeginAnimation(RangeBase.ValueProperty, FactoryAnimation.CreateIn(RAMLoad.Value, ramValue, 0.2, null, false, true));
+ CPULoad.BeginAnimation(RangeBase.ValueProperty, FactoryAnimation.CreateIn(CPULoad.Value, cpuValue, 0.2, useCubicEase: true));
+ RAMLoad.BeginAnimation(RangeBase.ValueProperty, FactoryAnimation.CreateIn(RAMLoad.Value, ramValue, 0.2, useCubicEase: true));
}));
}
@@ -99,7 +99,7 @@ namespace GTweak.View
{
PopupCopy.IsOpen = true;
CopyTextToastBody.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0, 0.9, 0.27, () => { PopupCopy.IsOpen = false; }, true));
- PopupCopy.BeginAnimation(Popup.VerticalOffsetProperty, FactoryAnimation.CreateIn(-20, -50, 0.35, null, false, true));
+ PopupCopy.BeginAnimation(Popup.VerticalOffsetProperty, FactoryAnimation.CreateIn(-20, -50, 0.35, useCubicEase: true));
}
private void BtnVision_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
diff --git a/.Source/GTweak/View/PakagesView.xaml.cs b/.Source/GTweak/View/PakagesView.xaml.cs
index 89a35559..9cb97dcf 100644
--- a/.Source/GTweak/View/PakagesView.xaml.cs
+++ b/.Source/GTweak/View/PakagesView.xaml.cs
@@ -27,12 +27,15 @@ namespace GTweak.View
Unloaded += delegate { _timer.Stop(); };
Loaded += delegate
{
- _timer = new TimerControlManager(TimeSpan.FromSeconds(5), TimerControlManager.TimerMode.CountUp, async time =>
+ _timer = new TimerControlManager(TimeSpan.Zero, TimerControlManager.TimerMode.CountUp, async time =>
{
- BackgroundWorker backgroundWorker = new BackgroundWorker();
- backgroundWorker.DoWork += delegate { _uninstalling.GetInstalledPackages(); };
- backgroundWorker.RunWorkerCompleted += delegate { Dispatcher.Invoke(() => { UninstallingPakages.OnPackagesChanged(); }); };
- backgroundWorker.RunWorkerAsync();
+ if ((int)time.TotalSeconds % 3 == 0)
+ {
+ BackgroundWorker backgroundWorker = new BackgroundWorker();
+ backgroundWorker.DoWork += delegate { _uninstalling.GetInstalledPackages(); };
+ backgroundWorker.RunWorkerCompleted += delegate { Dispatcher.Invoke(() => { UninstallingPakages.OnPackagesChanged(); }); };
+ backgroundWorker.RunWorkerAsync();
+ }
});
_timer.Start();
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index f9c2c124..80aff0fe 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -31,7 +31,7 @@ namespace GTweak.Windows
TranslateTransform transform = (TranslateTransform)SettingsPanel.RenderTransform;
double toX = _settingsOpen ? 400 : 0;
_settingsOpen = !_settingsOpen;
- transform.BeginAnimation(TranslateTransform.XProperty, FactoryAnimation.CreateIn(transform.X, toX, 0.5, null, false, true));
+ transform.BeginAnimation(TranslateTransform.XProperty, FactoryAnimation.CreateIn(transform.X, toX, 0.5, useCubicEase: true));
}
#region TitleBar
@@ -253,7 +253,7 @@ namespace GTweak.Windows
UpdateBanner.Visibility = Visibility.Visible;
UpdateBanner.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0, 1, 0.3));
- (UpdateBanner.RenderTransform as TranslateTransform).BeginAnimation(TranslateTransform.YProperty, FactoryAnimation.CreateIn(-20, 0, 0.3, null, false, true));
+ (UpdateBanner.RenderTransform as TranslateTransform).BeginAnimation(TranslateTransform.YProperty, FactoryAnimation.CreateIn(-20, 0, 0.3, useCubicEase: true));
}
}
}
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index 09ee0659..df16ea32 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -58,7 +58,7 @@ namespace GTweak.Windows
notificationSound.Play();
}
- BeginAnimation(LeftProperty, FactoryAnimation.CreateIn(primaryMonitorArea.Right + 10, primaryMonitorArea.Right - Width - 10, 0.3, null, false, true));
+ BeginAnimation(LeftProperty, FactoryAnimation.CreateIn(primaryMonitorArea.Right + 10, primaryMonitorArea.Right - Width - 10, 0.3, useCubicEase: true));
}
}
}