Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mouse hover animation can be disabled #18

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SnapIt.Common/Entities/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public Settings()
public bool IsVersion3000MessageShown { get; set; }
public bool CheckForNewVersion { get; set; } = true;
public bool RunAsAdmin { get; set; } = true;

public bool MouseHoverAnimation { get; set; } = false;
//public Color HighlightColor { get; set; } = System.Windows.Media.Color.FromArgb(255, 33, 33, 33).Convert();
//public Color OverlayColor { get; set; } = System.Windows.Media.Color.FromArgb(255, 99, 99, 99).Convert();
//public Color BorderColor { get; set; } = System.Windows.Media.Color.FromArgb(255, 200, 200, 200).Convert();
Expand Down
12 changes: 10 additions & 2 deletions SnapIt.Controls/SnapArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public SnapArea()
Name = $"snaparea_{Guid.NewGuid():N}";
}

public void NormalStyle()
public void NormalStyle(bool animate = true)
{
ColorAnimation animation = new ColorAnimation
{
Expand All @@ -117,7 +117,15 @@ public void NormalStyle()
// return;

area.Background = brush;
brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);

if (animate)
{
brush.BeginAnimation(SolidColorBrush.ColorProperty, animation);
}
else
{
area.Background = Theme.OverlayBrush;
}
}
}

Expand Down
11 changes: 9 additions & 2 deletions SnapIt.Controls/SnapFullOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void NormalStyle()
Visibility = Visibility.Hidden;
}

public void OnHoverStyle()
public void OnHoverStyle(bool animate = true)
{
DoubleAnimation animation = new DoubleAnimation
{
Expand All @@ -65,7 +65,14 @@ public void OnHoverStyle()
{
Visibility = Visibility.Visible;

overlay.BeginAnimation(OpacityProperty, animation);
if (animate)
{
overlay.BeginAnimation(OpacityProperty, animation);
}
else
{
overlay.Opacity = Theme.Opacity;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions SnapIt.Controls/SnapOverlay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ public void NormalStyle()
SnapFullOverlay.NormalStyle();
}

public void OnHoverStyle()
public void OnHoverStyle(bool animate = true)
{
Overlay.Background = Brushes.Transparent;
Border.Visibility = Visibility.Hidden;
MergedIcon.Visibility = Visibility.Hidden;

SnapFullOverlay.OnHoverStyle();
SnapFullOverlay.OnHoverStyle(animate);
}

private void SnapOverlay_SizeChanged(object sender, SizeChangedEventArgs e)
Expand Down
15 changes: 8 additions & 7 deletions SnapIt.Controls/SnapWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SnapWindow : Window, IWindow
private readonly IWinApiService winApiService;
private SnapArea currentArea;
private SnapOverlay currentOverlay;
private bool animate = false;

public SnapScreen Screen { get; set; }
public List<Rectangle> SnapAreaBoundries { get; set; }
Expand Down Expand Up @@ -53,13 +54,13 @@ public SnapWindow(
X = (float)(100 / (screen.ScaleFactor * 100)),
Y = (float)(100 / (screen.ScaleFactor * 100))
};

animate = settingService.Settings.MouseHoverAnimation;
}

//TODO test here
public new void Show()
{
base.Show();
//MaximizeWindow();
}

protected override void OnSourceInitialized(EventArgs e)
Expand Down Expand Up @@ -149,17 +150,17 @@ public Rectangle SelectElementWithPoint(int x, int y)

if (dependencyObject is SnapArea && currentArea?.Name != ((SnapArea)dependencyObject).Name)
{
currentArea?.NormalStyle();
currentArea?.NormalStyle(animate);
currentOverlay?.NormalStyle();
}
else if (dependencyObject is not SnapArea)
{
currentArea?.NormalStyle();
currentArea?.NormalStyle(animate);
}

if (dependencyObject is SnapOverlay && currentOverlay?.Name != ((SnapOverlay)dependencyObject).Name)
{
currentArea?.NormalStyle();
currentArea?.NormalStyle(animate);
currentOverlay?.NormalStyle();
}
else if (dependencyObject is not SnapOverlay)
Expand All @@ -175,7 +176,7 @@ public Rectangle SelectElementWithPoint(int x, int y)

if (!(currentArea != null && currentArea.Name == ((SnapArea)dependencyObject).Name))
{
snapArea.OnHoverStyle();
snapArea.OnHoverStyle(animate);
}

currentArea = snapArea;
Expand All @@ -190,7 +191,7 @@ public Rectangle SelectElementWithPoint(int x, int y)

if (!(currentOverlay != null && currentOverlay?.Name == ((SnapOverlay)dependencyObject).Name))
{
snapOverlay.OnHoverStyle();
snapOverlay.OnHoverStyle(animate);
}

currentArea = null;
Expand Down
Binary file modified SnapIt.Packaging/Images/LargeTile.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/LargeTile.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/LargeTile.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/LargeTile.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/LargeTile.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SmallTile.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SmallTile.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SmallTile.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SmallTile.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SmallTile.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SplashScreen.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SplashScreen.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SplashScreen.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SplashScreen.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/SplashScreen.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/Square150x150Logo.scale-100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/Square150x150Logo.scale-125.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/Square150x150Logo.scale-150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/Square150x150Logo.scale-400.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.scale-100.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.scale-125.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.scale-150.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.scale-200.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.scale-400.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.targetsize-16.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.targetsize-24.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.targetsize-256.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.targetsize-32.png
Binary file modified SnapIt.Packaging/Images/Square44x44Logo.targetsize-48.png
Binary file modified SnapIt.Packaging/Images/StoreLogo.scale-100.png
Binary file modified SnapIt.Packaging/Images/StoreLogo.scale-125.png
Binary file modified SnapIt.Packaging/Images/StoreLogo.scale-150.png
Binary file modified SnapIt.Packaging/Images/StoreLogo.scale-200.png
Binary file modified SnapIt.Packaging/Images/StoreLogo.scale-400.png
Binary file modified SnapIt.Packaging/Images/Wide310x150Logo.scale-100.png
Binary file modified SnapIt.Packaging/Images/Wide310x150Logo.scale-125.png
Binary file modified SnapIt.Packaging/Images/Wide310x150Logo.scale-150.png
Binary file modified SnapIt.Packaging/Images/Wide310x150Logo.scale-200.png
Binary file modified SnapIt.Packaging/Images/Wide310x150Logo.scale-400.png
1 change: 1 addition & 0 deletions SnapIt.Services/MouseService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Windows.Forms;
using SharpHook;
using SnapIt.Common;
using SnapIt.Common.Entities;
using SnapIt.Common.Events;
using SnapIt.Common.Extensions;
Expand Down
16 changes: 16 additions & 0 deletions SnapIt/ViewModels/Pages/SettingsPageViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Windows;
using SnapIt.Application;
using SnapIt.Application.Contracts;
using SnapIt.Common;
using SnapIt.Common.Entities;
using SnapIt.Common.Mvvm;
using SnapIt.Services.Contracts;
Expand All @@ -10,6 +12,7 @@ namespace SnapIt.ViewModels.Pages;

public class SettingsPageViewModel : ViewModelBase
{
private readonly ISnapManager snapManager;
private readonly ISettingService settingService;
private readonly IThemeService themeService;
private bool isStartupTaskActive;
Expand Down Expand Up @@ -37,6 +40,9 @@ public UITheme SelectedTheme
public bool IsRunAsAdmin
{ get => settingService.Settings.RunAsAdmin; set { settingService.Settings.RunAsAdmin = value; } }

public bool MouseHoverAnimation
{ get => settingService.Settings.MouseHoverAnimation; set { settingService.Settings.MouseHoverAnimation = value; ApplyChanges(); } }

public bool IsStartupTaskActive
{
get => isStartupTaskActive;
Expand All @@ -60,6 +66,7 @@ public SettingsPageViewModel(
ISettingService settingService,
IThemeService themeService)
{
this.snapManager = snapManager;
this.settingService = settingService;
this.themeService = themeService;
ThemeList = [
Expand All @@ -80,6 +87,15 @@ public override async Task InitializeAsync(RoutedEventArgs args)
IsStartupTaskActive = await settingService.GetStartupTaskStatusAsync();
}

private void ApplyChanges()
{
if (!Dev.IsActive)
{
snapManager.Dispose();
snapManager.InitializeAsync();
}
}

private void ChangeTheme()
{
switch (settingService.Settings.AppTheme)
Expand Down
14 changes: 14 additions & 0 deletions SnapIt/Views/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@
<ui:ToggleSwitch IsChecked="{Binding IsRunAsAdmin}" />
</ui:CardControl>

<ui:CardControl Margin="0,0,0,8">
<ui:CardControl.Header>
<StackPanel Grid.Column="0" VerticalAlignment="Center">
<TextBlock FontSize="14" Text="Disable mouse hover animations" />
<TextBlock
FontSize="12"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="It is recommend to disable it if hovering not responsive enough."
TextWrapping="Wrap" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding MouseHoverAnimation}" />
</ui:CardControl>

<ui:CardControl
Margin="0,0,0,8"
Header="Check for new version"
Expand Down
Loading