mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-16 10:58:31 -05:00
Start modernization
This commit is contained in:
@@ -16,7 +16,7 @@ namespace FeedCenter.Options
|
||||
|
||||
ApplicationNameLabel.Text = Properties.Resources.ApplicationDisplayName;
|
||||
|
||||
string version = UpdateCheck.LocalVersion.ToString();
|
||||
var version = UpdateCheck.LocalVersion.ToString();
|
||||
VersionLabel.Text = string.Format(Properties.Resources.Version, version);
|
||||
|
||||
CompanyLabel.Text = ((AssemblyCompanyAttribute) Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace FeedCenter.Options
|
||||
{
|
||||
_checkedListBoxItems = new List<CheckedListItem<Feed>>();
|
||||
|
||||
foreach (var feed in database.AllFeeds)
|
||||
foreach (var feed in database.Feeds)
|
||||
_checkedListBoxItems.Add(new CheckedListItem<Feed> { Item = feed });
|
||||
|
||||
_collectionViewSource = new CollectionViewSource { Source = _checkedListBoxItems };
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:properties="clr-namespace:FeedCenter.Properties"
|
||||
xmlns:feedCenter="clr-namespace:FeedCenter"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
d:DataContext="{d:DesignInstance Type=feedCenter:Feed}"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:validation="clr-namespace:Common.Wpf.Validation;assembly=Common.Wpf"
|
||||
mc:Ignorable="d"
|
||||
Title="FeedWindow"
|
||||
Height="300"
|
||||
Width="450"
|
||||
@@ -33,8 +38,15 @@
|
||||
<TextBox Name="UrlTextBox"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Text="{Binding Path=Source, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}"
|
||||
Margin="6" />
|
||||
Margin="6">
|
||||
<TextBox.Text>
|
||||
<Binding Path="Source" UpdateSourceTrigger="Explicit" ValidatesOnExceptions="True">
|
||||
<Binding.ValidationRules>
|
||||
<validation:RequiredValidationRule></validation:RequiredValidationRule>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<Label Content="{x:Static properties:Resources.feedNameLabel}"
|
||||
VerticalContentAlignment="Center"
|
||||
Target="{Binding ElementName=NameTextBox}"
|
||||
@@ -44,9 +56,16 @@
|
||||
Padding="0" />
|
||||
<TextBox Name="NameTextBox"
|
||||
Grid.Column="1"
|
||||
Text="{Binding Path=Name, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=true}"
|
||||
Grid.Row="1"
|
||||
Margin="6" />
|
||||
Margin="6">
|
||||
<TextBox.Text>
|
||||
<Binding Path="Name" UpdateSourceTrigger="Explicit" ValidatesOnExceptions="True">
|
||||
<Binding.ValidationRules>
|
||||
<validation:RequiredValidationRule></validation:RequiredValidationRule>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<Label Content="{x:Static properties:Resources.feedCategoryLabel}"
|
||||
Target="{Binding ElementName=CategoryComboBox}"
|
||||
VerticalContentAlignment="Center"
|
||||
@@ -58,10 +77,9 @@
|
||||
Name="CategoryComboBox"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="ID"
|
||||
SelectedValue="{Binding Path=Category.ID}"
|
||||
SelectedValue="{Binding Path=Category.Id}"
|
||||
Grid.Row="2"
|
||||
Margin="6" />
|
||||
|
||||
<CheckBox Grid.ColumnSpan="2"
|
||||
Grid.Column="0"
|
||||
Name="ReadIntervalCheckBox"
|
||||
@@ -109,7 +127,6 @@
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Margin="6">
|
||||
|
||||
<ComboBoxItem Content="{x:Static properties:Resources.openAllSingleToolbarButton}"
|
||||
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" />
|
||||
<ComboBoxItem Content="{x:Static properties:Resources.openAllMultipleToolbarButton}"
|
||||
@@ -145,11 +162,18 @@
|
||||
Margin="6"
|
||||
Padding="20,0,0,0" />
|
||||
<TextBox Name="AuthenticationUserNameTextBox"
|
||||
Text="{Binding Path=Username, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}"
|
||||
Grid.Column="1"
|
||||
IsEnabled="{Binding ElementName=RequiresAuthenticationCheckBox, Path=IsChecked}"
|
||||
Grid.Row="1"
|
||||
Margin="6" />
|
||||
Margin="6">
|
||||
<TextBox.Text>
|
||||
<Binding Path="Username" UpdateSourceTrigger="Explicit" ValidatesOnExceptions="True">
|
||||
<Binding.ValidationRules>
|
||||
<validation:RequiredValidationRule></validation:RequiredValidationRule>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<Label Content="{x:Static properties:Resources.authenticationPasswordLabel}"
|
||||
Target="{Binding ElementName=AuthenticationPasswordTextBox}"
|
||||
VerticalContentAlignment="Center"
|
||||
@@ -182,4 +206,4 @@
|
||||
IsCancel="True"
|
||||
Margin="0,0,12,12" />
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Data.Entity;
|
||||
using Common.Wpf.Extensions;
|
||||
using Common.Wpf.Extensions;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -17,10 +16,8 @@ namespace FeedCenter.Options
|
||||
|
||||
public bool? Display(FeedCenterEntities database, Feed feed, Window owner)
|
||||
{
|
||||
database.Categories.Load();
|
||||
|
||||
// Bind the category combo box
|
||||
CategoryComboBox.ItemsSource = database.Categories.Local;
|
||||
CategoryComboBox.ItemsSource = database.Categories;
|
||||
|
||||
// Set the data context
|
||||
DataContext = feed;
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Xml;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
@@ -28,7 +27,7 @@ namespace FeedCenter.Options
|
||||
{
|
||||
base.LoadPanel(database);
|
||||
|
||||
var collectionViewSource = new CollectionViewSource { Source = Database.AllCategories };
|
||||
var collectionViewSource = new CollectionViewSource { Source = Database.Categories };
|
||||
collectionViewSource.SortDescriptions.Add(new SortDescription("SortKey", ListSortDirection.Ascending));
|
||||
collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
|
||||
|
||||
@@ -304,7 +303,7 @@ namespace FeedCenter.Options
|
||||
|
||||
if (result.HasValue && result.Value)
|
||||
{
|
||||
Database.Categories.Add(category);
|
||||
Database.SaveChanges(() => Database.Categories.Add(category));
|
||||
|
||||
CategoryListBox.SelectedItem = category;
|
||||
|
||||
@@ -330,7 +329,7 @@ namespace FeedCenter.Options
|
||||
|
||||
var category = (Category) CategoryListBox.SelectedItem;
|
||||
|
||||
category.Feeds.ToList().ForEach(feed => feed.Category = defaultCategory);
|
||||
category.Feeds?.ToList().ForEach(feed => feed.Category = defaultCategory);
|
||||
|
||||
var index = CategoryListBox.SelectedIndex;
|
||||
|
||||
@@ -339,7 +338,7 @@ namespace FeedCenter.Options
|
||||
else
|
||||
CategoryListBox.SelectedIndex = index + 1;
|
||||
|
||||
Database.Categories.Remove(category);
|
||||
Database.SaveChanges(() => Database.Categories.Remove(category));
|
||||
|
||||
SetCategoryButtonStates();
|
||||
}
|
||||
@@ -371,7 +370,7 @@ namespace FeedCenter.Options
|
||||
{
|
||||
if (_collectionViewSource == null)
|
||||
{
|
||||
_collectionViewSource = new CollectionViewSource { Source = Database.AllFeeds };
|
||||
_collectionViewSource = new CollectionViewSource { Source = Database.Feeds };
|
||||
_collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
|
||||
_collectionViewSource.Filter += HandleCollectionViewSourceFilter;
|
||||
|
||||
@@ -393,7 +392,7 @@ namespace FeedCenter.Options
|
||||
|
||||
var feed = (Feed) e.Item;
|
||||
|
||||
e.Accepted = (feed.Category.ID == selectedCategory.ID);
|
||||
e.Accepted = (feed.Category.Id == selectedCategory.Id);
|
||||
}
|
||||
|
||||
private void HandleTextBlockDrop(object sender, DragEventArgs e)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using FeedCenter.Data;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
@@ -10,7 +11,7 @@ namespace FeedCenter.Options
|
||||
|
||||
private readonly List<OptionsPanelBase> _optionPanels = new List<OptionsPanelBase>();
|
||||
|
||||
private readonly FeedCenterEntities _database = new FeedCenterEntities();
|
||||
private readonly FeedCenterEntities _database = Database.Entities;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -43,7 +44,7 @@ namespace FeedCenter.Options
|
||||
private void LoadCategories()
|
||||
{
|
||||
// Loop over each panel
|
||||
foreach (OptionsPanelBase optionsPanel in _optionPanels)
|
||||
foreach (var optionsPanel in _optionPanels)
|
||||
{
|
||||
// Tell the panel to load itself
|
||||
optionsPanel.LoadPanel(_database);
|
||||
@@ -95,7 +96,7 @@ namespace FeedCenter.Options
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Loop over each panel and ask them to validate
|
||||
foreach (OptionsPanelBase optionsPanel in _optionPanels)
|
||||
foreach (var optionsPanel in _optionPanels)
|
||||
{
|
||||
// If validation fails...
|
||||
if (!optionsPanel.ValidatePanel())
|
||||
@@ -109,14 +110,14 @@ namespace FeedCenter.Options
|
||||
}
|
||||
|
||||
// Loop over each panel and ask them to save
|
||||
foreach (OptionsPanelBase optionsPanel in _optionPanels)
|
||||
foreach (var optionsPanel in _optionPanels)
|
||||
{
|
||||
// Save!
|
||||
optionsPanel.SavePanel();
|
||||
}
|
||||
|
||||
// Save the actual settings
|
||||
_database.SaveChanges();
|
||||
_database.SaveChanges(() => { });
|
||||
Properties.Settings.Default.Save();
|
||||
|
||||
DialogResult = true;
|
||||
|
||||
14
Application/Options/Setting.cs
Normal file
14
Application/Options/Setting.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Realms;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
public class Setting : RealmObject
|
||||
{
|
||||
[PrimaryKey]
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
|
||||
[Ignored]
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user