Rework much of options UI

This commit is contained in:
2023-04-13 20:05:55 -04:00
parent ace251fd4f
commit 5c0c84a068
18 changed files with 322 additions and 331 deletions

View File

@@ -126,7 +126,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="ChrisKaczor.ApplicationUpdate" Version="1.0.2" /> <PackageReference Include="ChrisKaczor.ApplicationUpdate" Version="1.0.2" />
<PackageReference Include="ChrisKaczor.GenericSettingsProvider" Version="1.0.3" /> <PackageReference Include="ChrisKaczor.GenericSettingsProvider" Version="1.0.3" />
<PackageReference Include="ChrisKaczor.InstalledBrowsers" Version="1.0.2" /> <PackageReference Include="ChrisKaczor.InstalledBrowsers" Version="1.0.3" />
<PackageReference Include="ChrisKaczor.Wpf.Application.SingleInstance" Version="1.0.4" /> <PackageReference Include="ChrisKaczor.Wpf.Application.SingleInstance" Version="1.0.4" />
<PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.2" /> <PackageReference Include="ChrisKaczor.Wpf.Application.StartWithWindows" Version="1.0.2" />
<PackageReference Include="ChrisKaczor.Wpf.Controls.HtmlTextBlock" Version="1.0.2" /> <PackageReference Include="ChrisKaczor.Wpf.Controls.HtmlTextBlock" Version="1.0.2" />
@@ -139,10 +139,11 @@
<PackageReference Include="DebounceThrottle" Version="2.0.0" /> <PackageReference Include="DebounceThrottle" Version="2.0.0" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" /> <PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="HtmlTextWriter" Version="2.1.1" /> <PackageReference Include="HtmlTextWriter" Version="2.1.1" />
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
<PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" GeneratePathProperty="true"> <PackageReference Include="Microsoft.SqlServer.Compact" Version="4.0.8876.1" GeneratePathProperty="true">
<NoWarn>NU1701</NoWarn> <NoWarn>NU1701</NoWarn>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.0" /> <PackageReference Include="Microsoft.Windows.Compatibility" Version="7.0.1" />
<PackageReference Include="NameBasedGrid" Version="0.10.1"> <PackageReference Include="NameBasedGrid" Version="0.10.1">
<NoWarn>NU1701</NoWarn> <NoWarn>NU1701</NoWarn>
</PackageReference> </PackageReference>

View File

@@ -4,21 +4,18 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:applicationUpdate="clr-namespace:ChrisKaczor.ApplicationUpdate;assembly=ChrisKaczor.ApplicationUpdate"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignHeight="150"
d:DesignWidth="300"> d:DesignWidth="300">
<Grid> <Grid>
<TextBlock Text="Label" <StackPanel options:Spacing.Vertical="10">
Name="ApplicationNameLabel" <TextBlock Text="{x:Static properties:Resources.ApplicationDisplayName}"
VerticalAlignment="Top" FontWeight="Bold" />
FontWeight="Bold" /> <TextBlock Text="{Binding Source={x:Static applicationUpdate:UpdateCheck.LocalVersion}, StringFormat={x:Static properties:Resources.Version}}"
<TextBlock Text="Label" Name="VersionLabel" />
Margin="0,22,0,0" <TextBlock Text="Chris Kaczor" />
Name="VersionLabel" </StackPanel>
VerticalAlignment="Top" />
<TextBlock Text="Label"
Margin="0,44,0,0"
Name="CompanyLabel"
VerticalAlignment="Top" />
</Grid> </Grid>
</options:OptionsPanelBase> </options:OptionsPanelBase>

View File

@@ -1,6 +1,4 @@
using System.Reflection; using System.Windows;
using System.Windows;
using ChrisKaczor.ApplicationUpdate;
namespace FeedCenter.Options; namespace FeedCenter.Options;
@@ -12,16 +10,4 @@ public partial class AboutOptionsPanel
} }
public override string CategoryName => Properties.Resources.optionCategoryAbout; public override string CategoryName => Properties.Resources.optionCategoryAbout;
public override void LoadPanel()
{
base.LoadPanel();
ApplicationNameLabel.Text = Properties.Resources.ApplicationDisplayName;
var version = UpdateCheck.LocalVersion.ToString();
VersionLabel.Text = string.Format(Properties.Resources.Version, version);
CompanyLabel.Text = ((AssemblyCompanyAttribute) Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
}
} }

View File

@@ -7,6 +7,7 @@
mc:Ignorable="d" mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox" xmlns:controls="clr-namespace:ChrisKaczor.Wpf.Windows;assembly=ChrisKaczor.Wpf.Windows.ControlBox"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
d:DataContext="{d:DesignInstance Type=feedCenter:Category}" d:DataContext="{d:DesignInstance Type=feedCenter:Category}"
Title="CategoryWindow" Title="CategoryWindow"
Width="300" Width="300"
@@ -17,7 +18,17 @@
FocusManager.FocusedElement="{Binding ElementName=NameTextBox}" FocusManager.FocusedElement="{Binding ElementName=NameTextBox}"
controls:ControlBox.HasMinimizeButton="False" controls:ControlBox.HasMinimizeButton="False"
controls:ControlBox.HasMaximizeButton="False"> controls:ControlBox.HasMaximizeButton="False">
<Grid Margin="6,3,6,6"> <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> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@@ -25,15 +36,13 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel <StackPanel
Grid.Row="0" Grid.Row="0"
Grid.Column="0"> Grid.Column="0">
<Label Content="{x:Static properties:Resources.categoryNameLabel}"
Padding="0"
Margin="0,0,0,1"
Target="{Binding ElementName=NameTextBox}" />
<TextBox Name="NameTextBox" <TextBox Name="NameTextBox"
VerticalAlignment="Center" VerticalAlignment="Center"
mah:TextBoxHelper.UseFloatingWatermark="True"
mah:TextBoxHelper.Watermark="{x:Static properties:Resources.categoryNameLabel}"
Text="{Binding Path=Name, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}"> Text="{Binding Path=Name, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True}">
</TextBox> </TextBox>
</StackPanel> </StackPanel>
@@ -44,7 +53,6 @@
Margin="0,5,0,0" Margin="0,5,0,0"
HorizontalAlignment="Right"> HorizontalAlignment="Right">
<Button Content="{x:Static properties:Resources.OkayButton}" <Button Content="{x:Static properties:Resources.OkayButton}"
Height="23"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Width="75" Width="75"
@@ -52,7 +60,6 @@
IsDefault="True" IsDefault="True"
Click="HandleOkayButtonClick" /> Click="HandleOkayButtonClick" />
<Button Content="{x:Static properties:Resources.CancelButton}" <Button Content="{x:Static properties:Resources.CancelButton}"
Height="23"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
Width="75" Width="75"

View File

@@ -5,61 +5,38 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignHeight="150"
d:DesignWidth="300"> d:DesignWidth="400">
<Grid> <StackPanel options:Spacing.Vertical="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<CheckBox Content="{x:Static properties:Resources.lockWindowCheckBox}" <CheckBox Content="{x:Static properties:Resources.lockWindowCheckBox}"
Height="16"
HorizontalAlignment="Left"
Name="LockWindowCheckBox" Name="LockWindowCheckBox"
VerticalAlignment="Top" IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=WindowLocked}"
Width="300" Click="OnSaveSettings" />
Grid.ColumnSpan="2"
Click="LockWindowCheckBox_Click" />
<CheckBox Content="{x:Static properties:Resources.displayEmptyFeedsCheckBox}" <CheckBox Content="{x:Static properties:Resources.displayEmptyFeedsCheckBox}"
Height="16"
HorizontalAlignment="Left"
Margin="0,22,0,0"
Name="DisplayEmptyFeedsCheckBox" Name="DisplayEmptyFeedsCheckBox"
VerticalAlignment="Top" IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=DisplayEmptyFeeds}"
Width="300" Click="OnSaveSettings" />
Grid.ColumnSpan="2" <ComboBox
Grid.Column="0" Name="ToolbarLocationComboBox"
Click="DisplayEmptyFeedsCheckBox_Click" /> mah:TextBoxHelper.UseFloatingWatermark="True"
<Label Grid.Column="0" mah:TextBoxHelper.Watermark="{x:Static properties:Resources.toolbarLocationLabel}"
Content="{x:Static properties:Resources.toolbarLocationLabel}" SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=ToolbarLocation}"
VerticalAlignment="Top" SelectedValuePath="Tag"
Margin="0,50,0,0" SelectionChanged="OnSaveSettings">
Padding="0,5,5,5"
Target="{Binding ElementName=ToolbarLocationComboBox}"
Width="97" />
<ComboBox Margin="8,53,0,0"
Name="ToolbarLocationComboBox"
VerticalAlignment="Top"
Grid.Column="1"
SelectionChanged="ToolbarLocationComboBox_SelectionChanged">
<ComboBoxItem Content="{x:Static properties:Resources.Top}" <ComboBoxItem Content="{x:Static properties:Resources.Top}"
Tag="{x:Static Dock.Top}" /> Tag="{x:Static Dock.Top}" />
<ComboBoxItem Content="{x:Static properties:Resources.Bottom}" <ComboBoxItem Content="{x:Static properties:Resources.Bottom}"
Tag="{x:Static Dock.Bottom}" /> Tag="{x:Static Dock.Bottom}" />
</ComboBox> </ComboBox>
<Label Grid.Column="0" <ComboBox
Content="{x:Static properties:Resources.multipleLineDisplayLabel}" Name="MultipleLineDisplayComboBox"
VerticalAlignment="Top" mah:TextBoxHelper.UseFloatingWatermark="True"
Margin="0,82,0,0" mah:TextBoxHelper.Watermark="{x:Static properties:Resources.multipleLineDisplayLabel}"
Padding="0,5,5,5" SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=MultipleLineDisplay}"
Target="{Binding ElementName=MultipleLineDisplayComboBox}" SelectedValuePath="Tag"
Width="97" /> SelectionChanged="OnSaveSettings">
<ComboBox Margin="8,86,0,0"
Name="MultipleLineDisplayComboBox"
VerticalAlignment="Top"
Grid.Column="1"
SelectionChanged="MultipleLineDisplayComboBox_SelectionChanged">
<ComboBoxItem Content="{x:Static properties:Resources.multipleLineDisplayNormal}" <ComboBoxItem Content="{x:Static properties:Resources.multipleLineDisplayNormal}"
Tag="{x:Static options:MultipleLineDisplay.Normal}" /> Tag="{x:Static options:MultipleLineDisplay.Normal}" />
<ComboBoxItem Content="{x:Static properties:Resources.multipleLineDisplaySingleLine}" <ComboBoxItem Content="{x:Static properties:Resources.multipleLineDisplaySingleLine}"
@@ -67,5 +44,5 @@
<ComboBoxItem Content="{x:Static properties:Resources.multipleLineDisplayFirstLine}" <ComboBoxItem Content="{x:Static properties:Resources.multipleLineDisplayFirstLine}"
Tag="{x:Static options:MultipleLineDisplay.FirstLine}" /> Tag="{x:Static options:MultipleLineDisplay.FirstLine}" />
</ComboBox> </ComboBox>
</Grid> </StackPanel>
</options:OptionsPanelBase> </options:OptionsPanelBase>

View File

@@ -1,7 +1,5 @@
using System.Linq; using FeedCenter.Properties;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using FeedCenter.Properties;
namespace FeedCenter.Options; namespace FeedCenter.Options;
@@ -18,43 +16,18 @@ public partial class DisplayOptionsPanel
{ {
base.LoadPanel(); base.LoadPanel();
LockWindowCheckBox.IsChecked = Settings.Default.WindowLocked;
DisplayEmptyFeedsCheckBox.IsChecked = Settings.Default.DisplayEmptyFeeds;
ToolbarLocationComboBox.SelectedItem = ToolbarLocationComboBox.Items.Cast<ComboBoxItem>().First(comboBoxItem => (Dock) comboBoxItem.Tag == Settings.Default.ToolbarLocation);
MultipleLineDisplayComboBox.SelectedItem = MultipleLineDisplayComboBox.Items.Cast<ComboBoxItem>().First(comboBoxItem => (MultipleLineDisplay) comboBoxItem.Tag == Settings.Default.MultipleLineDisplay);
MarkLoaded(); MarkLoaded();
} }
private void LockWindowCheckBox_Click(object sender, System.Windows.RoutedEventArgs e) private void OnSaveSettings(object sender, RoutedEventArgs e)
{ {
if (!HasLoaded) return; SaveSettings();
if (LockWindowCheckBox.IsChecked.HasValue && Settings.Default.WindowLocked != LockWindowCheckBox.IsChecked.Value)
Settings.Default.WindowLocked = LockWindowCheckBox.IsChecked.Value;
} }
private void DisplayEmptyFeedsCheckBox_Click(object sender, System.Windows.RoutedEventArgs e) private void SaveSettings()
{ {
if (!HasLoaded) return; if (!HasLoaded) return;
if (DisplayEmptyFeedsCheckBox.IsChecked.HasValue && Settings.Default.DisplayEmptyFeeds != DisplayEmptyFeedsCheckBox.IsChecked.Value) Settings.Default.Save();
Settings.Default.DisplayEmptyFeeds = DisplayEmptyFeedsCheckBox.IsChecked.Value;
}
private void ToolbarLocationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!HasLoaded) return;
var dock = (Dock) ((ComboBoxItem) ToolbarLocationComboBox.SelectedItem).Tag;
Settings.Default.ToolbarLocation = dock;
}
private void MultipleLineDisplayComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!HasLoaded) return;
var multipleLineDisplay = (MultipleLineDisplay) ((ComboBoxItem) MultipleLineDisplayComboBox.SelectedItem).Tag;
Settings.Default.MultipleLineDisplay = multipleLineDisplay;
} }
} }

View File

@@ -13,6 +13,16 @@
WindowStartupLocation="CenterOwner" WindowStartupLocation="CenterOwner"
Icon="/FeedCenter;component/Resources/Application.ico" Icon="/FeedCenter;component/Resources/Application.ico"
FocusManager.FocusedElement="{Binding ElementName=UrlTextBox}"> FocusManager.FocusedElement="{Binding ElementName=UrlTextBox}">
<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> <Grid>
<TabControl Name="OptionsTabControl" <TabControl Name="OptionsTabControl"
Margin="12,12,12,41"> Margin="12,12,12,41">

View File

@@ -29,6 +29,8 @@
CanUserResizeRows="False" CanUserResizeRows="False"
IsReadOnly="True" IsReadOnly="True"
HeadersVisibility="Column" HeadersVisibility="Column"
BorderThickness="1,1,1,1"
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
Background="{x:Null}" Background="{x:Null}"
PreviewMouseLeftButtonDown="HandleFeedListPreviewMouseLeftButtonDown" SelectionChanged="FeedListBox_SelectionChanged"> PreviewMouseLeftButtonDown="HandleFeedListPreviewMouseLeftButtonDown" SelectionChanged="FeedListBox_SelectionChanged">
<DataGrid.Columns> <DataGrid.Columns>
@@ -48,12 +50,6 @@
Handler="HandleListBoxItemPreviewMouseMove" /> Handler="HandleListBoxItemPreviewMouseMove" />
</Style> </Style>
</DataGrid.ItemContainerStyle> </DataGrid.ItemContainerStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness"
Value="0" />
</Style>
</DataGrid.CellStyle>
</DataGrid> </DataGrid>
<DataGrid Name="CategoryListBox" <DataGrid Name="CategoryListBox"
SelectionChanged="HandleCategoryListBoxSelectionChanged" SelectionChanged="HandleCategoryListBoxSelectionChanged"
@@ -65,6 +61,8 @@
CanUserResizeRows="False" CanUserResizeRows="False"
IsReadOnly="True" IsReadOnly="True"
HeadersVisibility="Column" HeadersVisibility="Column"
BorderThickness="1,1,1,1"
BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
AllowDrop="True" AllowDrop="True"
Background="{x:Null}" Background="{x:Null}"
d:DataContext="{d:DesignInstance Type=feedCenter:Category }"> d:DataContext="{d:DesignInstance Type=feedCenter:Category }">
@@ -86,12 +84,6 @@
Handler="CategoryListBox_MouseDoubleClick" /> Handler="CategoryListBox_MouseDoubleClick" />
</Style> </Style>
</DataGrid.ItemContainerStyle> </DataGrid.ItemContainerStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="BorderThickness"
Value="0" />
</Style>
</DataGrid.CellStyle>
</DataGrid> </DataGrid>
<Border Grid.Column="2" <Border Grid.Column="2"
Grid.Row="1" Grid.Row="1"

View File

@@ -5,54 +5,33 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:installedBrowsers="clr-namespace:ChrisKaczor.InstalledBrowsers;assembly=ChrisKaczor.InstalledBrowsers"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignHeight="300"
d:DesignWidth="300"> d:DesignWidth="300">
<Grid> <StackPanel options:Spacing.Vertical="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="15" />
<RowDefinition Height="Auto" />
<RowDefinition Height="5" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<CheckBox Content="{x:Static properties:Resources.startWithWindowsCheckBox}" <CheckBox Content="{x:Static properties:Resources.startWithWindowsCheckBox}"
Name="StartWithWindowsCheckBox" Name="StartWithWindowsCheckBox"
VerticalAlignment="Top" IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=StartWithWindows}"
VerticalContentAlignment="Center" Click="OnSaveSettings" />
Margin="0,5"
Grid.ColumnSpan="2"
Click="StartWithWindowsCheckBox_Click" />
<Label Content="{x:Static properties:Resources.defaultBrowserLabel}"
Target="{Binding ElementName=BrowserComboBox}"
Grid.Column="0"
Grid.Row="2"
Padding="0"
VerticalContentAlignment="Center"
Margin="0,0,5,0" />
<ComboBox Name="BrowserComboBox" <ComboBox Name="BrowserComboBox"
Grid.Row="2" mah:TextBoxHelper.UseFloatingWatermark="True"
Grid.Column="1" mah:TextBoxHelper.Watermark="{x:Static properties:Resources.defaultBrowserLabel}"
VerticalContentAlignment="Center" d:DataContext="{d:DesignInstance Type=installedBrowsers:InstalledBrowser}"
SelectionChanged="BrowserComboBox_SelectionChanged"> DisplayMemberPath="Name"
</ComboBox> ItemsSource="{Binding Source={x:Static installedBrowsers:InstalledBrowser.InstalledBrowsers}}"
<Label Content="{x:Static properties:Resources.defaultUserAgentLabel}" SelectedValuePath="Key"
Target="{Binding ElementName=BrowserComboBox}" SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=Browser}"
Grid.Column="0" SelectionChanged="OnSaveSettings" />
Grid.Row="4"
Padding="0"
VerticalContentAlignment="Center"
Margin="0,0,5,0" />
<ComboBox Name="UserAgentComboBox" <ComboBox Name="UserAgentComboBox"
Grid.Row="4" mah:TextBoxHelper.UseFloatingWatermark="True"
Grid.Column="1" mah:TextBoxHelper.Watermark="{x:Static properties:Resources.defaultUserAgentLabel}"
VerticalContentAlignment="Center" d:DataContext="{d:DesignInstance Type=options:UserAgentItem}"
SelectionChanged="UserAgentComboBox_SelectionChanged"> DisplayMemberPath="Caption"
</ComboBox> ItemsSource="{Binding Source={x:Static options:UserAgentItem.UserAgents}}"
</Grid> SelectedValuePath="UserAgent"
SelectedValue="{Binding Source={x:Static properties:Settings.Default}, Path=DefaultUserAgent}"
SelectionChanged="OnSaveSettings" />
</StackPanel>
</options:OptionsPanelBase> </options:OptionsPanelBase>

View File

@@ -1,8 +1,6 @@
using ChrisKaczor.InstalledBrowsers; using ChrisKaczor.Wpf.Application;
using ChrisKaczor.Wpf.Application; using FeedCenter.Properties;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace FeedCenter.Options; namespace FeedCenter.Options;
@@ -19,87 +17,20 @@ public partial class GeneralOptionsPanel
{ {
base.LoadPanel(); base.LoadPanel();
var settings = Properties.Settings.Default;
StartWithWindowsCheckBox.IsChecked = settings.StartWithWindows;
LoadBrowserComboBox(BrowserComboBox, settings.Browser);
LoadUserAgentComboBox(UserAgentComboBox, settings.DefaultUserAgent);
MarkLoaded(); MarkLoaded();
} }
private static void LoadBrowserComboBox(Selector selector, string selected) private void OnSaveSettings(object sender, RoutedEventArgs e)
{ {
selector.SelectedIndex = 0; SaveSettings();
ComboBoxItem selectedItem = null;
var browsers = InstalledBrowser.GetInstalledBrowsers(true);
foreach (var browser in browsers)
{
var item = new ComboBoxItem { Content = browser.Value.Name, Tag = browser.Key };
selector.Items.Add(item);
if (browser.Key == selected)
selectedItem = item;
}
if (selectedItem != null)
selector.SelectedItem = selectedItem;
} }
private static void LoadUserAgentComboBox(Selector selector, string selected) private void SaveSettings()
{
selector.SelectedIndex = 0;
ComboBoxItem selectedItem = null;
var userAgents = UserAgentItem.GetUserAgents();
foreach (var userAgent in userAgents)
{
var item = new ComboBoxItem { Content = userAgent.Caption, Tag = userAgent.UserAgent };
selector.Items.Add(item);
if (userAgent.UserAgent == selected)
selectedItem = item;
}
if (selectedItem != null)
selector.SelectedItem = selectedItem;
}
private void StartWithWindowsCheckBox_Click(object sender, System.Windows.RoutedEventArgs e)
{ {
if (!HasLoaded) return; if (!HasLoaded) return;
var settings = Properties.Settings.Default; Settings.Default.Save();
if (StartWithWindowsCheckBox.IsChecked.HasValue && Application.Current.SetStartWithWindows(Settings.Default.StartWithWindows);
settings.StartWithWindows != StartWithWindowsCheckBox.IsChecked.Value)
settings.StartWithWindows = StartWithWindowsCheckBox.IsChecked.Value;
System.Windows.Application.Current.SetStartWithWindows(settings.StartWithWindows);
}
private void BrowserComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!HasLoaded) return;
var settings = Properties.Settings.Default;
settings.Browser = (string) ((ComboBoxItem) BrowserComboBox.SelectedItem).Tag;
}
private void UserAgentComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!HasLoaded) return;
var settings = Properties.Settings.Default;
settings.DefaultUserAgent = (string) ((ComboBoxItem) UserAgentComboBox.SelectedItem).Tag;
} }
} }

View File

@@ -0,0 +1,73 @@
using JetBrains.Annotations;
using System.Windows;
using System.Windows.Controls;
namespace FeedCenter.Options;
public class MarginSetter
{
private static Thickness GetLastItemMargin(DependencyObject obj)
{
return (Thickness) obj.GetValue(LastItemMarginProperty);
}
[UsedImplicitly]
public static Thickness GetMargin(DependencyObject obj)
{
return (Thickness) obj.GetValue(MarginProperty);
}
private static void MarginChangedCallback(object sender, DependencyPropertyChangedEventArgs e)
{
// Make sure this is put on a panel
if (sender is not Panel panel)
return;
// Avoid duplicate registrations
panel.Loaded -= OnPanelLoaded;
panel.Loaded += OnPanelLoaded;
if (panel.IsLoaded)
{
OnPanelLoaded(panel, null);
}
}
private static void OnPanelLoaded(object sender, RoutedEventArgs e)
{
var panel = (Panel) sender;
// Go over the children and set margin for them:
for (var i = 0; i < panel.Children.Count; i++)
{
var child = panel.Children[i];
if (child is not FrameworkElement fe)
continue;
var isLastItem = i == panel.Children.Count - 1;
fe.Margin = isLastItem ? GetLastItemMargin(panel) : GetMargin(panel);
}
}
[UsedImplicitly]
public static void SetLastItemMargin(DependencyObject obj, Thickness value)
{
obj.SetValue(LastItemMarginProperty, value);
}
[UsedImplicitly]
public static void SetMargin(DependencyObject obj, Thickness value)
{
obj.SetValue(MarginProperty, value);
}
// Using a DependencyProperty as the backing store for Margin. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MarginProperty =
DependencyProperty.RegisterAttached("Margin", typeof(Thickness), typeof(MarginSetter),
new UIPropertyMetadata(new Thickness(), MarginChangedCallback));
public static readonly DependencyProperty LastItemMarginProperty =
DependencyProperty.RegisterAttached("LastItemMargin", typeof(Thickness), typeof(MarginSetter),
new UIPropertyMetadata(new Thickness(), MarginChangedCallback));
}

View File

@@ -8,21 +8,44 @@
ResizeMode="CanResize" ResizeMode="CanResize"
WindowStartupLocation="CenterScreen" WindowStartupLocation="CenterScreen"
Icon="/FeedCenter;component/Resources/Application.ico"> Icon="/FeedCenter;component/Resources/Application.ico">
<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> <Grid>
<ListBox HorizontalAlignment="Left" <Grid.RowDefinitions>
Name="CategoryListBox" <RowDefinition Height="*" />
Width="126" <RowDefinition Height="Auto" />
SelectionChanged="HandleSelectedCategoryChanged" </Grid.RowDefinitions>
Margin="12,12,0,41" /> <Grid.ColumnDefinitions>
<ContentControl Margin="144,12,12,41" <ColumnDefinition Width="130" />
Name="ContentControl" <ColumnDefinition Width="5" />
IsTabStop="False" /> <ColumnDefinition Width="*" />
<Button Content="{x:Static properties:Resources.CloseButton}" </Grid.ColumnDefinitions>
Margin="0,0,12,12" <ListBox
Height="23" Grid.Column="0"
VerticalAlignment="Bottom" Grid.Row="0"
HorizontalAlignment="Right" Name="CategoryListBox"
Width="75" SelectionChanged="HandleSelectedCategoryChanged" />
IsCancel="True" /> <ContentControl
Grid.Column="2"
Grid.Row="0"
Margin="0,6,6,6"
Name="ContentControl"
IsTabStop="False" />
<Button
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
Margin="0,6,6,6"
Content="{x:Static properties:Resources.CloseButton}"
HorizontalAlignment="Right"
IsCancel="True" />
</Grid> </Grid>
</Window> </Window>

View File

@@ -0,0 +1,55 @@
using JetBrains.Annotations;
using System.Windows;
namespace FeedCenter.Options
{
public class Spacing
{
public static double GetHorizontal(DependencyObject obj)
{
return (double) obj.GetValue(HorizontalProperty);
}
public static double GetVertical(DependencyObject obj)
{
return (double) obj.GetValue(VerticalProperty);
}
private static void HorizontalChangedCallback(object sender, DependencyPropertyChangedEventArgs e)
{
var space = (double) e.NewValue;
var obj = (DependencyObject) sender;
MarginSetter.SetMargin(obj, new Thickness(0, 0, space, 0));
MarginSetter.SetLastItemMargin(obj, new Thickness(0));
}
[UsedImplicitly]
public static void SetHorizontal(DependencyObject obj, double space)
{
obj.SetValue(HorizontalProperty, space);
}
[UsedImplicitly]
public static void SetVertical(DependencyObject obj, double value)
{
obj.SetValue(VerticalProperty, value);
}
private static void VerticalChangedCallback(object sender, DependencyPropertyChangedEventArgs e)
{
var space = (double) e.NewValue;
var obj = (DependencyObject) sender;
MarginSetter.SetMargin(obj, new Thickness(0, 0, 0, space));
MarginSetter.SetLastItemMargin(obj, new Thickness(0));
}
public static readonly DependencyProperty VerticalProperty =
DependencyProperty.RegisterAttached("Vertical", typeof(double), typeof(Spacing),
new UIPropertyMetadata(0d, VerticalChangedCallback));
public static readonly DependencyProperty HorizontalProperty =
DependencyProperty.RegisterAttached("Horizontal", typeof(double), typeof(Spacing),
new UIPropertyMetadata(0d, HorizontalChangedCallback));
}
}

View File

@@ -6,19 +6,15 @@
xmlns:options="clr-namespace:FeedCenter.Options" xmlns:options="clr-namespace:FeedCenter.Options"
xmlns:properties="clr-namespace:FeedCenter.Properties" xmlns:properties="clr-namespace:FeedCenter.Properties"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="300" d:DesignHeight="150"
d:DesignWidth="300"> d:DesignWidth="250">
<Grid> <StackPanel options:Spacing.Vertical="10">
<CheckBox Content="{x:Static properties:Resources.checkVersionOnStartupCheckBox}" <CheckBox Content="{x:Static properties:Resources.checkVersionOnStartupCheckBox}"
Name="CheckVersionOnStartupCheckBox" Name="CheckVersionOnStartupCheckBox"
VerticalAlignment="Top" IsChecked="{Binding Source={x:Static properties:Settings.Default}, Path=CheckVersionAtStartup}"
Click="CheckVersionOnStartupCheckBox_Click" /> Click="OnSaveSettings" />
<Button Content="{x:Static properties:Resources.checkVersionNowButton}" <Button Content="{x:Static properties:Resources.checkVersionNowButton}"
Height="23"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="0,22,0,0"
VerticalAlignment="Top"
Width="75"
Click="HandleCheckVersionNowButtonClick" /> Click="HandleCheckVersionNowButtonClick" />
</Grid> </StackPanel>
</options:OptionsPanelBase> </options:OptionsPanelBase>

View File

@@ -1,5 +1,6 @@
using System.Windows; using ChrisKaczor.ApplicationUpdate;
using ChrisKaczor.ApplicationUpdate; using FeedCenter.Properties;
using System.Windows;
namespace FeedCenter.Options; namespace FeedCenter.Options;
@@ -12,25 +13,20 @@ public partial class UpdateOptionsPanel
public override string CategoryName => Properties.Resources.optionCategoryUpdate; public override string CategoryName => Properties.Resources.optionCategoryUpdate;
public override void LoadPanel() private void HandleCheckVersionNowButtonClick(object sender, RoutedEventArgs e)
{
base.LoadPanel();
CheckVersionOnStartupCheckBox.IsChecked = Properties.Settings.Default.CheckVersionAtStartup;
MarkLoaded();
}
private void HandleCheckVersionNowButtonClick(object sender, System.Windows.RoutedEventArgs e)
{ {
UpdateCheck.DisplayUpdateInformation(true); UpdateCheck.DisplayUpdateInformation(true);
} }
private void CheckVersionOnStartupCheckBox_Click(object sender, System.Windows.RoutedEventArgs e) private void OnSaveSettings(object sender, RoutedEventArgs e)
{
SaveSettings();
}
private void SaveSettings()
{ {
if (!HasLoaded) return; if (!HasLoaded) return;
if (CheckVersionOnStartupCheckBox.IsChecked.HasValue && Properties.Settings.Default.CheckVersionAtStartup != CheckVersionOnStartupCheckBox.IsChecked.Value) Settings.Default.Save();
Properties.Settings.Default.CheckVersionAtStartup = CheckVersionOnStartupCheckBox.IsChecked.Value;
} }
} }

View File

@@ -2,38 +2,33 @@
namespace FeedCenter.Options namespace FeedCenter.Options
{ {
internal class UserAgentItem public class UserAgentItem
{ {
internal string Caption { get; set; } public string Caption { get; set; }
internal string UserAgent { get; set; } public string UserAgent { get; set; }
internal static List<UserAgentItem> GetUserAgents() public static List<UserAgentItem> UserAgents => new()
{ {
var userAgents = new List<UserAgentItem> new UserAgentItem
{ {
new() Caption = Properties.Resources.DefaultUserAgentCaption,
{ UserAgent = string.Empty
Caption = Properties.Resources.DefaultUserAgentCaption, },
UserAgent = string.Empty new UserAgentItem
}, {
new() Caption = "Windows RSS Platform 2.0",
{ UserAgent = "Windows-RSS-Platform/2.0 (MSIE 9.0; Windows NT 6.1)"
Caption = "Windows RSS Platform 2.0", },
UserAgent = "Windows-RSS-Platform/2.0 (MSIE 9.0; Windows NT 6.1)" new UserAgentItem
}, {
new() Caption = "Feedly 1.0",
{ UserAgent = "Feedly/1.0"
Caption = "Feedly 1.0", },
UserAgent = "Feedly/1.0" new UserAgentItem
}, {
new() Caption = "curl",
{ UserAgent = "curl/7.47.0"
Caption = "curl", }
UserAgent = "curl/7.47.0" };
}
};
return userAgents;
}
} }
} }

View File

@@ -215,7 +215,7 @@ namespace FeedCenter.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to _Name:. /// Looks up a localized string similar to Name.
/// </summary> /// </summary>
public static string categoryNameLabel { public static string categoryNameLabel {
get { get {
@@ -508,7 +508,7 @@ namespace FeedCenter.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Default _browser:. /// Looks up a localized string similar to Default browser.
/// </summary> /// </summary>
public static string defaultBrowserLabel { public static string defaultBrowserLabel {
get { get {
@@ -526,7 +526,7 @@ namespace FeedCenter.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Default _user agent:. /// Looks up a localized string similar to Default user agent.
/// </summary> /// </summary>
public static string defaultUserAgentLabel { public static string defaultUserAgentLabel {
get { get {
@@ -994,7 +994,7 @@ namespace FeedCenter.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to _Multi-line items:. /// Looks up a localized string similar to Multiline titles.
/// </summary> /// </summary>
public static string multipleLineDisplayLabel { public static string multipleLineDisplayLabel {
get { get {
@@ -1444,7 +1444,7 @@ namespace FeedCenter.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to _Tool bar location:. /// Looks up a localized string similar to Toolbar location.
/// </summary> /// </summary>
public static string toolbarLocationLabel { public static string toolbarLocationLabel {
get { get {
@@ -1462,7 +1462,7 @@ namespace FeedCenter.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Version: {0}. /// Looks up a localized string similar to Version {0}.
/// </summary> /// </summary>
public static string Version { public static string Version {
get { get {

View File

@@ -149,7 +149,7 @@
<value>&lt; no title &gt;</value> <value>&lt; no title &gt;</value>
</data> </data>
<data name="Version" xml:space="preserve"> <data name="Version" xml:space="preserve">
<value>Version: {0}</value> <value>Version {0}</value>
</data> </data>
<data name="SplashCheckingForUpdate" xml:space="preserve"> <data name="SplashCheckingForUpdate" xml:space="preserve">
<value>Checking for update...</value> <value>Checking for update...</value>
@@ -320,7 +320,7 @@
<value>Right</value> <value>Right</value>
</data> </data>
<data name="toolbarLocationLabel" xml:space="preserve"> <data name="toolbarLocationLabel" xml:space="preserve">
<value>_Tool bar location:</value> <value>Toolbar location</value>
</data> </data>
<data name="Top" xml:space="preserve"> <data name="Top" xml:space="preserve">
<value>Top</value> <value>Top</value>
@@ -347,7 +347,7 @@
<value>_Register as default feed reader</value> <value>_Register as default feed reader</value>
</data> </data>
<data name="defaultBrowserLabel" xml:space="preserve"> <data name="defaultBrowserLabel" xml:space="preserve">
<value>Default _browser:</value> <value>Default browser</value>
</data> </data>
<data name="DefaultBrowserCaption" xml:space="preserve"> <data name="DefaultBrowserCaption" xml:space="preserve">
<value>&lt; Windows Default &gt;</value> <value>&lt; Windows Default &gt;</value>
@@ -365,7 +365,7 @@
<value>Edit Category</value> <value>Edit Category</value>
</data> </data>
<data name="multipleLineDisplayLabel" xml:space="preserve"> <data name="multipleLineDisplayLabel" xml:space="preserve">
<value>_Multi-line items:</value> <value>Multiline titles</value>
</data> </data>
<data name="multipleLineDisplayFirstLine" xml:space="preserve"> <data name="multipleLineDisplayFirstLine" xml:space="preserve">
<value>Show only first line</value> <value>Show only first line</value>
@@ -527,7 +527,7 @@
<value>Feed Center</value> <value>Feed Center</value>
</data> </data>
<data name="defaultUserAgentLabel" xml:space="preserve"> <data name="defaultUserAgentLabel" xml:space="preserve">
<value>Default _user agent:</value> <value>Default user agent</value>
</data> </data>
<data name="SplashLoadingDatabase" xml:space="preserve"> <data name="SplashLoadingDatabase" xml:space="preserve">
<value>Loading database...</value> <value>Loading database...</value>
@@ -536,7 +536,7 @@
<value>Migrating legacy database...</value> <value>Migrating legacy database...</value>
</data> </data>
<data name="categoryNameLabel" xml:space="preserve"> <data name="categoryNameLabel" xml:space="preserve">
<value>_Name:</value> <value>Name</value>
</data> </data>
<data name="ConfirmDeleteCategory" xml:space="preserve"> <data name="ConfirmDeleteCategory" xml:space="preserve">
<value>Are you sure you want to delete this category? <value>Are you sure you want to delete this category?