More UI updates and cleanup

This commit is contained in:
2023-04-26 21:57:19 -04:00
parent edd01cc052
commit 7638d9c2c7
20 changed files with 225 additions and 273 deletions

View File

@@ -185,10 +185,7 @@ public static class LegacyDatabase
{
foreach (var category in categories)
{
if (category.Name == Category.DefaultName)
category.IsDefault = true;
category.Feeds = feeds.Where(f => f.CategoryId == category.Id).ToList();
category.IsDefault = category.Name == Category.DefaultName;
}
foreach (var feed in feeds)

View File

@@ -101,5 +101,6 @@
xcopy /s /y /i "$(PkgMicrosoft_SqlServer_Compact)\NativeBinaries\amd64\*.*" "$(TargetDir)amd64"
</PostBuildEvent>
<ApplicationIcon>Resources\Application.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
</Project>

View File

@@ -5,34 +5,15 @@ using System.Xml;
namespace FeedCenter.FeedParsers;
[Serializable]
internal class InvalidFeedFormatException : ApplicationException
{
internal InvalidFeedFormatException(Exception exception)
: base(string.Empty, exception)
{
}
}
internal abstract class FeedParserBase
{
#region Member variables
protected readonly Feed Feed;
#endregion
#region Constructor
protected FeedParserBase(Feed feed)
{
Feed = feed;
}
#endregion
#region Methods
public abstract FeedReadResult ParseFeed(string feedText);
protected abstract FeedItem ParseFeedItem(XmlNode node);
@@ -57,9 +38,6 @@ internal abstract class FeedParserBase
{
Log.Logger.Information("New link: " + newFeedItem.Link);
// Associate the new item with the right feed
newFeedItem.Feed = Feed;
// Set the item as new
newFeedItem.New = true;
@@ -96,10 +74,6 @@ internal abstract class FeedParserBase
sequence++;
}
#endregion
#region Parser creation and detection
public static FeedParserBase CreateFeedParser(Feed feed, string feedText)
{
var feedType = DetectFeedType(feedText);
@@ -155,6 +129,4 @@ internal abstract class FeedParserBase
throw new FeedParseException(FeedParseError.InvalidXml);
}
}
#endregion
}

View File

@@ -0,0 +1,12 @@
using System;
namespace FeedCenter.FeedParsers;
[Serializable]
internal class InvalidFeedFormatException : ApplicationException
{
internal InvalidFeedFormatException(Exception exception)
: base(string.Empty, exception)
{
}
}

View File

@@ -1,10 +1,9 @@
using System;
using JetBrains.Annotations;
using Realms;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using JetBrains.Annotations;
using Realms;
namespace FeedCenter;
@@ -20,9 +19,6 @@ public class Category : RealmObject, INotifyDataErrorInfo
_dataErrorDictionary.ErrorsChanged += DataErrorDictionaryErrorsChanged;
}
[Ignored]
public ICollection<Feed> Feeds { get; set; }
[PrimaryKey]
public Guid Id { get; set; } = Guid.NewGuid();

View File

@@ -22,42 +22,6 @@ using System.Text.RegularExpressions;
namespace FeedCenter;
#region Enumerations
public enum MultipleOpenAction
{
IndividualPages,
SinglePage
}
public enum FeedType
{
Unknown,
Rss,
Rdf,
Atom
}
public enum FeedReadResult
{
Success,
NotModified,
NotDue,
UnknownError,
InvalidXml,
NotEnabled,
Unauthorized,
NoResponse,
NotFound,
Timeout,
ConnectionFailed,
ServerError,
Moved,
TemporarilyUnavailable
}
#endregion
public partial class Feed : RealmObject, INotifyDataErrorInfo
{
private static HttpClient _httpClient;
@@ -71,9 +35,7 @@ public partial class Feed : RealmObject, INotifyDataErrorInfo
}
public bool Authenticate { get; set; }
public Guid CategoryId { get; set; }
public int CheckInterval { get; set; } = 60;
public string Description { get; set; }
public bool Enabled { get; set; } = true;
@@ -225,8 +187,6 @@ public partial class Feed : RealmObject, INotifyDataErrorInfo
_dataErrorDictionary.AddError(propertyName, $"{propertyName} cannot be empty");
}
#region Reading
public FeedReadResult Read(bool forceRead = false)
{
Log.Logger.Information("Reading feed: {0}", Source);
@@ -494,6 +454,4 @@ public partial class Feed : RealmObject, INotifyDataErrorInfo
[GeneratedRegex("&(?!(?:[a-z]+|#[0-9]+|#x[0-9a-f]+);)")]
private static partial Regex UnescapedAmpersandRegex();
#endregion
}

View File

@@ -9,9 +9,6 @@ public partial class FeedItem : RealmObject
{
public bool BeenRead { get; set; }
public string Description { get; set; }
public Feed Feed { get; set; }
public Guid FeedId { get; set; }
public string Guid { get; set; }
@@ -22,7 +19,6 @@ public partial class FeedItem : RealmObject
public string Link { get; set; }
public bool New { get; set; }
public int Sequence { get; set; }
public string Title { get; set; }
public static FeedItem Create()

View File

@@ -0,0 +1,19 @@
namespace FeedCenter;
public enum FeedReadResult
{
Success,
NotModified,
NotDue,
UnknownError,
InvalidXml,
NotEnabled,
Unauthorized,
NoResponse,
NotFound,
Timeout,
ConnectionFailed,
ServerError,
Moved,
TemporarilyUnavailable
}

View File

@@ -0,0 +1,9 @@
namespace FeedCenter;
public enum FeedType
{
Unknown,
Rss,
Rdf,
Atom
}

View File

@@ -0,0 +1,7 @@
namespace FeedCenter;
public enum MultipleOpenAction
{
IndividualPages,
SinglePage
}

View File

@@ -72,7 +72,7 @@ public partial class MainWindow
// If the category changed then reset the current feed to the first in the category
if (_currentCategory?.Id != category?.Id)
{
_currentFeed = category == null ? _database.Feeds.FirstOrDefault() : category.Feeds.FirstOrDefault();
_currentFeed = category == null ? _database.Feeds.FirstOrDefault() : _database.Feeds.FirstOrDefault(f => f.CategoryId == category.Id);
}
// Set the current category

View File

@@ -104,8 +104,6 @@ public partial class MainWindow : IDisposable
HandleCommandLine(commandLine);
}
#region Setting events
private void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
{
// Make sure we're on the right thread
@@ -147,10 +145,6 @@ public partial class MainWindow : IDisposable
}
}
#endregion
#region Database helpers
private void ResetDatabase()
{
// Get the ID of the current feed
@@ -191,10 +185,6 @@ public partial class MainWindow : IDisposable
: _feedList.OrderBy(feed => feed.Name).AsEnumerable().ElementAt(_feedIndex);
}
#endregion
#region Feed display
private void UpdateToolbarButtonState()
{
// Cache the feed count to save (a little) time
@@ -429,6 +419,4 @@ public partial class MainWindow : IDisposable
// Clear the list
LinkTextList.Items.Clear();
}
#endregion
}

View File

@@ -7,34 +7,41 @@
xmlns:my="clr-namespace:FeedCenter.Properties"
xmlns:feedCenter="clr-namespace:FeedCenter"
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Controls;assembly=ChrisKaczor.Wpf.Controls.Link"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:options="clr-namespace:FeedCenter.Options"
WindowStartupLocation="CenterOwner"
Icon="/FeedCenter;component/Resources/Application.ico"
FocusManager.FocusedElement="{Binding ElementName=FeedLinkFilterText}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/light.cobalt.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Content="{x:Static my:Resources.FeedLinkFilterLabel}"
Margin="6"
Padding="0"
VerticalContentAlignment="Center"
Target="{Binding ElementName=FeedLinkFilterText}" />
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Grid.Row="0"
Grid.Column="1"
Grid.Column="0"
mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="{x:Static my:Resources.FeedLinkFilterLabel}"
mah:TextBoxHelper.SelectAllOnFocus="True"
Name="FeedLinkFilterText"
Margin="6"
TextChanged="HandleFilterTextChanged" />
<Border Grid.Row="1"
Grid.ColumnSpan="2"
Grid.Column="0"
Margin="6"
Margin="0,6"
BorderThickness="1"
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
<Grid>
@@ -45,9 +52,9 @@
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsControl Name="FilteredFeedsList">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Margin="2"
Content="{Binding Item.Name}"
<DataTemplate DataType="options:CheckedFeedListItem">
<CheckBox Content="{Binding Item.Name}"
Margin="4"
IsChecked="{Binding IsChecked}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
@@ -58,18 +65,17 @@
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
<StackPanel Orientation="Horizontal"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<TextBlock Margin="2"
Text="{x:Static my:Resources.SelectLabel}">
</TextBlock>
<controls:Link Margin="2"
<TextBlock Margin="4,2,2,2"
Text="{x:Static my:Resources.SelectLabel}" />
<controls:Link Margin="2,2,4,2"
Click="HandleSelectAll"
Text="{x:Static my:Resources.SelectAllLabel}">
</controls:Link>
<controls:Link Margin="2"
<controls:Link Margin="2,2,4,2"
Click="HandleSelectNone"
Text="{x:Static my:Resources.SelectNoneLabel}">
</controls:Link>
<controls:Link Margin="2"
<controls:Link Margin="2,2,4,2"
Click="HandleSelectInvert"
Text="{x:Static my:Resources.SelectInvertLabel}">
</controls:Link>
@@ -77,51 +83,44 @@
</Border>
</Grid>
</Border>
<Grid Grid.Row="2"
Grid.Column="0"
MouseRightButtonUp="HandleGridMouseRightButtonUp"
ToolTip="{x:Static my:Resources.EnableHint}">
<Label Content="{x:Static my:Resources.openLabel}"
Name="OpenLabel"
Padding="4,0,0,0"
Margin="6,8,6,6"
ToolTip="{x:Static my:Resources.DisableHint}"
IsEnabled="False" />
</Grid>
<Grid Grid.Column="1"
Grid.Row="2"
MouseRightButtonUp="HandleGridMouseRightButtonUp"
ToolTip="{x:Static my:Resources.EnableHint}">
<Grid Grid.Column="0"
Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<CheckBox Name="OpenCheckBox"
Grid.Column="0" />
<ComboBox Name="OpenComboBox"
VerticalContentAlignment="Center"
Grid.Column="1"
SelectedIndex="0"
Margin="6"
ToolTip="{x:Static my:Resources.DisableHint}"
IsEnabled="False">
HorizontalContentAlignment="Stretch"
mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="{x:Static my:Resources.openLabel}"
IsEnabled="{Binding ElementName=OpenCheckBox, Path=IsChecked}">
<ComboBoxItem Content="{x:Static my:Resources.openAllMultipleToolbarButton}"
Tag="{x:Static feedCenter:MultipleOpenAction.IndividualPages}" />
<ComboBoxItem Content="{x:Static my:Resources.openAllSingleToolbarButton}"
Tag="{x:Static feedCenter:MultipleOpenAction.SinglePage}" />
</ComboBox>
</Grid>
<Button Content="{x:Static my:Resources.OkayButton}"
Height="23"
HorizontalAlignment="Right"
IsDefault="True"
Margin="0,6,87,6"
VerticalAlignment="Bottom"
Width="75"
Grid.Column="1"
Grid.Row="3"
Click="HandleOkButtonClick" />
<Button Content="{x:Static my:Resources.CancelButton}"
Grid.Column="1"
Height="23"
HorizontalAlignment="Right"
IsCancel="True"
Margin="0,6,6,6"
VerticalAlignment="Bottom"
Width="75"
Grid.Row="3" />
<StackPanel Grid.Column="0"
Grid.Row="3"
Orientation="Horizontal"
Margin="0,5,0,0"
HorizontalAlignment="Right">
<Button Content="{x:Static my:Resources.OkayButton}"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="75"
Margin="0,0,5,0"
IsDefault="True"
Click="HandleOkButtonClick" />
<Button Content="{x:Static my:Resources.CancelButton}"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="75"
IsCancel="True" />
</StackPanel>
</Grid>
</Window>

View File

@@ -1,10 +1,10 @@
using System.Collections.Generic;
using FeedCenter.Data;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using FeedCenter.Data;
namespace FeedCenter.Options;
@@ -52,11 +52,14 @@ public partial class BulkFeedWindow
private void HandleOkButtonClick(object sender, RoutedEventArgs e)
{
foreach (var item in _checkedListBoxItems.Where(i => i.IsChecked))
Database.Entities.SaveChanges(() =>
{
if (OpenComboBox.IsEnabled)
item.Item.MultipleOpenAction = (MultipleOpenAction) ((ComboBoxItem) OpenComboBox.SelectedItem).Tag;
}
foreach (var item in _checkedListBoxItems.Where(i => i.IsChecked))
{
if (OpenComboBox.IsEnabled)
item.Item.MultipleOpenAction = (MultipleOpenAction) ((ComboBoxItem) OpenComboBox.SelectedItem).Tag;
}
});
DialogResult = true;
Close();
@@ -91,10 +94,4 @@ public partial class BulkFeedWindow
checkedListItem.IsChecked = !checkedListItem.IsChecked;
}
}
private void HandleGridMouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
OpenLabel.IsEnabled = !OpenLabel.IsEnabled;
OpenComboBox.IsEnabled = !OpenComboBox.IsEnabled;
}
}

View File

@@ -0,0 +1,6 @@
namespace FeedCenter.Options
{
public class CheckedFeedListItem : CheckedListItem<Feed>
{
}
}

View File

@@ -10,6 +10,16 @@
mc:Ignorable="d"
d:DesignHeight="311"
d:DesignWidth="425">
<options:OptionsPanelBase.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.FlatButton.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/light.cobalt.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</options:OptionsPanelBase.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
@@ -20,41 +30,11 @@
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DataGrid Name="FeedListBox"
SelectionMode="Extended"
Grid.Column="2"
Grid.Row="0"
AutoGenerateColumns="False"
GridLinesVisibility="None"
CanUserResizeRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
BorderThickness="1,1,1,1"
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
Background="{x:Null}"
PreviewMouseLeftButtonDown="HandleFeedListPreviewMouseLeftButtonDown" SelectionChanged="FeedListBox_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.FeedNameColumnHeader}"
SortDirection="Ascending"
Width="*" />
<DataGridTextColumn Binding="{Binding LastUpdated, StringFormat=d}"
Header="{x:Static properties:Resources.LastUpdatedColumnHeader}"
Width="Auto" />
</DataGrid.Columns>
<DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick"
Handler="HandleListBoxItemMouseDoubleClick" />
<EventSetter Event="PreviewMouseMove"
Handler="HandleListBoxItemPreviewMouseMove" />
</Style>
</DataGrid.ItemContainerStyle>
</DataGrid>
<DataGrid Name="CategoryListBox"
SelectionChanged="HandleCategoryListBoxSelectionChanged"
<DataGrid Name="CategoryDataGrid"
SelectionChanged="HandleCategoryDataGridSelectionChanged"
Grid.Row="0"
SelectionMode="Single"
SelectionUnit="FullRow"
Grid.Column="0"
AutoGenerateColumns="False"
GridLinesVisibility="None"
@@ -65,25 +45,60 @@
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
AllowDrop="True"
Background="{x:Null}"
d:DataContext="{d:DesignInstance Type=feedCenter:Category }">
d:DataContext="{d:DesignInstance feedCenter:Category }">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.CategoryNameColumnHeader}"
SortDirection="Ascending"
Width="*" />
</DataGrid.Columns>
<DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow"
BasedOn="{StaticResource MahApps.Styles.DataGridRow}">
<EventSetter Event="Drop"
Handler="CategoryListBox_Drop" />
Handler="HandleCategoryDataGridRowDrop" />
<EventSetter Event="DragEnter"
Handler="CategoryListBox_DragEnter" />
Handler="HandleCategoryDataGridRowDragEnter" />
<EventSetter Event="DragLeave"
Handler="CategoryListBox_DragLeave" />
Handler="HandleCategoryDataGridRowDragLeave" />
<EventSetter Event="MouseDoubleClick"
Handler="CategoryListBox_MouseDoubleClick" />
Handler="HandleCategoryDataGridRowMouseDoubleClick" />
</Style>
</DataGrid.ItemContainerStyle>
</DataGrid.RowStyle>
</DataGrid>
<DataGrid Name="FeedDataGrid"
SelectionMode="Extended"
Grid.Column="2"
Grid.Row="0"
AutoGenerateColumns="False"
GridLinesVisibility="None"
CanUserResizeRows="False"
IsReadOnly="True"
SelectionUnit="FullRow"
HeadersVisibility="Column"
BorderThickness="1,1,1,1"
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
Background="{x:Null}"
SelectionChanged="HandleFeedDataGridSelectionChanged"
d:DataContext="{d:DesignInstance feedCenter:Feed }">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}"
Header="{x:Static properties:Resources.FeedNameColumnHeader}"
SortDirection="Ascending"
Width="*" />
<DataGridTextColumn Binding="{Binding LastUpdated, StringFormat=d}"
Header="{x:Static properties:Resources.LastUpdatedColumnHeader}"
Width="Auto" />
</DataGrid.Columns>
<DataGrid.RowStyle>
<Style TargetType="DataGridRow"
BasedOn="{StaticResource MahApps.Styles.DataGridRow}">
<EventSetter Event="MouseDoubleClick"
Handler="HandleFeedDataGridRowMouseDoubleClick" />
<EventSetter Event="PreviewMouseLeftButtonDown"
Handler="HandleFeedDataGridRowPreviewMouseLeftButtonDown" />
</Style>
</DataGrid.RowStyle>
</DataGrid>
<Border Grid.Column="2"
Grid.Row="1"

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using FeedCenter.Data;
using Microsoft.Win32;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
@@ -6,8 +8,6 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Xml;
using FeedCenter.Data;
using Microsoft.Win32;
namespace FeedCenter.Options;
@@ -31,22 +31,22 @@ public partial class FeedsOptionsPanel
collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
collectionViewSource.IsLiveSortingRequested = true;
CategoryListBox.ItemsSource = collectionViewSource.View;
CategoryListBox.SelectedIndex = 0;
CategoryDataGrid.ItemsSource = collectionViewSource.View;
CategoryDataGrid.SelectedIndex = 0;
}
private void SetFeedButtonStates()
{
AddFeedButton.IsEnabled = true;
EditFeedButton.IsEnabled = FeedListBox.SelectedItems.Count == 1;
DeleteFeedButton.IsEnabled = FeedListBox.SelectedItems.Count > 0;
EditFeedButton.IsEnabled = FeedDataGrid.SelectedItems.Count == 1;
DeleteFeedButton.IsEnabled = FeedDataGrid.SelectedItems.Count > 0;
}
private void AddFeed()
{
var feed = Feed.Create();
var category = (Category) CategoryListBox.SelectedItem;
var category = (Category) CategoryDataGrid.SelectedItem;
feed.CategoryId = category.Id;
@@ -59,17 +59,17 @@ public partial class FeedsOptionsPanel
Database.Entities.SaveChanges(() => Database.Entities.Feeds.Add(feed));
FeedListBox.SelectedItem = feed;
FeedDataGrid.SelectedItem = feed;
SetFeedButtonStates();
}
private void EditSelectedFeed()
{
if (FeedListBox.SelectedItem == null)
if (FeedDataGrid.SelectedItem == null)
return;
var feed = (Feed) FeedListBox.SelectedItem;
var feed = (Feed) FeedDataGrid.SelectedItem;
var feedWindow = new FeedWindow();
@@ -81,9 +81,9 @@ public partial class FeedsOptionsPanel
if (MessageBox.Show(ParentWindow, Properties.Resources.ConfirmDeleteFeeds, Properties.Resources.ConfirmDeleteTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
var selectedItems = new Feed[FeedListBox.SelectedItems.Count];
var selectedItems = new Feed[FeedDataGrid.SelectedItems.Count];
FeedListBox.SelectedItems.CopyTo(selectedItems, 0);
FeedDataGrid.SelectedItems.CopyTo(selectedItems, 0);
foreach (var feed in selectedItems)
Database.Entities.SaveChanges(() => Database.Entities.Feeds.Remove(feed));
@@ -239,11 +239,11 @@ public partial class FeedsOptionsPanel
{
AddCategoryButton.IsEnabled = true;
var selectedId = ((Category) CategoryListBox.SelectedItem).Id;
var selectedId = ((Category) CategoryDataGrid.SelectedItem).Id;
EditCategoryButton.IsEnabled = CategoryListBox.SelectedItem != null &&
EditCategoryButton.IsEnabled = CategoryDataGrid.SelectedItem != null &&
selectedId != Database.Entities.DefaultCategory.Id;
DeleteCategoryButton.IsEnabled = CategoryListBox.SelectedItem != null &&
DeleteCategoryButton.IsEnabled = CategoryDataGrid.SelectedItem != null &&
selectedId != Database.Entities.DefaultCategory.Id;
}
@@ -260,17 +260,17 @@ public partial class FeedsOptionsPanel
Database.Entities.SaveChanges(() => Database.Entities.Categories.Add(category));
CategoryListBox.SelectedItem = category;
CategoryDataGrid.SelectedItem = category;
SetCategoryButtonStates();
}
private void EditSelectedCategory()
{
if (CategoryListBox.SelectedItem == null)
if (CategoryDataGrid.SelectedItem == null)
return;
var category = (Category) CategoryListBox.SelectedItem;
var category = (Category) CategoryDataGrid.SelectedItem;
var categoryWindow = new CategoryWindow();
@@ -279,7 +279,7 @@ public partial class FeedsOptionsPanel
private void DeleteSelectedCategory()
{
var category = (Category) CategoryListBox.SelectedItem;
var category = (Category) CategoryDataGrid.SelectedItem;
if (MessageBox.Show(ParentWindow, string.Format(Properties.Resources.ConfirmDeleteCategory, category.Name), Properties.Resources.ConfirmDeleteTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
return;
@@ -289,12 +289,12 @@ public partial class FeedsOptionsPanel
foreach (var feed in Database.Entities.Feeds.Where(f => f.CategoryId == category.Id))
Database.Entities.SaveChanges(() => feed.CategoryId = defaultCategory.Id);
var index = CategoryListBox.SelectedIndex;
var index = CategoryDataGrid.SelectedIndex;
if (index == CategoryListBox.Items.Count - 1)
CategoryListBox.SelectedIndex = index - 1;
if (index == CategoryDataGrid.Items.Count - 1)
CategoryDataGrid.SelectedIndex = index - 1;
else
CategoryListBox.SelectedIndex = index + 1;
CategoryDataGrid.SelectedIndex = index + 1;
Database.Entities.SaveChanges(() => Database.Entities.Categories.Remove(category));
@@ -316,7 +316,7 @@ public partial class FeedsOptionsPanel
DeleteSelectedCategory();
}
private void HandleCategoryListBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
private void HandleCategoryDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (_collectionViewSource == null)
{
@@ -324,13 +324,13 @@ public partial class FeedsOptionsPanel
_collectionViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
_collectionViewSource.Filter += HandleCollectionViewSourceFilter;
FeedListBox.ItemsSource = _collectionViewSource.View;
FeedDataGrid.ItemsSource = _collectionViewSource.View;
}
_collectionViewSource.View.Refresh();
if (FeedListBox.Items.Count > 0)
FeedListBox.SelectedIndex = 0;
if (FeedDataGrid.Items.Count > 0)
FeedDataGrid.SelectedIndex = 0;
SetFeedButtonStates();
SetCategoryButtonStates();
@@ -338,14 +338,14 @@ public partial class FeedsOptionsPanel
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
{
var selectedCategory = (Category) CategoryListBox.SelectedItem;
var selectedCategory = (Category) CategoryDataGrid.SelectedItem;
var feed = (Feed) e.Item;
e.Accepted = feed.CategoryId == selectedCategory.Id;
}
private void CategoryListBox_Drop(object sender, DragEventArgs e)
private void HandleCategoryDataGridRowDrop(object sender, DragEventArgs e)
{
var feedList = (List<Feed>) e.Data.GetData(typeof(List<Feed>));
@@ -361,31 +361,21 @@ public partial class FeedsOptionsPanel
dataGridRow.FontWeight = FontWeights.Normal;
}
private void HandleListBoxItemPreviewMouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
return;
var selectedItems = FeedListBox.SelectedItems.Cast<Feed>().ToList();
DragDrop.DoDragDrop(FeedListBox, selectedItems, DragDropEffects.Move);
}
private void CategoryListBox_DragEnter(object sender, DragEventArgs e)
private void HandleCategoryDataGridRowDragEnter(object sender, DragEventArgs e)
{
var dataGridRow = (DataGridRow) sender;
dataGridRow.FontWeight = FontWeights.Bold;
}
private void CategoryListBox_DragLeave(object sender, DragEventArgs e)
private void HandleCategoryDataGridRowDragLeave(object sender, DragEventArgs e)
{
var dataGridRow = (DataGridRow) sender;
dataGridRow.FontWeight = FontWeights.Normal;
}
private void HandleListBoxItemMouseDoubleClick(object sender, MouseButtonEventArgs e)
private void HandleFeedDataGridRowMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
EditSelectedFeed();
}
@@ -396,20 +386,14 @@ public partial class FeedsOptionsPanel
bulkFeedWindow.Display(Window.GetWindow(this));
}
private void HandleFeedListPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
private void HandleFeedDataGridRowPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// Get the object that was clicked on
var originalSource = (DependencyObject) e.OriginalSource;
var selectedItems = FeedDataGrid.SelectedItems.Cast<Feed>().ToList();
// Look for a row that contains the object
var dataGridRow = (DataGridRow) FeedListBox.ContainerFromElement(originalSource);
// If the selection already contains this row then ignore it
if (dataGridRow != null && FeedListBox.SelectedItems.Contains(dataGridRow.Item))
e.Handled = true;
DragDrop.DoDragDrop(FeedDataGrid, selectedItems, DragDropEffects.Move);
}
private void CategoryListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
private void HandleCategoryDataGridRowMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (!EditCategoryButton.IsEnabled)
return;
@@ -417,7 +401,7 @@ public partial class FeedsOptionsPanel
EditSelectedCategory();
}
private void FeedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
private void HandleFeedDataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
{
SetFeedButtonStates();
}

View File

@@ -733,7 +733,7 @@ namespace FeedCenter.Properties {
}
/// <summary>
/// Looks up a localized string similar to Feed _link contains:.
/// Looks up a localized string similar to Feed link contains.
/// </summary>
public static string FeedLinkFilterLabel {
get {

View File

@@ -419,7 +419,7 @@
<value>Edit Multiple Feeds</value>
</data>
<data name="FeedLinkFilterLabel" xml:space="preserve">
<value>Feed _link contains:</value>
<value>Feed link contains</value>
</data>
<data name="SelectAllLabel" xml:space="preserve">
<value>All</value>

View File

@@ -128,8 +128,6 @@ public class XmlSanitizingStream : StreamReader
return nextCharacter;
} // method
#region Read*() method overrides
// The following methods are exact copies of the methods in TextReader,
// extracting by disassembling it in Reflector
@@ -219,6 +217,4 @@ public class XmlSanitizingStream : StreamReader
return builder.ToString();
}
#endregion
} // class