Remove feed reading async code

Update to new binding expression code on options dialog
Update to .NET framework 4.5.1
This commit is contained in:
2014-07-11 20:40:47 -04:00
parent 6cdc334d53
commit 7e3eedd844
8 changed files with 63 additions and 83 deletions

View File

@@ -1,11 +1,9 @@
using System.Collections.Generic;
using Common.Wpf.Extensions;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using Common.Wpf.Extensions;
namespace FeedCenter.Options
{
public partial class CategoryWindow
@@ -33,25 +31,22 @@ namespace FeedCenter.Options
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
{
// Get a list of all explicit binding expressions
Dictionary<FrameworkElement, BindingExpression> bindingExpressionDictionary = this.GetExplicitBindingExpressions();
// Get the values as a list
List<BindingExpression> bindingExpressions = bindingExpressionDictionary.Values.ToList();
var bindingExpressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
// Loop over each binding expression and clear any existing error
bindingExpressions.ForEach(Validation.ClearInvalid);
bindingExpressions.ForEach(b => Validation.ClearInvalid(b.BindingExpression));
// Force all explicit bindings to update the source
bindingExpressions.ForEach(bindingExpression => bindingExpression.UpdateSource());
bindingExpressions.ForEach(bindingExpression => bindingExpression.BindingExpression.UpdateSource());
// See if there are any errors
bool hasError = bindingExpressions.Exists(bindingExpression => bindingExpression.HasError);
var hasError = bindingExpressions.Exists(bindingExpression => bindingExpression.BindingExpression.HasError);
// If there was an error then set focus to the bad controls
if (hasError)
{
// Get the first framework element with an error
FrameworkElement firstErrorElement = bindingExpressionDictionary.First(pair => pair.Value.HasError).Key;
var firstErrorElement = bindingExpressions.First(b => b.BindingExpression.HasError).FrameworkElement;
// Set focus
firstErrorElement.Focus();

View File

@@ -1,12 +1,10 @@
using System.Collections.Generic;
using Common.Wpf.Extensions;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using Common.Wpf.Extensions;
namespace FeedCenter.Options
{
public partial class FeedWindow
@@ -36,11 +34,8 @@ namespace FeedCenter.Options
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
{
// Get a dictionary of all framework elements and explicit binding expressions
Dictionary<FrameworkElement, BindingExpression> bindingExpressionDictionary = this.GetExplicitBindingExpressions();
// Get just the binding expressions
var bindingExpressions = bindingExpressionDictionary.Values;
// Get a list of all framework elements and explicit binding expressions
var bindingExpressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
// Loop over each binding expression and clear any existing error
this.ClearAllValidationErrors(bindingExpressions);
@@ -49,19 +44,19 @@ namespace FeedCenter.Options
this.UpdateAllSources(bindingExpressions);
// See if there are any errors
bool hasError = bindingExpressions.Any(b => b.HasError);
var hasError = bindingExpressions.Any(b => b.BindingExpression.HasError);
// If there was an error then set focus to the bad controls
if (hasError)
{
// Get the first framework element with an error
FrameworkElement firstErrorElement = bindingExpressionDictionary.First(pair => pair.Value.HasError).Key;
var firstErrorElement = bindingExpressions.First(b => b.BindingExpression.HasError).FrameworkElement;
// Loop over each tab item
foreach (TabItem tabItem in optionsTabControl.Items)
{
// Cast the content as visual
Visual content = (Visual) tabItem.Content;
var content = (Visual) tabItem.Content;
// See if the control with the error is a descendant
if (firstErrorElement.IsDescendantOf(content))

View File

@@ -1,7 +1,7 @@
using System.Windows.Controls;
using Common.Internet;
using Common.Internet;
using Common.Wpf.Extensions;
using System.Windows.Controls;
using System.Windows.Data;
namespace FeedCenter.Options
{
@@ -30,11 +30,12 @@ namespace FeedCenter.Options
{
var settings = Properties.Settings.Default;
string browser = (string) ((ComboBoxItem) browserComboBox.SelectedItem).Tag;
if (settings.Browser != browser)
settings.Browser = browser;
var browser = (string) ((ComboBoxItem) browserComboBox.SelectedItem).Tag;
this.UpdateAllSources();
settings.Browser = browser;
var expressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
this.UpdateAllSources(expressions);
}
public override string CategoryName
@@ -51,7 +52,7 @@ namespace FeedCenter.Options
var browsers = Browser.DetectInstalledBrowsers();
foreach (var browser in browsers)
{
ComboBoxItem item = new ComboBoxItem { Content = browser.Value.Name, Tag = browser.Key };
var item = new ComboBoxItem { Content = browser.Value.Name, Tag = browser.Key };
comboBox.Items.Add(item);