diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml index ecfce639437f8f8f4ba112be6b505ebbae3782d5..bf4829f5fbbe7c81f20793480993219261da71bc 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml @@ -8,15 +8,17 @@ mc:Ignorable="d" Height="550" Width="900"> <Grid> - <header:HeaderTemplate VerticalAlignment="Top"/> - <Button Content="Subscription" Style="{StaticResource TopMenuButon}" HorizontalAlignment="Right" Margin="0,4,180,0" VerticalAlignment="Top" Height="26" Width="80"/> - <Button Content="Contact" Style="{StaticResource TopMenuButon}" HorizontalAlignment="Right" Margin="0,4,100,0" VerticalAlignment="Top" Height="26" Width="80"/> - <Button Content="Distractions" Style="{StaticResource TopMenuButon}" HorizontalAlignment="Right" Margin="0,4,20,0" VerticalAlignment="Top" Height="26" Width="80"/> + <Button Margin="0,100,150,10" Width="40" Height="40" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" BorderBrush="Transparent" Click="discardSession_Click"> + <Grid > + <Line X1="5" Y1="5" X2="35" Y2="35" Stroke="Gray" StrokeThickness="5" /> + <Line X1="5" Y1="35" X2="35" Y2="5" Stroke="Gray" StrokeThickness="5" /> + </Grid> + </Button> <TextBlock Name ="Title" Text="Focus Session 0 of 0" Style="{StaticResource Heading1}" HorizontalAlignment="Center" Height="42" TextWrapping="Wrap" VerticalAlignment="Top" Width="442" Margin="0,133,0,0"/> <TextBlock Name="Clock" Text="00:00" Style="{StaticResource Heading1}" HorizontalAlignment="Center" Height="104" TextWrapping="Wrap" VerticalAlignment="Top" Width="326" Margin="0,180,0,0" FontSize="72" FontWeight="Bold"/> <StackPanel x:Name="CyclesIndicatorPanel" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,60,0,0"> </StackPanel> - <Button Content="Start" Name="PlayPauseButton" Style="{StaticResource PlayPauseButton}" HorizontalAlignment="Center" Margin="0,320,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Click="Button_Click"/> + <Button Content="Pause" Name="PlayPauseButton" Style="{StaticResource PlayPauseButton}" HorizontalAlignment="Center" Margin="0,320,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Click="PlayPause_Click"/> </Grid> </Window> \ No newline at end of file diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs index 912c3120316dcafd993e1157d813f554229f2bba..3cc526863f4bdd89b1427376d2cb5def00fc1aa2 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml.cs @@ -33,7 +33,7 @@ namespace InnoLabProjektDektopApp private Timer timer; private int maxTime; private int seconds; - private int step = 0; //Indicates whether the timer is running (-1) or paused (0) + private int step = -1; //Indicates whether the timer is running (-1) or paused (0) private int sessions; private int currentSession = 1; //Tracks which session is currently running @@ -47,7 +47,7 @@ namespace InnoLabProjektDektopApp { InitializeComponent(); this.focusPeriod = focusPeriod; - this.breakPeriod = breakPeriod; + this.breakPeriod = breakPeriod * 60; this.cycles = cycles; this.distractionMode = distractionMode; this.mascotVisible = mascotVisible; @@ -55,57 +55,56 @@ namespace InnoLabProjektDektopApp this.insultingWords = insultingWords; GlobalSettings.setDefaults(this); - this.maxTime = focusPeriod/2; //todo: multiply with 60 later + this.maxTime = focusPeriod * 60; //todo: multiply with 60 later this.seconds = this.maxTime; this.sessions = cycles; - timer = new Timer(timertick, null,0,1000); //A background timer calls timertick every second + timer = new Timer(timertick, null, 0, 1000); //A background timer calls timertick every second CreateCycleIndicators(); // Kreise erstellen updateTexts(); } - private void timertick(object state) -{ - Dispatcher.Invoke(() => - { - seconds += step; // Reduziere Zeit, wenn der Timer läuft - updateTexts(); // Aktualisiere die UI - - // Fortschrittsanzeige nur während der Fokusperiode aktualisieren - if (!isBreakPeriod) + private void timertick(object state) { - CreateCycleIndicators(); // Fortschritt für Fokus-Perioden anzeigen - } + Dispatcher.Invoke(() => + { + seconds += step; // Reduziere Zeit, wenn der Timer läuft + updateTexts(); // Aktualisiere die UI - if (seconds <= 0) // Wenn die Zeit abgelaufen ist - { - stopTimer(); // Timer stoppen + // Fortschrittsanzeige nur während der Fokusperiode aktualisieren - if (isBreakPeriod) // Wenn wir in einer Pause sind - { - isBreakPeriod = false; // Zurück zum Fokus - seconds = maxTime; // Zeit für die Fokusperiode - currentSession++; // Gehe zum nächsten Zyklus - } - else // Wenn wir im Fokus sind - { - isBreakPeriod = true; // Wechsel in den Pausenmodus - seconds = breakPeriod; // Zeit für die Pause - } + CreateCycleIndicators(); // Fortschritt für Fokus-Perioden anzeigen - if (currentSession > sessions) // Wenn alle Zyklen abgeschlossen sind - { - timer.Dispose(); // Timer stoppen und aufräumen - MessageBox.Show("All sessions completed!", "Info", MessageBoxButton.OK, MessageBoxImage.Information); - return; - } - startTimer(); // Starte den Timer für die nächste Periode + if (seconds <= 0) // Wenn die Zeit abgelaufen ist + { + stopTimer(); // Timer stoppen + + if (isBreakPeriod) // Wenn wir in einer Pause sind + { + isBreakPeriod = false; // Zurück zum Fokus + seconds = maxTime; // Zeit für die Fokusperiode + currentSession++; // Gehe zum nächsten Zyklus + } + else // Wenn wir im Fokus sind + { + isBreakPeriod = true; // Wechsel in den Pausenmodus + seconds = breakPeriod; // Zeit für die Pause + } + + if (currentSession > sessions) // Wenn alle Zyklen abgeschlossen sind + { + timer.Dispose(); // Timer stoppen und aufräumen + MessageBox.Show("All sessions completed!", "Info", MessageBoxButton.OK, MessageBoxImage.Information); + return; + } + + startTimer(); // Starte den Timer für die nächste Periode + } + }); } - }); -} @@ -147,12 +146,15 @@ namespace InnoLabProjektDektopApp } - private void Button_Click(object sender, RoutedEventArgs e) + private void PlayPause_Click(object sender, RoutedEventArgs e) { - if (step < 0) { + if (step < 0) + { stopTimer(); - } else { - startTimer(); + } + else + { + startTimer(); } } @@ -166,41 +168,46 @@ namespace InnoLabProjektDektopApp { if (i + 1 == currentSession) // Highlight the current session with a ProgressBar { - Grid cycleGrid = new Grid + if (isBreakPeriod) // Während der BreakPeriod { - Width = 50, - Height = 20, // Höhe des erweiterten Kreises - Margin = new Thickness(10), - }; - - // Background for the current cycle - Rectangle backgroundRectangle = new Rectangle + // Zeige ausgefüllten Kreis für die aktuelle Session + Ellipse filledCircle = new Ellipse + { + Width = 20, + Height = 20, + Margin = new Thickness(10), + Fill = new SolidColorBrush(Color.FromRgb(72, 98, 132)), // Ausgefüllter Kreis + }; + CyclesIndicatorPanel.Children.Add(filledCircle); + } + else // Während der FocusPeriod { - Width = 50, - Height = 20, - Fill = Brushes.LightGray, - RadiusX = 10, - RadiusY = 10, - }; - - // ProgressBar (uses the existing logic) - Rectangle progressBar = new Rectangle - { - Width = 50, // Gleiche Breite wie der Hintergrund - Height = 20, // Gleiche Höhe wie der Hintergrund - Fill = GradientGenerator.generateTwoColorBrush( - Color.FromRgb(72, 98, 132), - Color.FromRgb(222, 222, 222), - 1 - (seconds / (double)maxTime) - ), - RadiusX = 10, - RadiusY = 10, - HorizontalAlignment = HorizontalAlignment.Left, - }; - - cycleGrid.Children.Add(backgroundRectangle); - cycleGrid.Children.Add(progressBar); // ProgressBar überlagert den Hintergrund - CyclesIndicatorPanel.Children.Add(cycleGrid); + // Zeige die ProgressBar für die aktuelle Session + Grid cycleGrid = new Grid + { + Width = 50, + Height = 20, // Höhe des erweiterten Kreises + Margin = new Thickness(10), + }; + + // ProgressBar + Rectangle progressBar = new Rectangle + { + Width = 50, // Gleiche Breite wie der Hintergrund + Height = 20, // Gleiche Höhe wie der Hintergrund + Fill = GradientGenerator.generateTwoColorBrush( + Color.FromRgb(72, 98, 132), + Color.FromRgb(222, 222, 222), + 1 - (seconds / (double)maxTime) + ), + RadiusX = 10, + RadiusY = 10, + HorizontalAlignment = HorizontalAlignment.Left, + }; + + cycleGrid.Children.Add(progressBar); // ProgressBar hinzufügen + CyclesIndicatorPanel.Children.Add(cycleGrid); + } } else { @@ -218,6 +225,66 @@ namespace InnoLabProjektDektopApp } } + private void discardSession_Click(object sender, RoutedEventArgs e) + { + // Neues Fenster für die Auswahl des Abbruchgrunds erstellen + Window reasonWindow = new Window + { + Title = "Warum beenden Sie die Sitzung?", + Width = 600, + Height = 180, + WindowStartupLocation = WindowStartupLocation.CenterScreen, + ResizeMode = ResizeMode.NoResize + }; + + // Haupt-StackPanel für die Radiobuttons und den OK-Button + StackPanel stackPanel = new StackPanel + { + Margin = new Thickness(10) + }; + + // Radiobuttons für die Gründe + RadioButton reason1 = new RadioButton { Content = "Ich habe mich dazu entschieden, frühzeitig zu beenden (wird in die Statistik mit aufgenommen).", Margin = new Thickness(5), IsChecked = true }; + RadioButton reason2 = new RadioButton { Content = "Mir ist etwas sehr Wichtiges dazwischengekommen, was ich nicht verschieben konnte.", Margin = new Thickness(5) }; + + // OK-Button + Button okButton = new Button + { + Content = "Ok", + Margin = new Thickness(5), + Width = 80, + HorizontalAlignment = HorizontalAlignment.Right + }; + okButton.Click += (s, args) => + { + string selectedReason = reason1.IsChecked == true ? "Ich habe mich dazu entschieden, frühzeitig zu beenden" : + reason2.IsChecked == true ? "Mir ist etwas sehr Wichtiges dazwischengekommen, was ich nicht verschieben konnte." : + "Kein Grund ausgewählt"; + + MessageBox.Show($"Abbruchgrund: {selectedReason}", "Sitzung beendet", MessageBoxButton.OK, MessageBoxImage.Information); + + // Zum OverviewScreen navigieren + var overviewScreen = new Overview(); + overviewScreen.Show(); + reasonWindow.Close(); // Fenster schließen + this.Close(); // Aktuelles Fenster schließen + }; + + // Radiobuttons und Button zum StackPanel hinzufügen + stackPanel.Children.Add(new TextBlock { Text = "Wählen Sie den Grund für den Abbruch aus:", Margin = new Thickness(5) }); + stackPanel.Children.Add(reason1); + stackPanel.Children.Add(reason2); + stackPanel.Children.Add(okButton); + + // StackPanel als Content des Fensters setzen + reasonWindow.Content = stackPanel; + + // Fenster anzeigen + reasonWindow.ShowDialog(); + } + + + } }