-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
257 additions
and
160 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
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,34 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Markup; | ||
using System.Windows.Media.Animation; | ||
|
||
namespace MusicX.Controls; | ||
|
||
public class LoadingBorder : Border | ||
{ | ||
public static readonly DependencyProperty IsLoadingProperty = DependencyProperty.Register( | ||
nameof(IsLoading), typeof(bool), typeof(LoadingBorder), new PropertyMetadata(true)); | ||
|
||
public bool IsLoading | ||
{ | ||
get => (bool)GetValue(IsLoadingProperty); | ||
set => SetValue(IsLoadingProperty, value); | ||
} | ||
|
||
protected override void OnInitialized(EventArgs e) | ||
{ | ||
base.OnInitialized(e); | ||
if (IsLoading && TryFindResource("LoadingBorderLoaderAnimation") is Storyboard storyboard) | ||
{ | ||
if (((INameScope)Style).FindName("LoadingBorderLoaderAnimation") is null) | ||
Style.RegisterName("LoadingBorderLoaderAnimation", new BeginStoryboard | ||
{ | ||
Storyboard = storyboard, | ||
Name = "LoadingBorderLoaderAnimation" | ||
}); | ||
BeginStoryboard(storyboard); | ||
} | ||
} | ||
} |
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,22 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
namespace MusicX.Converters; | ||
|
||
public class BooleanToHiddenVisibilityConverter : IValueConverter | ||
{ | ||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
if (value is bool flag) | ||
return flag ? Visibility.Visible : Visibility.Hidden; | ||
|
||
return Visibility.Visible; | ||
} | ||
|
||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) | ||
{ | ||
return value is Visibility.Visible; | ||
} | ||
} |
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,42 @@ | ||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:MusicX.Controls"> | ||
<Style x:Key="DefaultLoadingBorderStyle" TargetType="controls:LoadingBorder"> | ||
<Style.Resources> | ||
<Storyboard x:Key="LoadingBorderLoaderAnimation"> | ||
<ColorAnimation Storyboard.TargetProperty="Background.(SolidColorBrush.Color)" | ||
AutoReverse="True" | ||
RepeatBehavior="Forever" | ||
Duration="0:0:1" | ||
From="#383838" To="#7f7f7f7f"> | ||
<ColorAnimation.EasingFunction> | ||
<ExponentialEase EasingMode="EaseIn" /> | ||
</ColorAnimation.EasingFunction> | ||
</ColorAnimation> | ||
</Storyboard> | ||
</Style.Resources> | ||
|
||
<Setter Property="HorizontalAlignment" Value="Left" /> | ||
<Setter Property="BorderThickness" Value="{StaticResource CardBorderThemeThickness}" /> | ||
|
||
<Style.Triggers> | ||
<Trigger Property="IsLoading" Value="True"> | ||
<Trigger.EnterActions> | ||
<BeginStoryboard Name="LoadingBorderLoaderAnimation" Storyboard="{StaticResource LoadingBorderLoaderAnimation}" /> | ||
</Trigger.EnterActions> | ||
<Trigger.ExitActions> | ||
<RemoveStoryboard BeginStoryboardName="LoadingBorderLoaderAnimation" /> | ||
</Trigger.ExitActions> | ||
<Setter Property="Background"> | ||
<Setter.Value> | ||
<SolidColorBrush Color="#383838" /> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="BorderBrush" Value="{DynamicResource CardBorderBrush}" /> | ||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
<Style TargetType="controls:LoadingBorder" BasedOn="{StaticResource DefaultLoadingBorderStyle}" /> | ||
</ResourceDictionary> |
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
Oops, something went wrong.