Skip to content
Snippets Groups Projects
Commit 71af0d37 authored by Marcel Kehrberg's avatar Marcel Kehrberg
Browse files

Merge branch 'develop' of https://gitlab.reutlingen-university.de/borst/CoFlow into develop

parents e07c63f3 7bfcb80e
No related branches found
No related tags found
1 merge request!64Browser addon
...@@ -72,7 +72,27 @@ namespace InnoLabProjektDektopApp ...@@ -72,7 +72,27 @@ namespace InnoLabProjektDektopApp
checkBox.Checked += CheckBox_CheckedChanged; checkBox.Checked += CheckBox_CheckedChanged;
checkBox.Unchecked += 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(checkBox);
stackPanel.Children.Add(deleteButtonBorder);
// Add the filtered StackPanel to ItemsPanel // Add the filtered StackPanel to ItemsPanel
ItemsPanel.Children.Add(stackPanel); ItemsPanel.Children.Add(stackPanel);
...@@ -174,7 +194,27 @@ namespace InnoLabProjektDektopApp ...@@ -174,7 +194,27 @@ namespace InnoLabProjektDektopApp
checkBox.Checked += CheckBox_CheckedChanged; checkBox.Checked += CheckBox_CheckedChanged;
checkBox.Unchecked += 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(checkBox);
stackPanel.Children.Add(deleteButtonBorder);
// Elemente zur Liste hinzufügen // Elemente zur Liste hinzufügen
ItemsPanel.Children.Add(stackPanel); ItemsPanel.Children.Add(stackPanel);
...@@ -206,6 +246,23 @@ namespace InnoLabProjektDektopApp ...@@ -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() private void SaveData()
{ {
try try
... ...
......
...@@ -196,13 +196,13 @@ namespace InnoLabProjektDektopApp ...@@ -196,13 +196,13 @@ namespace InnoLabProjektDektopApp
// Add to UI dynamically // Add to UI dynamically
var newGrid = new Grid { Margin = new Thickness(5, 2, 5, 2) }; 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 = new GridLength(1, GridUnitType.Star) });
newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
newGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
var newCheckBox = new CheckBox var newCheckBox = new CheckBox
{ {
Margin = new Thickness(5), Margin = new Thickness(5),
IsChecked = isDistracting, IsChecked = isDistracting,
ToolTip = $"{mainWindowTitle} ({processName})", ToolTip = $"{mainWindowTitle} ({processName})",
...@@ -216,7 +216,6 @@ namespace InnoLabProjektDektopApp ...@@ -216,7 +216,6 @@ namespace InnoLabProjektDektopApp
}; };
newCheckBox.Content = textBlock; newCheckBox.Content = textBlock;
newCheckBox.Checked += CheckBox_CheckedChanged; newCheckBox.Checked += CheckBox_CheckedChanged;
newCheckBox.Unchecked += CheckBox_CheckedChanged; newCheckBox.Unchecked += CheckBox_CheckedChanged;
...@@ -239,14 +238,35 @@ namespace InnoLabProjektDektopApp ...@@ -239,14 +238,35 @@ namespace InnoLabProjektDektopApp
}; };
editButtonBorder.MouseDown += (s, e) => EditItemInList(processName, mainWindowTitle); 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(newCheckBox, 0);
Grid.SetColumn(editButtonBorder, 1); Grid.SetColumn(editButtonBorder, 1);
Grid.SetColumn(deleteButtonBorder, 2);
newGrid.Children.Add(newCheckBox); newGrid.Children.Add(newCheckBox);
newGrid.Children.Add(editButtonBorder); newGrid.Children.Add(editButtonBorder);
newGrid.Children.Add(deleteButtonBorder);
// Element zum UI-Stack hinzufügen // Add element to the UI stack
ItemsPanel.Children.Add(newGrid); ItemsPanel.Children.Add(newGrid);
} }
...@@ -262,6 +282,13 @@ namespace InnoLabProjektDektopApp ...@@ -262,6 +282,13 @@ namespace InnoLabProjektDektopApp
RefreshProgramList(); RefreshProgramList();
} }
private void DeleteItemInList(string processName)
{
_data["Programs"].RemoveAll(p => p.ProcessName.Equals(processName, StringComparison.CurrentCultureIgnoreCase));
SaveData();
RefreshProgramList();
}
public void RefreshProgramList() public void RefreshProgramList()
{ {
ItemsPanel.Children.Clear(); ItemsPanel.Children.Clear();
... ...
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
xmlns:local="clr-namespace:InnoLabProjektDektopApp" xmlns:local="clr-namespace:InnoLabProjektDektopApp"
xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates"
mc:Ignorable="d" mc:Ignorable="d"
ShowsNavigationUI="True"
Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}">
<ScrollViewer> <ScrollViewer>
<Grid VerticalAlignment="Center"> <Grid VerticalAlignment="Center">
... ...
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates"
mc:Ignorable="d" mc:Ignorable="d"
Unloaded="Page_Unloaded" Unloaded="Page_Unloaded"
ShowsNavigationUI="False"
Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}"> Background="{StaticResource BACKGROUND_PRIMARY_BRUSH}">
<Grid> <Grid>
... ...
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
xmlns:local="clr-namespace:InnoLabProjektDektopApp" xmlns:local="clr-namespace:InnoLabProjektDektopApp"
xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates" xmlns:header="clr-namespace:InnoLabProjektDektopApp.Screens.Templates"
mc:Ignorable="d" mc:Ignorable="d"
Height="550" Width="900" ShowsNavigationUI="False"> Height="550" Width="900">
</NavigationWindow> </NavigationWindow>
...@@ -18,19 +18,8 @@ namespace InnoLabProjektDektopApp ...@@ -18,19 +18,8 @@ namespace InnoLabProjektDektopApp
/// </summary> /// </summary>
public partial class End : NavigationWindow 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(); InitializeComponent();
GlobalSettings.setDefaults(this); GlobalSettings.setDefaults(this);
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment