electron removed

This commit is contained in:
kitbyte
2025-03-21 23:35:16 +02:00
parent 8e33e58939
commit 4049ade4b1
54 changed files with 3635 additions and 828 deletions
+49
View File
@@ -0,0 +1,49 @@
<Grid x:Class="WeModPatcher.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:WeModPatcher.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>
<TextBlock x:Name="Title" Text="This is title" Foreground="{DynamicResource Foreground}"
HorizontalAlignment="Left" FontWeight="Bold" FontSize="16"
VerticalAlignment="Bottom"/>
<ContentPresenter x:Name="Presenter" Margin="0 20 0 0"
Content="{Binding PopupContent}" Grid.Row="2"/>
</Grid>
</Border>
</Grid>
@@ -0,0 +1,100 @@
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace WeModPatcher.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();
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;
}
}
}