feat: autocompletions

This commit is contained in:
2026-03-11 14:28:43 +01:00
parent da8ce47f8b
commit a0de93f98c
13 changed files with 7054 additions and 8 deletions

View File

@@ -43,6 +43,9 @@ namespace CarManagerV3.Forms
read: () => Properties.Settings.Default.AllowPrerelease,
write: v => Properties.Settings.Default.AllowPrerelease = v);
//TODO: implement refresh settings
lblEnv.Text = lblEnv.Text.Replace("%E%", InstallModeDetector.IsInstalledViaMsi() ? "Installed via MSI" : "Running in portable mode");
}
@@ -60,10 +63,33 @@ namespace CarManagerV3.Forms
private void saveSettings()
{
bool requiresRestart = false;
foreach (var kvp in settingsMap)
{
kvp.Value.Save();
if (kvp.Value.RequiresRestart())
requiresRestart = true;
}
Properties.Settings.Default.Save();
if(requiresRestart)
{
DialogResult result = MessageBox.Show(
"Some changes you made require a restart to take effect. Do you want to restart now?",
"Restart Required",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
Application.Restart();
} else
{
MessageBox.Show("Please restart the application as soon as possible to ensure all changes take effect.", "Restart Recommended", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private void resetSettings()
@@ -106,6 +132,7 @@ namespace CarManagerV3.Forms
void Load();
void Save();
void Reset();
bool RequiresRestart();
}
internal sealed class SettingBinding<T> : ISettingBinding
@@ -115,14 +142,18 @@ namespace CarManagerV3.Forms
private readonly Func<T> read;
private readonly Action<T> write;
private readonly Action<T, T>? onChange;
private readonly bool requiresRestart;
private bool changeRequiresRestart;
public SettingBinding(Control control, T defaultValue, Func<T> read, Action<T> write, Action<T, T>? onChange = null)
public SettingBinding(Control control, T defaultValue, Func<T> read, Action<T> write, bool requiresRestart = false, Action<T, T>? onChange = null)
{
this.control = control;
this.defaultValue = defaultValue;
this.read = read;
this.write = write;
this.onChange = onChange;
this.requiresRestart = requiresRestart;
this.changeRequiresRestart = false;
}
public void Load()
@@ -140,10 +171,15 @@ namespace CarManagerV3.Forms
if (onChange != null && !EqualityComparer<T>.Default.Equals(before, after))
onChange(before, after);
if (requiresRestart && !EqualityComparer<T>.Default.Equals(before, after))
changeRequiresRestart = true;
}
public void Reset() => write(defaultValue);
public bool RequiresRestart() => changeRequiresRestart;
private void ApplyToControl(T value)
{
switch (control)