From b3a923f6066cfb3c065a192496c529ead95502db Mon Sep 17 00:00:00 2001
From: Sandra Borst <108298114+VerfluchteZocke@users.noreply.github.com>
Date: Sat, 8 Mar 2025 00:34:08 +0100
Subject: [PATCH] improved design of overview page, made seonds warning mode
 work, made it possible to enter custom values

---
 .../Screens/Regulaer/01Overview.xaml          | 183 +++++---
 .../Screens/Regulaer/01Overview.xaml.cs       | 412 ++++++++++++++++--
 2 files changed, 496 insertions(+), 99 deletions(-)

diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml
index 0701f3f..c0c4792 100644
--- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml
+++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml
@@ -5,9 +5,10 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:InnoLabProjektDektopApp"
         xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates"
-        mc:Ignorable="d">
+        mc:Ignorable="d"
+       Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}">
     <ScrollViewer>
-    <Grid>
+        <Grid VerticalAlignment="Center">
         <StackPanel Margin="20,0,20,20">
 
             <!-- Überschrift -->
@@ -19,7 +20,7 @@
             
 
             <!-- Profiles and Add Button Section -->
-            <Border Background="#333333" CornerRadius="10" Padding="15" >
+                <Border  Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15" >
                 <StackPanel Orientation="Vertical">
                     <TextBlock Style="{StaticResource Header2}" 
 Text="Want to customize this profile?" 
@@ -62,7 +63,7 @@ HorizontalAlignment="Left" />
             </Border>
 
             <!-- Settings Section -->
-            <Border Background="#333333" CornerRadius="10" Padding="15" Margin="0,20,0,0">
+                <Border Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15" Margin="0,20,0,0">
                 <StackPanel>
                     <!-- Überschrift innerhalb des Hintergrunds -->
                     <TextBlock Style="{StaticResource Header2}" 
@@ -75,71 +76,143 @@ HorizontalAlignment="Left" />
                             <StackPanel Grid.Row="0" Grid.Column="0" Margin="10">
                                 <TextBlock Text="Focus period" FontSize="14" FontWeight="Bold" Foreground="White" />
                                 <StackPanel Orientation="Horizontal">
-                                    <ComboBox x:Name="FocusPeriodComboBox" HorizontalAlignment="Left" Height="30" Width="70" FontSize="14" Padding="5" SelectionChanged="ComboBox_SelectionChanged" IsEditable="True" PreviewTextInput="ComboBox_PreviewTextInput">
-                                        <ComboBoxItem Content="1" />
-                                        <ComboBoxItem Content="20" />
-                                        <ComboBoxItem Content="30" />
-                                        <ComboBoxItem Content="40" />
-                                        <ComboBoxItem Content="50" IsSelected="True" />
-                                        <ComboBoxItem Content="60" />
-                                        <ComboBoxItem Content="90" />
-                                        <ComboBoxItem Content="120" />
-                                        <ComboBoxItem Content="150" />
-                                        <ComboBoxItem Content="180" />
-                                    </ComboBox>
-                                    <TextBlock Text="minutes" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="14" Foreground="Gray" />
+
+                                    <Border Name="DropdownBorder1" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5"  Margin="0,5,0,0"
+Width="70" MouseDown="TogglePopup1">
+                                        <Grid>
+                                            <TextBox x:Name="SelectedText1" Text="45" Foreground="{StaticResource BACKGROUND_PRIMARY_BRUSH}" 
+                 FontWeight="Bold" VerticalAlignment="Center" Margin="10,0,30,0"
+                 Background="Transparent" BorderThickness="0" TextChanged="SelectedTextBox_TextChanged"/>
+                                            <Path Fill="{StaticResource BACKGROUND_PRIMARY_BRUSH}" Data="M 0 0 L 8 8 L 16 0 Z" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10"/>
+                                        </Grid>
+                                    </Border>
+
+                                    <!-- Popup für die Dropdown-Liste -->
+                                    <Popup Name="PopupMenu1" Placement="Bottom" PlacementTarget="{Binding ElementName=DropdownBorder1}" StaysOpen="True" Width="70">
+                                        <Border Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Width="70">
+                                            <ListBox x:Name="CategoryList1" SelectionChanged="CategoryList_SelectionChanged1" Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}">
+                                                <ListBoxItem Content="20"/>
+                                                <ListBoxItem Content="30"/>
+                                                <ListBoxItem Content="45"/>
+                                                <ListBoxItem Content="60"/>
+                                                <ListBoxItem Content="90"/>
+                                                <ListBoxItem Content="120"/>
+                                                <ListBoxItem Content="180"/>
+                                            </ListBox>
+                                        </Border>
+                                    </Popup>
+                                    <TextBlock Text="minutes" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="14" />
                                 </StackPanel>
                             </StackPanel>
 
                             <StackPanel Grid.Row="0" Grid.Column="1" Margin="10">
                                 <TextBlock Text="Break period" FontSize="14" FontWeight="Bold" Foreground="White" />
                                 <StackPanel Orientation="Horizontal">
-                                    <ComboBox x:Name="BreakPeriodComboBox" HorizontalAlignment="Left" Height="30" Width="70" FontSize="14" Padding="5" IsEditable="True" PreviewTextInput="ComboBox_PreviewTextInput">
-                                        <ComboBoxItem Content="0" />
-                                        <ComboBoxItem Content="1" />
-                                        <ComboBoxItem Content="3" />
-                                        <ComboBoxItem Content="5" />
-                                        <ComboBoxItem Content="10" IsSelected="True" />
-                                        <ComboBoxItem Content="15" />
-                                        <ComboBoxItem Content="20" />
-                                        <ComboBoxItem Content="25" />
-                                        <ComboBoxItem Content="30" />
-                                    </ComboBox>
-                                    <TextBlock Text="minutes" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="14" Foreground="Gray" />
+
+                                    <Border Name="DropdownBorder2" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5"  Margin="0,5,0,0"
+Width="70" MouseDown="TogglePopup2">
+                                        <Grid>
+                                            <TextBox x:Name="SelectedText2" Text="10" Foreground="{StaticResource BACKGROUND_PRIMARY_BRUSH}" 
+                 FontWeight="Bold" VerticalAlignment="Center" Margin="10,0,30,0"
+                 Background="Transparent" BorderThickness="0" TextChanged="SelectedTextBox_TextChanged"/>
+                                            <Path Fill="{StaticResource BACKGROUND_PRIMARY_BRUSH}" Data="M 0 0 L 8 8 L 16 0 Z" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10"/>
+                                        </Grid>
+                                    </Border>
+
+                                    <!-- Popup für die Dropdown-Liste -->
+                                    <Popup Name="PopupMenu2" Placement="Bottom" PlacementTarget="{Binding ElementName=DropdownBorder2}" StaysOpen="True" Width="70">
+                                        <Border Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Width="70">
+                                            <ListBox x:Name="CategoryList2" SelectionChanged="CategoryList_SelectionChanged2" Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}">
+                                                <ListBoxItem Content="0"/>
+                                                <ListBoxItem Content="1"/>
+                                                <ListBoxItem Content="3"/>
+                                                <ListBoxItem Content="5"/>
+                                                <ListBoxItem Content="10"/>
+                                                <ListBoxItem Content="20"/>
+                                                <ListBoxItem Content="30"/>
+                                            </ListBox>
+                                        </Border>
+                                    </Popup>
+                                    <TextBlock Text="minutes" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="14" />
                                 </StackPanel>
                             </StackPanel>
 
                             <StackPanel Grid.Row="0" Grid.Column="2" Margin="10">
                                 <TextBlock Text="Cycles" FontSize="14" FontWeight="Bold" Foreground="White" />
-                                <ComboBox x:Name="CyclesComboBox" HorizontalAlignment="Left" Height="30" Width="50" FontSize="14" Padding="5" IsEditable="True" PreviewTextInput="ComboBox_PreviewTextInput">
-                                    <ComboBoxItem Content="1" />
-                                    <ComboBoxItem Content="2" />
-                                    <ComboBoxItem Content="3" />
-                                    <ComboBoxItem Content="4" IsSelected="True" />
-                                    <ComboBoxItem Content="5" />
-                                    <ComboBoxItem Content="6" />
-                                </ComboBox>
+
+                                <Border Name="DropdownBorder3" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5"  Margin="0,5,0,0"
+Width="70" MouseDown="TogglePopup3">
+                                    <Grid>
+                                        <TextBox x:Name="SelectedText3" Text="10" Foreground="{StaticResource BACKGROUND_PRIMARY_BRUSH}" 
+                 FontWeight="Bold" VerticalAlignment="Center" Margin="10,0,30,0"
+                 Background="Transparent" BorderThickness="0" TextChanged="SelectedTextBox_TextChanged"/>
+                                        <Path Fill="{StaticResource BACKGROUND_PRIMARY_BRUSH}" Data="M 0 0 L 8 8 L 16 0 Z" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10"/>
+                                    </Grid>
+                                </Border>
+
+                                <!-- Popup für die Dropdown-Liste -->
+                                <Popup Name="PopupMenu3" Placement="Bottom" PlacementTarget="{Binding ElementName=DropdownBorder3}" StaysOpen="True" Width="70">
+                                    <Border Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Width="70">
+                                        <ListBox x:Name="CategoryList3" SelectionChanged="CategoryList_SelectionChanged3" Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}">
+                                            <ListBoxItem Content="1"/>
+                                            <ListBoxItem Content="2"/>
+                                            <ListBoxItem Content="3"/>
+                                            <ListBoxItem Content="4"/>
+                                            <ListBoxItem Content="5"/>
+                                            <ListBoxItem Content="6"/>
+                                        </ListBox>
+                                    </Border>
+                                </Popup>
                             </StackPanel>
 
                             <!-- Zweite Reihe -->
-                            <StackPanel Grid.Row="1" Grid.Column="0" Margin="10" x:Name="SecondsWarningPanel" >
+                            <StackPanel Grid.Row="1" Grid.Column="0" Margin="10" x:Name="SecondsWarningPanel" Visibility="Collapsed" >
                                 <TextBlock Text="Seconds" Foreground="White" FontSize="14" FontWeight="Bold" />
-                                <ComboBox x:Name="SecondsWarningComboBox" Width="50" HorizontalAlignment="Left">
-                                    <ComboBoxItem Content="3" />
-                                    <ComboBoxItem Content="5" />
-                                    <ComboBoxItem Content="10" IsSelected="True"/>
-                                    <ComboBoxItem Content="15" />
-                                    <ComboBoxItem Content="30" />
-                                </ComboBox>
+                                <Border Name="DropdownBorder4" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5"  Margin="0,5,0,0"
+Width="70" MouseDown="TogglePopup4">
+                                    <Grid>
+                                        <TextBox x:Name="SelectedText4" Text="4" Foreground="{StaticResource BACKGROUND_PRIMARY_BRUSH}" 
+                 FontWeight="Bold" VerticalAlignment="Center" Margin="10,0,30,0"
+                 Background="Transparent" BorderThickness="0" TextChanged="SelectedTextBox_TextChanged"/>
+                                        <Path Fill="{StaticResource BACKGROUND_PRIMARY_BRUSH}" Data="M 0 0 L 8 8 L 16 0 Z" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10"/>
+                                    </Grid>
+                                </Border>
+
+                                <!-- Popup für die Dropdown-Liste -->
+                                <Popup Name="PopupMenu4" Placement="Bottom" PlacementTarget="{Binding ElementName=DropdownBorder4}" StaysOpen="True" Width="70">
+                                    <Border Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Width="70">
+                                        <ListBox x:Name="CategoryList4" SelectionChanged="CategoryList_SelectionChanged4" Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}">
+                                            <ListBoxItem Content="3"/>
+                                            <ListBoxItem Content="5"/>
+                                            <ListBoxItem Content="10"/>
+                                            <ListBoxItem Content="15"/>
+                                            <ListBoxItem Content="30" />
+                                        </ListBox>
+                                    </Border>
+                                </Popup>
                             </StackPanel>
 
                             <StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="10">
                                 <TextBlock Text="Distraction Mode" Foreground="White" FontSize="14" FontWeight="Bold" />
-                                <ComboBox x:Name="DistractionModeComboBox" Width="170" HorizontalAlignment="Left" SelectionChanged="DistractionMode_SelectionChanged">
-                                    <ComboBoxItem Content="Full-blocking mode" IsSelected="True" />
-                                    <ComboBoxItem Content="seconds warning mode" />
-                                    <ComboBoxItem Content="Mascot feedback only" />
-                                </ComboBox>
+                                
+                                <Border Name="DropdownBorder" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Margin="0,5,0,0"
+Width="200" MouseDown="TogglePopup">
+                                    <Grid>
+                                        <TextBlock x:Name="SelectedText" Text="Full-blocking mode" Foreground="{StaticResource BACKGROUND_PRIMARY_BRUSH}" FontWeight="Bold" VerticalAlignment="Center" Margin="10,0,30,0"/>
+                                        <Path Fill="{StaticResource BACKGROUND_PRIMARY_BRUSH}" Data="M 0 0 L 8 8 L 16 0 Z" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10"/>
+                                    </Grid>
+                                </Border>
+
+                                <!-- Popup für die Dropdown-Liste -->
+                                <Popup Name="PopupMenu" Placement="Bottom" PlacementTarget="{Binding ElementName=DropdownBorder}" StaysOpen="True" Width="200">
+                                    <Border Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Width="200">
+                                        <ListBox x:Name="CategoryList" SelectionChanged="CategoryList_SelectionChanged" Background="{StaticResource HIGHLIGHT_SECONDARY_BRUSH}">
+                                            <ListBoxItem Content="Full-blocking mode"/>
+                                            <ListBoxItem Content="seconds warning mode"/>
+                                            <ListBoxItem Content="Mascot feedback only"/>
+                                        </ListBox>
+                                    </Border>
+                                </Popup>
                             </StackPanel>
 
                             <StackPanel Grid.Row="1" Grid.Column="2" VerticalAlignment="Center" Margin="10" Width="150">
@@ -190,14 +263,12 @@ TextChanged="FocusTopicInputBox_TextChanged" />
             </Grid>
             <!-- Start Button -->
 
-            <Border Width="150" Height="50" CornerRadius="25" Background="Gray" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="0,10,0,0">
-                <Button Background="Transparent" BorderThickness="0" Click="StartButton_Click">
-                    <TextBlock Text="Start" FontSize="16" FontWeight="Bold" Foreground="#1A202C" HorizontalAlignment="Center" VerticalAlignment="Center" />
-                </Button>
-            </Border>
+                <Border Margin="0,10" Style="{StaticResource RoundedButtonBorder}" MouseDown="StartButton_Click">
+                    <TextBlock Text="Start" Style="{StaticResource ButtonTextStyle}" />
+                </Border>
 
 
-        </StackPanel>
+            </StackPanel>
 
     </Grid>
     </ScrollViewer>
diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs
index ded3731..13a8568 100644
--- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs
+++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs
@@ -1,6 +1,8 @@
 using InnoLabProjektDektopApp.Services;
 using System.IO;
+using System.Net.Sockets;
 using System.Text.Json;
+using System.Text.RegularExpressions;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
@@ -54,64 +56,113 @@ namespace InnoLabProjektDektopApp
                         // Focus Period
                         if (profileSettings.TryGetProperty("focusPeriod", out var focusPeriodElement))
                         {
-                            string focusPeriod = focusPeriodElement.GetString();
-                            FocusPeriodComboBox.Text = focusPeriod;
+                            string focusPeriod = focusPeriodElement.GetString() ?? "45";
+
+                            // Setze den geladenen Wert in das Textfeld (SelectedText1)
+                            SelectedText1.Text = focusPeriod;
+
+                            // Falls der geladene Wert mit einem ListBoxItem übereinstimmt, markiere es
+                            foreach (ListBoxItem item in CategoryList1.Items)
+                            {
+                                if (item.Content.ToString() == focusPeriod)
+                                {
+                                    CategoryList1.SelectedItem = item;
+                                    break;
+                                }
+                            }
                         }
 
+
                         // Break Period
                         if (profileSettings.TryGetProperty("breakPeriod", out var breakPeriodElement))
                         {
-                            string breakPeriod = breakPeriodElement.GetString();
-                            BreakPeriodComboBox.Text = breakPeriod;
+                            string breakPeriod = breakPeriodElement.GetString() ?? "10";
+
+                            // Setze den geladenen Wert in das Textfeld
+                            SelectedText2.Text = breakPeriod;
+
+                            // Falls der geladene Wert mit einem ListBoxItem übereinstimmt, markiere es
+                            foreach (ListBoxItem item in CategoryList2.Items)
+                            {
+                                if (item.Content.ToString() == breakPeriod)
+                                {
+                                    CategoryList2.SelectedItem = item;
+                                    break;
+                                }
+                            }
                         }
 
                         // Cycles
                         if (profileSettings.TryGetProperty("cycles", out var cyclesElement))
                         {
-                            string cycles = cyclesElement.GetString();
-                            CyclesComboBox.Text = cycles;
+                            string cycles = cyclesElement.GetString() ?? "4";
+
+                            // Setze den geladenen Wert in das Textfeld
+                            SelectedText3.Text = cycles;
+
+                            // Falls der geladene Wert mit einem ListBoxItem übereinstimmt, markiere es
+                            foreach (ListBoxItem item in CategoryList3.Items)
+                            {
+                                if (item.Content.ToString() == cycles)
+                                {
+                                    CategoryList3.SelectedItem = item;
+                                    break;
+                                }
+                            }
                         }
 
                         // Distraction Mode
+                        
                         if (profileSettings.TryGetProperty("distractionMode", out var distractionModeElement))
                         {
-                            string distractionMode = distractionModeElement.GetString();
-                            DistractionModeComboBox.SelectedItem = FindComboBoxItem(DistractionModeComboBox, distractionMode);
+                            string distractionMode = distractionModeElement.GetString() ?? "Full-blocking mode";
 
-                            // Zusätzliche ComboBox für Sekunden aktivieren, wenn Modus "seconds warning mode" ist
-                            if (distractionMode == "seconds warning mode")
-                            {
-                                SecondsWarningComboBox.Visibility = Visibility.Visible;
 
-                                
+                            // Setze den geladenen Wert in das Textfeld
+                            SelectedText.Text = distractionMode;
+
+                            // Falls der geladene Wert mit einem ListBoxItem übereinstimmt, markiere es
+                            foreach (ListBoxItem item in CategoryList.Items)
+                            {
+                                if (item.Content.ToString() == distractionMode)
+                                {
+                                    CategoryList.SelectedItem = item;
+                                    break;
+                                }
                             }
-                            else
+
+                            // Zusätzliche ComboBox für Sekunden aktivieren, wenn Modus "seconds warning mode" ist
+                            if (distractionMode == "seconds warning mode")
                             {
-                                SecondsWarningComboBox.Visibility = Visibility.Collapsed;
+                                SecondsWarningPanel.Visibility = Visibility.Visible;                              
                             }
+
                         }
 
-                        //Get information about seconds
+
+                        // Get information about warning seconds
                         if (profileSettings.TryGetProperty("warningSeconds", out var warningSecondsElement))
                         {
                             string warningSeconds = warningSecondsElement.GetString();
 
-                            // Überprüfen, ob der Wert existiert, andernfalls auf Standard setzen
-                            var item = SecondsWarningComboBox.Items
-                                .OfType<ComboBoxItem>()
+                            // Überprüfen, ob der gespeicherte Wert in der ListBox vorhanden ist
+                            var item = CategoryList4.Items
+                                .OfType<ListBoxItem>()
                                 .FirstOrDefault(i => i.Content.ToString() == warningSeconds);
 
                             if (item != null)
                             {
-                                SecondsWarningComboBox.SelectedItem = item;
+                                // Falls der Wert in der Liste existiert, setze ihn als Auswahl
+                                SelectedText4.Text = item.Content.ToString();
                             }
                             else
                             {
-                                // Setze einen Standardwert, falls der gespeicherte Wert ungültig ist
-                                SecondsWarningComboBox.SelectedItem = "10"; // Default: "10"
+                                // Falls der gespeicherte Wert ungültig ist oder nicht gefunden wurde, Standardwert setzen
+                                SelectedText4.Text = "10"; // Standard: "10"
                             }
                         }
 
+
                         // Mascot Visibility
                         if (profileSettings.TryGetProperty("mascotVisibility", out var mascotVisibilityElement))
                         {
@@ -204,10 +255,100 @@ namespace InnoLabProjektDektopApp
         private void StartButton_Click(object sender, RoutedEventArgs e)
         {
             // Werte auslesen
-            int focusPeriod = int.Parse(((ComboBoxItem)FocusPeriodComboBox.SelectedItem)?.Content.ToString().Split()[0] ?? "50");
-            int breakPeriod = int.Parse(((ComboBoxItem)BreakPeriodComboBox.SelectedItem)?.Content.ToString().Split()[0] ?? "10");
-            int cycles = int.Parse(((ComboBoxItem)CyclesComboBox.SelectedItem)?.Content.ToString() ?? "4");
-            string distractionMode = ((ComboBoxItem)DistractionModeComboBox.SelectedItem)?.Content.ToString() ?? "Full-blocking mode";
+            int focusPeriod;
+
+            // Prüfe zuerst, ob die TextBox (`SelectedText1`) eine gültige Zahl enthält
+            if (int.TryParse(SelectedText1.Text, out focusPeriod))
+            {
+                // Wert aus der TextBox wurde erfolgreich als Ganzzahl geparst
+            }
+            else if (CategoryList1.SelectedItem is ListBoxItem selectedItem &&
+                     int.TryParse(selectedItem.Content.ToString(), out focusPeriod))
+            {
+                // Falls die TextBox leer ist, prüfe ob ein Wert in der ListBox ausgewählt wurde
+            }
+            else
+            {
+                // Falls nichts gültiges eingegeben wurde, setze den Standardwert 50
+                focusPeriod = 50;
+            }
+
+            // Werte auslesen
+            int breakPeriod;
+
+            // Prüfe zuerst, ob die TextBox (`SelectedText1`) eine gültige Zahl enthält
+            if (int.TryParse(SelectedText2.Text, out breakPeriod))
+            {
+                // Wert aus der TextBox wurde erfolgreich als Ganzzahl geparst
+            }
+            else if (CategoryList2.SelectedItem is ListBoxItem selectedItem &&
+                     int.TryParse(selectedItem.Content.ToString(), out breakPeriod))
+            {
+                // Falls die TextBox leer ist, prüfe ob ein Wert in der ListBox ausgewählt wurde
+            }
+            else
+            {
+                // Falls nichts gültiges eingegeben wurde, setze den Standardwert 50
+                breakPeriod = 10;
+            }
+
+            // Werte auslesen
+            int cycles;
+
+            // Prüfe zuerst, ob die TextBox (`SelectedText1`) eine gültige Zahl enthält
+            if (int.TryParse(SelectedText3.Text, out cycles))
+            {
+                // Wert aus der TextBox wurde erfolgreich als Ganzzahl geparst
+            }
+            else if (CategoryList3.SelectedItem is ListBoxItem selectedItem &&
+                     int.TryParse(selectedItem.Content.ToString(), out cycles))
+            {
+                // Falls die TextBox leer ist, prüfe ob ein Wert in der ListBox ausgewählt wurde
+            }
+            else
+            {
+                // Falls nichts gültiges eingegeben wurde, setze den Standardwert 50
+                cycles = 4;
+            }
+
+            // Standardwert für distractionMode
+            string distractionMode = "Full-blocking mode";
+
+            // Prüfe zuerst, ob die TextBox (`SelectedText`) einen gültigen Wert enthält
+            if (!string.IsNullOrWhiteSpace(SelectedText.Text))
+            {
+                distractionMode = SelectedText.Text; // Wert aus der TextBox übernehmen
+            }
+            else if (CategoryList.SelectedItem is ListBoxItem selectedItem)
+            {
+                distractionMode = selectedItem.Content.ToString(); // Falls in der ListBox etwas gewählt wurde
+            }
+            else
+            {
+                // Falls nichts gültiges eingegeben wurde, setze den Standardwert
+                distractionMode = "Full-blocking mode";
+            }
+
+            int warningSeconds;
+
+            // Prüfe zuerst, ob die TextBox (`SelectedText1`) eine gültige Zahl enthält
+            if (int.TryParse(SelectedText4.Text, out warningSeconds))
+            {
+                // Wert aus der TextBox wurde erfolgreich als Ganzzahl geparst
+            }
+            else if (CategoryList4.SelectedItem is ListBoxItem selectedItem &&
+                     int.TryParse(selectedItem.Content.ToString(), out warningSeconds))
+            {
+                // Falls die TextBox leer ist, prüfe ob ein Wert in der ListBox ausgewählt wurde
+            }
+            else
+            {
+                MessageBox.Show("THIS", "Title", MessageBoxButton.OK, MessageBoxImage.Information);
+
+                // Falls nichts gültiges eingegeben wurde, setze den Standardwert 50
+                warningSeconds = 10;
+            }
+
             string mascotVisible = ((ComboBoxItem)MascotVisibilityComboBox.SelectedItem)?.Content.ToString() ?? "Yes";
             bool wordsOfAffirmation = WordsOfAffirmationCheckBox.IsChecked ?? false;
             bool insultingWords = InsultingWordsCheckBox.IsChecked ?? false;
@@ -217,6 +358,7 @@ namespace InnoLabProjektDektopApp
                             $"Break Period: {breakPeriod} minutes\n" +
                             $"Cycles: {cycles}\n" +
                             $"Distraction Mode: {distractionMode}\n" +
+                            $"Warning Seconds: {warningSeconds}\n" +
                             $"Mascot Visible: {mascotVisible}\n" +
                             $"Words of Affirmation: {wordsOfAffirmation}\n" +
                             $"Insulting Words: {insultingWords}",
@@ -247,24 +389,7 @@ namespace InnoLabProjektDektopApp
 
         }
 
-        private void DistractionMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            if (DistractionModeComboBox.SelectedItem != null &&
-                DistractionModeComboBox.SelectedItem.ToString().Contains("seconds warning mode"))
-            {
-                SecondsWarningPanel.Visibility = Visibility.Visible;
 
-                // Setze einen Standardwert, falls keiner ausgewählt ist
-                if (SecondsWarningComboBox.SelectedItem == null)
-                {
-                    SecondsWarningComboBox.SelectedItem = "10"; // Default: "10"
-                }
-            }
-            else
-            {
-                SecondsWarningPanel.Visibility = Visibility.Collapsed;
-            }
-            } 
 
         private void MascotVisibilityComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
@@ -288,7 +413,208 @@ namespace InnoLabProjektDektopApp
             }
         }
 
+        private void SelectedTextBox_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            TextBox textBox = sender as TextBox;
+            if (textBox == null) return;
+
+            string input = textBox.Text;
+
+            // Erlaubt nur numerische Eingaben (positive Ganzzahlen) und begrenzt die Länge auf 3 Zeichen
+            if (!Regex.IsMatch(input, @"^\d*$"))
+            {
+                int cursorPos = textBox.SelectionStart - 1; // Cursor-Position speichern
+                textBox.Text = Regex.Replace(input, @"\D", ""); // Alle nicht-numerischen Zeichen entfernen
+                textBox.SelectionStart = Math.Max(cursorPos, 0); // Cursor wieder an die ursprüngliche Stelle setzen
+            }
+
+            // Maximal 3 Zeichen erlauben
+            if (textBox.Text.Length > 3)
+            {
+                int cursorPos = textBox.SelectionStart - 1; // Cursor-Position speichern
+                textBox.Text = textBox.Text.Substring(0, 3); // Kürzt den Text auf 3 Zeichen
+                textBox.SelectionStart = Math.Max(cursorPos, 0); // Cursor-Position wieder setzen
+            }
+        }
+
+        private void TogglePopup(object sender, MouseButtonEventArgs e)
+        {
+            // Popup umschalten
+            PopupMenu.IsOpen = !PopupMenu.IsOpen;
+
+            // Wenn das Popup geöffnet wird, registriere das globale Klick-Event
+            if (PopupMenu.IsOpen)
+            {
+                this.PreviewMouseDown += ClosePopupOnClickOutside;
+            }
+        }
+
+        private void CategoryList_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+            if (CategoryList.SelectedItem is ListBoxItem selectedItem)
+            {
+                SelectedText.Text = selectedItem.Content.ToString();
+                PopupMenu.IsOpen = false; // Popup schließen nach Auswahl
+                this.PreviewMouseDown -= ClosePopupOnClickOutside; // Event entfernen
+
+                if (SelectedText.Text.Contains("seconds warning mode"))
+                {
+                    SecondsWarningPanel.Visibility = Visibility.Visible;
+
+                    // Setze einen Standardwert für Warning Seconds, falls kein Wert vorhanden ist
+                    if (string.IsNullOrWhiteSpace(SelectedText.Text))
+                    {
+                        SelectedText.Text = "10"; // Default-Wert für Warning Seconds
+                    }
+                }
+                else
+                {
+                    SecondsWarningPanel.Visibility = Visibility.Collapsed;
+                }
+            }
+        }
+
+        private void ClosePopupOnClickOutside(object sender, MouseButtonEventArgs e)
+        {
+            if (!PopupMenu.IsMouseOver && !DropdownBorder.IsMouseOver)
+            {
+                PopupMenu.IsOpen = false;
+                this.PreviewMouseDown -= ClosePopupOnClickOutside; // Event entfernen
+            }
+        }
+
+        private void TogglePopup1(object sender, MouseButtonEventArgs e)
+        {
+            // Popup umschalten
+            PopupMenu1.IsOpen = !PopupMenu1.IsOpen;
+
+            // Wenn das Popup geöffnet wird, registriere das globale Klick-Event
+            if (PopupMenu1.IsOpen)
+            {
+                this.PreviewMouseDown += ClosePopupOnClickOutside1;
+            }
+        }
+
+        private void CategoryList_SelectionChanged1(object sender, SelectionChangedEventArgs e)
+        {
+            if (CategoryList1.SelectedItem is ListBoxItem selectedItem)
+            {
+                SelectedText1.Text = selectedItem.Content.ToString();
+                PopupMenu1.IsOpen = false; // Popup schließen nach Auswahl
+                this.PreviewMouseDown -= ClosePopupOnClickOutside1; // Event entfernen
+            }
+        }
+
+        
+
+
+
+        private void ClosePopupOnClickOutside1(object sender, MouseButtonEventArgs e)
+        {
+            if (!PopupMenu1.IsMouseOver && !DropdownBorder1.IsMouseOver)
+            {
+                PopupMenu1.IsOpen = false;
+                this.PreviewMouseDown -= ClosePopupOnClickOutside1; // Event entfernen
+            }
+        }
+
+        private void TogglePopup2(object sender, MouseButtonEventArgs e)
+        {
+            // Popup umschalten
+            PopupMenu2.IsOpen = !PopupMenu2.IsOpen;
+
+            // Wenn das Popup geöffnet wird, registriere das globale Klick-Event
+            if (PopupMenu2.IsOpen)
+            {
+                this.PreviewMouseDown += ClosePopupOnClickOutside2;
+            }
+        }
 
+        private void CategoryList_SelectionChanged2(object sender, SelectionChangedEventArgs e)
+        {
+            if (CategoryList2.SelectedItem is ListBoxItem selectedItem)
+            {
+                SelectedText2.Text = selectedItem.Content.ToString();
+                PopupMenu2.IsOpen = false; // Popup schließen nach Auswahl
+                this.PreviewMouseDown -= ClosePopupOnClickOutside2; // Event entfernen
+            }
+        }
+
+
+        private void ClosePopupOnClickOutside2(object sender, MouseButtonEventArgs e)
+        {
+            if (!PopupMenu2.IsMouseOver && !DropdownBorder2.IsMouseOver)
+            {
+                PopupMenu2.IsOpen = false;
+                this.PreviewMouseDown -= ClosePopupOnClickOutside2; // Event entfernen
+            }
+        }
+
+        private void TogglePopup3(object sender, MouseButtonEventArgs e)
+        {
+            // Popup umschalten
+            PopupMenu3.IsOpen = !PopupMenu2.IsOpen;
+
+            // Wenn das Popup geöffnet wird, registriere das globale Klick-Event
+            if (PopupMenu3.IsOpen)
+            {
+                this.PreviewMouseDown += ClosePopupOnClickOutside3;
+            }
+        }
+
+        private void CategoryList_SelectionChanged3(object sender, SelectionChangedEventArgs e)
+        {
+            if (CategoryList3.SelectedItem is ListBoxItem selectedItem)
+            {
+                SelectedText3.Text = selectedItem.Content.ToString();
+                PopupMenu3.IsOpen = false; // Popup schließen nach Auswahl
+                this.PreviewMouseDown -= ClosePopupOnClickOutside3; // Event entfernen
+            }
+        }
+
+
+
+        private void ClosePopupOnClickOutside3(object sender, MouseButtonEventArgs e)
+        {
+            if (!PopupMenu3.IsMouseOver && !DropdownBorder2.IsMouseOver)
+            {
+                PopupMenu3.IsOpen = false;
+                this.PreviewMouseDown -= ClosePopupOnClickOutside3; // Event entfernen
+            }
+        }
+
+        private void TogglePopup4(object sender, MouseButtonEventArgs e)
+        {
+            // Popup umschalten
+            PopupMenu4.IsOpen = !PopupMenu2.IsOpen;
+
+            // Wenn das Popup geöffnet wird, registriere das globale Klick-Event
+            if (PopupMenu4.IsOpen)
+            {
+                this.PreviewMouseDown += ClosePopupOnClickOutside4;
+            }
+        }
+
+        private void CategoryList_SelectionChanged4(object sender, SelectionChangedEventArgs e)
+        {
+            if (CategoryList4.SelectedItem is ListBoxItem selectedItem)
+            {
+                SelectedText4.Text = selectedItem.Content.ToString();
+                PopupMenu4.IsOpen = false; // Popup schließen nach Auswahl
+                this.PreviewMouseDown -= ClosePopupOnClickOutside4; // Event entfernen
+            }
+        }
+
+
+
+        private void ClosePopupOnClickOutside4(object sender, MouseButtonEventArgs e)
+        {
+            if (!PopupMenu4.IsMouseOver && !DropdownBorder2.IsMouseOver)
+            {
+                PopupMenu4.IsOpen = false;
+                this.PreviewMouseDown -= ClosePopupOnClickOutside4; // Event entfernen
+            }
+        }
 
     }
 }
-- 
GitLab