-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Crash on searching again if pickedById fixed. Click issue fixed for poster screens.
- Loading branch information
1 parent
8991a0e
commit a04fd21
Showing
6 changed files
with
108 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using System.Windows.Threading; | ||
using Microsoft.Xaml.Behaviors; | ||
using Prism.Commands; | ||
|
||
namespace FoliCon.Modules | ||
{ | ||
public class ClickBehavior : Behavior<Image> | ||
{ | ||
private readonly DispatcherTimer _timer = new(); | ||
|
||
public ClickBehavior() | ||
{ | ||
_timer.Interval = TimeSpan.FromSeconds(0.2); | ||
_timer.Tick += Timer_Tick; | ||
} | ||
|
||
public static readonly DependencyProperty ClickCommandProperty = | ||
DependencyProperty.Register(nameof(ClickCommand), typeof(ICommand), typeof(ClickBehavior)); | ||
public static readonly DependencyProperty CommandParameterProperty = | ||
DependencyProperty.Register(nameof(CommandParameter), typeof(object), typeof(ClickBehavior)); | ||
public Object CommandParameter | ||
{ | ||
get => GetValue(CommandParameterProperty); | ||
set => SetValue(CommandParameterProperty, value); | ||
} | ||
public ICommand ClickCommand | ||
{ | ||
get => (ICommand)GetValue(ClickCommandProperty); | ||
set => SetValue(ClickCommandProperty, value); | ||
} | ||
|
||
public static readonly DependencyProperty DoubleClickCommandProperty = | ||
DependencyProperty.Register(nameof(DoubleClickCommand), typeof(ICommand), typeof(ClickBehavior)); | ||
|
||
public ICommand DoubleClickCommand | ||
{ | ||
get => (ICommand)GetValue(DoubleClickCommandProperty); | ||
set => SetValue(DoubleClickCommandProperty, value); | ||
} | ||
|
||
protected override void OnAttached() | ||
{ | ||
base.OnAttached(); | ||
AssociatedObject.Loaded += AssociatedObject_Loaded; | ||
AssociatedObject.Unloaded += AssociatedObject_Unloaded; | ||
} | ||
|
||
private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
AssociatedObject.Loaded -= AssociatedObject_Loaded; | ||
AssociatedObject.PreviewMouseLeftButtonDown += AssociatedObject_PreviewMouseLeftButtonDown; | ||
} | ||
|
||
private void AssociatedObject_Unloaded(object sender, RoutedEventArgs e) | ||
{ | ||
AssociatedObject.Unloaded -= AssociatedObject_Unloaded; | ||
AssociatedObject.PreviewMouseLeftButtonDown -= AssociatedObject_PreviewMouseLeftButtonDown; | ||
} | ||
|
||
private void Timer_Tick(object sender, EventArgs e) | ||
{ | ||
_timer.Stop(); | ||
ClickCommand?.Execute(CommandParameter); | ||
} | ||
|
||
private void AssociatedObject_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) | ||
{ | ||
if (e.ClickCount == 2) | ||
{ | ||
_timer.Stop(); | ||
DoubleClickCommand?.Execute(CommandParameter); | ||
} | ||
else | ||
{ | ||
_timer.Start(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters