mirror of
https://github.com/openbullet/openbullet.git
synced 2023-10-21 07:33:42 -05:00
This resolves the request #135
2 dropdown boxes were added to customize the proxy test site and success key. The sites and keys are stored in Settings/ProxyManagerSettings.json file
This commit is contained in:
@@ -8,5 +8,6 @@ namespace OpenBullet
|
||||
{
|
||||
public EnvironmentSettings Environment { get; set; }
|
||||
public RLSettingsViewModel RLSettings { get; set; }
|
||||
public ProxyManagerSettings ProxyManagerSettings { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ namespace OpenBullet
|
||||
|
||||
// Initialize Settings
|
||||
OB.Settings.RLSettings = new RLSettingsViewModel();
|
||||
OB.Settings.ProxyManagerSettings = new ProxyManagerSettings();
|
||||
OB.OBSettings = new OBSettingsViewModel();
|
||||
|
||||
// Create / Load Settings
|
||||
@@ -106,10 +107,26 @@ namespace OpenBullet
|
||||
}
|
||||
else
|
||||
{
|
||||
OB.Settings.RLSettings = IOManager.LoadSettings(OB.rlSettingsFile);
|
||||
OB.Settings.RLSettings = IOManager.LoadSettings<RLSettingsViewModel>(OB.rlSettingsFile);
|
||||
OB.Logger.LogInfo(Components.Main, "Loaded the existing RuriLib Settings file");
|
||||
}
|
||||
|
||||
if (!File.Exists(OB.proxyManagerSettingsFile))
|
||||
{
|
||||
OB.Logger.LogWarning(Components.Main, "Proxy manager Settings file not found, generating a default one");
|
||||
OB.Settings.ProxyManagerSettings.ProxySiteUrls.Add(OB.defaultProxySiteUrl);
|
||||
OB.Settings.ProxyManagerSettings.ActiveProxySiteUrl = OB.defaultProxySiteUrl;
|
||||
OB.Settings.ProxyManagerSettings.ProxyKeys.Add(OB.defaultProxyKey);
|
||||
OB.Settings.ProxyManagerSettings.ActiveProxyKey = OB.defaultProxyKey;
|
||||
IOManager.SaveSettings(OB.proxyManagerSettingsFile, OB.Settings.ProxyManagerSettings);
|
||||
OB.Logger.LogInfo(Components.Main, $"Created the default proxy manager Settings file {OB.proxyManagerSettingsFile}");
|
||||
}
|
||||
else
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings = IOManager.LoadSettings<ProxyManagerSettings>(OB.proxyManagerSettingsFile);
|
||||
OB.Logger.LogInfo(Components.Main, "Loaded the existing proxy manager Settings file");
|
||||
}
|
||||
|
||||
if (!File.Exists(OB.obSettingsFile))
|
||||
{
|
||||
MessageBox.Show("OpenBullet Settings file not found, generating a default one");
|
||||
|
||||
@@ -56,10 +56,13 @@ namespace OpenBullet
|
||||
public static readonly string dataBaseBackupFile = @"DB/OpenBullet-BackupCopy.db";
|
||||
public static readonly string obSettingsFile = @"Settings/OBSettings.json";
|
||||
public static readonly string rlSettingsFile = @"Settings/RLSettings.json";
|
||||
public static readonly string proxyManagerSettingsFile = @"Settings/ProxyManagerSettings.json";
|
||||
public static readonly string envFile = @"Settings/Environment.ini";
|
||||
public static readonly string licenseFile = @"Settings/License.txt";
|
||||
public static readonly string logFile = @"Log.txt";
|
||||
public static readonly string configFolder = @"Configs";
|
||||
public static readonly string pluginsFolder = @"Plugins";
|
||||
public static readonly string defaultProxySiteUrl = "https://google.com";
|
||||
public static readonly string defaultProxyKey = "title>Google";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,11 +175,9 @@ namespace OpenBullet.ViewModels
|
||||
private int botsAmount = 1;
|
||||
public int BotsAmount { get { return botsAmount; } set { botsAmount = value; OnPropertyChanged(); } }
|
||||
|
||||
private string testSite = "https://google.com";
|
||||
public string TestSite { get { return testSite; } set { testSite = value; OnPropertyChanged(); } }
|
||||
public string TestSite { get { return OB.Settings.ProxyManagerSettings.ActiveProxySiteUrl; } set { OB.Settings.ProxyManagerSettings.ActiveProxySiteUrl = value; OnPropertyChanged(); } }
|
||||
|
||||
private string successKey = "title>Google";
|
||||
public string SuccessKey { get { return successKey; } set { successKey = value; OnPropertyChanged(); } }
|
||||
public string SuccessKey { get { return OB.Settings.ProxyManagerSettings.ActiveProxyKey; } set { OB.Settings.ProxyManagerSettings.ActiveProxyKey = value; OnPropertyChanged(); } }
|
||||
|
||||
private bool onlyUntested = true;
|
||||
public bool OnlyUntested { get { return onlyUntested; } set { onlyUntested = value; OnPropertyChanged(); } }
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:utils="clr-namespace:System.Web;assembly=System"
|
||||
xmlns:local="clr-namespace:OpenBullet.Views.Main"
|
||||
xmlns:openbullet="clr-namespace:OpenBullet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="550" d:DesignWidth="780"
|
||||
Title="ProxyManager">
|
||||
@@ -31,7 +32,7 @@
|
||||
<Grid Grid.Column="0" Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="65" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="1.5*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
@@ -43,17 +44,76 @@
|
||||
<Label Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" Content="Progress:" />
|
||||
<Label Grid.Column="0" Grid.Row="1" VerticalAlignment="Center" Content="Test On:" />
|
||||
<ProgressBar x:Name="progressBar" Grid.Column="1" Grid.Row="0" Minimum="0" Maximum="1" Margin="5" />
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Margin="5" Text="{Binding TestSite}" VerticalContentAlignment="Center"/>
|
||||
<Grid Grid.Column="1" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="35"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox IsEditable="True" Text="{Binding TestSite}"
|
||||
ItemsSource="{Binding Source={x:Static openbullet:OB.Settings}, Path=ProxyManagerSettings.ProxySiteUrls}" Grid.Column="0" Margin="5">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Grid.Column="0"/>
|
||||
<Image Source="/Images/Icons/minus.png" Width="20" MouseDown="RemoveProxySiteUrl_OnMouseDown" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" Margin="5 0 0 0" ToolTip="Delete the test site url" Grid.Column="2" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ComboBoxItem}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
<Image Source="/Images/Icons/plus.png" Width="20" MouseDown="AddProxySiteUrl_OnMouseDown" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" Margin="5 0" ToolTip="Add the test site url" Grid.Column="1" />
|
||||
</Grid>
|
||||
<DockPanel Grid.Column="2" Grid.Row="0" VerticalAlignment="Center">
|
||||
<Label Content="Bots: " />
|
||||
<Label Width="35" Content="{Binding BotsAmount}" />
|
||||
<Slider x:Name="botsSlider" VerticalAlignment="Center" TickFrequency="20" TickPlacement="Both" Minimum="1" Maximum="200" ValueChanged="botsSlider_ValueChanged" Margin="0 0 10 0"/>
|
||||
</DockPanel>
|
||||
<DockPanel Grid.Column="2" Grid.Row="1">
|
||||
<Label Content="Success Key:" VerticalAlignment="Center" />
|
||||
<TextBox Margin="5" Text="{Binding SuccessKey}" VerticalContentAlignment="Center"/>
|
||||
</DockPanel>
|
||||
|
||||
<Grid Grid.Column="2" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="35"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<DockPanel Grid.Column="0">
|
||||
<Label Content="Success Key:" VerticalAlignment="Center" />
|
||||
<ComboBox IsEditable="True" Text="{Binding SuccessKey}"
|
||||
ItemsSource="{Binding Source={x:Static openbullet:OB.Settings}, Path=ProxyManagerSettings.ProxyKeys}" Margin="5">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="30"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="{Binding}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Grid.Column="0"/>
|
||||
<Image Source="/Images/Icons/minus.png" Width="20" MouseDown="RemoveProxyKey_OnMouseDown" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" Margin="5 0 0 0" ToolTip="Delete the test site key" Grid.Column="2" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
<ComboBox.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type ComboBoxItem}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
</ComboBox.ItemContainerStyle>
|
||||
</ComboBox>
|
||||
</DockPanel>
|
||||
<Image Source="/Images/Icons/plus.png" Width="20" MouseDown="AddProxyKey_OnMouseDown" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" Margin="5 0" ToolTip="Add the test site key" Grid.Column="1" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- Check Button -->
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using RuriLib;
|
||||
|
||||
namespace OpenBullet.Views.Main
|
||||
{
|
||||
@@ -53,6 +54,18 @@ namespace OpenBullet.Views.Main
|
||||
botsSlider.IsEnabled = false;
|
||||
Status = WorkerStatus.Running;
|
||||
|
||||
if (OB.Settings.ProxyManagerSettings.ProxySiteUrls.Contains(vm.TestSite) == false)
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings.ProxySiteUrls.Add(vm.TestSite);
|
||||
}
|
||||
|
||||
if (OB.Settings.ProxyManagerSettings.ProxyKeys.Contains(vm.SuccessKey) == false)
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings.ProxyKeys.Add(vm.SuccessKey);
|
||||
}
|
||||
|
||||
IOManager.SaveSettings(OB.proxyManagerSettingsFile, OB.Settings.ProxyManagerSettings);
|
||||
|
||||
var items = vm.OnlyUntested ? vm.Proxies.Where(p => p.Working == ProxyWorking.UNTESTED) : vm.Proxies;
|
||||
|
||||
// Setup the progress bar
|
||||
@@ -331,6 +344,66 @@ namespace OpenBullet.Views.Main
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void AddProxySiteUrl_OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (OB.Settings.ProxyManagerSettings.ProxySiteUrls.Contains(vm.TestSite) == false)
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings.ProxySiteUrls.Add(vm.TestSite);
|
||||
IOManager.SaveSettings(OB.proxyManagerSettingsFile, OB.Settings.ProxyManagerSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveProxySiteUrl_OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Image image &&
|
||||
image.Parent is Grid grid &&
|
||||
grid.Children.Count == 2 &&
|
||||
grid.Children[0] is TextBlock textBlock)
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings.ProxySiteUrls.Remove(textBlock.Text);
|
||||
IOManager.SaveSettings(OB.proxyManagerSettingsFile, OB.Settings.ProxyManagerSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddProxyKey_OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (OB.Settings.ProxyManagerSettings.ProxyKeys.Contains(vm.SuccessKey) == false)
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings.ProxyKeys.Add(vm.SuccessKey);
|
||||
IOManager.SaveSettings(OB.proxyManagerSettingsFile, OB.Settings.ProxyManagerSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveProxyKey_OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Image image &&
|
||||
image.Parent is Grid grid &&
|
||||
grid.Children.Count == 2 &&
|
||||
grid.Children[0] is TextBlock textBlock)
|
||||
{
|
||||
OB.Settings.ProxyManagerSettings.ProxyKeys.Remove(textBlock.Text);
|
||||
IOManager.SaveSettings(OB.proxyManagerSettingsFile, OB.Settings.ProxyManagerSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void Image_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is Image image)
|
||||
{
|
||||
image.Width = 25;
|
||||
image.Height = 25;
|
||||
}
|
||||
}
|
||||
|
||||
private void Image_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (sender is Image image)
|
||||
{
|
||||
image.Width = 20;
|
||||
image.Height = 20;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace RuriLib
|
||||
/// </summary>
|
||||
/// <param name="settingsFile">The file you want to save to</param>
|
||||
/// <param name="settings">The RuriLib settings object</param>
|
||||
public static void SaveSettings(string settingsFile, RLSettingsViewModel settings)
|
||||
public static void SaveSettings<T>(string settingsFile, T settings)
|
||||
{
|
||||
File.WriteAllText(settingsFile, JsonConvert.SerializeObject(settings, Formatting.Indented));
|
||||
}
|
||||
@@ -31,9 +31,9 @@ namespace RuriLib
|
||||
/// </summary>
|
||||
/// <param name="settingsFile">The file you want to load from</param>
|
||||
/// <returns>An instance of RLSettingsViewModel</returns>
|
||||
public static RLSettingsViewModel LoadSettings(string settingsFile)
|
||||
public static T LoadSettings<T>(string settingsFile)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<RLSettingsViewModel>(File.ReadAllText(settingsFile));
|
||||
return JsonConvert.DeserializeObject<T>(File.ReadAllText(settingsFile));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -342,6 +342,7 @@
|
||||
<Compile Include="Models\CustomKeychain.cs" />
|
||||
<Compile Include="Models\EnvironmentSettings.cs" />
|
||||
<Compile Include="Models\DataRule.cs" />
|
||||
<Compile Include="ViewModels\ProxyManagerSettings.cs" />
|
||||
<Compile Include="ViewModels\RLSettings\SettingsCaptchas.cs" />
|
||||
<Compile Include="ViewModels\RLSettings\SettingsGeneral.cs" />
|
||||
<Compile Include="ViewModels\RLSettings\SettingsProxies.cs" />
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RuriLib.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides settings for the proxy manager.
|
||||
/// </summary>
|
||||
public class ProxyManagerSettings : ViewModelBase
|
||||
{
|
||||
private ObservableCollection<string> proxySiteUrls = new ObservableCollection<string>();
|
||||
/// <summary>The list of the urls for sites to test the proxies on.</summary>
|
||||
public ObservableCollection<string> ProxySiteUrls { get { return proxySiteUrls; } set { proxySiteUrls = value; OnPropertyChanged(); } }
|
||||
|
||||
private ObservableCollection<string> proxyKeys = new ObservableCollection<string>();
|
||||
/// <summary>The list of the keys for sites to test the proxies on.</summary>
|
||||
public ObservableCollection<string> ProxyKeys { get { return proxyKeys; } set { proxyKeys = value; OnPropertyChanged(); } }
|
||||
|
||||
private string activeProxySiteUrl;
|
||||
/// <summary>The selected dropdown item in the proxy site urls dropdown</summary>
|
||||
public string ActiveProxySiteUrl { get { return activeProxySiteUrl; } set { activeProxySiteUrl = value; OnPropertyChanged(); } }
|
||||
|
||||
private string activeProxyKey;
|
||||
/// <summary>The selected dropdown item in the proxy keys dropdown</summary>
|
||||
public string ActiveProxyKey { get { return activeProxyKey; } set { activeProxyKey = value; OnPropertyChanged(); } }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user