diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/02Progress.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/02Progress.xaml index 397b2ee82116ea7ab631fb26a3b28f0adf8e2c24..f774a37a6ed02df402a7089f684469e40b6c4935 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/02Progress.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/02Progress.xaml @@ -7,7 +7,8 @@ mc:Ignorable="d" Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> - <Grid VerticalAlignment="Center"> + <ScrollViewer> + <Grid VerticalAlignment="Center" Margin="0,20,0,20"> <!-- Überschrift --> <TextBlock Text="Your way to working more focused" Style="{StaticResource Header0}" @@ -96,4 +97,5 @@ </Border> </StackPanel> </Grid> + </ScrollViewer> </Page> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml index 84252f5b70d470ecac0e5b54e3fcaea41b7fab9b..23f61d5c1798e270bc6fffd2a13bd6ebf121aa39 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml @@ -7,7 +7,8 @@ xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" mc:Ignorable="d" Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> - <Grid VerticalAlignment="Center"> + <ScrollViewer> + <Grid VerticalAlignment="Center" Margin="0,20,0,20"> <StackPanel Margin="20,0,20,20"> @@ -65,25 +66,22 @@ Height="30" Margin="165,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Right" -MouseDown="SearchButton_Click"> +> <TextBlock Text="🔍" FontSize="14" VerticalAlignment="Center" HorizontalAlignment="Center" - Style="{StaticResource ButtonTextStyle2}"/> + /> </Border> - - - - </Grid> + </Grid> </Border> </Grid> <TextBlock Text="By clicking on each category, you can change the programs/websites that should be marked as distracting."/> - <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="20,0,0,8" Height="0"> + <ScrollViewer Visibility="Collapsed" VerticalScrollBarVisibility="Auto" Margin="20,0,0,8" Height="100" x:Name="SearchResultsPanelContainer"> <StackPanel x:Name="SearchResultsPanel" /> </ScrollViewer> @@ -149,8 +147,8 @@ MouseDown="SearchButton_Click"> <!-- Popup für die Dropdown-Liste --> <Popup Name="PopupMenu" Placement="Bottom" StaysOpen="True" Width="200"> - <Border Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Width="200"> - <ListBox x:Name="CategoryList" SelectionChanged="CategoryList_SelectionChanged" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}"> + <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="Social Media"/> <ListBoxItem Content="Shopping"/> <ListBoxItem Content="Games"/> @@ -185,7 +183,7 @@ MouseDown="SearchButton_Click"> <!-- Kategorie: Social Media --> <StackPanel Margin="10"> - <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Grid_MouseDown"> + <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Border_PreviewMouseDown"> <Grid> <Image Source="pack://application:,,,/Assets/socialmediaicon.png" VerticalAlignment="Center" HorizontalAlignment="Center" Width="100"/> <CheckBox x:Name="SocialMediaCheckBox" IsChecked="True" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" /> @@ -200,7 +198,7 @@ MouseDown="SearchButton_Click"> <!-- Kategorie: Shopping --> <StackPanel Margin="10"> - <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Grid_MouseDown"> + <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Border_PreviewMouseDown"> <Grid> <Image Width="100" Source="pack://application:,,,/Assets/shoppingicon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <CheckBox x:Name="ShoppingCheckBox" IsChecked="True" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" /> @@ -215,7 +213,7 @@ MouseDown="SearchButton_Click"> <!-- Kategorie: Games --> <StackPanel Margin="10"> - <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Grid_MouseDown"> + <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Border_PreviewMouseDown"> <Grid> <Image Width="100" Source="pack://application:,,,/Assets/gamesicon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <CheckBox x:Name="GamesCheckBox" IsChecked="True" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" /> @@ -231,7 +229,7 @@ MouseDown="SearchButton_Click"> <!-- Kategorie: Porn --> <StackPanel Margin="10"> - <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Grid_MouseDown"> + <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Border_PreviewMouseDown"> <Grid> <Image Width="100" Source="pack://application:,,,/Assets/pornicon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <CheckBox x:Name="PornCheckBox" IsChecked="True" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" /> @@ -246,7 +244,7 @@ MouseDown="SearchButton_Click"> <!-- Kategorie: Other Websites --> <StackPanel Margin="10"> - <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Grid_MouseDown"> + <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Border_PreviewMouseDown"> <Grid> <Image Width="80" Source="pack://application:,,,/Assets/otherwebsitesicon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <CheckBox x:Name="OtherWebsitesCheckBox" IsChecked="True" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" /> @@ -261,7 +259,7 @@ MouseDown="SearchButton_Click"> <!-- Kategorie: Other Programs --> <StackPanel Margin="10"> - <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Grid_MouseDown"> + <Border CornerRadius="20" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" Height="120" Width="170" MouseDown="Border_PreviewMouseDown"> <Grid> <Image Width="100" Source="pack://application:,,,/Assets/programsicon.png" VerticalAlignment="Center" HorizontalAlignment="Center" /> <CheckBox x:Name="OtherProgramsCheckBox" IsChecked="True" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10" /> @@ -277,36 +275,35 @@ MouseDown="SearchButton_Click"> </Grid> </Border> - </StackPanel> - - <!-- Pagination --> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,550,0,0" VerticalAlignment="Top"> - <Border Style="{StaticResource RoundedButtonBorder}" MouseDown="PreviousPage_Click" Width="100" Margin="10"> - <TextBlock Text="Previous" Style="{StaticResource ButtonTextStyle}" /> - </Border> - <StackPanel Orientation="Horizontal"> - <Ellipse Width="15" Height="15" Fill="{StaticResource TEXT_PRIMARY_BRUSH}" Margin="5"/> - <!-- Aktive Seite --> - <Ellipse Width="15" Height="15" Fill="{StaticResource TEXT_PRIMARY_BRUSH}" Margin="5"/> - <!-- Inaktive Seite --> - <Ellipse Width="15" Height="15" Fill="Gray" Margin="5"/> - <Ellipse Width="15" Height="15" Fill="Gray" Margin="5"/> - </StackPanel> - - <!-- - <Button Content="1" Width="20" Margin="5" Click="first_Page" /> - <Button Content="2" Width="20" Margin="5" Click="Second_Page" /> - <Button Content="3" Width="20" Margin="5" Click="third_Page" /> - <Button Content="4" Width="20" Margin="5" Click="fourth_Page" /> - <Button Content="5" Width="20" Margin="5" Click="fifth_Page" /> - --> + <!-- Pagination --> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0" VerticalAlignment="Top"> + <Border Style="{StaticResource RoundedButtonBorder}" MouseDown="PreviousPage_Click" Width="100" Margin="10"> + <TextBlock Text="Previous" Style="{StaticResource ButtonTextStyle}" /> + </Border> + <StackPanel Orientation="Horizontal"> + <Ellipse Width="15" Height="15" Fill="{StaticResource TEXT_PRIMARY_BRUSH}" Margin="5"/> + <!-- Aktive Seite --> + <Ellipse Width="15" Height="15" Fill="{StaticResource TEXT_PRIMARY_BRUSH}" Margin="5"/> + <!-- Inaktive Seite --> + <Ellipse Width="15" Height="15" Fill="Gray" Margin="5"/> + <Ellipse Width="15" Height="15" Fill="Gray" Margin="5"/> + </StackPanel> - <Border Style="{StaticResource RoundedButtonBorder}" MouseDown="NextPage_Click" Width="100" Margin="10"> - <TextBlock Text="Next" Style="{StaticResource ButtonTextStyle}" /> - </Border> - </StackPanel> + <!-- + <Button Content="1" Width="20" Margin="5" Click="first_Page" /> + <Button Content="2" Width="20" Margin="5" Click="Second_Page" /> + <Button Content="3" Width="20" Margin="5" Click="third_Page" /> + <Button Content="4" Width="20" Margin="5" Click="fourth_Page" /> + <Button Content="5" Width="20" Margin="5" Click="fifth_Page" /> + --> - </Grid> + <Border Style="{StaticResource RoundedButtonBorder}" MouseDown="NextPage_Click" Width="100" Margin="10"> + <TextBlock Text="Next" Style="{StaticResource ButtonTextStyle}" /> + </Border> + </StackPanel> + </StackPanel> + </Grid> + </ScrollViewer> </Page> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml.cs index ac074af5be2314fd741aed01e26bd29955127715..aa2a0f9818fefac5e1d072baeb078866b642b929 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_0Distractions.xaml.cs @@ -13,6 +13,7 @@ using System.Text.Json; using System.Text.RegularExpressions; using System.IO; using System.Collections.Generic; +using System.Diagnostics; namespace InnoLabProjektDektopApp { @@ -33,18 +34,8 @@ namespace InnoLabProjektDektopApp - private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) - { - // Placeholder ein- oder ausblenden - if (!string.IsNullOrEmpty(SearchBox.Text)) - { - SearchPlaceholder.Visibility = Visibility.Collapsed; // Ausblenden - } - else - { - SearchPlaceholder.Visibility = Visibility.Visible; // Einblenden - } - } + + private void CheckBox_Changed(object sender, RoutedEventArgs e) { @@ -55,7 +46,7 @@ namespace InnoLabProjektDektopApp } } - private void SearchButton_Click(object sender, RoutedEventArgs e) + private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) { if (data == null || data.Count == 0) { @@ -65,37 +56,47 @@ namespace InnoLabProjektDektopApp string searchText = SearchBox.Text.Trim().ToLower(); + // Wenn das Suchfeld leer ist, blende sowohl Placeholder als auch das Panel aus if (string.IsNullOrEmpty(searchText)) { - MessageBox.Show("Please enter a search term."); + SearchPlaceholder.Visibility = Visibility.Visible; // Placeholder anzeigen + SearchResultsPanelContainer.Visibility = Visibility.Collapsed; // Suchergebnisse ausblenden return; } - // Clear previous search results + // Wenn Text vorhanden ist, blende den Placeholder aus und zeige das Panel + SearchPlaceholder.Visibility = Visibility.Collapsed; + SearchResultsPanelContainer.Visibility = Visibility.Visible; + + // Vorherige Suchergebnisse löschen SearchResultsPanel.Children.Clear(); - // Search through all categories and URLs + bool hasResults = false; + + // Durchsuche alle Kategorien und URLs foreach (var category in data) { foreach (var entry in category.Value) { if (entry.Url.ToLower().Contains(searchText)) { - // Create a StackPanel for each result + hasResults = true; + + // StackPanel für jedes Suchergebnis erstellen var resultPanel = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(5) }; - // Create CheckBox + // CheckBox erstellen var checkBox = new CheckBox { IsChecked = entry.IsDistracting, Margin = new Thickness(5), VerticalAlignment = VerticalAlignment.Center, - Tag = (category.Key, entry) // Tag to store category and entry reference + Tag = (category.Key, entry) // Speichert Kategorie und Eintrag }; checkBox.Checked += CheckBox_Changed; checkBox.Unchecked += CheckBox_Changed; - // Add URL Text + // URL als Text anzeigen var urlText = new TextBlock { Text = entry.Url, @@ -103,7 +104,7 @@ namespace InnoLabProjektDektopApp VerticalAlignment = VerticalAlignment.Center }; - // Add Category Text + // Kategorie als grauen Text anzeigen var categoryText = new TextBlock { Text = $"[{category.Key}]", @@ -112,25 +113,37 @@ namespace InnoLabProjektDektopApp Foreground = Brushes.Gray }; - // Add components to result panel + // Elemente zum Ergebnis-Panel hinzufügen resultPanel.Children.Add(checkBox); resultPanel.Children.Add(urlText); resultPanel.Children.Add(categoryText); - // Add result panel to SearchResultsPanel + // Panel zur Anzeige der Suchergebnisse hinzufügen SearchResultsPanel.Children.Add(resultPanel); } } } - if (SearchResultsPanel.Children.Count == 0) + // Falls keine Ergebnisse gefunden wurden, "No results found." anzeigen + if (!hasResults) { - MessageBox.Show("No results found."); + var noResultsText = new TextBlock + { + Text = "No results found.", + FontSize = 16, + FontWeight = FontWeights.Bold, + Foreground = Brushes.Gray, + HorizontalAlignment = HorizontalAlignment.Center, + Margin = new Thickness(10) + }; + + SearchResultsPanel.Children.Add(noResultsText); } } + private void LoadJsonData() { try @@ -279,22 +292,23 @@ private void ClosePopupOnClickOutside(object sender, MouseButtonEventArgs e) } - - private void Grid_MouseDown(object sender, MouseButtonEventArgs e) + private void Border_PreviewMouseDown(object sender, MouseButtonEventArgs e) { - var grid = sender as Grid; - if (grid != null) + var border = sender as Border; + if (border != null && border.Child is Grid grid) { - // Suche die Checkbox im Grid + Debug.WriteLine("Das ist ein Log-Eintrag."); + var checkbox = grid.Children.OfType<CheckBox>().FirstOrDefault(); if (checkbox != null) { - // Toggle den Zustand der Checkbox checkbox.IsChecked = !checkbox.IsChecked; + e.Handled = true; // Verhindert, dass andere Elemente das Event blockieren } } } + private void PreviousPage_Click(object sender, RoutedEventArgs e) { this.NavigationService.Navigate(new Progress());