herunterfahren button links unten

This commit is contained in:
iTob 2026-02-24 21:07:34 +01:00
parent 074f3ccb7f
commit 3a3c780c07
3 changed files with 169 additions and 7 deletions

View File

@ -32,6 +32,13 @@
<Folder Include="Features\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="artifacts\**\*.cs" />
<EmbeddedResource Remove="artifacts\**\*" />
<None Remove="artifacts\**\*" />
<Page Remove="artifacts\**\*.xaml" />
</ItemGroup>
<ItemGroup>
<None Update="Core\AppSettings\app.settings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@ -27,7 +27,7 @@
x:Name="MainFrame"
NavigationUIVisibility="Hidden"
HorizontalAlignment="Center"
Background="LightBlue"
Background="Black"
VerticalAlignment="Center"
Panel.ZIndex="0" />
@ -54,9 +54,8 @@
<liveView:TimerControlRectangleAnimation x:Name="TimerControlRectangleAnimation" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom" Name="ButtonPanel" Background="Transparent" Panel.ZIndex="2"
Visibility="Hidden"
Margin="0 0 0 0">
<ui:Button Content="Start" Click="NavToLiveView" Width="200" Height="75" VerticalAlignment="Bottom"
Margin="0 0 5 0" />
<ui:Button Content="Hide Debug" Click="SetVisibilityDebugConsole" Width="200" Height="75"
VerticalAlignment="Bottom" Margin="0 0 5 0" />
<!-- <ui:Button Content="Take Photo" Click="StartTakePhotoProcess" Width="200" Height="75" VerticalAlignment="Bottom" -->
@ -75,9 +74,96 @@
<ui:Button Content="Pictures" Click="SetVisibilityPicturePanel" Width="200" Height="75"
VerticalAlignment="Bottom" Margin="0 0 5 0" />
<ui:Button Content="Close" Appearance="Danger" Click="CloseApp" Width="200" Height="75" VerticalAlignment="Bottom" Margin="0 0 5 0" />
<ui:Button x:Name="DebugCloseButton" Content="Close" Appearance="Danger" Click="CloseApp" Width="200" Height="75" VerticalAlignment="Bottom" Margin="0 0 5 0" />
</StackPanel>
<!-- Shutdown Slider (bottom-left) -->
<Grid Grid.Row="0"
x:Name="ShutdownDock"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="20"
Panel.ZIndex="3"
Visibility="Hidden">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:Button Grid.Column="0"
x:Name="ShutdownToggleButton"
Content="&#xE7E8;"
FontFamily="Segoe MDL2 Assets"
FontSize="28"
Width="64"
Height="64"
Appearance="Danger"
Click="ToggleShutdownSlider" />
<Border Grid.Column="1"
Width="160"
Height="64"
Margin="8 0 0 0"
CornerRadius="10"
Background="#44202020"
ClipToBounds="True">
<Grid RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TranslateTransform x:Name="ShutdownSliderTransform" X="160" />
</Grid.RenderTransform>
<ui:Button x:Name="ShutdownConfirmButton"
Content="&#xE7E8;"
FontFamily="Segoe MDL2 Assets"
FontSize="24"
Appearance="Danger"
Width="160"
Height="64"
Click="ShutdownWindows" />
</Grid>
</Border>
</Grid>
<!-- Welcome Overlay -->
<Grid Grid.RowSpan="2"
x:Name="WelcomeOverlay"
Background="#CC000000"
Panel.ZIndex="10">
<Border Background="#E61A1A1A"
BorderBrush="#66FFFFFF"
BorderThickness="1"
CornerRadius="20"
Padding="48"
MaxWidth="900"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="Willkommen bei CamBooth!"
Foreground="White"
FontSize="56"
FontWeight="Bold"
TextAlignment="Center"
Margin="0 0 0 20"/>
<TextBlock Text="In wenigen Sekunden bist du bereit: Mit Start aktivierst du die Kamera und kannst direkt loslegen."
Foreground="#FFE8E8E8"
FontSize="28"
TextAlignment="Center"
TextWrapping="Wrap"
Margin="0 0 0 16"/>
<TextBlock Text="Viel Spaß mit der CamBooth!"
Foreground="#FFFFD280"
FontSize="34"
FontWeight="SemiBold"
TextAlignment="Center"
Margin="0 0 0 36"/>
<ui:Button Content="Start"
Click="StartExperience"
Width="240"
Height="80"
HorizontalAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
<!-- DebugFrame -->
<Frame Grid.Row="1"
x:Name="DebugFrame"

View File

@ -1,6 +1,8 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Threading;
using CamBooth.App.Core.AppSettings;
@ -33,6 +35,16 @@ public partial class MainWindow : Window
private bool _isPhotoProcessRunning;
private bool _isCameraStarted;
private bool _isShutdownSliderOpen;
private const string ShutdownGlyphClosed = "\uE7E8";
private const string ShutdownGlyphOpen = "\uE711";
private const double ShutdownSliderOffset = 160;
private readonly DispatcherTimer _focusStatusAnimationTimer = new() { Interval = TimeSpan.FromMilliseconds(250) };
private int _focusStatusDots;
@ -59,6 +71,11 @@ public partial class MainWindow : Window
this._focusStatusDots = (this._focusStatusDots + 1) % 4;
this.CaptureStatusText.Text = $"Scharfstellen{new string('.', this._focusStatusDots)}";
};
#if DEBUG
this.DebugCloseButton.Visibility = Visibility.Visible;
#else
this.DebugCloseButton.Visibility = Visibility.Collapsed;
#endif
logger.Info($"config file loaded: '{appSettings.ConfigFileName}'");
logger.Info("MainWindow initialized");
}
@ -107,10 +124,24 @@ public partial class MainWindow : Window
}
private void NavToLiveView(object sender, RoutedEventArgs e)
private void StartExperience(object sender, RoutedEventArgs e)
{
_liveViewPage = new LiveViewPage(this._logger, this._appSettings, this._cameraService);
MainFrame.Navigate(this._liveViewPage);
this.StartLiveViewIfNeeded();
this.WelcomeOverlay.Visibility = Visibility.Collapsed;
this.ButtonPanel.Visibility = Visibility.Visible;
this.ShutdownDock.Visibility = Visibility.Visible;
}
private void StartLiveViewIfNeeded()
{
if (this._isCameraStarted)
{
return;
}
this._liveViewPage = new LiveViewPage(this._logger, this._appSettings, this._cameraService);
this.MainFrame.Navigate(this._liveViewPage);
this._isCameraStarted = true;
}
@ -211,6 +242,44 @@ public partial class MainWindow : Window
this.Close();
}
private void ShutdownWindows(object sender, RoutedEventArgs e)
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = "shutdown",
Arguments = "/s /t 0",
CreateNoWindow = true,
UseShellExecute = false
});
}
catch (Exception exception)
{
this._logger.Error(exception.Message);
System.Windows.MessageBox.Show("Windows konnte nicht heruntergefahren werden. Bitte erneut versuchen.");
}
}
private void ToggleShutdownSlider(object sender, RoutedEventArgs e)
{
this._isShutdownSliderOpen = !this._isShutdownSliderOpen;
this.ShutdownToggleButton.Content = this._isShutdownSliderOpen ? ShutdownGlyphOpen : ShutdownGlyphClosed;
this.AnimateShutdownSlider(this._isShutdownSliderOpen);
}
private void AnimateShutdownSlider(bool open)
{
var animation = new DoubleAnimation
{
To = open ? 0 : ShutdownSliderOffset,
Duration = TimeSpan.FromMilliseconds(250),
EasingFunction = new QuadraticEase()
};
this.ShutdownSliderTransform.BeginAnimation(System.Windows.Media.TranslateTransform.XProperty, animation);
}
private void StartFocusStatusAnimation()
{
this._focusStatusDots = 0;