mirror of
https://github.com/ckaczor/FeedCenter.git
synced 2026-01-13 17:22:48 -05:00
Add setting for default user agent
This commit is contained in:
@@ -268,9 +268,6 @@
|
||||
<Compile Include="Options\OptionsWindow.xaml.cs">
|
||||
<DependentUpon>OptionsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Options\ReadingOptionsPanel.xaml.cs">
|
||||
<DependentUpon>ReadingOptionsPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Options\UpdateOptionsPanel.xaml.cs">
|
||||
<DependentUpon>UpdateOptionsPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -341,10 +338,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Options\ReadingOptionsPanel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Options\UpdateOptionsPanel.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@@ -142,7 +142,10 @@ namespace FeedCenter
|
||||
webRequest.Credentials = new NetworkCredential(Username, Password, Domain);
|
||||
|
||||
// Set a user agent string
|
||||
webRequest.UserAgent = "FeedCenter " + UpdateCheck.LocalVersion;
|
||||
if (string.IsNullOrWhiteSpace(Properties.Settings.Default.DefaultUserAgent))
|
||||
webRequest.UserAgent = "FeedCenter/" + UpdateCheck.LocalVersion;
|
||||
else
|
||||
webRequest.UserAgent = Properties.Settings.Default.DefaultUserAgent;
|
||||
}
|
||||
|
||||
// Set the default encoding
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<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="*" />
|
||||
@@ -17,6 +25,34 @@
|
||||
Name="StartWithWindowsCheckBox"
|
||||
VerticalAlignment="Top"
|
||||
VerticalContentAlignment="Center"
|
||||
Margin="0,5"
|
||||
Grid.ColumnSpan="2" />
|
||||
<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"
|
||||
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}"
|
||||
Grid.Column="0"
|
||||
Grid.Row="4"
|
||||
Padding="0"
|
||||
VerticalContentAlignment="Center"
|
||||
Margin="0,0,5,0" />
|
||||
<ComboBox Name="UserAgentComboBox"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
VerticalContentAlignment="Center">
|
||||
</ComboBox>
|
||||
|
||||
</Grid>
|
||||
</options:OptionsPanelBase>
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using Common.Wpf.Extensions;
|
||||
using Common.Internet;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
internal class UserAgentItem
|
||||
{
|
||||
internal string Caption { get; set; }
|
||||
internal string UserAgent { get; set; }
|
||||
}
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
@@ -17,6 +27,10 @@ namespace FeedCenter.Options
|
||||
var settings = Properties.Settings.Default;
|
||||
|
||||
StartWithWindowsCheckBox.IsChecked = settings.StartWithWindows;
|
||||
|
||||
LoadBrowserComboBox(BrowserComboBox, settings.Browser);
|
||||
|
||||
LoadUserAgentComboBox(UserAgentComboBox, settings.DefaultUserAgent);
|
||||
}
|
||||
|
||||
public override bool ValidatePanel()
|
||||
@@ -28,12 +42,91 @@ namespace FeedCenter.Options
|
||||
{
|
||||
var settings = Properties.Settings.Default;
|
||||
|
||||
if (StartWithWindowsCheckBox.IsChecked.HasValue && settings.StartWithWindows != StartWithWindowsCheckBox.IsChecked.Value)
|
||||
if (StartWithWindowsCheckBox.IsChecked.HasValue &&
|
||||
settings.StartWithWindows != StartWithWindowsCheckBox.IsChecked.Value)
|
||||
settings.StartWithWindows = StartWithWindowsCheckBox.IsChecked.Value;
|
||||
|
||||
Application.Current.SetStartWithWindows(settings.StartWithWindows);
|
||||
|
||||
settings.Browser = (string) ((ComboBoxItem) BrowserComboBox.SelectedItem).Tag;
|
||||
|
||||
settings.DefaultUserAgent = (string) ((ComboBoxItem) UserAgentComboBox.SelectedItem).Tag;
|
||||
|
||||
var expressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
|
||||
this.UpdateAllSources(expressions);
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.optionCategoryGeneral;
|
||||
|
||||
private static void LoadBrowserComboBox(ComboBox comboBox, string selected)
|
||||
{
|
||||
comboBox.SelectedIndex = 0;
|
||||
|
||||
ComboBoxItem selectedItem = null;
|
||||
|
||||
var browsers = Browser.DetectInstalledBrowsers();
|
||||
foreach (var browser in browsers)
|
||||
{
|
||||
var item = new ComboBoxItem { Content = browser.Value.Name, Tag = browser.Key };
|
||||
|
||||
comboBox.Items.Add(item);
|
||||
|
||||
if (browser.Key == selected)
|
||||
selectedItem = item;
|
||||
}
|
||||
|
||||
if (selectedItem != null)
|
||||
comboBox.SelectedItem = selectedItem;
|
||||
}
|
||||
|
||||
private static void LoadUserAgentComboBox(ComboBox comboBox, string selected)
|
||||
{
|
||||
comboBox.SelectedIndex = 0;
|
||||
|
||||
ComboBoxItem selectedItem = null;
|
||||
|
||||
var userAgents = GetUserAgents();
|
||||
foreach (var userAgent in userAgents)
|
||||
{
|
||||
var item = new ComboBoxItem { Content = userAgent.Caption, Tag = userAgent.UserAgent };
|
||||
|
||||
comboBox.Items.Add(item);
|
||||
|
||||
if (userAgent.UserAgent == selected)
|
||||
selectedItem = item;
|
||||
}
|
||||
|
||||
if (selectedItem != null)
|
||||
comboBox.SelectedItem = selectedItem;
|
||||
}
|
||||
|
||||
private static List<UserAgentItem> GetUserAgents()
|
||||
{
|
||||
var userAgents = new List<UserAgentItem>
|
||||
{
|
||||
new UserAgentItem
|
||||
{
|
||||
Caption = Properties.Resources.DefaultUserAgentCaption,
|
||||
UserAgent = string.Empty
|
||||
},
|
||||
new UserAgentItem
|
||||
{
|
||||
Caption = "Windows RSS Platform 2.0",
|
||||
UserAgent = "Windows-RSS-Platform/2.0 (MSIE 9.0; Windows NT 6.1)"
|
||||
},
|
||||
new UserAgentItem
|
||||
{
|
||||
Caption = "Feedly 1.0",
|
||||
UserAgent = "Feedly/1.0"
|
||||
},
|
||||
new UserAgentItem
|
||||
{
|
||||
Caption = "curl",
|
||||
UserAgent = "curl/7.47.0"
|
||||
}
|
||||
};
|
||||
|
||||
return userAgents;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ namespace FeedCenter.Options
|
||||
_optionPanels.Add(new GeneralOptionsPanel());
|
||||
_optionPanels.Add(new DisplayOptionsPanel());
|
||||
_optionPanels.Add(new FeedsOptionsPanel());
|
||||
_optionPanels.Add(new ReadingOptionsPanel());
|
||||
_optionPanels.Add(new UpdateOptionsPanel());
|
||||
_optionPanels.Add(new AboutOptionsPanel());
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
<options:OptionsPanelBase x:Class="FeedCenter.Options.ReadingOptionsPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:options="clr-namespace:FeedCenter.Options"
|
||||
xmlns:properties="clr-namespace:FeedCenter.Properties"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="300">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Content="{x:Static properties:Resources.browserLabel}"
|
||||
Target="{Binding ElementName=BrowserComboBox}"
|
||||
Grid.Column="0"
|
||||
Padding="0"
|
||||
VerticalContentAlignment="Center"
|
||||
Margin="0,0,5,0" />
|
||||
<ComboBox Name="BrowserComboBox"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
VerticalContentAlignment="Center">
|
||||
<ComboBoxItem Content="{x:Static properties:Resources.DefaultBrowserCaption}"
|
||||
Tag="" />
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</options:OptionsPanelBase>
|
||||
@@ -1,64 +0,0 @@
|
||||
using Common.Internet;
|
||||
using Common.Wpf.Extensions;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace FeedCenter.Options
|
||||
{
|
||||
public partial class ReadingOptionsPanel
|
||||
{
|
||||
public ReadingOptionsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override void LoadPanel(FeedCenterEntities database)
|
||||
{
|
||||
base.LoadPanel(database);
|
||||
|
||||
var settings = Properties.Settings.Default;
|
||||
|
||||
LoadBrowserComboBox(BrowserComboBox, settings.Browser);
|
||||
}
|
||||
|
||||
public override bool ValidatePanel()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SavePanel()
|
||||
{
|
||||
var settings = Properties.Settings.Default;
|
||||
|
||||
var browser = (string) ((ComboBoxItem) BrowserComboBox.SelectedItem).Tag;
|
||||
|
||||
settings.Browser = browser;
|
||||
|
||||
var expressions = this.GetBindingExpressions(new[] { UpdateSourceTrigger.Explicit });
|
||||
this.UpdateAllSources(expressions);
|
||||
}
|
||||
|
||||
public override string CategoryName => Properties.Resources.optionCategoryReading;
|
||||
|
||||
private static void LoadBrowserComboBox(ComboBox comboBox, string selected)
|
||||
{
|
||||
comboBox.SelectedIndex = 0;
|
||||
|
||||
ComboBoxItem selectedItem = null;
|
||||
|
||||
var browsers = Browser.DetectInstalledBrowsers();
|
||||
foreach (var browser in browsers)
|
||||
{
|
||||
var item = new ComboBoxItem { Content = browser.Value.Name, Tag = browser.Key };
|
||||
|
||||
comboBox.Items.Add(item);
|
||||
|
||||
if (browser.Key == selected)
|
||||
selectedItem = item;
|
||||
}
|
||||
|
||||
if (selectedItem != null)
|
||||
comboBox.SelectedItem = selectedItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Application/Properties/Resources.Designer.cs
generated
38
Application/Properties/Resources.Designer.cs
generated
@@ -169,15 +169,6 @@ namespace FeedCenter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to _Browser:.
|
||||
/// </summary>
|
||||
public static string browserLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("browserLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Edit Multiple Feeds.
|
||||
/// </summary>
|
||||
@@ -470,7 +461,7 @@ namespace FeedCenter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Default.
|
||||
/// Looks up a localized string similar to < Windows Default >.
|
||||
/// </summary>
|
||||
public static string DefaultBrowserCaption {
|
||||
get {
|
||||
@@ -478,6 +469,33 @@ namespace FeedCenter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Default _browser:.
|
||||
/// </summary>
|
||||
public static string defaultBrowserLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("defaultBrowserLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Feed Center.
|
||||
/// </summary>
|
||||
public static string DefaultUserAgentCaption {
|
||||
get {
|
||||
return ResourceManager.GetString("DefaultUserAgentCaption", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Default _user agent:.
|
||||
/// </summary>
|
||||
public static string defaultUserAgentLabel {
|
||||
get {
|
||||
return ResourceManager.GetString("defaultUserAgentLabel", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete Category.
|
||||
/// </summary>
|
||||
|
||||
@@ -346,11 +346,11 @@
|
||||
<data name="registerAsDefaultFeedReaderCheckBox" xml:space="preserve">
|
||||
<value>_Register as default feed reader</value>
|
||||
</data>
|
||||
<data name="browserLabel" xml:space="preserve">
|
||||
<value>_Browser:</value>
|
||||
<data name="defaultBrowserLabel" xml:space="preserve">
|
||||
<value>Default _browser:</value>
|
||||
</data>
|
||||
<data name="DefaultBrowserCaption" xml:space="preserve">
|
||||
<value>Default</value>
|
||||
<value>< Windows Default ></value>
|
||||
</data>
|
||||
<data name="feedCategoryLabel" xml:space="preserve">
|
||||
<value>_Category:</value>
|
||||
@@ -523,4 +523,10 @@
|
||||
<data name="CategoryFilterHeader" xml:space="preserve">
|
||||
<value>Category: {0}</value>
|
||||
</data>
|
||||
<data name="DefaultUserAgentCaption" xml:space="preserve">
|
||||
<value>Feed Center</value>
|
||||
</data>
|
||||
<data name="defaultUserAgentLabel" xml:space="preserve">
|
||||
<value>Default _user agent:</value>
|
||||
</data>
|
||||
</root>
|
||||
15
Application/Properties/Settings.Designer.cs
generated
15
Application/Properties/Settings.Designer.cs
generated
@@ -12,7 +12,7 @@ namespace FeedCenter.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@@ -289,5 +289,18 @@ namespace FeedCenter.Properties {
|
||||
this["LastCategoryID"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Configuration.SettingsProviderAttribute(typeof(Common.Settings.GenericSettingsProvider))]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("")]
|
||||
public string DefaultUserAgent {
|
||||
get {
|
||||
return ((string)(this["DefaultUserAgent"]));
|
||||
}
|
||||
set {
|
||||
this["DefaultUserAgent"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,5 +71,8 @@
|
||||
<Setting Name="LastCategoryID" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
<Setting Name="DefaultUserAgent" Provider="Common.Settings.GenericSettingsProvider" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -60,6 +60,9 @@
|
||||
<setting name="LastCategoryID" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
<setting name="DefaultUserAgent" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</FeedCenter.Properties.Settings>
|
||||
</userSettings>
|
||||
<applicationSettings>
|
||||
|
||||
Reference in New Issue
Block a user