Update to EF6

This commit is contained in:
2014-07-14 17:38:14 -04:00
parent 7e3eedd844
commit 2f90035494
39 changed files with 2022 additions and 1944 deletions

View File

@@ -3,7 +3,7 @@ using System.Reflection;
namespace FeedCenter.Options
{
public partial class AboutOptionsPanel
public partial class AboutOptionsPanel
{
public AboutOptionsPanel()
{

View File

@@ -7,6 +7,7 @@
xmlns:my="clr-namespace:FeedCenter.Properties"
xmlns:Options="clr-namespace:FeedCenter.Options"
xmlns:LinkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
xmlns:feedCenter="clr-namespace:FeedCenter"
WindowStartupLocation="CenterOwner"
Icon="/FeedCenter;component/Resources/Application.ico"
FocusManager.FocusedElement="{Binding ElementName=feedLinkFilterText}">
@@ -97,9 +98,9 @@
ToolTip="{x:Static my:Resources.DisableHint}"
IsEnabled="False">
<ComboBoxItem Content="{x:Static my:Resources.openAllMultipleToolbarButton}"
Tag="{x:Static Options:MultipleOpenAction.IndividualPages}" />
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" />
<ComboBoxItem Content="{x:Static my:Resources.openAllSingleToolbarButton}"
Tag="{x:Static Options:MultipleOpenAction.SinglePage}" />
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" />
</ComboBox>
</Grid>
<Button Content="{x:Static my:Resources.OkayButton}"

View File

@@ -1,12 +1,11 @@
using System.Collections.Generic;
using Common.Wpf;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Common.Wpf;
namespace FeedCenter.Options
{
public partial class BulkFeedWindow
@@ -39,9 +38,9 @@ namespace FeedCenter.Options
void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
{
CheckedListItem<Feed> checkedListBoxItem = (CheckedListItem<Feed>) e.Item;
var checkedListBoxItem = (CheckedListItem<Feed>) e.Item;
Feed feed = checkedListBoxItem.Item;
var feed = checkedListBoxItem.Item;
e.Accepted = feed.Link.Contains(feedLinkFilterText.Text);
}
@@ -56,7 +55,7 @@ namespace FeedCenter.Options
foreach (var item in _checkedListBoxItems.Where(i => i.IsChecked))
{
if (openComboBox.IsEnabled)
item.Item.MultipleOpenAction = (int) ((ComboBoxItem) openComboBox.SelectedItem).Tag;
item.Item.MultipleOpenAction = (MultipleOpenAction) ((ComboBoxItem) openComboBox.SelectedItem).Tag;
}
DialogResult = true;

View File

@@ -1,8 +1,7 @@
using System.Linq;
using FeedCenter.Properties;
using System.Linq;
using System.Windows.Controls;
using FeedCenter.Properties;
namespace FeedCenter.Options
{
public partial class DisplayOptionsPanel
@@ -35,13 +34,11 @@ namespace FeedCenter.Options
if (displayEmptyFeedsCheckBox.IsChecked.HasValue && Settings.Default.DisplayEmptyFeeds != displayEmptyFeedsCheckBox.IsChecked.Value)
Settings.Default.DisplayEmptyFeeds = displayEmptyFeedsCheckBox.IsChecked.Value;
Dock dock = (Dock) ((ComboBoxItem) toolbarLocationComboBox.SelectedItem).Tag;
if (Settings.Default.ToolbarLocation != dock)
Settings.Default.ToolbarLocation = dock;
var dock = (Dock) ((ComboBoxItem) toolbarLocationComboBox.SelectedItem).Tag;
Settings.Default.ToolbarLocation = dock;
MultipleLineDisplay multipleLineDisplay = (MultipleLineDisplay) ((ComboBoxItem) multipleLineDisplayComboBox.SelectedItem).Tag;
if (Settings.Default.MultipleLineDisplay != multipleLineDisplay)
Settings.Default.MultipleLineDisplay = multipleLineDisplay;
var multipleLineDisplay = (MultipleLineDisplay) ((ComboBoxItem) multipleLineDisplayComboBox.SelectedItem).Tag;
Settings.Default.MultipleLineDisplay = multipleLineDisplay;
}
public override string CategoryName

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Properties="clr-namespace:FeedCenter.Properties"
xmlns:Options="clr-namespace:FeedCenter.Options"
xmlns:feedCenter="clr-namespace:FeedCenter"
Title="FeedWindow"
Height="300"
Width="450"
@@ -10,7 +10,7 @@
Icon="/FeedCenter;component/Resources/Application.ico"
FocusManager.FocusedElement="{Binding ElementName=urlTextBox}">
<Window.Resources>
<Options:MultipleOpenActionConverter x:Key="multipleOpenActionConverter" />
<feedCenter:MultipleOpenActionConverter x:Key="multipleOpenActionConverter" />
</Window.Resources>
<Grid Name="mainGrid">
<TabControl Name="optionsTabControl"
@@ -116,9 +116,9 @@
Margin="6">
<ComboBoxItem Content="{x:Static Properties:Resources.openAllSingleToolbarButton}"
Tag="{x:Static Options:MultipleOpenAction.SinglePage}" />
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" />
<ComboBoxItem Content="{x:Static Properties:Resources.openAllMultipleToolbarButton}"
Tag="{x:Static Options:MultipleOpenAction.IndividualPages}" />
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" />
</ComboBox>
</Grid>
</TabItem>

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Microsoft.Win32;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
@@ -6,7 +7,6 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Xml;
using Microsoft.Win32;
namespace FeedCenter.Options
{
@@ -27,7 +27,7 @@ namespace FeedCenter.Options
{
base.LoadPanel(database);
CollectionViewSource collectionViewSource = new CollectionViewSource { Source = Database.AllCategories };
var collectionViewSource = new CollectionViewSource { Source = Database.AllCategories };
collectionViewSource.SortDescriptions.Add(new SortDescription("SortKey", ListSortDirection.Ascending));
collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
@@ -61,15 +61,15 @@ namespace FeedCenter.Options
private void AddFeed()
{
Feed feed = new Feed();
var feed = Feed.Create();
FeedWindow feedWindow = new FeedWindow();
var feedWindow = new FeedWindow();
bool? result = feedWindow.Display(Database, feed, Window.GetWindow(this));
var result = feedWindow.Display(Database, feed, Window.GetWindow(this));
if (result.HasValue && result.Value)
{
Database.Feeds.AddObject(feed);
Database.Feeds.Add(feed);
feedListBox.SelectedItem = feed;
@@ -82,18 +82,18 @@ namespace FeedCenter.Options
if (feedListBox.SelectedItem == null)
return;
Feed feed = (Feed) feedListBox.SelectedItem;
var feed = (Feed) feedListBox.SelectedItem;
FeedWindow feedWindow = new FeedWindow();
var feedWindow = new FeedWindow();
feedWindow.Display(Database, feed, Window.GetWindow(this));
}
private void DeleteSelectedFeed()
{
Feed feed = (Feed) feedListBox.SelectedItem;
var feed = (Feed) feedListBox.SelectedItem;
Database.Feeds.DeleteObject(feed);
Database.Feeds.Remove(feed);
SetFeedButtonStates();
}
@@ -134,20 +134,20 @@ namespace FeedCenter.Options
private void ExportFeeds()
{
// Setup the save file dialog
SaveFileDialog saveFileDialog = new SaveFileDialog
var saveFileDialog = new SaveFileDialog
{
Filter = Properties.Resources.ImportExportFilter,
FilterIndex = 0,
OverwritePrompt = true
};
bool? result = saveFileDialog.ShowDialog();
var result = saveFileDialog.ShowDialog();
if (!result.Value)
if (!result.GetValueOrDefault(false))
return;
// Setup the writer settings
XmlWriterSettings writerSettings = new XmlWriterSettings
var writerSettings = new XmlWriterSettings
{
Indent = true,
CheckCharacters = true,
@@ -155,7 +155,7 @@ namespace FeedCenter.Options
};
// Create an XML writer for the file chosen
XmlWriter xmlWriter = XmlWriter.Create(saveFileDialog.FileName, writerSettings);
var xmlWriter = XmlWriter.Create(saveFileDialog.FileName, writerSettings);
// Start the opml element
xmlWriter.WriteStartElement("opml");
@@ -164,7 +164,7 @@ namespace FeedCenter.Options
xmlWriter.WriteStartElement("body");
// Loop over each feed
foreach (Feed feed in Database.Feeds.OrderBy(feed => feed.Name))
foreach (var feed in Database.Feeds.OrderBy(feed => feed.Name))
{
// Start the outline element
xmlWriter.WriteStartElement("outline");
@@ -196,22 +196,22 @@ namespace FeedCenter.Options
private void ImportFeeds()
{
// Setup the open file dialog
OpenFileDialog openFileDialog = new OpenFileDialog
var openFileDialog = new OpenFileDialog
{
Filter = Properties.Resources.ImportExportFilter,
FilterIndex = 0
};
bool? result = openFileDialog.ShowDialog();
var result = openFileDialog.ShowDialog();
if (!result.Value)
if (!result.GetValueOrDefault(false))
return;
// Setup the reader settings
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true };
var xmlReaderSettings = new XmlReaderSettings { IgnoreWhitespace = true };
// Create an XML reader for the file chosen
XmlReader xmlReader = XmlReader.Create(openFileDialog.FileName, xmlReaderSettings);
var xmlReader = XmlReader.Create(openFileDialog.FileName, xmlReaderSettings);
try
{
@@ -228,7 +228,8 @@ namespace FeedCenter.Options
while (xmlReader.NodeType != XmlNodeType.EndElement)
{
// Create a new feed
Feed feed = new Feed { Category = Database.Categories.ToList().First(c => c.IsDefault) };
var feed = Feed.Create();
feed.Category = Database.Categories.ToList().First(c => c.IsDefault);
// Loop over all attributes
while (xmlReader.MoveToNextAttribute())
@@ -259,7 +260,7 @@ namespace FeedCenter.Options
feed.Name = feed.Title;
// Add the feed to the main list
Database.Feeds.AddObject(feed);
Database.Feeds.Add(feed);
// Move back to the element node
xmlReader.MoveToElement();
@@ -293,15 +294,15 @@ namespace FeedCenter.Options
private void AddCategory()
{
Category category = new Category();
var category = Category.Create();
CategoryWindow categoryWindow = new CategoryWindow();
var categoryWindow = new CategoryWindow();
bool? result = categoryWindow.Display(category, Window.GetWindow(this));
var result = categoryWindow.Display(category, Window.GetWindow(this));
if (result.HasValue && result.Value)
{
Database.Categories.AddObject(category);
Database.Categories.Add(category);
categoryListBox.SelectedItem = category;
@@ -314,18 +315,18 @@ namespace FeedCenter.Options
if (categoryListBox.SelectedItem == null)
return;
Category category = (Category) categoryListBox.SelectedItem;
var category = (Category) categoryListBox.SelectedItem;
CategoryWindow categoryWindow = new CategoryWindow();
var categoryWindow = new CategoryWindow();
categoryWindow.Display(category, Window.GetWindow(this));
}
private void DeleteSelectedCategory()
{
Category category = (Category) categoryListBox.SelectedItem;
var category = (Category) categoryListBox.SelectedItem;
Database.Categories.DeleteObject(category);
Database.Categories.Remove(category);
SetCategoryButtonStates();
}
@@ -357,14 +358,14 @@ namespace FeedCenter.Options
{
if (_collectionViewSource == null)
{
_collectionViewSource = new CollectionViewSource {Source = Database.AllFeeds};
_collectionViewSource = new CollectionViewSource { Source = Database.AllFeeds };
_collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
_collectionViewSource.Filter += HandleCollectionViewSourceFilter;
feedListBox.ItemsSource = _collectionViewSource.View;
}
_collectionViewSource.View.Refresh();
_collectionViewSource.View.Refresh();
if (feedListBox.Items.Count > 0)
feedListBox.SelectedIndex = 0;
@@ -374,20 +375,20 @@ namespace FeedCenter.Options
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
{
Category selectedCategory = (Category) categoryListBox.SelectedItem;
var selectedCategory = (Category) categoryListBox.SelectedItem;
Feed feed = (Feed) e.Item;
var feed = (Feed) e.Item;
e.Accepted = (feed.Category == selectedCategory);
}
private void HandleTextBlockDrop(object sender, DragEventArgs e)
{
List<Feed> feedList = (List<Feed>) e.Data.GetData(typeof(List<Feed>));
var feedList = (List<Feed>) e.Data.GetData(typeof(List<Feed>));
Category category = (Category) ((DataGridRow) sender).Item;
var category = (Category) ((DataGridRow) sender).Item;
foreach (Feed feed in feedList)
foreach (var feed in feedList)
feed.Category = category;
_collectionViewSource.View.Refresh();
@@ -399,7 +400,7 @@ namespace FeedCenter.Options
{
if (e.LeftButton == MouseButtonState.Pressed)
{
List<Feed> selectedItems = feedListBox.SelectedItems.Cast<Feed>().ToList();
var selectedItems = feedListBox.SelectedItems.Cast<Feed>().ToList();
DragDrop.DoDragDrop(feedListBox, selectedItems, DragDropEffects.Move);
}
@@ -407,14 +408,14 @@ namespace FeedCenter.Options
private void HandleTextBlockDragEnter(object sender, DragEventArgs e)
{
DataGridRow dataGridRow = (DataGridRow) sender;
var dataGridRow = (DataGridRow) sender;
dataGridRow.FontWeight = FontWeights.Bold;
}
private void HandleTextBlockDragLeave(object sender, DragEventArgs e)
{
DataGridRow dataGridRow = (DataGridRow) sender;
var dataGridRow = (DataGridRow) sender;
dataGridRow.FontWeight = FontWeights.Normal;
}
@@ -426,7 +427,7 @@ namespace FeedCenter.Options
private void HandleMultipleEditClick(object sender, RoutedEventArgs e)
{
BulkFeedWindow bulkFeedWindow = new BulkFeedWindow();
var bulkFeedWindow = new BulkFeedWindow();
bulkFeedWindow.Display(Window.GetWindow(this), Database);
}
}

View File

@@ -1,8 +1,4 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace FeedCenter.Options
namespace FeedCenter.Options
{
public enum MultipleLineDisplay
{
@@ -10,24 +6,4 @@ namespace FeedCenter.Options
SingleLine,
FirstLine
}
public enum MultipleOpenAction
{
IndividualPages,
SinglePage
}
[ValueConversion(typeof(int), typeof(MultipleOpenAction))]
public class MultipleOpenActionConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (MultipleOpenAction) value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int) value;
}
}
}

View File

@@ -1,6 +1,6 @@
namespace FeedCenter.Options
{
public partial class UpdateOptionsPanel
public partial class UpdateOptionsPanel
{
public UpdateOptionsPanel()
{