mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-02-11 18:48:36 -05:00
More UI updates and cleanup
This commit is contained in:
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
6
Application/Options/CheckedFeedListItem.cs
Normal file
6
Application/Options/CheckedFeedListItem.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
public class CheckedFeedListItem : CheckedListItem<Feed>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
@@ -64,26 +44,61 @@
|
||||
BorderThickness="1,1,1,1"
|
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
|
||||
AllowDrop="True"
|
||||
Background="{x:Null}"
|
||||
d:DataContext="{d:DesignInstance Type=feedCenter:Category }">
|
||||
Background="{x:Null}"
|
||||
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"
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user