Skip to content

Portable Tool for an Ideal Windows Setup

-edit anim

Greedeksedc261a4044c
diff --git a/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs b/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs
index 1e906209..3fb7a9f3 100644
--- a/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs
+++ b/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs
@@ -1,5 +1,6 @@
using GTweak.Utilities.Helpers;
using System;
+using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -70,65 +71,67 @@ namespace GTweak.Assets.UserControl
private void AnimationToggle(bool isState, bool isSkipAnimation = false)
{
- ThicknessAnimationUsingKeyFrames thicknessAnimKeyFrames = new ThicknessAnimationUsingKeyFrames();
+ Dispatcher.Invoke(() => {
+ ThicknessAnimationUsingKeyFrames thicknessAnimKeyFrames = new ThicknessAnimationUsingKeyFrames();
- if (isState && Dot.Margin != _rightSide)
- {
- EasingThicknessKeyFrame fromFrame = new EasingThicknessKeyFrame(_leftSide)
- {
- KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))
- };
-
- EasingThicknessKeyFrame toFrame = new EasingThicknessKeyFrame(_rightSide)
+ if (isState && Dot.Margin != _rightSide)
{
- KeyTime = isSkipAnimation ? KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)) : KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100))
- };
-
- thicknessAnimKeyFrames.KeyFrames.Add(fromFrame);
- thicknessAnimKeyFrames.KeyFrames.Add(toFrame);
- Timeline.SetDesiredFrameRate(thicknessAnimKeyFrames, 400);
- Dot.BeginAnimation(MarginProperty, thicknessAnimKeyFrames);
-
- BrushAnimation brushanimation = new BrushAnimation()
+ EasingThicknessKeyFrame fromFrame = new EasingThicknessKeyFrame(_leftSide)
+ {
+ KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))
+ };
+
+ EasingThicknessKeyFrame toFrame = new EasingThicknessKeyFrame(_rightSide)
+ {
+ KeyTime = isSkipAnimation ? KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)) : KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(150))
+ };
+
+ thicknessAnimKeyFrames.KeyFrames.Add(fromFrame);
+ thicknessAnimKeyFrames.KeyFrames.Add(toFrame);
+ Timeline.SetDesiredFrameRate(thicknessAnimKeyFrames, 400);
+ Dot.BeginAnimation(MarginProperty, thicknessAnimKeyFrames);
+
+ BrushAnimation brushanimation = new BrushAnimation()
+ {
+ From = brushOffColor,
+ To = brushOnColor,
+ SpeedRatio = 1,
+ Duration = isSkipAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromMilliseconds(150)
+ };
+ Timeline.SetDesiredFrameRate(brushanimation, 400);
+ Back.BeginAnimation(Shape.FillProperty, brushanimation);
+ ToggleText.Style = (Style)FindResource("Text");
+ }
+
+ else if (!isState && Dot.Margin != _leftSide)
{
- From = brushOffColor,
- To = brushOnColor,
- SpeedRatio = 1,
- Duration = isSkipAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromMilliseconds(100)
- };
- Timeline.SetDesiredFrameRate(brushanimation, 400);
- Back.BeginAnimation(Shape.FillProperty, brushanimation);
- ToggleText.Style = (Style)FindResource("Text");
- }
-
- else if (!isState && Dot.Margin != _leftSide)
- {
- EasingThicknessKeyFrame fromFrame = new EasingThicknessKeyFrame(_rightSide)
- {
- KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))
- };
-
- EasingThicknessKeyFrame toFrame = new EasingThicknessKeyFrame(_leftSide)
- {
- KeyTime = isSkipAnimation ? KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)) : KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100))
- };
-
- thicknessAnimKeyFrames.KeyFrames.Add(fromFrame);
- thicknessAnimKeyFrames.KeyFrames.Add(toFrame);
- Timeline.SetDesiredFrameRate(thicknessAnimKeyFrames, 400);
- Dot.BeginAnimation(MarginProperty, thicknessAnimKeyFrames);
-
- BrushAnimation brushanimation = new BrushAnimation()
- {
- From = brushOnColor,
- To = brushOffColor,
- SpeedRatio = 1,
- Duration = isSkipAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromMilliseconds(100)
- };
- Timeline.SetDesiredFrameRate(brushanimation, 400);
- Back.BeginAnimation(Shape.FillProperty, brushanimation);
- ToggleText.Style = (Style)FindResource("Text_In");
- }
+ EasingThicknessKeyFrame fromFrame = new EasingThicknessKeyFrame(_rightSide)
+ {
+ KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0))
+ };
+
+ EasingThicknessKeyFrame toFrame = new EasingThicknessKeyFrame(_leftSide)
+ {
+ KeyTime = isSkipAnimation ? KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)) : KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(150))
+ };
+
+ thicknessAnimKeyFrames.KeyFrames.Add(fromFrame);
+ thicknessAnimKeyFrames.KeyFrames.Add(toFrame);
+ Timeline.SetDesiredFrameRate(thicknessAnimKeyFrames, 400);
+ Dot.BeginAnimation(MarginProperty, thicknessAnimKeyFrames);
+
+ BrushAnimation brushanimation = new BrushAnimation()
+ {
+ From = brushOnColor,
+ To = brushOffColor,
+ SpeedRatio = 1,
+ Duration = isSkipAnimation ? TimeSpan.FromSeconds(0) : TimeSpan.FromMilliseconds(150)
+ };
+ Timeline.SetDesiredFrameRate(brushanimation, 400);
+ Back.BeginAnimation(Shape.FillProperty, brushanimation);
+ ToggleText.Style = (Style)FindResource("Text_In");
+ }
+ });
}
}
}
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml.cs b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
index 0192b82b..cbac5d45 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml.cs
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml.cs
@@ -86,42 +86,45 @@ namespace GTweak.Windows
break;
}
- Rect primaryMonitorArea = SystemParameters.WorkArea;
+ Dispatcher.Invoke(() =>
+ {
+ Rect primaryMonitorArea = SystemParameters.WorkArea;
- Top = primaryMonitorArea.Bottom - Height - 10;
- Left = primaryMonitorArea.Right - Width - 10;
+ Top = primaryMonitorArea.Bottom - Height - 10;
+ Left = primaryMonitorArea.Right - Width - 10;
- DoubleAnimationUsingKeyFrames doubleAnimKeyFrames = new DoubleAnimationUsingKeyFrames();
+ DoubleAnimationUsingKeyFrames doubleAnimKeyFrames = new DoubleAnimationUsingKeyFrames();
- EasingDoubleKeyFrame fromFrame = new EasingDoubleKeyFrame(primaryMonitorArea.Right)
- {
- KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)),
- EasingFunction = new QuadraticEase()
- };
+ EasingDoubleKeyFrame fromFrame = new EasingDoubleKeyFrame(primaryMonitorArea.Right)
+ {
+ KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0)),
+ EasingFunction = new QuadraticEase()
+ };
- EasingDoubleKeyFrame toFrame = new EasingDoubleKeyFrame(primaryMonitorArea.Right - Width - 10)
- {
- KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)),
- EasingFunction = new QuadraticEase()
- };
+ EasingDoubleKeyFrame toFrame = new EasingDoubleKeyFrame(primaryMonitorArea.Right - Width - 10)
+ {
+ KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)),
+ EasingFunction = new QuadraticEase()
+ };
- doubleAnimKeyFrames.KeyFrames.Add(fromFrame);
- doubleAnimKeyFrames.KeyFrames.Add(toFrame);
+ doubleAnimKeyFrames.KeyFrames.Add(fromFrame);
+ doubleAnimKeyFrames.KeyFrames.Add(toFrame);
- DoubleAnimation doubleAnim = new DoubleAnimation()
- {
- From = 0,
- To = 1,
- SpeedRatio = 3,
- EasingFunction = new QuadraticEase(),
- Duration = TimeSpan.FromSeconds(0.8)
- };
-
- Timeline.SetDesiredFrameRate(doubleAnim, 400);
- Timeline.SetDesiredFrameRate(doubleAnimKeyFrames, 400);
-
- BeginAnimation(Canvas.LeftProperty, doubleAnimKeyFrames);
- BeginAnimation(OpacityProperty, doubleAnim);
+ DoubleAnimation doubleAnim = new DoubleAnimation()
+ {
+ From = 0,
+ To = 1,
+ SpeedRatio = 3,
+ EasingFunction = new QuadraticEase(),
+ Duration = TimeSpan.FromSeconds(0.8)
+ };
+
+ Timeline.SetDesiredFrameRate(doubleAnim, 400);
+ Timeline.SetDesiredFrameRate(doubleAnimKeyFrames, 400);
+
+ BeginAnimation(Canvas.LeftProperty, doubleAnimKeyFrames);
+ BeginAnimation(OpacityProperty, doubleAnim);
+ });
}
private void Window_Closing(object sender, CancelEventArgs e)