diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/InnoLabProjektDektopApp.csproj b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/InnoLabProjektDektopApp.csproj index 673c2784c7de7777c924f3437a7dd0aa9aa560dd..f2715a8d338acb5501cf38b91456019f66be8da7 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/InnoLabProjektDektopApp.csproj +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/InnoLabProjektDektopApp.csproj @@ -1502,4 +1502,8 @@ <Resource Include="Styles\Styles.xaml" /> </ItemGroup> + <Target Name="PreBuild" BeforeTargets="PreBuildEvent"> + <Exec Command="echo {} > "$(TargetDir)settings.json"" /> + </Target> + </Project> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml index 48e2dd8122362c811ab91fa2ea94cae71c410b79..286a196952a88b4be56e6d1ee029a5db992011de 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml @@ -9,12 +9,66 @@ Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"> <Grid VerticalAlignment="Center"> + <Grid.RowDefinitions> + <RowDefinition Height="*"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="105*"/> + <ColumnDefinition Width="475*"/> + <ColumnDefinition Width="132*"/> + </Grid.ColumnDefinitions> + + <StackPanel Margin="20,20,20,3" Grid.ColumnSpan="3" Grid.Row="0"> + + <!--Project Area--> + <TextBlock Style="{StaticResource Header1}" + Text="Your project with saved settings" + HorizontalAlignment="Left" /> + <!--Box 1--> + <Border Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15" Margin="0,10,0,0"> + <!-- Project Pic and Name --> + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10" HorizontalAlignment="Left"> - <StackPanel Margin="20,20,20,20"> + <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"> + <Border Width="80" Height="80" Background="LightBlue" CornerRadius="40"> + <Image Source="pack://application:,,,/Assets/profileicon.png" Stretch="Uniform" Margin="10"/> + </Border> + </StackPanel> - <TextBlock Style="{StaticResource Header1}" + <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"> + <TextBox x:Name="ProjectNameTextBox" Text="Project Name" Margin="10,0,0,0" BorderThickness="0" Background="Transparent" FontWeight="Bold" Foreground="White" FontSize="14" CaretBrush="White"/> + <Border Height="1" Width="300" Background="White" Margin="10,2,0,0"/> + </StackPanel> + + </StackPanel> + </StackPanel> + </Border> + + <!--Box 2--> + <Border Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15" Margin="0,10,0,20"> + <StackPanel Orientation="Vertical"> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10" HorizontalAlignment="Left"> + + <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"> + <TextBlock Text="To the distractions saved in your profile" VerticalAlignment="Center" Grid.Column="0" FontSize="14" FontWeight="SemiBold"/> + </StackPanel> + + <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"> + <Button Content="➡" Width="30" Height="30" Background="Transparent" BorderThickness="0"/> + </StackPanel> + + </StackPanel> + </StackPanel> + </Border> + + + <!--Settings Area--> + <TextBlock Style="{StaticResource Header2}" Text="Change the settings as you want" + FontWeight="Bold" HorizontalAlignment="Left" /> <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0,10,0,0"> @@ -299,7 +353,7 @@ Width="70" MouseDown="TogglePopup4"> <!-- Pagination --> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,478,0,0" VerticalAlignment="Top"> + <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="-186,0,0,10" VerticalAlignment="Top" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1"> <Border Style="{StaticResource RoundedButtonBorder}" MouseDown="PreviousPage_Click" Width="100" Margin="10"> <TextBlock Text="Previous" Style="{StaticResource ButtonTextStyle}" /> </Border> @@ -321,7 +375,7 @@ Width="70" MouseDown="TogglePopup4"> --> <Border Style="{StaticResource RoundedButtonBorder}" MouseDown="NextPage_Click" Width="100" Margin="10"> - <TextBlock Text="Next" Style="{StaticResource ButtonTextStyle}" /> + <TextBlock Text="Save" Style="{StaticResource ButtonTextStyle}" /> </Border> </StackPanel> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml.cs index db7bb5b05bc011efaa6f0b2e684a6592533de84b..324956f44a78fd8ead06b809875ebdea36ff15f5 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/04Settings.xaml.cs @@ -56,65 +56,80 @@ namespace InnoLabProjektDektopApp } + // -------------------------------------------------------------- - - private void SaveSettings() + private void SaveSettings(string? projectName = null) { - // Sammle die Werte aus den ComboBoxen oder verwende Standardwerte - string focusPeriod = string.IsNullOrWhiteSpace(SelectedText2.Text) ? "45" : SelectedText2.Text; - string breakPeriod = string.IsNullOrWhiteSpace(SelectedText3.Text) ? "45" : SelectedText3.Text; - string cycles = string.IsNullOrWhiteSpace(SelectedText4.Text) ? "4" : SelectedText4.Text; - - string distractionMode = DistractionModeFullBlocking.IsChecked == true - ? "Full-blocking mode" - : DistractionModeMascotFeedback.IsChecked == true - ? "Mascot feedback only" - : "seconds warning mode"; - - string warningSeconds = !string.IsNullOrWhiteSpace(SelectedText.Text) - ? SelectedText.Text - : "10"; - - string mascotVisible = MascotVisibleYes.IsChecked == true ? "Yes" : "No"; + string filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json"); + Dictionary<string, Dictionary<string, string>> settings; - bool wordsOfAffirmation = WordsOfAffirmationCheckBox.IsChecked ?? false; - bool insultingWords = InsultingWordsCheckBox.IsChecked ?? false; + // load existig json file or create new one + if (File.Exists(filePath)) + { + string jsonContent = File.ReadAllText(filePath); + settings = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(jsonContent) ?? new(); + } + else + { + settings = new(); + } - // JSON-Datei erstellen - var settings = new Dictionary<string, Dictionary<string, string>> - { - { - "profile1", - new Dictionary<string, string> + // if no project name from overview, then new project + if (string.IsNullOrWhiteSpace(projectName)) { - { "focusPeriod", focusPeriod }, - { "breakPeriod", breakPeriod }, - { "cycles", cycles }, - { "distractionMode", distractionMode }, - { "warningSeconds", warningSeconds }, - { "mascotVisibility", mascotVisible }, - { "wordsOfAffirmation", wordsOfAffirmation.ToString() }, - { "insultingWords", insultingWords.ToString() } + for (int i = 1; i <= 8; i++) + { + string newProjectKey = $"project{i}"; + if (!settings.ContainsKey(newProjectKey)) + { + projectName = newProjectKey; + break; + } + } } - } - }; - string filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json"); + // if user tries to add one project more then one can + if (string.IsNullOrWhiteSpace(projectName)) + { + MessageBox.Show("You have reached the maximum number of 8 projects. Please delete an existing project before adding a new one.", "Limit Reached", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } - // JSON speichern + // get values of settings oder default values + var projectSettings = new Dictionary<string, string> +{ + { "displayName", string.IsNullOrWhiteSpace(ProjectNameTextBox.Text) ? projectName : ProjectNameTextBox.Text }, + { "focusPeriod", string.IsNullOrWhiteSpace(SelectedText2.Text) ? "45" : SelectedText2.Text }, + { "breakPeriod", string.IsNullOrWhiteSpace(SelectedText3.Text) ? "10" : SelectedText3.Text }, + { "cycles", string.IsNullOrWhiteSpace(SelectedText4.Text) ? "4" : SelectedText4.Text }, + { "distractionMode", DistractionModeFullBlocking.IsChecked == true ? "Full-blocking mode" : + DistractionModeMascotFeedback.IsChecked == true ? "Mascot feedback only" : "seconds warning mode" }, + { "warningSeconds", string.IsNullOrWhiteSpace(SelectedText.Text) ? "10" : SelectedText.Text }, + { "mascotVisibility", MascotVisibleYes.IsChecked == true ? "Yes" : "No" }, + { "wordsOfAffirmation", (WordsOfAffirmationCheckBox.IsChecked ?? false).ToString() }, + { "insultingWords", (InsultingWordsCheckBox.IsChecked ?? false).ToString() } +}; + + // save project or overwrite + settings[projectName] = projectSettings; + + // save json File.WriteAllText(filePath, JsonSerializer.Serialize(settings, new JsonSerializerOptions { WriteIndented = true })); - // Nach dem Speichern: JSON lesen und in der MessageBox anzeigen - if (File.Exists(filePath)) + MessageBox.Show($"Settings saved for {projectName}.", "Success.", MessageBoxButton.OK, MessageBoxImage.Information); + + // show massageBox + /*if (File.Exists(filePath)) { string jsonContent = File.ReadAllText(filePath); var savedSettings = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(jsonContent); - if (savedSettings != null && savedSettings.ContainsKey("profile1")) + if (savedSettings != null && savedSettings.ContainsKey("project1")) { - var profileSettings = savedSettings["profile1"]; + var profileSettings = savedSettings["project1"]; - string message = "Saved Settings for profile1:\n"; + string message = "Saved Settings for this profile:\n"; + message += $"Filepath: {filePath}\n"; foreach (var setting in profileSettings) { message += $"{setting.Key}: {setting.Value}\n"; @@ -122,8 +137,10 @@ namespace InnoLabProjektDektopApp MessageBox.Show(message, "Saved Settings", MessageBoxButton.OK, MessageBoxImage.Information); } - } + }*/ + } + // -------------------------------------------------------------- private void PreviousPage_Click(object sender, RoutedEventArgs e) { diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml index b933c47faea18b1442867017d1cb749140354a44..56de8cfd7428d57ea02b0a84807947ea4d378ec7 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml @@ -10,69 +10,67 @@ Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> <ScrollViewer> <Grid VerticalAlignment="Center"> - - - <StackPanel Margin="20,0,20,20"> - - - <!-- Überschrift --> - <TextBlock Style="{StaticResource Header1}" - Text="Selection and editing of your saved profiles" + <!-- Überschrift --> + <TextBlock Style="{StaticResource Header1}" + Text="Selection and editing of your saved projects" HorizontalAlignment="Left" - Margin="50,10,0,10" /> - - - - <!-- Profiles and Add Button Section --> - <Border Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15" > - <StackPanel Orientation="Vertical" > - <TextBlock Style="{StaticResource Header2}" -Text="Want to customize this profile?" -HorizontalAlignment="Left" /> - <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Background="#333333" Margin="10" HorizontalAlignment="Left"> - - - <!-- Profil 1 --> - <StackPanel Orientation="Vertical" Margin="10,0,0,0" VerticalAlignment="Center"> - <Border Width="80" Height="80" Background="LightBlue" CornerRadius="40"> - <Image Source="pack://application:,,,/Assets/profileicon.png" Stretch="Uniform" Margin="10"/> - </Border> - <TextBlock FontWeight="Bold" Text="Profile 1" Foreground="White" FontSize="14" HorizontalAlignment="Center" Margin="0,5,0,0" /> - <Button Width="20" Height="20" Background="Transparent" BorderThickness="0" Click="EditProfile_Click" HorizontalAlignment="Center" ToolTip="Edit Profile" Margin="0,-205,-80,0"> - <Image Source="pack://application:,,,/Assets/pencilicon.png" Stretch="Uniform" /> - </Button> - </StackPanel> - - <!-- Profil 2 --> - <StackPanel Orientation="Vertical" Margin="20,0,0,0" VerticalAlignment="Center"> - <Border Width="80" Height="80" Background="Gray" CornerRadius="40"> - <Image Source="pack://application:,,,/Assets/profileicon.png" Stretch="Uniform" Margin="10"/> - </Border> - <TextBlock Text="Profile 2" Foreground="White" FontSize="14" HorizontalAlignment="Center" Margin="0,5,0,0" /> - </StackPanel> - - <!-- Plus Button --> - <Border Width="50" Height="50" Background="Gray" CornerRadius="25" Margin="20,-15,0,0"> - <Button Width="50" Height="50" Background="Transparent" BorderThickness="0" Click="AddProfile_Click" HorizontalAlignment="Center" VerticalAlignment="Center"> - <TextBlock Text="+" FontSize="24" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" /> - </Button> - </Border> + Margin="40,10,0,10" /> + + + + <!-- Profiles and Add Button Section --> + <Border Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15"> + <StackPanel Orientation="Vertical"> + <TextBlock Style="{StaticResource Header2}" + Text="Your chosen project - click to edit" + HorizontalAlignment="Left" /> + + <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled"> + <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10" HorizontalAlignment="Left"> + + <!-- Dynamische Anzeige der Projekte --> + <ItemsControl x:Name="ProjectItemsControl" HorizontalAlignment="Left"> + <ItemsControl.ItemsPanel> + <ItemsPanelTemplate> + <StackPanel Orientation="Horizontal"/> + <!-- Ändert die Anordnung auf horizontal --> + </ItemsPanelTemplate> + </ItemsControl.ItemsPanel> + <ItemsControl.ItemTemplate> + <DataTemplate> + <StackPanel Orientation="Vertical" Margin="0,0,30,0" VerticalAlignment="Center"> + <Button Click="Profile_Click" Background="Transparent" BorderThickness="0" Padding="0" Tag="{Binding Key}"> + <Border Width="80" Height="80" Background="LightBlue" CornerRadius="40"> + <Image Source="pack://application:,,,/Assets/profileicon.png" Stretch="Uniform" Margin="10"/> + </Border> + </Button> + <TextBlock FontWeight="Bold" Text="{Binding Value}" Foreground="White" FontSize="14" HorizontalAlignment="Center" Margin="0,5,0,0"/> + <Button Width="20" Height="20" Background="Transparent" BorderThickness="0" Click="EditProfile_Click" HorizontalAlignment="Center" ToolTip="Edit Profile" Margin="0,-195,-80,0"> + <Image Source="pack://application:,,,/Assets/pencilicon.png" Stretch="Uniform" /> + </Button> + </StackPanel> + </DataTemplate> + </ItemsControl.ItemTemplate> + </ItemsControl> + + <!-- Plus Button --> + <Border Width="50" Height="50" Background="Gray" CornerRadius="25" Margin="5,0,0,20"> + <Button Width="50" Height="50" Background="Transparent" BorderThickness="0" Click="AddProfile_Click" HorizontalAlignment="Center" VerticalAlignment="Center"> + <TextBlock Text="+" FontSize="24" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" Margin="0,-5,0,0"/> + </Button> + </Border> + </StackPanel> + </ScrollViewer> </StackPanel> - </StackPanel> - - - - - - </Border> + </Border> - <!-- Settings Section --> + <!-- Settings Section --> <Border Background="{StaticResource BACKGROUND_SECONDARY_BRUSH}" CornerRadius="10" Padding="15" Margin="0,20,0,0"> - <StackPanel> - <!-- Überschrift innerhalb des Hintergrunds --> - <TextBlock Style="{StaticResource Header2}" + <StackPanel> + <!-- Überschrift innerhalb des Hintergrunds --> + <TextBlock Style="{StaticResource Header2}" Text="Settings for this session" /> @@ -200,7 +198,7 @@ Width="70" MouseDown="TogglePopup4"> <StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="10"> <TextBlock Text="Distraction Mode" Foreground="White" FontSize="14" FontWeight="Bold" /> - + <Border Name="DropdownBorder" Background="{StaticResource HIGHLIGHT_PRIMARY_BRUSH}" CornerRadius="5" BorderThickness="1" BorderBrush="Black" Margin="0,5,0,0" Width="200" MouseDown="TogglePopup"> <Grid> @@ -256,13 +254,13 @@ Width="70" MouseDown="TogglePopup5" HorizontalAlignment="Left"> </WrapPanel> </StackPanel> - </Border> - <TextBlock Text="Optional: What do you want to focus on during this session? (Premium)" Foreground="Gray" FontSize="14" FontWeight="Bold" Margin="0,20,0,0"/> + </Border> + <TextBlock Text="Optional: What do you want to focus on during this session? (Premium)" Foreground="Gray" FontSize="14" FontWeight="Bold" Margin="0,20,0,0"/> - <!-- Input Field with Placeholder --> - <Grid Grid.Column="1" VerticalAlignment="Center" Margin="0,5,10,0"> - <TextBox x:Name="FocusTopicInputBox" + <!-- Input Field with Placeholder --> + <Grid Grid.Column="1" VerticalAlignment="Center" Margin="0,5,10,0"> + <TextBox x:Name="FocusTopicInputBox" VerticalAlignment="Center" Padding="5" FontSize="14" @@ -276,7 +274,7 @@ Background="Transparent" BorderBrush="Gray" BorderThickness="1" TextChanged="FocusTopicInputBox_TextChanged" /> - <TextBlock x:Name="FocusTopicPlaceholder" + <TextBlock x:Name="FocusTopicPlaceholder" Text="I want to focus on..." VerticalAlignment="Center" Foreground="Gray" @@ -284,8 +282,8 @@ TextChanged="FocusTopicInputBox_TextChanged" /> Padding="5" IsHitTestVisible="False" Margin="5,0,0,0" /> - </Grid> - <!-- Start Button --> + </Grid> + <!-- Start Button --> <Border Margin="0,20" Style="{StaticResource RoundedButtonBorder}" MouseDown="StartButton_Click"> <TextBlock Text="Start" Style="{StaticResource ButtonTextStyle}" /> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs index 24d8f6236e281be86a036d43683d0792914ce8e4..b1d4d7c24a18bafc16613ddac7d0e4b8a6aa051a 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml.cs @@ -1,5 +1,6 @@ using InnoLabProjektDektopApp.Screens.Regulaer; using InnoLabProjektDektopApp.Services; +using System.Collections.ObjectModel; using InnoLabProjektDektopApp.Services.WebSocketServer; using System.IO; using System.Net.Sockets; @@ -17,13 +18,16 @@ namespace InnoLabProjektDektopApp public partial class Overview : Page { // Aktuelles Profil, für das Einstellungen geladen werden sollen - private string profile = "profile1"; + private string project = "project1"; // Pfad zur JSON-Datei, in der die Einstellungen gespeichert sind private string SettingsFilePath; private static Session tmpSession = null; + // ObservableCollection, die die Projektnamen enthält + private ObservableCollection<KeyValuePair<string, string>> projectNames = new ObservableCollection<KeyValuePair<string, string>>(); + public Overview() { InitializeComponent(); @@ -32,13 +36,83 @@ namespace InnoLabProjektDektopApp this.SettingsFilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json"); // Einstellungen für das aktuelle Profil laden + LoadProjectNames(); LoadSettings(); + + // Die ProjectNames im UI an ItemsControl binden + ProjectItemsControl.ItemsSource = projectNames; } - public static Session getSession() { + public static Session getSession() + { return tmpSession; } + private List<string> projectNamesList = new List<string>(); // Liste der Projekt-Namen + + private void LoadProjectNames() + { + try + { + // JSON-Datei lesen + if (File.Exists(SettingsFilePath)) + { + string jsonContent = File.ReadAllText(SettingsFilePath); + var settings = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(jsonContent); + + if (settings != null) + { + // Alle Projekte durchgehen und den projectKey und displayName zur Liste hinzufügen + foreach (var projectKey in settings.Keys) + { + var projectSettings = settings[projectKey]; + + if (projectSettings.TryGetProperty("displayName", out var displayNameElement)) + { + string displayName = displayNameElement.GetString() ?? "Unbekannt"; + projectNames.Add(new KeyValuePair<string, string>(projectKey, displayName)); // projectKey und displayName speichern + } + } + } + } + } + catch (Exception ex) + { + Console.WriteLine($"Fehler beim Laden der Projekt-Namen: {ex.Message}"); + } + } + + + + private void Profile_Click(object sender, RoutedEventArgs e) + { + if (sender is Button button && button.Tag is string clickedProjectKey) + { + try + { + if (File.Exists(SettingsFilePath)) + { + string jsonContent = File.ReadAllText(SettingsFilePath); + var settings = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(jsonContent); + + if (settings != null && settings.ContainsKey(clickedProjectKey)) + { + project = clickedProjectKey; // Setze das aktive Projekt + LoadSettings(); // Lade die Einstellungen für das gewählte Projekt + MessageBox.Show($"Projekt gewechselt zu: {project}"); + } + } + } + catch (Exception ex) + { + MessageBox.Show($"Fehler beim Laden des Projekts: {ex.Message}"); + } + } + } + + + + // Methode, um die Einstellungen für das aktuelle Profil aus der JSON-Datei zu laden private void LoadSettings() { @@ -51,9 +125,9 @@ namespace InnoLabProjektDektopApp string jsonContent = File.ReadAllText(SettingsFilePath); var settings = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(jsonContent); - if (settings != null && settings.ContainsKey(profile)) + if (settings != null && settings.ContainsKey(project)) { - var profileSettings = settings[profile]; + var profileSettings = settings[project]; // Focus Period if (profileSettings.TryGetProperty("focusPeriod", out var focusPeriodElement)) @@ -114,7 +188,7 @@ namespace InnoLabProjektDektopApp } // Distraction Mode - + if (profileSettings.TryGetProperty("distractionMode", out var distractionModeElement)) { string distractionMode = distractionModeElement.GetString() ?? "Full-blocking mode"; @@ -136,7 +210,7 @@ namespace InnoLabProjektDektopApp // Zusätzliche ComboBox für Sekunden aktivieren, wenn Modus "seconds warning mode" ist if (distractionMode == "seconds warning mode") { - SecondsWarningPanel.Visibility = Visibility.Visible; + SecondsWarningPanel.Visibility = Visibility.Visible; } } @@ -211,7 +285,7 @@ namespace InnoLabProjektDektopApp } else { - MessageBox.Show($"No settings found for profile '{profile}'", "Info", MessageBoxButton.OK, MessageBoxImage.Information); + MessageBox.Show($"No settings found for profile '{project}'", "Info", MessageBoxButton.OK, MessageBoxImage.Information); } } else @@ -242,14 +316,15 @@ namespace InnoLabProjektDektopApp // Ereignis-Handler für den "Edit Profile"-Button private void EditProfile_Click(object sender, RoutedEventArgs e) { - var distractions = new Distractions(); - this.NavigationService.Navigate(distractions); + //var distractions = new Distractions(); + //this.NavigationService.Navigate(distractions); } // Ereignis-Handler für den "Add Profile"-Button private void AddProfile_Click(object sender, RoutedEventArgs e) { - MessageBox.Show("Add Profile clicked!"); + var settingsPage = new Settings(); + this.NavigationService.Navigate(settingsPage); } // Ereignis-Handler, um den Placeholder für das Textfeld anzuzeigen oder auszublenden @@ -268,7 +343,7 @@ namespace InnoLabProjektDektopApp // Ereignis-Handler für den "Start"-Button private void StartButton_Click(object sender, RoutedEventArgs e) { - + @@ -435,7 +510,8 @@ namespace InnoLabProjektDektopApp } } - public static Session getSessionInstance() { + public static Session getSessionInstance() + { return tmpSession; } @@ -547,7 +623,7 @@ namespace InnoLabProjektDektopApp } } - + diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs index 68348628017c56886961a584bd30ad06c18acf30..a109275665e942de8e6aac159db6f3d5d79271ff 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/Mascott.xaml.cs @@ -144,7 +144,7 @@ namespace InnoLabProjektDektopApp.Screens.Regulaer private bool mascottVisible() { - String profile = "profile1"; + String profile = "project1"; String SettingsFilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.json"); if (File.Exists(SettingsFilePath)) diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Utils/NotifyIconManager.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Utils/NotifyIconManager.cs index 5e2585d295847c8eb2e8975e51956169c11e8ac1..0d3b83b82b76480dd885a041e281a99a0c492003 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Utils/NotifyIconManager.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Utils/NotifyIconManager.cs @@ -230,7 +230,7 @@ namespace InnoLabProjektDektopApp.Utils { string jsonContent = File.ReadAllText(path); var settings = JsonSerializer.Deserialize<Dictionary<string, JsonElement>>(jsonContent); - if (settings != null && settings.TryGetValue("profile1", out JsonElement profileSettings)) + if (settings != null && settings.TryGetValue("project1", out JsonElement profileSettings)) { _settings.focusPeriod = int.Parse(profileSettings.GetProperty("focusPeriod").GetString().Replace(" minutes", "")); _settings.breakPeriod = int.Parse(profileSettings.GetProperty("breakPeriod").GetString().Replace(" minutes", ""));