diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_1DistractionsList.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_1DistractionsList.xaml.cs index 93fbd1f31938bb554fd97f5978b97767b564c286..21aa4e68c6c03cfa66c3f7fa344449fe3d0113c8 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_1DistractionsList.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_1DistractionsList.xaml.cs @@ -72,7 +72,27 @@ namespace InnoLabProjektDektopApp checkBox.Checked += CheckBox_CheckedChanged; checkBox.Unchecked += CheckBox_CheckedChanged; + var deleteButtonBorder = new Border + { + Style = (Style)Application.Current.Resources["RoundedButtonBorder"], + Child = new TextBlock + { + Text = "Delete", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + Foreground = (Brush)Application.Current.Resources["BACKGROUND_PRIMARY_BRUSH"], + FontWeight = FontWeights.Bold + }, + Margin = new Thickness(5, 0, 10, 0), + Cursor = Cursors.Hand, + Width = 50, + Height = 30, + CornerRadius = new CornerRadius(10) + }; + deleteButtonBorder.MouseDown += (s, e) => DeleteItemInList(item); + stackPanel.Children.Add(checkBox); + stackPanel.Children.Add(deleteButtonBorder); // Add the filtered StackPanel to ItemsPanel ItemsPanel.Children.Add(stackPanel); @@ -174,7 +194,27 @@ namespace InnoLabProjektDektopApp checkBox.Checked += CheckBox_CheckedChanged; checkBox.Unchecked += CheckBox_CheckedChanged; + var deleteButtonBorder = new Border + { + Style = (Style)Application.Current.Resources["RoundedButtonBorder"], + Child = new TextBlock + { + Text = "Delete", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + Foreground = (Brush)Application.Current.Resources["BACKGROUND_PRIMARY_BRUSH"], + FontWeight = FontWeights.Bold + }, + Margin = new Thickness(5, 0, 10, 0), + Cursor = Cursors.Hand, + Width = 50, + Height = 30, + CornerRadius = new CornerRadius(10) + }; + deleteButtonBorder.MouseDown += (s, e) => DeleteItemInList(item); + stackPanel.Children.Add(checkBox); + stackPanel.Children.Add(deleteButtonBorder); // Elemente zur Liste hinzufügen ItemsPanel.Children.Add(stackPanel); @@ -206,6 +246,23 @@ namespace InnoLabProjektDektopApp } } + private void DeleteItemInList(WebsiteEntry websiteEntry) + { + if (MessageBox.Show($"Are you sure you want to delete '{websiteEntry.Url}'?", "Delete Item", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) + { + // Remove the item from the list + _data[_category].Remove(websiteEntry); + // Save changes to the JSON + SaveData(); + // Remove the item from the UI + var itemStackPanel = ItemsPanel.Children.OfType<StackPanel>().FirstOrDefault(sp => sp.Children.OfType<CheckBox>().Any(cb => cb.Tag == websiteEntry)); + if (itemStackPanel != null) + { + ItemsPanel.Children.Remove(itemStackPanel); + } + } + } + private void SaveData() { try diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_2ProgramsList.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_2ProgramsList.xaml.cs index 3365b45992e236b642ac8b443b2de3be208d65a8..5660309a7e57f58e9a5a947296e85537cdef14b5 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_2ProgramsList.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/FirstLaunch/03_2ProgramsList.xaml.cs @@ -196,13 +196,13 @@ namespace InnoLabProjektDektopApp // Add to UI dynamically var newGrid = new Grid { Margin = new Thickness(5, 2, 5, 2) }; - // Zwei Spalten: 1. für CheckBox + Text, 2. für den Button + // Drei Spalten: 1. für CheckBox + Text, 2. für den Edit Button, 3. für den Delete Button newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); var newCheckBox = new CheckBox { - Margin = new Thickness(5), IsChecked = isDistracting, ToolTip = $"{mainWindowTitle} ({processName})", @@ -216,7 +216,6 @@ namespace InnoLabProjektDektopApp }; newCheckBox.Content = textBlock; - newCheckBox.Checked += CheckBox_CheckedChanged; newCheckBox.Unchecked += CheckBox_CheckedChanged; @@ -239,14 +238,35 @@ namespace InnoLabProjektDektopApp }; editButtonBorder.MouseDown += (s, e) => EditItemInList(processName, mainWindowTitle); - // Elemente ins Grid setzen + var deleteButtonBorder = new Border + { + Style = (Style)Application.Current.Resources["RoundedButtonBorder"], + Child = new TextBlock + { + Text = "Delete", + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + Foreground = (Brush)Application.Current.Resources["BACKGROUND_PRIMARY_BRUSH"], + FontWeight = FontWeights.Bold + }, + Margin = new Thickness(5, 0, 10, 0), + Cursor = Cursors.Hand, + Width = 50, + Height = 30, + CornerRadius = new CornerRadius(10) + }; + deleteButtonBorder.MouseDown += (s, e) => DeleteItemInList(processName); + + // Set elements in the Grid Grid.SetColumn(newCheckBox, 0); Grid.SetColumn(editButtonBorder, 1); + Grid.SetColumn(deleteButtonBorder, 2); newGrid.Children.Add(newCheckBox); newGrid.Children.Add(editButtonBorder); + newGrid.Children.Add(deleteButtonBorder); - // Element zum UI-Stack hinzufügen + // Add element to the UI stack ItemsPanel.Children.Add(newGrid); } @@ -262,6 +282,13 @@ namespace InnoLabProjektDektopApp RefreshProgramList(); } + private void DeleteItemInList(string processName) + { + _data["Programs"].RemoveAll(p => p.ProcessName.Equals(processName, StringComparison.CurrentCultureIgnoreCase)); + SaveData(); + RefreshProgramList(); + } + public void RefreshProgramList() { ItemsPanel.Children.Clear(); diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml index fae4acda6c1db8e5bc8e0b89ba48aa78dff0de1d..c9e1ebc39e3904dd0c1e77e4858295db6c9a909e 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/01Overview.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:InnoLabProjektDektopApp" xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" mc:Ignorable="d" + ShowsNavigationUI="True" Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> <ScrollViewer> <Grid VerticalAlignment="Center"> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml index d1ef418d0cb3147b78875c088ec9da35296de0f0..bead1c814f98b0f8b577481db79e747b41e3c554 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/02Session.xaml @@ -7,6 +7,7 @@ xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" mc:Ignorable="d" Unloaded="Page_Unloaded" + ShowsNavigationUI="False" Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> <Grid> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml index 272dba2997fe60bdc7e6d5f3de0b17df0e3dd105..3c2d7cdd2719d6583abc5c5507d6889aec5b06da 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml @@ -6,6 +6,6 @@ xmlns:local="clr-namespace:InnoLabProjektDektopApp" xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" mc:Ignorable="d" - Height="550" Width="900" ShowsNavigationUI="False"> + Height="550" Width="900"> </NavigationWindow> diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml.cs index 3457898ff59ed69e82d8331054979ab58877492d..6359cb32c305a63e1d7f2e458d1bfbc05d6e33dc 100644 --- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml.cs +++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Screens/Regulaer/03End.xaml.cs @@ -18,19 +18,8 @@ namespace InnoLabProjektDektopApp /// </summary> public partial class End : NavigationWindow { - public End(String sessionInfoJsonPath) + public End() { - // read the session info json file - string sessionInfoJson = File.ReadAllText(sessionInfoJsonPath); - dynamic sessionInfo = JsonNode.Parse(sessionInfoJson); - - DateTime sessionEndTime = sessionInfo["SessionEndTime"].GetValue<DateTime>(); - var cycleStartTimes = sessionInfo["cycleStartTimes"]; - int finalDistractionStage = sessionInfo["finalDistractionStage"].GetValue<int>(); - var processInfoList = sessionInfo["ProcessInfoList"].AsArray(); - var breakInfoList = sessionInfo["BreakInfoList"].AsArray(); - - InitializeComponent(); GlobalSettings.setDefaults(this);