refactor: rebrand project to WandEnhancer

This commit is contained in:
kitbyte
2026-03-30 21:39:06 +03:00
parent 9a5d3799bf
commit 5273930eef
65 changed files with 262 additions and 250 deletions
+20
View File
@@ -0,0 +1,20 @@
<UserControl x:Class="WandEnhancer.View.Controls.InfoItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WandEnhancer.View.Controls"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Viewbox Width="20" Height="20" VerticalAlignment="Top">
<Path Fill="{Binding IconColor}" Data="{Binding IconData}"/>
</Viewbox>
<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="5 0 5 0" TextWrapping="Wrap"
FontSize="12" Text="{Binding Text}"/>
</Grid>
</UserControl>
@@ -0,0 +1,42 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace WandEnhancer.View.Controls
{
public partial class InfoItem : UserControl
{
public static readonly DependencyProperty IconDataProperty =
DependencyProperty.Register(nameof(IconData), typeof(Geometry), typeof(InfoItem));
public static readonly DependencyProperty IconColorProperty =
DependencyProperty.Register(nameof(IconColor), typeof(Brush), typeof(InfoItem));
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register(nameof(Text), typeof(string), typeof(InfoItem));
public Geometry IconData
{
get => (Geometry)GetValue(IconDataProperty);
set => SetValue(IconDataProperty, value);
}
public Brush IconColor
{
get => (Brush)GetValue(IconColorProperty);
set => SetValue(IconColorProperty, value);
}
public string Text
{
get => (string)GetValue(TextProperty);
set => SetValue(TextProperty, value);
}
public InfoItem()
{
InitializeComponent();
this.DataContext = this;
}
}
}
+51
View File
@@ -0,0 +1,51 @@
<Grid x:Class="WandEnhancer.View.Controls.PopupHost"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WandEnhancer.View.Controls"
mc:Ignorable="d"
Visibility="Collapsed">
<Border x:Name="Splash" Background="Black" CornerRadius="7"
Opacity="0.45"
MouseLeftButtonDown="HidePopup"/>
<Border Background="{DynamicResource Background}" d:Margin="0"
Margin="0 40 0 40" x:Name="PopupPresenter" Width="Auto" Height="Auto"
BorderBrush="{DynamicResource Border}" BorderThickness="1" MinWidth="300"
VerticalAlignment="Center" HorizontalAlignment="Center" CornerRadius="4" Padding="15 10 10 15">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button BorderThickness="0" BorderBrush="Transparent"
Tag="{StaticResource CloseIcon}"
Width="25" Height="25" Padding="8" Background="Transparent"
HorizontalAlignment="Right" VerticalAlignment="Top" Click="HidePopup"
x:Name="cancel">
<Button.Style>
<Style BasedOn="{StaticResource IconButton}" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource MutedForeground}"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource Foreground}"/>
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<StackPanel Grid.Row="0" x:Name="TitleContainer" Orientation="Horizontal">
<TextBlock x:Name="Title" Text="This is title" Foreground="{DynamicResource Foreground}"
HorizontalAlignment="Left" FontWeight="Bold" FontSize="16"
VerticalAlignment="Bottom"/>
</StackPanel>
<ContentPresenter x:Name="Presenter" Margin="0 20 0 0"
Content="{Binding PopupContent}" Grid.Row="2"/>
</Grid>
</Border>
</Grid>
@@ -0,0 +1,104 @@
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace WandEnhancer.View.Controls
{
public partial class PopupHost : Grid
{
internal Action Closed;
public static readonly DependencyProperty PopupContentProperty =
DependencyProperty.Register("PopupContent", typeof(object), typeof(PopupHost), new PropertyMetadata(null));
internal readonly SemaphoreSlim OpenedSemaphore = new SemaphoreSlim(1, 1);
private DoubleAnimation OpeningAnimation;
private DoubleAnimation ClosingAnimation;
public bool IsOpen
{
get => this.Visibility == Visibility.Visible;
set
{
if (value)
{
if(OpenedSemaphore.CurrentCount == 0)
return;
Visibility = Visibility.Visible;
cancel.Focus();
PopupPresenter.BeginAnimation(OpacityProperty, OpeningAnimation);
OpenedSemaphore.Wait();
}
else
{
PopupPresenter.BeginAnimation(OpacityProperty, ClosingAnimation);
}
}
}
public object PopupContent
{
get => GetValue(PopupContentProperty);
set => SetValue(PopupContentProperty, value);
}
private void HidePopup(object sender, EventArgs e)
{
if (OpenedSemaphore.CurrentCount == 1)
return;
IsOpen = false;
}
private void OnClosing(object sender, EventArgs e)
{
if (PopupContent == null)
return;
Visibility = Visibility.Collapsed;
Closed?.Invoke();
if (PopupContent is IDisposable disposable)
{
disposable.Dispose();
}
PopupContent = null;
Closed = null;
OpenedSemaphore.Release();
}
public PopupHost()
{
InitializeComponent();
PreviewKeyDown += (sender, e) =>
{
if (e.Key != Key.Escape)
return;
HidePopup(null, null);
e.Handled = true;
};
OpeningAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.4)))
{
EasingFunction = App.Current.FindResource("BaseAnimationFunction") as IEasingFunction
};
OpeningAnimation.Freeze();
ClosingAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(0.2)));
ClosingAnimation.Completed += OnClosing;
ClosingAnimation.Freeze();
this.Splash.DataContext = this;
this.PopupPresenter.DataContext = this;
}
}
}