Implemented application configuration setting to disable the busy indicator (by default).

This commit is contained in:
LoRd_MuldeR 2021-11-13 17:11:08 +01:00
parent 801f812714
commit d2ea1a7a7c
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
4 changed files with 76 additions and 0 deletions

View File

@ -3,4 +3,7 @@
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup> </startup>
<appSettings>
<add key="DisableBusyIndicator" value="false" />
</appSettings>
</configuration> </configuration>

View File

@ -56,6 +56,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xaml" /> <Reference Include="System.Xaml" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
@ -79,6 +80,7 @@
<Compile Include="Controls\PasswordToggleBox.xaml.cs"> <Compile Include="Controls\PasswordToggleBox.xaml.cs">
<DependentUpon>PasswordToggleBox.xaml</DependentUpon> <DependentUpon>PasswordToggleBox.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Utilities\ApplicationConfig.cs" />
<Compile Include="Utilities\CPUFeatures.cs" /> <Compile Include="Utilities\CPUFeatures.cs" />
<Compile Include="Process\SlunkCryptRunner.cs" /> <Compile Include="Process\SlunkCryptRunner.cs" />
<Compile Include="Utilities\BusyManager.cs" /> <Compile Include="Utilities\BusyManager.cs" />

View File

@ -37,6 +37,7 @@ namespace com.muldersoft.slunkcrypt.gui
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public const int MIN_PASSWD_LENGTH = 8, REC_PASSWD_LENGTH = 12, GEN_PASSWD_LENGTH = 24, MAX_PASSWD_LENGTH = 256, MAX_PATH = 259; public const int MIN_PASSWD_LENGTH = 8, REC_PASSWD_LENGTH = 12, GEN_PASSWD_LENGTH = 24, MAX_PASSWD_LENGTH = 256, MAX_PATH = 259;
private readonly ApplicationConfig m_config = new ApplicationConfig();
private readonly Lazy<string> m_about = new Lazy<string>(CreateAboutText); private readonly Lazy<string> m_about = new Lazy<string>(CreateAboutText);
private readonly Random m_random = new Random(); private readonly Random m_random = new Random();
private readonly ObservableCollection<string> m_logFile = new ObservableCollection<string>(); private readonly ObservableCollection<string> m_logFile = new ObservableCollection<string>();
@ -63,6 +64,7 @@ namespace com.muldersoft.slunkcrypt.gui
m_dispatcherTimer.Tick += DispatcherTimer_Tick; m_dispatcherTimer.Tick += DispatcherTimer_Tick;
m_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200); m_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200);
m_logFileReadOnly = new ReadOnlyObservableCollection<string>(m_logFile); m_logFileReadOnly = new ReadOnlyObservableCollection<string>(m_logFile);
m_disableAnimation = m_config.DisableBusyIndicator;
} }
// ============================================================================= // =============================================================================
@ -373,6 +375,10 @@ namespace com.muldersoft.slunkcrypt.gui
SystemMenu systemMenu = new SystemMenu(this, SystemMenu_Activated); SystemMenu systemMenu = new SystemMenu(this, SystemMenu_Activated);
m_menuId_disableAnimation = systemMenu.AppendMenu("Disable Busy Indicator"); m_menuId_disableAnimation = systemMenu.AppendMenu("Disable Busy Indicator");
m_menuId_enableExpertMode = systemMenu.AppendMenu("Expert Settings"); m_menuId_enableExpertMode = systemMenu.AppendMenu("Expert Settings");
if (m_disableAnimation && m_menuId_disableAnimation.HasValue)
{
systemMenu.ModifyMenu(m_menuId_disableAnimation.Value, m_disableAnimation);
}
CreateIndicatorElements(); CreateIndicatorElements();
} }

View File

@ -0,0 +1,65 @@
/******************************************************************************/
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
/* This work has been released under the CC0 1.0 Universal license! */
/******************************************************************************/
using System;
using System.Configuration;
namespace com.muldersoft.slunkcrypt.gui.utils
{
class ApplicationConfig
{
private readonly Lazy<KeyValueConfigurationCollection> m_settings = new Lazy<KeyValueConfigurationCollection>(InitializeSettings);
public bool DisableBusyIndicator
{
get
{
return GetConfigValueAsBool("DisableBusyIndicator");
}
}
protected string GetConfigValue(string name)
{
KeyValueConfigurationCollection settings = m_settings.Value;
if (!ReferenceEquals(settings, null))
{
KeyValueConfigurationElement element = settings[name];
if (!ReferenceEquals(element, null))
{
string value = element.Value;
return string.IsNullOrWhiteSpace(value) ? string.Empty : value;
}
}
return string.Empty;
}
protected bool GetConfigValueAsBool(string name)
{
string value;
if (!string.IsNullOrWhiteSpace(value = GetConfigValue(name)))
{
bool result;
if (bool.TryParse(value.Trim(), out result))
{
return result;
}
}
return false;
}
private static KeyValueConfigurationCollection InitializeSettings()
{
try
{
Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
return configuration.AppSettings.Settings;
}
catch
{
return null;
}
}
}
}