mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-15 02:48:31 -05:00
More cleanup and fixes
This commit is contained in:
@@ -1,22 +1,13 @@
|
||||
using FeedCenter.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
public partial class OptionsWindow
|
||||
{
|
||||
#region Member variables
|
||||
|
||||
private readonly List<OptionsPanelBase> _optionPanels = new();
|
||||
|
||||
private readonly FeedCenterEntities _database = Database.Entities;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public OptionsWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -28,10 +19,6 @@ namespace FeedCenter.Options
|
||||
LoadCategories();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Category handling
|
||||
|
||||
private void AddCategories()
|
||||
{
|
||||
_optionPanels.Add(new GeneralOptionsPanel());
|
||||
@@ -47,7 +34,7 @@ namespace FeedCenter.Options
|
||||
foreach (var optionsPanel in _optionPanels)
|
||||
{
|
||||
// Tell the panel to load itself
|
||||
optionsPanel.LoadPanel(_database);
|
||||
optionsPanel.LoadPanel();
|
||||
|
||||
// Add the panel to the category ist
|
||||
CategoryListBox.Items.Add(new CategoryListItem(optionsPanel));
|
||||
@@ -72,10 +59,6 @@ namespace FeedCenter.Options
|
||||
SelectCategory(((CategoryListItem) CategoryListBox.SelectedItem).Panel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Category list item
|
||||
|
||||
private class CategoryListItem
|
||||
{
|
||||
public OptionsPanelBase Panel { get; }
|
||||
@@ -90,40 +73,5 @@ namespace FeedCenter.Options
|
||||
return Panel.CategoryName;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Loop over each panel and ask them to validate
|
||||
foreach (var optionsPanel in _optionPanels)
|
||||
{
|
||||
// If validation fails...
|
||||
if (!optionsPanel.ValidatePanel())
|
||||
{
|
||||
// ...select the right category
|
||||
SelectCategory(optionsPanel);
|
||||
|
||||
// Stop validation
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over each panel and ask them to save
|
||||
foreach (var optionsPanel in _optionPanels)
|
||||
{
|
||||
// Save!
|
||||
optionsPanel.SavePanel();
|
||||
}
|
||||
|
||||
// Save the actual settings
|
||||
_database.SaveChanges(() => { });
|
||||
Properties.Settings.Default.Save();
|
||||
|
||||
DialogResult = true;
|
||||
|
||||
// Close the window
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user