Skip to content
Snippets Groups Projects

Delete option, Navbar fix

6 files
+ 93
18
Compare changes
  • Side-by-side
  • Inline

Files

@@ -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
Loading