diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml
index 2469aea..e4695f0 100644
--- a/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml
@@ -3,6 +3,7 @@
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:liveView="clr-namespace:CamBooth.App.Features.LiveView"
mc:Ignorable="d"
Title="LiveViewPage" Width="1350" Height="900"
Background="PaleVioletRed">
diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs
index e23a283..2d3c45d 100644
--- a/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs
@@ -57,8 +57,7 @@ public partial class LiveViewPage : Page
this._logger.Error(ex.Message);
}
}
-
-
+
public void Dispose()
{
this._cameraService.Dispose();
diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/TimerControl.xaml b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControl.xaml
new file mode 100644
index 0000000..5d8c1e8
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControl.xaml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/TimerControl.xaml.cs b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControl.xaml.cs
new file mode 100644
index 0000000..78c958c
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControl.xaml.cs
@@ -0,0 +1,75 @@
+using System.Windows.Controls;
+using System.Windows.Media.Animation;
+using System.Windows.Threading;
+
+namespace CamBooth.App.Features.LiveView;
+
+public partial class ModernTimerControl : UserControl
+{
+ private DispatcherTimer _timer;
+
+ private int _remainingTime; // Zeit in Sekunden
+
+
+ public ModernTimerControl()
+ {
+ InitializeComponent();
+ InitializeTimer();
+ }
+
+
+ private void InitializeTimer()
+ {
+ _timer = new DispatcherTimer
+ {
+ Interval = TimeSpan.FromSeconds(1)
+ };
+ _timer.Tick += Timer_Tick;
+ }
+
+
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ if (_remainingTime > 0)
+ {
+ _remainingTime--;
+ TimerText.Text = TimeSpan.FromSeconds(_remainingTime).ToString(@"mm\:ss");
+ }
+ else
+ {
+ _timer.Stop();
+ StatusText.Text = "Zeit abgelaufen!";
+ }
+ }
+
+
+ public void StartTimer(int durationInSeconds)
+ {
+ _remainingTime = durationInSeconds;
+ TimerText.Text = TimeSpan.FromSeconds(_remainingTime).ToString(@"mm\:ss");
+ StatusText.Text = "Timer läuft...";
+ _timer.Start();
+ ShowTimer();
+ }
+
+
+ public void StopTimer()
+ {
+ _timer.Stop();
+ StatusText.Text = "Timer angehalten";
+ }
+
+
+ public void ShowTimer()
+ {
+ var fadeInAnimation = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(300));
+ TimerContainer.BeginAnimation(OpacityProperty, fadeInAnimation);
+ }
+
+
+ public void HideTimer()
+ {
+ var fadeOutAnimation = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(300));
+ TimerContainer.BeginAnimation(OpacityProperty, fadeOutAnimation);
+ }
+}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/TimerControlRectangleAnimation.xaml b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControlRectangleAnimation.xaml
new file mode 100644
index 0000000..df06915
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControlRectangleAnimation.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+ HIER EINE ANWEISUNG ANZEIGEN
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/TimerControlRectangleAnimation.xaml.cs b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControlRectangleAnimation.xaml.cs
new file mode 100644
index 0000000..01b364f
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/TimerControlRectangleAnimation.xaml.cs
@@ -0,0 +1,123 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+
+using Microsoft.Win32;
+
+namespace CamBooth.App.Features.LiveView;
+
+public partial class TimerControlRectangleAnimation : UserControl
+{
+ public delegate void TimerElapsedEventHandler();
+
+ public static event TimerElapsedEventHandler OnTimerEllapsed;
+
+ private DispatcherTimer _timer;
+
+ private int _remainingTime; // Zeit in Sekunden
+
+ private double _totalDuration; // Gesamtzeit in Sekunden
+
+ private Storyboard _progressBarAnimation;
+
+
+ public TimerControlRectangleAnimation()
+ {
+ InitializeComponent();
+ InitializeTimer();
+ }
+
+ private void InitializeTimer()
+ {
+ _timer = new DispatcherTimer
+ {
+ Interval = TimeSpan.FromSeconds(1)
+ };
+ _timer.Tick += OnTimerTick;
+ }
+
+
+ private void OnTimerTick(object sender, EventArgs e)
+ {
+ if (_remainingTime > 0)
+ {
+ _remainingTime--;
+
+ // TimerText.Text = TimeSpan.FromSeconds(_remainingTime).ToString(@"mm\:ss");
+ }
+ else
+ {
+ _timer.Stop();
+
+ // StatusText.Text = "Zeit abgelaufen!";
+ StopProgressBarAnimation();
+
+ OnTimerEllapsed?.Invoke();
+ }
+ }
+
+
+ public void StartTimer(int durationInSeconds)
+ {
+ _totalDuration = durationInSeconds;
+ _remainingTime = durationInSeconds;
+
+ // TimerText.Text = TimeSpan.FromSeconds(_remainingTime).ToString(@"mm\:ss");
+ // StatusText.Text = "Timer läuft...";
+ _timer.Start();
+
+ StartProgressBarAnimation();
+ ShowTimer();
+ }
+
+
+ public void StopTimer()
+ {
+ _timer.Stop();
+ StopProgressBarAnimation();
+
+ // StatusText.Text = "Timer angehalten";
+ }
+
+
+ public void ShowTimer()
+ {
+ var fadeInAnimation = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(300));
+ TimerContainer.BeginAnimation(OpacityProperty, fadeInAnimation);
+ }
+
+
+ public void HideTimer()
+ {
+ var fadeOutAnimation = new DoubleAnimation(1, 0, TimeSpan.FromMilliseconds(300));
+ TimerContainer.BeginAnimation(OpacityProperty, fadeOutAnimation);
+ }
+
+
+ private void StartProgressBarAnimation()
+ {
+ // Fortschrittsbalken-Animation
+ _progressBarAnimation = new Storyboard();
+ var widthAnimation = new DoubleAnimation
+ {
+ From = 1350, // Volle Breite des Containers
+ To = 0, // Endet bei 0 Breite
+ Duration = TimeSpan.FromSeconds(_totalDuration),
+ FillBehavior = FillBehavior.Stop
+ };
+
+ Storyboard.SetTarget(widthAnimation, ProgressBar);
+ Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Rectangle.WidthProperty));
+
+ _progressBarAnimation.Children.Add(widthAnimation);
+ _progressBarAnimation.Begin();
+ }
+
+
+ private void StopProgressBarAnimation()
+ {
+ _progressBarAnimation?.Stop();
+ }
+}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/MainWindow.xaml b/src/CamBooth/CamBooth.App/MainWindow.xaml
index 86e94e8..4eb07c3 100644
--- a/src/CamBooth/CamBooth.App/MainWindow.xaml
+++ b/src/CamBooth/CamBooth.App/MainWindow.xaml
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:CamBooth.App"
+ xmlns:liveView="clr-namespace:CamBooth.App.Features.LiveView"
mc:Ignorable="d"
Title="MainWindow"
Background="Black"
@@ -49,19 +50,18 @@
VerticalAlignment="Bottom"
Panel.ZIndex="1" />
-
-
-
-
+
+
+
-
diff --git a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
index 12df279..306067f 100644
--- a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
+++ b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
@@ -30,8 +30,9 @@ public partial class MainWindow : Window
private LiveViewPage? _liveViewPage;
- public MainWindow(Logger logger,
- AppSettingsService appSettings,
+ public MainWindow(
+ Logger logger,
+ AppSettingsService appSettings,
PictureGalleryService pictureGalleryService,
CameraService cameraService)
{
@@ -44,9 +45,27 @@ public partial class MainWindow : Window
this.SetVisibilityPicturePanel(this._isPicturePanelVisible);
_ = this._pictureGalleryService.LoadThumbnailsToCache();
this.Closing += OnClosing;
+ TimerControlRectangleAnimation.OnTimerEllapsed += TimerControlRectangleAnimation_OnTimerEllapsed;
logger.Info("MainWindow initialized");
}
+
+ private void TimerControlRectangleAnimation_OnTimerEllapsed()
+ {
+ try
+ {
+ this._cameraService.TakePhoto();
+ SwitchButtonAndTimerPanel();
+ }
+ catch (Exception exception)
+ {
+ //TODO: mit content dialog ersetzen
+ System.Windows.MessageBox.Show("Sorry, da ging was schief!");
+ this._logger.Info(exception.Message);
+ }
+ }
+
+
private void SetVisibilityPicturePanel(bool visibility)
{
if (visibility)
@@ -96,19 +115,17 @@ public partial class MainWindow : Window
}
- private void TakePhoto(object sender, RoutedEventArgs e)
+ private void StartTakePhotoProcess(object sender, RoutedEventArgs e)
{
- try
- {
- this._cameraService.TakePhoto();
- }
- catch (Exception exception)
- {
- System.Windows.MessageBox.Show("Sorry, da ging was schief!");
- this._logger.Info(exception.Message);
- }
+ TimerControlRectangleAnimation.StartTimer(5);
+ SwitchButtonAndTimerPanel();
}
+ private void SwitchButtonAndTimerPanel()
+ {
+ this.ButtonPanel.Visibility = this.ButtonPanel.Visibility == Visibility.Hidden ? Visibility.Visible : Visibility.Hidden;
+ this.TimerPanel.Visibility = this.TimerPanel.Visibility == Visibility.Hidden ? Visibility.Visible : Visibility.Hidden;
+ }
private void SetVisibilityPicturePanel(object sender, RoutedEventArgs e)
{
diff --git a/src/CamBooth/CamBooth.sln.DotSettings.user b/src/CamBooth/CamBooth.sln.DotSettings.user
index 587c839..07e734a 100644
--- a/src/CamBooth/CamBooth.sln.DotSettings.user
+++ b/src/CamBooth/CamBooth.sln.DotSettings.user
@@ -11,5 +11,6 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
\ No newline at end of file