revert to VB and update to new project file format

This commit is contained in:
schedpas
2020-09-25 09:04:15 +02:00
parent 04869b2814
commit 9feaf658be
313 changed files with 9895 additions and 17566 deletions

View File

@@ -1,113 +0,0 @@
using System;
namespace Pilz.Configuration
{
public class AutoSaveConfigurationManager : ConfigurationManager
{
private bool addedHandler = false;
private bool enableAutoSave = false;
private string _ConfigFilePath = string.Empty;
private bool _AutoLoadConfigOnAccess = false;
public string ConfigFilePath
{
get
{
return _ConfigFilePath;
}
set
{
_ConfigFilePath = value;
if (AutoLoadConfigOnAccess)
Load();
}
}
public bool AutoLoadConfigOnAccess
{
get
{
return _AutoLoadConfigOnAccess;
}
set
{
_AutoLoadConfigOnAccess = value;
if (value)
Load();
}
}
public bool AutoSaveConfigOnExit
{
get
{
return enableAutoSave;
}
set
{
if (enableAutoSave != value)
{
enableAutoSave = value;
switch (enableAutoSave)
{
case true:
{
AddAutoSaveHandler();
break;
}
case false:
{
RemoveAutoSaveHandler();
break;
}
}
}
}
}
private void AddAutoSaveHandler()
{
if (!addedHandler)
{
System.Windows.Forms.Application.ApplicationExit += AutoSaveSettingsOnExit;
addedHandler = true;
}
}
private void RemoveAutoSaveHandler()
{
System.Windows.Forms.Application.ApplicationExit -= AutoSaveSettingsOnExit;
addedHandler = false;
}
private void AutoSaveSettingsOnExit(object sender, EventArgs e)
{
Save();
}
private void Save()
{
if (!string.IsNullOrEmpty(ConfigFilePath) && Configuration is object)
{
Configuration.WriteToFile(ConfigFilePath);
}
}
private void Load()
{
if (!string.IsNullOrEmpty(ConfigFilePath))
{
Configuration.ReadFromFile(ConfigFilePath);
}
}
~AutoSaveConfigurationManager()
{
RemoveAutoSaveHandler();
}
}
}