mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-01-13 17:22:48 -05:00
More modernization
- Split generic "common" libraries into specific libraries - Use other packages in lieu of custom code - General cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Common.Update;
|
||||
using CKaczor.ApplicationUpdate;
|
||||
using System.Reflection;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
@@ -33,4 +33,4 @@ namespace FeedCenter.Options
|
||||
|
||||
public override string CategoryName => Properties.Resources.optionCategoryAbout;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
Height="300"
|
||||
Width="500"
|
||||
xmlns:my="clr-namespace:FeedCenter.Properties"
|
||||
xmlns:linkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
|
||||
xmlns:feedCenter="clr-namespace:FeedCenter"
|
||||
xmlns:controls="clr-namespace:CKaczor.Wpf.Controls;assembly=Wpf.Controls.Link"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/FeedCenter;component/Resources/Application.ico"
|
||||
FocusManager.FocusedElement="{Binding ElementName=FeedLinkFilterText}">
|
||||
@@ -61,18 +61,18 @@
|
||||
<TextBlock Margin="2"
|
||||
Text="{x:Static my:Resources.SelectLabel}">
|
||||
</TextBlock>
|
||||
<linkControl:LinkControl Margin="2"
|
||||
Click="HandleSelectAll"
|
||||
Text="{x:Static my:Resources.SelectAllLabel}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Margin="2"
|
||||
Click="HandleSelectNone"
|
||||
Text="{x:Static my:Resources.SelectNoneLabel}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Margin="2"
|
||||
Click="HandleSelectInvert"
|
||||
Text="{x:Static my:Resources.SelectInvertLabel}">
|
||||
</linkControl:LinkControl>
|
||||
<controls:Link Margin="2"
|
||||
Click="HandleSelectAll"
|
||||
Text="{x:Static my:Resources.SelectAllLabel}">
|
||||
</controls:Link>
|
||||
<controls:Link Margin="2"
|
||||
Click="HandleSelectNone"
|
||||
Text="{x:Static my:Resources.SelectNoneLabel}">
|
||||
</controls:Link>
|
||||
<controls:Link Margin="2"
|
||||
Click="HandleSelectInvert"
|
||||
Text="{x:Static my:Resources.SelectInvertLabel}">
|
||||
</controls:Link>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
@@ -124,4 +124,4 @@
|
||||
Width="75"
|
||||
Grid.Row="3" />
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
||||
@@ -1,5 +1,4 @@
|
||||
using Common.Wpf;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
@@ -36,7 +35,7 @@ namespace FeedCenter.Options
|
||||
ShowDialog();
|
||||
}
|
||||
|
||||
void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
||||
private void HandleCollectionViewSourceFilter(object sender, FilterEventArgs e)
|
||||
{
|
||||
var checkedListBoxItem = (CheckedListItem<Feed>) e.Item;
|
||||
|
||||
|
||||
@@ -2,44 +2,71 @@
|
||||
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:feedCenter="clr-namespace:FeedCenter"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:validation="clr-namespace:CKaczor.Wpf.Validation;assembly=Wpf.Validation"
|
||||
xmlns:controls="clr-namespace:CKaczor.Wpf.Windows;assembly=Wpf.Windows.ControlBox"
|
||||
d:DataContext="{d:DesignInstance Type=feedCenter:Category}"
|
||||
Title="CategoryWindow"
|
||||
Height="119"
|
||||
Width="339"
|
||||
Width="300"
|
||||
ResizeMode="NoResize"
|
||||
SizeToContent="Height"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Icon="/FeedCenter;component/Resources/Application.ico"
|
||||
FocusManager.FocusedElement="{Binding ElementName=NameTextBox}">
|
||||
<Grid>
|
||||
FocusManager.FocusedElement="{Binding ElementName=NameTextBox}"
|
||||
controls:ControlBox.HasMinimizeButton="False"
|
||||
controls:ControlBox.HasMaximizeButton="False">
|
||||
<Grid Margin="8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="367*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="{x:Static properties:Resources.feedCategoryLabel}"
|
||||
HorizontalAlignment="Left"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Target="{Binding ElementName=NameTextBox}"
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
Margin="12,12,0,0" />
|
||||
<TextBox Margin="7,14,12,0"
|
||||
Name="NameTextBox"
|
||||
Text="{Binding Path=Name, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}"
|
||||
VerticalAlignment="Top"
|
||||
Grid.Column="1" />
|
||||
<Button Content="{x:Static properties:Resources.OkayButton}"
|
||||
Height="23"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
IsDefault="True"
|
||||
Margin="0,0,93,12"
|
||||
Click="HandleOkayButtonClick"
|
||||
Grid.Column="1" />
|
||||
<Button Content="{x:Static properties:Resources.CancelButton}"
|
||||
Height="23"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
IsCancel="True"
|
||||
Margin="0,0,12,12"
|
||||
Grid.Column="1" />
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center" />
|
||||
<TextBox Name="NameTextBox"
|
||||
VerticalAlignment="Center"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1">
|
||||
<TextBox.Text>
|
||||
<Binding Path="Name" UpdateSourceTrigger="Explicit" ValidatesOnExceptions="True">
|
||||
<Binding.ValidationRules>
|
||||
<validation:RequiredValidationRule></validation:RequiredValidationRule>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
Grid.Row="2"
|
||||
Orientation="Horizontal"
|
||||
Margin="0,4,0,0"
|
||||
HorizontalAlignment="Right">
|
||||
<Button Content="{x:Static properties:Resources.OkayButton}"
|
||||
Height="23"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
Margin="0,0,5,0"
|
||||
IsDefault="True"
|
||||
Click="HandleOkayButtonClick" />
|
||||
<Button Content="{x:Static properties:Resources.CancelButton}"
|
||||
Height="23"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="75"
|
||||
IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
||||
@@ -1,8 +1,5 @@
|
||||
using Common.Wpf.Extensions;
|
||||
using System.Linq;
|
||||
using CKaczor.Wpf.Validation;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
@@ -19,7 +16,9 @@ namespace FeedCenter.Options
|
||||
DataContext = category;
|
||||
|
||||
// Set the title based on the state of the category
|
||||
Title = string.IsNullOrWhiteSpace(category.Name) ? Properties.Resources.CategoryWindowAdd : Properties.Resources.CategoryWindowEdit;
|
||||
Title = string.IsNullOrWhiteSpace(category.Name)
|
||||
? Properties.Resources.CategoryWindowAdd
|
||||
: Properties.Resources.CategoryWindowEdit;
|
||||
|
||||
// Set the window owner
|
||||
Owner = owner;
|
||||
@@ -30,29 +29,8 @@ namespace FeedCenter.Options
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Get a list of all explicit binding expressions
|
||||
var bindingExpressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
|
||||
|
||||
// Loop over each binding expression and clear any existing error
|
||||
bindingExpressions.ForEach(b => Validation.ClearInvalid(b.BindingExpression));
|
||||
|
||||
// Force all explicit bindings to update the source
|
||||
bindingExpressions.ForEach(bindingExpression => bindingExpression.BindingExpression.UpdateSource());
|
||||
|
||||
// See if there are any errors
|
||||
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
|
||||
var firstErrorElement = bindingExpressions.First(b => b.BindingExpression.HasError).FrameworkElement;
|
||||
|
||||
// Set focus
|
||||
firstErrorElement.Focus();
|
||||
|
||||
if (!this.Validate())
|
||||
return;
|
||||
}
|
||||
|
||||
// Dialog is good
|
||||
DialogResult = true;
|
||||
@@ -61,4 +39,4 @@ namespace FeedCenter.Options
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Application/Options/CheckedListItem.cs
Normal file
41
Application/Options/CheckedListItem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace FeedCenter.Options;
|
||||
|
||||
public class CheckedListItem<T> : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private bool _isChecked;
|
||||
private readonly T _item;
|
||||
|
||||
public CheckedListItem() { }
|
||||
|
||||
public CheckedListItem(T item, bool isChecked = false)
|
||||
{
|
||||
_item = item;
|
||||
_isChecked = isChecked;
|
||||
}
|
||||
|
||||
public T Item
|
||||
{
|
||||
get => _item;
|
||||
init
|
||||
{
|
||||
_item = value;
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item"));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsChecked
|
||||
{
|
||||
get => _isChecked;
|
||||
set
|
||||
{
|
||||
_isChecked = value;
|
||||
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsChecked"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
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"
|
||||
xmlns:validation="clr-namespace:CKaczor.Wpf.Validation;assembly=Wpf.Validation"
|
||||
mc:Ignorable="d"
|
||||
Title="FeedWindow"
|
||||
Height="300"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Common.Wpf.Extensions;
|
||||
using CKaczor.Wpf.Validation;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:options="clr-namespace:FeedCenter.Options"
|
||||
xmlns:linkControl="clr-namespace:Common.Wpf.LinkControl;assembly=Common.Wpf"
|
||||
xmlns:properties="clr-namespace:FeedCenter.Properties"
|
||||
xmlns:controls="clr-namespace:CKaczor.Wpf.Controls;assembly=Wpf.Controls.Link"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="311"
|
||||
d:DesignWidth="425">
|
||||
@@ -95,39 +95,39 @@
|
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<linkControl:LinkControl Name="AddFeedButton"
|
||||
Margin="2"
|
||||
Click="HandleAddFeedButtonClick"
|
||||
Text="{x:Static properties:Resources.AddLink}"
|
||||
ToolTip="{x:Static properties:Resources.AddFeedButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Name="EditFeedButton"
|
||||
Margin="2"
|
||||
Click="HandleEditFeedButtonClick"
|
||||
Text="{x:Static properties:Resources.EditLink}"
|
||||
ToolTip="{x:Static properties:Resources.EditFeedButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Name="DeleteFeedButton"
|
||||
Margin="2"
|
||||
Click="HandleDeleteFeedButtonClick"
|
||||
Text="{x:Static properties:Resources.DeleteLink}"
|
||||
ToolTip="{x:Static properties:Resources.DeleteFeedButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Margin="6,2,2,2"
|
||||
Click="HandleImportButtonClick"
|
||||
Text="{x:Static properties:Resources.ImportLink}"
|
||||
ToolTip="{x:Static properties:Resources.ImportFeedsButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Margin="2"
|
||||
Click="HandleExportButtonClick"
|
||||
Text="{x:Static properties:Resources.ExportLink}"
|
||||
ToolTip="{x:Static properties:Resources.ExportFeedsButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Margin="6,2,2,2"
|
||||
Click="HandleMultipleEditClick"
|
||||
Text="{x:Static properties:Resources.MultipleEditLink}"
|
||||
ToolTip="{x:Static properties:Resources.MultipleEditButton}">
|
||||
</linkControl:LinkControl>
|
||||
<controls:Link Name="AddFeedButton"
|
||||
Margin="2"
|
||||
Click="HandleAddFeedButtonClick"
|
||||
Text="{x:Static properties:Resources.AddLink}"
|
||||
ToolTip="{x:Static properties:Resources.AddFeedButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Name="EditFeedButton"
|
||||
Margin="2"
|
||||
Click="HandleEditFeedButtonClick"
|
||||
Text="{x:Static properties:Resources.EditLink}"
|
||||
ToolTip="{x:Static properties:Resources.EditFeedButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Name="DeleteFeedButton"
|
||||
Margin="2"
|
||||
Click="HandleDeleteFeedButtonClick"
|
||||
Text="{x:Static properties:Resources.DeleteLink}"
|
||||
ToolTip="{x:Static properties:Resources.DeleteFeedButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Margin="6,2,2,2"
|
||||
Click="HandleImportButtonClick"
|
||||
Text="{x:Static properties:Resources.ImportLink}"
|
||||
ToolTip="{x:Static properties:Resources.ImportFeedsButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Margin="2"
|
||||
Click="HandleExportButtonClick"
|
||||
Text="{x:Static properties:Resources.ExportLink}"
|
||||
ToolTip="{x:Static properties:Resources.ExportFeedsButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Margin="6,2,2,2"
|
||||
Click="HandleMultipleEditClick"
|
||||
Text="{x:Static properties:Resources.MultipleEditLink}"
|
||||
ToolTip="{x:Static properties:Resources.MultipleEditButton}">
|
||||
</controls:Link>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border Grid.Row="1"
|
||||
@@ -136,24 +136,24 @@
|
||||
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}">
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<linkControl:LinkControl Name="AddCategoryButton"
|
||||
Margin="2"
|
||||
Click="HandleAddCategoryButtonClick"
|
||||
Text="{x:Static properties:Resources.AddLink}"
|
||||
ToolTip="{x:Static properties:Resources.AddCategoryButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Name="EditCategoryButton"
|
||||
Margin="2"
|
||||
Click="HandleEditCategoryButtonClick"
|
||||
Text="{x:Static properties:Resources.EditLink}"
|
||||
ToolTip="{x:Static properties:Resources.EditCategoryButton}">
|
||||
</linkControl:LinkControl>
|
||||
<linkControl:LinkControl Name="DeleteCategoryButton"
|
||||
Margin="2"
|
||||
Click="HandleDeleteCategoryButtonClick"
|
||||
Text="{x:Static properties:Resources.DeleteLink}"
|
||||
ToolTip="{x:Static properties:Resources.DeleteCategoryButton}">
|
||||
</linkControl:LinkControl>
|
||||
<controls:Link Name="AddCategoryButton"
|
||||
Margin="2"
|
||||
Click="HandleAddCategoryButtonClick"
|
||||
Text="{x:Static properties:Resources.AddLink}"
|
||||
ToolTip="{x:Static properties:Resources.AddCategoryButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Name="EditCategoryButton"
|
||||
Margin="2"
|
||||
Click="HandleEditCategoryButtonClick"
|
||||
Text="{x:Static properties:Resources.EditLink}"
|
||||
ToolTip="{x:Static properties:Resources.EditCategoryButton}">
|
||||
</controls:Link>
|
||||
<controls:Link Name="DeleteCategoryButton"
|
||||
Margin="2"
|
||||
Click="HandleDeleteCategoryButtonClick"
|
||||
Text="{x:Static properties:Resources.DeleteLink}"
|
||||
ToolTip="{x:Static properties:Resources.DeleteCategoryButton}">
|
||||
</controls:Link>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
VerticalContentAlignment="Center">
|
||||
<ComboBoxItem Content="{x:Static properties:Resources.DefaultBrowserCaption}"
|
||||
Tag="" />
|
||||
</ComboBox>
|
||||
<Label Content="{x:Static properties:Resources.defaultUserAgentLabel}"
|
||||
Target="{Binding ElementName=BrowserComboBox}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using Common.Wpf.Extensions;
|
||||
using Common.Internet;
|
||||
using CKaczor.InstalledBrowsers;
|
||||
using CKaczor.Wpf.Application;
|
||||
using CKaczor.Wpf.Validation;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace FeedCenter.Options
|
||||
settings.StartWithWindows != StartWithWindowsCheckBox.IsChecked.Value)
|
||||
settings.StartWithWindows = StartWithWindowsCheckBox.IsChecked.Value;
|
||||
|
||||
Application.Current.SetStartWithWindows(settings.StartWithWindows);
|
||||
System.Windows.Application.Current.SetStartWithWindows(settings.StartWithWindows);
|
||||
|
||||
settings.Browser = (string) ((ComboBoxItem) BrowserComboBox.SelectedItem).Tag;
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace FeedCenter.Options
|
||||
|
||||
var expressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
|
||||
this.UpdateAllSources(expressions);
|
||||
|
||||
this.Validate();
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.optionCategoryGeneral;
|
||||
@@ -64,7 +66,7 @@ namespace FeedCenter.Options
|
||||
|
||||
ComboBoxItem selectedItem = null;
|
||||
|
||||
var browsers = Browser.DetectInstalledBrowsers();
|
||||
var browsers = InstalledBrowser.GetInstalledBrowsers(true);
|
||||
foreach (var browser in browsers)
|
||||
{
|
||||
var item = new ComboBoxItem { Content = browser.Value.Name, Tag = browser.Key };
|
||||
@@ -129,4 +131,4 @@ namespace FeedCenter.Options
|
||||
return userAgents;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using Common.Update;
|
||||
using CKaczor.ApplicationUpdate;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
@@ -34,4 +34,4 @@ namespace FeedCenter.Options
|
||||
UpdateCheck.DisplayUpdateInformation(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user