mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-17 02:51:37 -05:00
Disallow edit and delete of default category
This commit is contained in:
@@ -290,8 +290,8 @@ namespace FeedCenter.Options
|
|||||||
private void SetCategoryButtonStates()
|
private void SetCategoryButtonStates()
|
||||||
{
|
{
|
||||||
AddCategoryButton.IsEnabled = true;
|
AddCategoryButton.IsEnabled = true;
|
||||||
EditCategoryButton.IsEnabled = (CategoryListBox.SelectedItem != null);
|
EditCategoryButton.IsEnabled = (CategoryListBox.SelectedItem != null && CategoryListBox.SelectedItem != Database.DefaultCategory);
|
||||||
DeleteCategoryButton.IsEnabled = (CategoryListBox.SelectedItem != null);
|
DeleteCategoryButton.IsEnabled = (CategoryListBox.SelectedItem != null && CategoryListBox.SelectedItem != Database.DefaultCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddCategory()
|
private void AddCategory()
|
||||||
@@ -326,8 +326,19 @@ namespace FeedCenter.Options
|
|||||||
|
|
||||||
private void DeleteSelectedCategory()
|
private void DeleteSelectedCategory()
|
||||||
{
|
{
|
||||||
|
var defaultCategory = Database.DefaultCategory;
|
||||||
|
|
||||||
var category = (Category) CategoryListBox.SelectedItem;
|
var category = (Category) CategoryListBox.SelectedItem;
|
||||||
|
|
||||||
|
category.Feeds.ToList().ForEach(feed => feed.Category = defaultCategory);
|
||||||
|
|
||||||
|
var index = CategoryListBox.SelectedIndex;
|
||||||
|
|
||||||
|
if (index == CategoryListBox.Items.Count - 1)
|
||||||
|
CategoryListBox.SelectedIndex = index - 1;
|
||||||
|
else
|
||||||
|
CategoryListBox.SelectedIndex = index + 1;
|
||||||
|
|
||||||
Database.Categories.Remove(category);
|
Database.Categories.Remove(category);
|
||||||
|
|
||||||
SetCategoryButtonStates();
|
SetCategoryButtonStates();
|
||||||
@@ -373,6 +384,7 @@ namespace FeedCenter.Options
|
|||||||
FeedListBox.SelectedIndex = 0;
|
FeedListBox.SelectedIndex = 0;
|
||||||
|
|
||||||
SetFeedButtonStates();
|
SetFeedButtonStates();
|
||||||
|
SetCategoryButtonStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user