Skip to content
Snippets Groups Projects
Commit 28289cfa authored by Sandra Borst's avatar Sandra Borst
Browse files

finished distractions screen design, improved search function and dropdown menu

parent dd420c73
Branches
No related tags found
1 merge request!46finished distractions screen design, improved search function and dropdown menu
......@@ -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>
......@@ -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,17 +66,14 @@ 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>
</Border>
......@@ -83,7 +81,7 @@ MouseDown="SearchButton_Click">
</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,10 +275,8 @@ MouseDown="SearchButton_Click">
</Grid>
</Border>
</StackPanel>
<!-- Pagination -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,550,0,0" VerticalAlignment="Top">
<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>
......@@ -306,7 +302,8 @@ MouseDown="SearchButton_Click">
</Border>
</StackPanel>
</StackPanel>
</Grid>
</ScrollViewer>
</Page>
......@@ -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());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment