Now the settings correctly update visually after being reset.

This commit is contained in:
ruri
2019-04-20 11:18:58 +02:00
parent 90ca84272f
commit 78483a1a84
11 changed files with 127 additions and 5 deletions
@@ -1,4 +1,7 @@
namespace RuriLib.ViewModels
using System.Collections.Generic;
using System.Reflection;
namespace RuriLib.ViewModels
{
/// <summary>
/// Provides captcha-related settings.
@@ -64,5 +67,19 @@
private int timeout = 120;
/// <summary>The maximum amount of time to wait until a captcha challenge is solved.</summary>
public int Timeout { get { return timeout; } set { timeout = value; OnPropertyChanged(); } }
/// <summary>
/// Resets the properties to their default value.
/// </summary>
public void Reset()
{
SettingsCaptchas def = new SettingsCaptchas();
IList<PropertyInfo> props = new List<PropertyInfo>(typeof(SettingsCaptchas).GetProperties());
foreach (PropertyInfo prop in props)
{
prop.SetValue(this, prop.GetValue(def, null));
}
}
}
}
@@ -1,4 +1,7 @@
namespace RuriLib.ViewModels
using System.Collections.Generic;
using System.Reflection;
namespace RuriLib.ViewModels
{
/// <summary>
/// The level of detail of a bot's status.
@@ -39,5 +42,19 @@
private bool _enableBotLog = false;
/// <summary>Whether to keep the LogBuffer from BotData stored for future use (slows down the Runner).</summary>
public bool EnableBotLog { get { return _enableBotLog; } set { _enableBotLog = value; OnPropertyChanged(); } }
/// <summary>
/// Resets the properties to their default value.
/// </summary>
public void Reset()
{
SettingsGeneral def = new SettingsGeneral();
IList<PropertyInfo> props = new List<PropertyInfo>(typeof(SettingsGeneral).GetProperties());
foreach (PropertyInfo prop in props)
{
prop.SetValue(this, prop.GetValue(def, null));
}
}
}
}
@@ -1,4 +1,6 @@
using Extreme.Net;
using System.Collections.Generic;
using System.Reflection;
namespace RuriLib.ViewModels
{
@@ -88,5 +90,19 @@ namespace RuriLib.ViewModels
/// </summary>
public string[] GlobalRetryKeys { get { return globalRetryKeys; } set { globalRetryKeys = value; OnPropertyChanged(); } }
#endregion
/// <summary>
/// Resets the properties to their default value.
/// </summary>
public void Reset()
{
SettingsProxies def = new SettingsProxies();
IList<PropertyInfo> props = new List<PropertyInfo>(typeof(SettingsProxies).GetProperties());
foreach (PropertyInfo prop in props)
{
prop.SetValue(this, prop.GetValue(def, null));
}
}
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Reflection;
namespace RuriLib.ViewModels
{
@@ -45,5 +46,19 @@ namespace RuriLib.ViewModels
private int pageLoadTimeout = 60;
/// <summary>The default timeout for page load in the browser.</summary>
public int PageLoadTimeout { get { return pageLoadTimeout; } set { pageLoadTimeout = value; OnPropertyChanged(); } }
/// <summary>
/// Resets the properties to their default value.
/// </summary>
public void Reset()
{
SettingsSelenium def = new SettingsSelenium();
IList<PropertyInfo> props = new List<PropertyInfo>(typeof(SettingsSelenium).GetProperties());
foreach (PropertyInfo prop in props)
{
prop.SetValue(this, prop.GetValue(def, null));
}
}
}
}
+11
View File
@@ -13,5 +13,16 @@
public SettingsCaptchas Captchas { get; set; } = new SettingsCaptchas();
/// <summary>The Selenium Settings of RuriLib.</summary>
public SettingsSelenium Selenium { get; set; } = new SettingsSelenium();
/// <summary>
/// Resets the properties to their default value.
/// </summary>
public void Reset()
{
General.Reset();
Proxies.Reset();
Captchas.Reset();
Selenium.Reset();
}
}
}